1
0
forked from 0ad/0ad

- fix w4 warnings

- add convenience macros for config_db(CFG_GET_SYS_VAL)
- VFSUtil::EnumDirEnts now uses flags instead of bool recursive
- UNUSED() for params, UNUSED2 (<- need better name) for variables
- config.h defines must be tested with #if (always defined) -> allows
detecting misspellings thanks to compiler warnings
- replace debug_assert(0) with debug_warn (its sole purpose)
- replace ScriptingHost::ValueToInt et al with ToPrimitive
- use nommgr.h to disable both mmgr and VC debug heap

This was SVN commit r2585.
This commit is contained in:
janwas 2005-08-09 15:55:44 +00:00
parent 630b375f4d
commit a69ac0dee9
115 changed files with 654 additions and 600 deletions

View File

@ -84,28 +84,23 @@ void CGameView::ScriptingInit()
CJSObject<CGameView>::ScriptingInit("GameView");
}
int CGameView::Initialize(CGameAttributes *pAttribs)
int CGameView::Initialize(CGameAttributes* UNUSED(pAttribs))
{
CConfigValue* cfg;
CFG_GET_SYS_VAL( "view.scroll.speed", Float, m_ViewScrollSpeed );
CFG_GET_SYS_VAL( "view.rotate.speed", Float, m_ViewRotateSensitivity );
CFG_GET_SYS_VAL( "view.rotate.keyboard.speed", Float, m_ViewRotateSensitivityKeyboard );
CFG_GET_SYS_VAL( "view.rotate.abouttarget.speed", Float, m_ViewRotateAboutTargetSensitivity );
CFG_GET_SYS_VAL( "view.rotate.keyboard.abouttarget.speed", Float, m_ViewRotateAboutTargetSensitivityKeyboard );
CFG_GET_SYS_VAL( "view.drag.speed", Float, m_ViewDragSensitivity );
CFG_GET_SYS_VAL( "view.zoom.speed", Float, m_ViewZoomSensitivity );
CFG_GET_SYS_VAL( "view.zoom.wheel.speed", Float, m_ViewZoomSensitivityWheel );
CFG_GET_SYS_VAL( "view.zoom.smoothness", Float, m_ViewZoomSmoothness );
CFG_GET_SYS_VAL( "view.snap.smoothness", Float, m_ViewSnapSmoothness );
#define getViewParameter( name, value ) STMT( \
cfg = g_ConfigDB.GetValue( CFG_SYSTEM, name );\
if( cfg ) cfg->GetFloat( value ); )
getViewParameter( "view.scroll.speed", m_ViewScrollSpeed );
getViewParameter( "view.rotate.speed", m_ViewRotateSensitivity );
getViewParameter( "view.rotate.keyboard.speed", m_ViewRotateSensitivityKeyboard );
getViewParameter( "view.rotate.abouttarget.speed", m_ViewRotateAboutTargetSensitivity );
getViewParameter( "view.rotate.keyboard.abouttarget.speed", m_ViewRotateAboutTargetSensitivityKeyboard );
getViewParameter( "view.drag.speed", m_ViewDragSensitivity );
getViewParameter( "view.zoom.speed", m_ViewZoomSensitivity );
getViewParameter( "view.zoom.wheel.speed", m_ViewZoomSensitivityWheel );
getViewParameter( "view.zoom.smoothness", m_ViewZoomSmoothness );
getViewParameter( "view.snap.smoothness", m_ViewSnapSmoothness );
#undef getViewParameter
if( ( m_ViewZoomSmoothness < 0.0f ) || ( m_ViewZoomSmoothness > 1.0f ) ) m_ViewZoomSmoothness = 0.02f;
if( ( m_ViewSnapSmoothness < 0.0f ) || ( m_ViewSnapSmoothness > 1.0f ) ) m_ViewSnapSmoothness = 0.02f;
if( ( m_ViewZoomSmoothness < 0.0f ) || ( m_ViewZoomSmoothness > 1.0f ) )
m_ViewZoomSmoothness = 0.02f;
if( ( m_ViewSnapSmoothness < 0.0f ) || ( m_ViewSnapSmoothness > 1.0f ) )
m_ViewSnapSmoothness = 0.02f;
return 0;
}
@ -704,13 +699,15 @@ int game_view_handler(const SDL_Event* ev)
return EV_PASS;
}
bool CGameView::JSI_StartCustomSelection(JSContext* context, unsigned int argc, jsval* argv)
bool CGameView::JSI_StartCustomSelection(
JSContext* UNUSED(context), uint UNUSED(argc), jsval* UNUSED(argv))
{
StartCustomSelection();
return true;
}
bool CGameView::JSI_EndCustomSelection(JSContext* context, unsigned int argc, jsval* argv)
bool CGameView::JSI_EndCustomSelection(
JSContext* UNUSED(context), uint UNUSED(argc), jsval* UNUSED(argv))
{
ResetInteraction();
return true;

View File

@ -267,6 +267,10 @@ private:
void ReadEnvironment(XMBElement parent);
int ReadEntities(XMBElement parent, double end_time);
int ReadNonEntities(XMBElement parent, double end_time);
// squelch "unable to generate" warnings
CXMLReader(const CXMLReader& rhs);
const CXMLReader& operator=(const CXMLReader& rhs);
};

View File

@ -50,9 +50,10 @@ void CMapWriter::SaveMap(const char* filename, CTerrain *pTerrain, CLightEnv *pL
// handle isn't in list
static u16 GetHandleIndex(const Handle handle,const std::vector<Handle>& handles)
{
for (uint i=0;i<(uint)handles.size();i++) {
const uint limit = MIN((uint)handles.size(), 0xFFFE); // paranoia
for (uint i=0;i<limit;i++) {
if (handles[i]==handle) {
return i;
return (u16)i;
}
}
@ -111,7 +112,8 @@ void CMapWriter::EnumTerrainTextures(CTerrain *pTerrain,
///////////////////////////////////////////////////////////////////////////////////////////////////
// PackMap: pack the current world into a raw data stream
void CMapWriter::PackMap(CFilePacker& packer, CTerrain *pTerrain, CLightEnv *pLightEnv, CUnitManager *pUnitMan)
void CMapWriter::PackMap(CFilePacker& packer, CTerrain* pTerrain,
CLightEnv* UNUSED(pLightEnv), CUnitManager* UNUSED(pUnitMan))
{
// now pack everything up
PackTerrain(packer, pTerrain);

View File

@ -64,8 +64,8 @@ bool CModel::InitModel(CModelDefPtr modeldef)
m_pModelDef = modeldef;
u32 numBones=modeldef->GetNumBones();
if (numBones>0) {
size_t numBones=modeldef->GetNumBones();
if (numBones != 0) {
// allocate matrices for bone transformations
m_BoneMatrices=new CMatrix3D[numBones];
m_InvBoneMatrices=new CMatrix3D[numBones];
@ -150,10 +150,10 @@ void CModel::CalcObjectBounds()
{
m_ObjectBounds.SetEmpty();
int numverts=m_pModelDef->GetNumVertices();
size_t numverts=m_pModelDef->GetNumVertices();
SModelVertex* verts=m_pModelDef->GetVertices();
for (int i=0;i<numverts;i++) {
for (size_t i=0;i<numverts;i++) {
m_ObjectBounds+=verts[i].m_Coords;
}
}
@ -172,7 +172,7 @@ void CModel::CalcAnimatedObjectBound(CSkeletonAnimDef* anim,CBound& result)
if (!SetAnimation(&dummyanim)) return;
}
int numverts=m_pModelDef->GetNumVertices();
size_t numverts=m_pModelDef->GetNumVertices();
SModelVertex* verts=m_pModelDef->GetVertices();
// Remove any transformations, so that we calculate the bounding box
@ -188,9 +188,9 @@ void CModel::CalcAnimatedObjectBound(CSkeletonAnimDef* anim,CBound& result)
float AnimTime = m_AnimTime;
// iterate through every frame of the animation
for (uint j=0;j<anim->GetNumFrames();j++) {
for (size_t j=0;j<anim->GetNumFrames();j++) {
// extend bounds by vertex positions at the frame
for (int i=0;i<numverts;i++) {
for (size_t i=0;i<numverts;i++) {
CVector3D tmp=SkinPoint(verts[i].m_Coords,verts[i].m_Blend,GetBoneMatrices());
result+=tmp;
}
@ -277,7 +277,7 @@ void CModel::GenerateBoneMatrices()
m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime,m_BoneMatrices);
const CMatrix3D& transform=GetTransform();
for (int i=0;i<m_pModelDef->GetNumBones();i++) {
for (size_t i=0;i<m_pModelDef->GetNumBones();i++) {
m_BoneMatrices[i].Concatenate(transform);
m_BoneMatrices[i].GetInverse(m_InvBoneMatrices[i]);
}
@ -416,7 +416,7 @@ void CModel::SetTransform(const CMatrix3D& transform)
InvalidateBounds();
// now set transforms on props
const CMatrix3D* bonematrices=GetBoneMatrices();
const CMatrix3D* bonematrices=GetBoneMatrices();// TODO2: this or m_BoneMatrices?
for (size_t i=0;i<m_Props.size();i++) {
const Prop& prop=m_Props[i];

View File

@ -107,11 +107,11 @@ void CModelDef::Save(const char* filename,const CModelDef* mdef)
CFilePacker packer(FILE_VERSION, "PSMD");
// pack everything up
u32 numVertices=mdef->GetNumVertices();
u32 numVertices=(u32)mdef->GetNumVertices();
packer.PackRaw(&numVertices,sizeof(numVertices));
packer.PackRaw(mdef->GetVertices(),sizeof(SModelVertex)*numVertices);
u32 numFaces=mdef->GetNumFaces();
u32 numFaces=(u32)mdef->GetNumFaces();
packer.PackRaw(&numFaces,sizeof(numFaces));
packer.PackRaw(mdef->GetFaces(),sizeof(SModelFace)*numFaces);

View File

@ -92,15 +92,15 @@ public:
public:
// accessor: get vertex data
int GetNumVertices() const { return m_NumVertices; }
size_t GetNumVertices() const { return (size_t)m_NumVertices; }
SModelVertex* GetVertices() const { return m_pVertices; }
// accessor: get face data
int GetNumFaces() const { return m_NumFaces; }
size_t GetNumFaces() const { return (size_t)m_NumFaces; }
SModelFace* GetFaces() const { return m_pFaces; }
// accessor: get bone data
int GetNumBones() const { return m_NumBones; }
size_t GetNumBones() const { return (size_t)m_NumBones; }
CBoneState* GetBones() const { return m_Bones; }

View File

@ -352,7 +352,7 @@ void CObjectBase::CalculateVariation(std::set<CStr>& strings, variation_key& cho
for (uint i = 0; i < grp->size(); ++i)
if (strings.count((*grp)[i].m_VariantName))
matches.push_back(i);
matches.push_back((u8)i); // "protected" by debug_assert
// If there's only one match, choose that one
if (matches.size() == 1)
@ -366,7 +366,7 @@ void CObjectBase::CalculateVariation(std::set<CStr>& strings, variation_key& cho
// If none matched the specified strings, choose from all the variants
if (matches.size() == 0)
for (uint i = 0; i < grp->size(); ++i)
matches.push_back(i);
matches.push_back((u8)i); // "protected" by debug_assert
// Sum the frequencies:
int totalFreq = 0;

View File

@ -180,7 +180,7 @@ int CObjectManager::LoadObjects()
//////////////////////////////////////////////////////////////////////////
// For ScEd:
static void GetObjectThunk(const char* path, const vfsDirEnt* ent, void* context)
static void GetObjectName_ThunkCb(const char* path, const DirEnt* UNUSED(ent), void* context)
{
std::vector<CStr>* names = (std::vector<CStr>*)context;
CStr name (path);
@ -188,7 +188,8 @@ static void GetObjectThunk(const char* path, const vfsDirEnt* ent, void* context
}
void CObjectManager::GetAllObjectNames(std::vector<CStr>& names)
{
VFSUtil::EnumDirEnts("art/actors/", "*.xml", true, GetObjectThunk, &names);
VFSUtil::EnumDirEnts("art/actors/", VFSUtil::RECURSIVE, "*.xml",
GetObjectName_ThunkCb, &names);
}
struct CObjectThing_Entity : public CObjectThing
@ -231,7 +232,7 @@ struct CObjectThing_Object : public CObjectThing
~CObjectThing_Object() {}
CObjectEntry* obj;
CUnit* unit;
void Create(CMatrix3D& transform, int playerID)
void Create(CMatrix3D& transform, int UNUSED(playerID))
{
unit = new CUnit(obj, obj->m_Model->Clone());
unit->GetModel()->SetTransform(transform);

View File

@ -47,7 +47,7 @@ public:
~CSkeletonAnimDef();
// return the number of keys in this animation
u32 GetNumKeys() const { return m_NumKeys; }
size_t GetNumKeys() const { return (size_t)m_NumKeys; }
// accessors: get a key for given bone at given time
Key& GetKey(u32 frame, u32 bone) { return m_Keys[frame*m_NumKeys+bone]; }
@ -59,7 +59,7 @@ public:
// return length of each frame, in ms
float GetFrameTime() const { return m_FrameTime; }
// return number of frames in animation
u32 GetNumFrames() const { return m_NumFrames; }
size_t GetNumFrames() const { return (size_t)m_NumFrames; }
// build matrices for all bones at the given time (in MS) in this animation
void BuildBoneMatrices(float time, CMatrix3D* matrices) const;

View File

@ -355,7 +355,7 @@ float CTerrain::FlattenArea(float x0,float x1,float z0,float z1)
for (u32 x=tx0;x<=tx1;x++) {
for (u32 z=tz0;z<=tz1;z++) {
m_Heightmap[z*m_MapSize + x]=y;
m_Heightmap[z*m_MapSize + x]=(u16)y;
CPatch* patch=GetPatch(x/PATCH_SIZE,z/PATCH_SIZE);
patch->SetDirty(RENDERDATA_UPDATE_VERTICES);
}
@ -369,10 +369,10 @@ float CTerrain::FlattenArea(float x0,float x1,float z0,float z1)
void CTerrain::RaiseVertex(int x, int z, int amount)
{
// Ignore out-of-bounds vertices
if (x < 0 || z < 0 || x >= (int)m_MapSize || z >= (int)m_MapSize)
if ((unsigned)x >= m_MapSize || (unsigned)z >= m_MapSize)
return;
m_Heightmap[x + z*m_MapSize] = clamp(m_Heightmap[x + z*m_MapSize] + amount, 0, 65535);
m_Heightmap[x + z*m_MapSize] = (u16)clamp(m_Heightmap[x + z*m_MapSize] + amount, 0, 65535);
}
void CTerrain::MakeDirty(int x0, int z0, int x1, int z1)

View File

@ -43,7 +43,7 @@ CTextureEntry::CTextureEntry(CTerrainProperties *props, CStr path):
else
slashPos++; // Skip the actual slash
if (dotPos == -1)
dotPos = m_TexturePath.Length();
dotPos = (long)m_TexturePath.Length();
m_Tag = m_TexturePath.GetSubstring(slashPos, dotPos-slashPos);
}

View File

@ -7,12 +7,13 @@
#include "TextureEntry.h"
#include "TerrainProperties.h"
#include "res/res.h"
#include "res/ogl_tex.h"
#include "ogl.h"
#include "timer.h"
#include "lib/res/res.h"
#include "lib/res/ogl_tex.h"
#include "lib/ogl.h"
#include "lib/timer.h"
#include "CLogger.h"
#include "ps/CLogger.h"
#include "ps/VFSUtil.h"
#define LOG_CATEGORY "graphics"
@ -88,12 +89,12 @@ void CTextureManager::DeleteTexture(CTextureEntry* entry)
// the VFS.
void CTextureManager::LoadTextures(CTerrainProperties *props, CStr path, const char* fileext_filter)
{
Handle dir=vfs_open_dir(path.c_str());
vfsDirEnt dent;
Handle dir=vfs_dir_open(path.c_str());
DirEnt dent;
if (dir > 0)
{
while (vfs_next_dirent(dir, &dent, fileext_filter) == 0)
while (vfs_dir_next_ent(dir, &dent, fileext_filter) == 0)
{
// Strip extension off of dent.name, add .xml, check if the file
// exists
@ -116,7 +117,7 @@ void CTextureManager::LoadTextures(CTerrainProperties *props, CStr path, const c
AddTexture(myprops, path+dent.name);
}
vfs_close_dir(dir);
vfs_dir_close(dir);
}
}
@ -140,17 +141,17 @@ void CTextureManager::RecurseDirectory(CTerrainProperties *parentProps, CStr pat
// Recurse once for each subdirectory
Handle dir=vfs_open_dir(path.c_str());
vfsDirEnt dent;
Handle dir=vfs_dir_open(path.c_str());
DirEnt dent;
if (dir > 0)
{
while (vfs_next_dirent(dir, &dent, "/") == 0)
while (vfs_dir_next_ent(dir, &dent, "/") == 0)
{
RecurseDirectory(props, path+dent.name+"/");
}
vfs_close_dir(dir);
vfs_dir_close(dir);
}
for (int i=0;i<ARRAY_SIZE(SupportedTextureFormats);i++)
@ -159,10 +160,10 @@ void CTextureManager::RecurseDirectory(CTerrainProperties *parentProps, CStr pat
}
}
int CTextureManager::LoadTerrainTextures()
{
RecurseDirectory(NULL, "art/textures/terrain/types/");
return 0;
}

View File

@ -77,6 +77,8 @@ public:
CTextureManager();
~CTextureManager();
// Find all XML's in the directory (with subdirs) and try to load them as
// terrain XML's
int LoadTerrainTextures();
CTextureEntry* FindTexture(CStr tag);

View File

@ -72,7 +72,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
wchar_t* text = clipboard_get();
if (text)
{
if (m_iBufferPos == pCaption->Length())
if (m_iBufferPos == (int)pCaption->Length())
*pCaption += text;
else
*pCaption = pCaption->Left(m_iBufferPos) + text +
@ -113,7 +113,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
m_iBufferPos == 0)
break;
if (m_iBufferPos == pCaption->Length())
if (m_iBufferPos == (int)pCaption->Length())
*pCaption = pCaption->Left( (long) pCaption->Length()-1);
else
*pCaption = pCaption->Left( m_iBufferPos-1 ) +
@ -137,7 +137,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
else
{
if (pCaption->Length() == 0 ||
m_iBufferPos == pCaption->Length())
m_iBufferPos == (int)pCaption->Length())
break;
*pCaption = pCaption->Left( m_iBufferPos ) +
@ -261,7 +261,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
}
if (m_iBufferPos != pCaption->Length())
if (m_iBufferPos != (int)pCaption->Length())
++m_iBufferPos;
}
else
@ -430,7 +430,7 @@ int CInput::ManuallyHandleEvent(const SDL_Event* ev)
DeleteCurSelection();
m_iBufferPos_Tail = -1;
if (m_iBufferPos == pCaption->Length())
if (m_iBufferPos == (int)pCaption->Length())
*pCaption += cooked;
else
*pCaption = pCaption->Left(m_iBufferPos) + CStrW(cooked) +
@ -796,7 +796,8 @@ void CInput::Draw()
}
// We might as well use 'i' here to iterate, because we need it
for (size_t i=0; i < it->m_ListOfX.size()+2; ++i)
// (often compared against ints, so don't make it size_t)
for (int i=0; i < (int)it->m_ListOfX.size()+2; ++i)
{
if (it->m_ListStart + i == VirtualFrom)
{
@ -812,13 +813,14 @@ void CInput::Draw()
// no else!
const bool at_end = (i == (int)it->m_ListOfX.size()+1);
if (drawing_box == true &&
(it->m_ListStart + i == VirtualTo ||
i == it->m_ListOfX.size()+1))
(it->m_ListStart + i == VirtualTo || at_end))
{
// Depending on if it's just a row change, or if it's
// the end of the select box, do slightly different things.
if (i == it->m_ListOfX.size()+1)
if (at_end)
{
if (it->m_ListStart + i != VirtualFrom)
{
@ -880,7 +882,7 @@ void CInput::Draw()
glPopMatrix();
}
if (i < it->m_ListOfX.size())
if (i < (int)it->m_ListOfX.size())
x_pointer += (float)font.GetCharacterWidth((*pCaption)[it->m_ListStart + i]);
}
@ -926,9 +928,10 @@ void CInput::Draw()
glTranslatef(-(float)(int)m_HorizontalScroll, 0.f, 0.f);
// We might as well use 'i' here, because we need it
for (size_t i=0; i < it->m_ListOfX.size()+1; ++i)
// (often compared against ints, so don't make it size_t)
for (int i=0; i < (int)it->m_ListOfX.size()+1; ++i)
{
if (!multiline && i < it->m_ListOfX.size())
if (!multiline && i < (int)it->m_ListOfX.size())
{
if (it->m_ListOfX[i] - m_HorizontalScroll < -buffer_zone)
{
@ -950,7 +953,7 @@ void CInput::Draw()
glColor4f(color.r, color.g, color.b, color.a);
}
if (i != it->m_ListOfX.size() &&
if (i != (int)it->m_ListOfX.size() &&
it->m_ListStart + i == m_iBufferPos)
{
// selecting only one, then we need only to draw a vertical line glyph.
@ -961,26 +964,26 @@ void CInput::Draw()
// Drawing selected area
if (SelectingText() &&
it->m_ListStart + (int)i >= VirtualFrom &&
it->m_ListStart + (int)i < VirtualTo &&
it->m_ListStart + i >= VirtualFrom &&
it->m_ListStart + i < VirtualTo &&
using_selected_color == false)
{
using_selected_color = true;
glColor4f(color_selected.r, color_selected.g, color_selected.b, color_selected.a);
}
if (i != it->m_ListOfX.size())
if (i != (int)it->m_ListOfX.size())
glwprintf(L"%lc", (*pCaption)[it->m_ListStart + i]);
// check it's now outside a one-liner, then we'll break
if (!multiline && i < it->m_ListOfX.size())
if (!multiline && i < (int)it->m_ListOfX.size())
{
if (it->m_ListOfX[i] - m_HorizontalScroll > m_CachedActualSize.GetWidth()-buffer_zone)
break;
}
}
if (it->m_ListStart + it->m_ListOfX.size() == m_iBufferPos)
if (it->m_ListStart + (int)it->m_ListOfX.size() == m_iBufferPos)
{
glColor4f(color.r, color.g, color.b, color.a);
glwprintf(L"%lc", 0xFE33);
@ -1027,7 +1030,7 @@ void CInput::UpdateText(int from, int to_before, int to_after)
SRow row;
row.m_ListStart = 0;
int to;
int to = 0; // make sure it's initialized
if (to_before == -1)
to = (int)caption.Length();
@ -1180,13 +1183,13 @@ void CInput::UpdateText(int from, int to_before, int to_after)
check_point_row_start += delta;
check_point_row_end += delta;
if (to != caption.Length())
if (to != (int)caption.Length())
to += delta;
}
}
int last_word_started=from;
int last_list_start=-1;
//int last_list_start=-1; // unused
float x_pos = 0.f;
//if (to_before != -1)
@ -1196,7 +1199,7 @@ void CInput::UpdateText(int from, int to_before, int to_after)
{
if (caption[i] == L'\n' && multiline)
{
if (i==to-1 && to != caption.Length())
if (i==to-1 && to != (int)caption.Length())
break; // it will be added outside
CStr c_caption1(caption.GetSubstring(row.m_ListStart, row.m_ListOfX.size()));
@ -1378,7 +1381,7 @@ void CInput::UpdateText(int from, int to_before, int to_after)
// we'll add has got the same value as the next row.
if (current_line != m_CharacterPositions.end())
{
if (row.m_ListStart + row.m_ListOfX.size() == current_line->m_ListStart)
if (row.m_ListStart + (int)row.m_ListOfX.size() == current_line->m_ListStart)
row.m_ListOfX.resize( row.m_ListOfX.size()-1 );
}
@ -1432,7 +1435,7 @@ int CInput::GetMouseHoveringTextPosition()
// TODO: Get the real font
CFont font(font_name);
float spacing = (float)font.GetLineSpacing();
float height = (float)font.GetHeight();
//float height = (float)font.GetHeight(); // unused
// Change mouse position relative to text.
mouse -= m_CachedActualSize.TopLeft();
@ -1499,7 +1502,7 @@ int CInput::GetXTextPosition(const list<SRow>::iterator &current, const float &x
}
// If a position wasn't found, we will assume the last
// character of that line.
if (i == current->m_ListOfX.size())
if (i == (int)current->m_ListOfX.size())
{
Ret += i;
wanted = x;

View File

@ -436,7 +436,7 @@ void CList::SelectNextElement()
CGUIList *pList;
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
if (selected != pList->m_Items.size()-1)
if (selected != (int)pList->m_Items.size()-1)
{
++selected;
GUI<int>::SetSetting(this, "selected", selected);
@ -474,7 +474,7 @@ void CList::SelectLastElement()
CGUIList *pList;
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
if (selected != pList->m_Items.size()-1)
if (selected != (int)pList->m_Items.size()-1)
{
GUI<int>::SetSetting(this, "selected", (int)pList->m_Items.size()-1);
}

View File

@ -228,7 +228,7 @@ bool __ParseString<CGUISpriteInstance>(const CStr& Value, CGUISpriteInstance &Ou
}
template <>
bool __ParseString<CGUIList>(const CStr& Value, CGUIList &Output)
bool __ParseString<CGUIList>(const CStr& UNUSED(Value), CGUIList& UNUSED(Output))
{
//LOG(WARNING, LOG_CATEGORY, "Cannot set a 'list' from a string.");
return false;

View File

@ -318,7 +318,7 @@ protected:
*
* @param Message GUI Message
*/
virtual void HandleMessage(const SGUIMessage& UNUSEDPARAM(Message)) {}
virtual void HandleMessage(const SGUIMessage& UNUSED(Message)) {}
/**
* Draws the object.
@ -340,7 +340,7 @@ protected:
* the key won't be passed on and processed by other handlers.
* This is used for keys that the GUI uses.
*/
virtual int ManuallyHandleEvent(const SDL_Event* ev) { return EV_PASS; }
virtual int ManuallyHandleEvent(const SDL_Event* UNUSED(ev)) { return EV_PASS; }
/**
* Loads a style.
@ -426,8 +426,8 @@ protected:
* Notice 'false' is default, because an object not using this function, should not
* have any additional children (and this function should never be called).
*/
virtual bool HandleAdditionalChildren(const XMBElement& UNUSEDPARAM(child),
CXeromyces* UNUSEDPARAM(pFile)) { return false; }
virtual bool HandleAdditionalChildren(const XMBElement& UNUSED(child),
CXeromyces* UNUSED(pFile)) { return false; }
/**
* Cached size, real size m_Size is actually dependent on resolution
@ -544,7 +544,7 @@ class CGUIDummyObject : public IGUIObject
public:
virtual void HandleMessage(const SGUIMessage& UNUSEDPARAM(Message)) {}
virtual void HandleMessage(const SGUIMessage& UNUSED(Message)) {}
virtual void Draw() {}
// Empty can never be hovered. It is only a category.
virtual bool MouseOver() { return false; }

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& UNUSEDPARAM(mouse)) { return false; }
virtual bool HoveringButtonMinus(const CPos& UNUSED(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& UNUSEDPARAM(mouse)) { return false; }
virtual bool HoveringButtonPlus(const CPos& UNUSED(mouse)) { return false; }
/**
* Get scroll-position

View File

@ -35,7 +35,7 @@ JSFunctionSpec JSI_GUISize::JSI_methods[] =
{ 0 }
};
JSBool JSI_GUISize::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
JSBool JSI_GUISize::construct(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* UNUSED(rval))
{
if (argc == 8)
{
@ -85,7 +85,7 @@ CStr ToPercentString(double pix, double per)
return CStr(per)+CStr("%")+( pix == 0.0 ? CStr() : pix > 0.0 ? CStr("+")+CStr(pix) : CStr(pix) );
}
JSBool JSI_GUISize::toString(JSContext* cx, JSObject* obj, uintN UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval)
JSBool JSI_GUISize::toString(JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval)
{
CStr buffer;
@ -139,7 +139,7 @@ JSFunctionSpec JSI_GUIColor::JSI_methods[] =
{ 0 }
};
JSBool JSI_GUIColor::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
JSBool JSI_GUIColor::construct(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* UNUSED(rval))
{
if (argc == 4)
{
@ -163,7 +163,8 @@ JSBool JSI_GUIColor::construct(JSContext* cx, JSObject* obj, unsigned int argc,
return JS_TRUE;
}
JSBool JSI_GUIColor::toString(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
JSBool JSI_GUIColor::toString(JSContext* cx, JSObject* obj,
uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval)
{
char buffer[256];
// Convert to integers, to be compatible with the GUI's string SetSetting
@ -202,7 +203,7 @@ JSFunctionSpec JSI_GUIMouse::JSI_methods[] =
{ 0 }
};
JSBool JSI_GUIMouse::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_GUIMouse::construct(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* UNUSED(rval))
{
if (argc == 3)
{
@ -220,7 +221,7 @@ JSBool JSI_GUIMouse::construct(JSContext* cx, JSObject* obj, unsigned int argc,
return JS_TRUE;
}
JSBool JSI_GUIMouse::toString(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
JSBool JSI_GUIMouse::toString(JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval)
{
char buffer[256];
snprintf(buffer, 256, "%i %i %i",

View File

@ -1,4 +1,4 @@
// $Id: JSInterface_GUITypes.h,v 1.2 2004/07/11 16:21:52 philip Exp $
// $Id$
#include "scripting/ScriptingHost.h"
@ -11,9 +11,9 @@
extern JSClass JSI_class; \
extern JSPropertySpec JSI_props[]; \
extern JSFunctionSpec JSI_methods[]; \
JSBool construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ); \
JSBool getByName( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ); \
JSBool toString( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ); \
JSBool construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ); \
JSBool getByName( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ); \
JSBool toString( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ); \
}
GUISTDTYPE(Size)

View File

@ -524,7 +524,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* UNUSEDPARAM(rval))
JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* UNUSED(rval))
{
if (argc == 0)
{
@ -542,7 +542,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc
}
JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* UNUSEDPARAM(obj), unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval)
{
debug_assert(argc == 1);
@ -569,7 +569,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 UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval)
JSBool JSI_IGUIObject::toString(JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval)
{
IGUIObject* e = (IGUIObject*)JS_GetPrivate( cx, obj );

View File

@ -14,9 +14,9 @@ namespace JSI_IGUIObject
JSBool delProperty(JSContext* cx, JSObject* obj, jsval id, jsval* vp);
JSBool getProperty(JSContext* cx, JSObject* obj, jsval id, jsval* vp);
JSBool setProperty(JSContext* cx, JSObject* obj, jsval id, jsval* vp);
JSBool construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval);
JSBool getByName(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval);
JSBool toString(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval);
JSBool construct(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval);
JSBool getByName(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval);
JSBool toString(JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval);
void init();
}

View File

@ -293,16 +293,16 @@ StringBuffer CLocale::Translate(const wchar_t* id)
LOG(WARNING, LOG_CATEGORY, "I18n: No translation found for string '%ls'", id);
// Just use the ID string directly, and remember it for the future
return StringBuffer(AddDefaultString(id), this);
return StringBuffer(&AddDefaultString(id), this);
}
return StringBuffer(*(*TransStr).second, this);
return StringBuffer((*TransStr).second, this);
}
void CLocale::AddToCache(StringBuffer* sb, Str& str)
{
CacheData& d = TranslationCache[&sb->String];
CacheData& d = TranslationCache[sb->String];
// Clean up any earlier cache entry
std::for_each(d.vars.begin(), d.vars.end(), delete_fn<BufferVariable>);
@ -317,7 +317,7 @@ bool CLocale::ReadCached(StringBuffer* sb, Str& str)
{
// Look for a string with the right key in the cache
std::map<TranslatedString*, CacheData>::iterator it =
TranslationCache.find(&sb->String);
TranslationCache.find(sb->String);
// See if it actually exists
if (it == TranslationCache.end())

View File

@ -24,7 +24,7 @@ All other methods are used internally by other I18n components.
#include <algorithm>
// GCC requires an explicit hash function for wide strings
#ifdef __GNUC__
#if GCC_VERSION
namespace __gnu_cxx
{
template<> struct hash<I18n::Str>
@ -76,11 +76,11 @@ namespace I18n
// Disable the "'this' used in base member initializer list" warning: only the
// pointer (and not the data it points to) is accessed by ScriptObject's
// constructor, so it shouldn't cause any problems.
#ifdef _MSC_VER
#if MSC_VERSION
# pragma warning (disable: 4355)
#endif
CLocale(JSContext* context, JSObject* scope) : Script(this, context, scope), CacheAge(0) {}
#ifdef _MSC_VER
#if MSC_VERSION
# pragma warning (default: 4355)
#endif

View File

@ -77,6 +77,7 @@ namespace JSI_i18n {
JS_ASSERT(object, "Failed to create i18n value object"); \
\
/* TODO: More error checking */ \
JS_ASSERT(argc == 1, "Create_" #x ": not enough params"); \
jsval type = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, #x)); \
jsval value = STRING_TO_JSVAL(JS_ValueToString(cx, argv[0])); \
JS_SetProperty(cx, object, "type", &type); \
@ -164,6 +165,7 @@ static JSBool JSFunc_Translate(JSContext *cx, JSObject *obj, uintN argc, jsval *
jsval locale_objval;
JS_ASSERT(JS_GetProperty(cx, obj, "i18n", &locale_objval), "translate() failed to find i18n object in current scope");
JSObject* locale_obj = JSVAL_TO_OBJECT(locale_objval);
UNUSED2(locale_obj);
CLocale* locale = (CLocale*)JS_GetPrivate(cx, JSVAL_TO_OBJECT(locale_objval));
StringBuffer sb = locale->Translate(phrase.c_str());
@ -364,7 +366,7 @@ ScriptValueString::ScriptValueString(ScriptObject& script, const wchar_t* s)
}
}
jsval ScriptValueString::GetJsval(const std::vector<BufferVariable*>& vars)
jsval ScriptValueString::GetJsval(const std::vector<BufferVariable*>& UNUSED(vars))
{
return Value;
}
@ -386,7 +388,7 @@ ScriptValueInteger::ScriptValueInteger(ScriptObject& script, const int v)
Value = INT_TO_JSVAL(v);
}
jsval ScriptValueInteger::GetJsval(const std::vector<BufferVariable*>& vars)
jsval ScriptValueInteger::GetJsval(const std::vector<BufferVariable*>& UNUSED(vars))
{
return Value;
}

View File

@ -48,7 +48,7 @@ namespace I18n
}
// On non-MSVC, or on MSVC with a native wchar_t type, define jschar separately
#if !defined(_MSC_VER) || !defined(_WCHAR_T_DEFINED)
#if !MSC_VERSION || !defined(_WCHAR_T_DEFINED)
StrImW(const jschar* s)
{
ref = new strImW_data;

View File

@ -8,7 +8,7 @@ using namespace I18n;
// Vaguely useful utility function for deleting stuff
template<typename T> void delete_fn(T* v) { delete v; }
const StrImW TSComponentString::ToString(CLocale* locale, std::vector<BufferVariable*>& vars) const
const StrImW TSComponentString::ToString(CLocale* UNUSED(locale), std::vector<BufferVariable*>& UNUSED(vars)) const
{
return String;
}

View File

@ -35,6 +35,10 @@ namespace I18n
private:
const StrImW String;
// squelch "unable to generate" warnings
TSComponentString(const TSComponentString& rhs);
const TSComponentString& operator=(const TSComponentString& rhs);
};
@ -64,6 +68,10 @@ namespace I18n
private:
const std::string Name;
std::vector<ScriptValue*> Params;
// squelch "unable to generate" warnings
TSComponentFunction(const TSComponentFunction& rhs);
const TSComponentFunction& operator=(const TSComponentFunction& rhs);
};

View File

@ -9,7 +9,7 @@
// the additional u8 cast ensures each character is treated as unsigned
// (otherwise, they'd be promoted to signed int before the u32 cast,
// which would break things).
#ifdef IS_BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
#define FOURCC(a,b,c,d) ( ((u32)(u8)a) << 24 | ((u32)(u8)b) << 16 | \
((u32)(u8)c) << 8 | ((u32)(u8)d) << 0 )
#else

View File

@ -470,10 +470,11 @@ void CConsole::SetBuffer(const wchar_t* szMessage, ...)
m_iBufferLength = m_iBufferPos = (int)wcslen(m_szBuffer);
}
void CConsole::UseHistoryFile( CStr filename, unsigned int historysize )
void CConsole::UseHistoryFile( CStr filename, int max_history_lines )
{
m_MaxHistoryLines = max_history_lines;
m_sHistoryFile = filename;
m_iHistorySize = historysize;
LoadHistory();
}
@ -592,10 +593,11 @@ void CConsole::SaveHistory()
{
CStr buffer;
std::deque<std::wstring>::iterator it;
unsigned int count = 0;
int line_count = 0;
for( it = m_deqBufHistory.begin(); it != m_deqBufHistory.end(); ++it )
{
if( count++ >= m_iHistorySize ) break;
if(line_count++ >= m_MaxHistoryLines)
break;
buffer = CStrW( *it ).ToUTF8() + "\n" + buffer;
}
vfs_store( m_sHistoryFile, (void*)buffer.c_str(), buffer.Length(), FILE_NO_AIO );

View File

@ -54,7 +54,7 @@ private:
int m_iBufferLength;
CStr m_sHistoryFile;
unsigned int m_iHistorySize;
int m_MaxHistoryLines;
bool m_bFocus;
bool m_bVisible; // console is to be drawn
@ -101,7 +101,7 @@ public:
void SetBuffer(const wchar_t* szMessage, ...);
void UseHistoryFile( CStr filename, unsigned int historysize );
void UseHistoryFile( CStr filename, int historysize );
// Only returns a pointer to the buffer; copy out of here if you want to keep it.
const wchar_t* GetBuffer();

View File

@ -64,6 +64,10 @@ private:
// Used to remember LogOnce messages
std::set<std::string> m_LoggedOnce;
// squelch "unable to generate" warnings
CLogger(const CLogger& rhs);
const CLogger& operator=(const CLogger& rhs);
};
#endif

View File

@ -38,7 +38,7 @@ CStr8 CStrW::ToUTF8() const
{
CStr8 result;
const wchar_t* source = &*begin();
//const wchar_t* source = &*begin(); // UNUSED
for (size_t i = 0; i < Length(); ++i)
{
unsigned short bytesToWrite;
@ -525,7 +525,6 @@ const u8 *CStrW::Deserialize(const u8 *buffer, const u8 *bufferend)
if ((const u8 *)strend >= bufferend) return NULL;
resize(strend - (const u16 *)buffer);
size_t i = 0;
const u16 *ptr = (const u16 *)buffer;
std::wstring::iterator str = begin();

View File

@ -93,7 +93,7 @@ public:
// CStr(8|W) construction from utf16strings, except on MSVC CStrW where
// CStrW === utf16string
#if !(defined(_MSC_VER) && defined(_UNICODE))
#if !(MSC_VERSION && defined(_UNICODE))
CStr(utf16string String) : std::tstring(String.begin(), String.end()) {}
#endif
@ -213,7 +213,7 @@ public:
// Do some range checking in debug builds
tchar& operator[](size_t n) { debug_assert(n < length()); return this->std::tstring::operator[](n); }
tchar &operator[](int n) { debug_assert(n >= 0 && (size_t)n < length()); return this->std::tstring::operator[](n); }
tchar& operator[](int n) { debug_assert((size_t)n < length()); return this->std::tstring::operator[](n); }
// Conversion to utf16string
inline utf16string utf16() const

View File

@ -63,7 +63,7 @@ namespace ConfigNamespace_JS
JS_ConvertStub, JS_FinalizeStub
};
JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* UNUSED(argv), jsval* rval )
{
if (argc != 0)
return JS_FALSE;
@ -78,7 +78,7 @@ namespace ConfigNamespace_JS
JS_SetPrivate(cx, obj, (void *)cfgNs);
}
JSBool WriteFile( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool WriteFile( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval )
{
EConfigNamespace cfgNs=(EConfigNamespace)(intptr_t)JS_GetPrivate(cx, obj);
if (cfgNs < 0 || cfgNs >= CFG_LAST)
@ -99,7 +99,7 @@ namespace ConfigNamespace_JS
return JS_FALSE;
}
JSBool Reload( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool Reload( JSContext* cx, JSObject* obj, uint argc, jsval* UNUSED(argv), jsval* rval )
{
if (argc != 0)
return JS_FALSE;
@ -113,7 +113,7 @@ namespace ConfigNamespace_JS
return JS_TRUE;
}
JSBool SetFile( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool SetFile( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* UNUSED(rval) )
{
if (argc != 0)
return JS_FALSE;
@ -159,7 +159,7 @@ namespace ConfigDB_JS
{0}
};
JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* UNUSED(argv), jsval* rval )
{
if (argc != 0)
return JS_FALSE;
@ -360,7 +360,7 @@ bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, CStr path)
return false;
}
uint offset=0;
//uint offset=0; // unused
TConfigMap &map=m_Map[ns];
TConfigMap::const_iterator it=map.begin();

View File

@ -120,4 +120,22 @@ public:
bool WriteFile(EConfigNamespace ns, bool useVFS, CStr path);
};
// stores the value of the given key into <destination>. this quasi-template
// convenience wrapper on top of CConfigValue::Get* simplifies user code and
// avoids "assignment within condition expression" warnings.
#define CFG_GET_SYS_VAL(name, type, destination)\
STMT(\
CConfigValue* val = g_ConfigDB.GetValue(CFG_SYSTEM, name);\
if(val)\
val->Get##type(destination);\
)
#define CFG_GET_USER_VAL(name, type, destination)\
STMT(\
CConfigValue* val = g_ConfigDB.GetValue(CFG_USER, name);\
if(val)\
val->Get##type(destination);\
)
#endif

View File

@ -19,7 +19,7 @@ CGame *g_Game=NULL;
// members or call member functions on this, the result will be undefined."
// In this case, the pointers are simply stored for later use, so there
// should be no problem.
#ifdef _MSC_VER
#if MSC_VERSION
# pragma warning (disable: 4355)
#endif
@ -33,7 +33,7 @@ CGame::CGame():
debug_printf("CGame::CGame(): Game object CREATED; initializing..\n");
}
#ifdef _MSC_VER
#if MSC_VERSION
# pragma warning (default: 4355)
#endif
@ -140,7 +140,7 @@ CPlayer *CGame::GetPlayer(uint idx)
if (m_Players.size() == 0)
{
// Hmm. This is a bit of a problem.
debug_assert(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###");
debug_warn("### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###");
abort();
return NULL; // else VC2005 warns about not returning a value
}

View File

@ -79,6 +79,10 @@ public:
private:
PSRETURN RegisterInit(CGameAttributes* pAttribs);
// squelch "unable to generate" warnings
CGame(const CGame& rhs);
const CGame& operator=(const CGame& rhs);
};
extern CGame *g_Game;

View File

@ -64,21 +64,22 @@ jsval CPlayerSlot::JSI_GetAssignment()
}
}
bool CPlayerSlot::JSI_AssignClosed(JSContext *cx, uintN argc, jsval *argv)
bool CPlayerSlot::JSI_AssignClosed(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
AssignClosed();
return true;
}
bool CPlayerSlot::JSI_AssignOpen(JSContext *cx, uintN argc, jsval *argv)
bool CPlayerSlot::JSI_AssignOpen(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
AssignOpen();
return true;
}
bool CPlayerSlot::JSI_AssignToSession(JSContext *cx, uintN argc, jsval *argv)
bool CPlayerSlot::JSI_AssignToSession(JSContext* UNUSED(cx), uintN argc, jsval* argv)
{
if (argc != 1) return false;
if (argc != 1)
return false;
CNetServerSession *pSession=ToNative<CNetServerSession>(argv[0]);
if (pSession)
{
@ -89,7 +90,7 @@ bool CPlayerSlot::JSI_AssignToSession(JSContext *cx, uintN argc, jsval *argv)
return true;
}
bool CPlayerSlot::JSI_AssignLocal(JSContext *cx, uintN argc, jsval *argv)
bool CPlayerSlot::JSI_AssignLocal(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
AssignToSessionID(1);
return true;
@ -144,7 +145,7 @@ namespace PlayerSlotArray_JS
CGameAttributes *pInstance=(CGameAttributes *)JS_GetPrivate(cx, obj);
if (!JSVAL_IS_INT(id))
return JS_FALSE;
uint index=g_ScriptingHost.ValueToInt(id);
uint index=ToPrimitive<uint>(id);
if (index > pInstance->m_NumSlots)
return JS_FALSE;
@ -153,7 +154,7 @@ namespace PlayerSlotArray_JS
return JS_TRUE;
}
JSBool SetProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
JSBool SetProperty( JSContext* UNUSED(cx), JSObject* UNUSED(obj), jsval UNUSED(id), jsval* UNUSED(vp) )
{
return JS_FALSE;
}
@ -166,7 +167,7 @@ namespace PlayerSlotArray_JS
JS_ConvertStub, JS_FinalizeStub
};
JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval )
JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* UNUSED(argv), jsval* rval )
{
if (argc != 0)
return JS_FALSE;
@ -266,7 +267,7 @@ void CGameAttributes::ScriptingInit()
CJSObject<CGameAttributes>::ScriptingInit("GameAttributes");
}
jsval CGameAttributes::JSI_GetOpenSlot(JSContext *cx, uintN argc, jsval *argv)
jsval CGameAttributes::JSI_GetOpenSlot(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
vector <CPlayerSlot *>::iterator it;
for (it = m_PlayerSlots.begin();it != m_PlayerSlots.end();++it)

View File

@ -2,7 +2,6 @@
#include "GameRecord.h"
void CGameRecord::WriteMessage(CNetMessage *pMsg)
void CGameRecord::WriteMessage(CNetMessage* UNUSED(pMsg))
{
}

View File

@ -395,7 +395,7 @@ int hotkeyInputHandler( const SDL_Event* ev )
// SDL-events bit
unsigned int closestMap;
uint closestMap = 0; // avoid "uninitialized" warning
size_t closestMapMatch = 0;
for( it = hotkeyMap[keycode].begin(); it < hotkeyMap[keycode].end(); it++ )

View File

@ -441,7 +441,7 @@ void CSelectedEntities::update()
void CMouseoverEntities::update( float timestep )
{
CCamera *pCamera=g_Game->GetView()->GetCamera();
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
//CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
CVector3D origin, dir;
pCamera->BuildCameraRay( origin, dir );
@ -786,8 +786,8 @@ int interactInputHandler( const SDL_Event* ev )
return EV_PASS;
CGameView *pView=g_Game->GetView();
CCamera *pCamera=pView->GetCamera();
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
//CCamera *pCamera=pView->GetCamera();
//CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
// One entry for each mouse button
static double lastclicktime[SDL_BUTTON_INDEX_COUNT];
@ -920,7 +920,7 @@ int interactInputHandler( const SDL_Event* ev )
return( EV_PASS );
}
bool isOnScreen( CEntity* ev, void* userdata )
bool isOnScreen( CEntity* ev, void* UNUSED(userdata) )
{
CCamera *pCamera=g_Game->GetView()->GetCamera();
@ -933,7 +933,7 @@ bool isOnScreen( CEntity* ev, void* userdata )
return( frustum.IsBoxVisible( ev->m_graphics_position, CBound() ) );
}
bool isMouseoverType( CEntity* ev, void* userdata )
bool isMouseoverType( CEntity* ev, void* UNUSED(userdata) )
{
std::vector<SMouseoverFader>::iterator it;
for( it = g_Mouseover.m_mouseover.begin(); it < g_Mouseover.m_mouseover.end(); it++ )

View File

@ -50,9 +50,9 @@ struct LoadRequest
LoadFunc func;
void* param;
const CStrW description;
CStrW description;
// rationale for storing as CStrW here:
// - needs to be wide because it's user-visible and will be translated.
// - needs to be WCS because it's user-visible and will be translated.
// - don't just store a pointer - the caller's string may be volatile.
// - the module interface must work in C, so we get/set as wchar_t*.

View File

@ -13,9 +13,13 @@ template<class T> struct MemFun_t
int(T::*func)(void);
MemFun_t(T* this__, int(T::*func_)(void))
: this_(this__), func(func_) {}
// squelch "unable to generate" warnings
MemFun_t(const MemFun_t& rhs);
const MemFun_t& operator=(const MemFun_t& rhs);
};
template<class T> static int MemFunThunk(void* param, double time_left)
template<class T> static int MemFunThunk(void* param, double UNUSED(time_left))
{
MemFun_t<T>* const mf = (MemFun_t<T>*)param;
int ret = (mf->this_->*mf->func)();
@ -42,9 +46,13 @@ template<class T, class Arg> struct MemFun1_t
int(T::*func)(Arg);
MemFun1_t(T* this__, int(T::*func_)(Arg), Arg arg_)
: this_(this__), func(func_), arg(arg_) {}
// squelch "unable to generate" warnings
MemFun1_t(const MemFun1_t& rhs);
const MemFun1_t& operator=(const MemFun1_t& rhs);
};
template<class T, class Arg> static int MemFun1Thunk(void* param, double time_left)
template<class T, class Arg> static int MemFun1Thunk(void* param, double UNUSED(time_left))
{
MemFun1_t<T, Arg>* const mf = (MemFun1_t<T, Arg>*)param;
int ret = (mf->this_->*mf->func)(mf->arg);

View File

@ -80,7 +80,7 @@ void CNetClient::ScriptingInit()
CJSObject<CNetClient>::ScriptingInit("NetClient");
}
bool CNetClient::JSI_BeginConnect(JSContext *cx, uintN argc, jsval *argv)
bool CNetClient::JSI_BeginConnect(JSContext* UNUSED(cx), uintN argc, jsval *argv)
{
CStr connectHostName;
uint connectPort=PS_DEFAULT_PORT;
@ -90,7 +90,7 @@ bool CNetClient::JSI_BeginConnect(JSContext *cx, uintN argc, jsval *argv)
}
if (argc >= 2)
{
connectPort=g_ScriptingHost.ValueToInt(argv[1]);
connectPort=ToPrimitive<int>(argv[1]);
}
PS_RESULT res=BeginConnect(connectHostName.c_str(), connectPort);
@ -292,7 +292,7 @@ bool CNetClient::PreGameHandler(CNetMessage *pMsg, CNetSession *pSession)
switch (msg->m_Assignment)
{
case PS_ASSIGN_SESSION:
if (msg->m_SessionID == pClient->m_SessionID)
if ((int)msg->m_SessionID == (int)pClient->m_SessionID) // squelch bogus sign mismatch warning
pClient->m_pLocalPlayerSlot=pSlot;
pSlot->AssignToSessionID(msg->m_SessionID);
break;

View File

@ -74,9 +74,9 @@ class CClientConnectDisconnectCommon: public CScriptEvent
CNetServerSession *m_pSession;
public:
CClientConnectDisconnectCommon(const wchar_t* eventName, int eventType,
int sessionID, const CStrW &name, CNetServerSession *pSession):
CScriptEvent(L"clientConnect", NET_JS_EVENT_CLIENT_CONNECT, false),
CClientConnectDisconnectCommon(const wchar_t* UNUSED(eventName), int UNUSED(eventType),
int sessionID, const CStrW &name, CNetServerSession* pSession)
: CScriptEvent(L"clientConnect", NET_JS_EVENT_CLIENT_CONNECT, false),
m_SessionID(sessionID),
m_Name(name),
m_pSession(pSession)

View File

@ -120,13 +120,15 @@ public: \
uint _nm::GetSerializedLength() const \
{ \
uint ret=_base::GetSerializedLength(); \
const _nm *thiz=this;
const _nm *thiz=this;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_START_ARRAY(_nm) \
std::vector <ARRAY_STRUCT_PREFIX(_nm)>::const_iterator it=_nm.begin(); \
while (it != _nm.end()) \
{ \
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_END_ARRAY() \
++it; \
@ -160,13 +162,15 @@ u8 *_nm::Serialize(u8 *buffer) const \
{ \
/*printf("In " #_nm "::Serialize()\n");*/ \
u8 *pos=_base::Serialize(buffer); \
const _nm *thiz=this;
const _nm *thiz=this;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_START_ARRAY(_nm) \
std::vector <ARRAY_STRUCT_PREFIX(_nm)>::const_iterator it=_nm.begin(); \
while (it != _nm.end()) \
{ \
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_END_ARRAY() \
++it; \
@ -211,12 +215,15 @@ const u8 *_nm::Deserialize(const u8 *pos, const u8 *end) \
{ \
pos=_base::Deserialize(pos, end); \
_nm *thiz=this; \
/*printf("In Deserialize" #_nm "\n"); */
/*printf("In Deserialize" #_nm "\n"); */\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_START_ARRAY(_nm) \
while (pos < end) \
{ \
ARRAY_STRUCT_PREFIX(_nm) *thiz=&*_nm.insert(_nm.end(), ARRAY_STRUCT_PREFIX(_nm)());
ARRAY_STRUCT_PREFIX(_nm) *thiz=&*_nm.insert(_nm.end(), ARRAY_STRUCT_PREFIX(_nm)());\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_END_ARRAY() \
}
@ -286,7 +293,8 @@ CStr _nm::GetString() const \
CStr _nm::GetStringRaw() const \
{ \
CStr ret; \
const _nm *thiz=this;
const _nm *thiz=this;\
UNUSED2(thiz); // preempt any "unused" warning
#define START_NMT_CLASS_DERIVED(_base, _nm, _tp) \
CStr _nm::GetString() const \
@ -297,7 +305,8 @@ CStr _nm::GetString() const \
CStr _nm::GetStringRaw() const \
{ \
CStr ret=_base::GetStringRaw() + _T(", "); \
const _nm *thiz=this;
const _nm *thiz=this;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_START_ARRAY(_nm) \
ret+=#_nm _T(": { "); \
@ -305,7 +314,8 @@ CStr _nm::GetStringRaw() const \
while (it != _nm.end()) \
{ \
ret+=_T(" { "); \
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;
const ARRAY_STRUCT_PREFIX(_nm) *thiz=&*it;\
UNUSED2(thiz); // preempt any "unused" warning
#define NMT_END_ARRAY() \
++it; \

View File

@ -40,8 +40,10 @@ CStr CNetMessage::GetString() const
return CStr("Unknown Message ")+CStr(m_Type);
}
const u8 *CNetMessage::Deserialize(const u8 *pos, const u8 *end)
{ return pos; }
const u8 *CNetMessage::Deserialize(const u8* pos, const u8* UNUSED(end))
{
return pos;
}
CNetMessage *CNetMessage::Copy() const
{
@ -90,7 +92,7 @@ CNetCommand *CNetMessage::CommandFromJSArgs(const CEntityList &entities, JSConte
try
{
msgType = g_ScriptingHost.ValueToInt( argv[0] );
msgType = ToPrimitive<int>( argv[0] );
}
catch(PSERROR_Scripting_ConversionFailed)
{
@ -110,8 +112,8 @@ CNetCommand *CNetMessage::CommandFromJSArgs(const CEntityList &entities, JSConte
ArgumentCountError();\
if (!JSVAL_IS_INT(argv[argIndex]) || !JSVAL_IS_INT(argv[argIndex+1])) \
ArgumentTypeError(); \
_msg->_field ## X = g_ScriptingHost.ValueToInt(argv[argIndex++]); \
_msg->_field ## Y = g_ScriptingHost.ValueToInt(argv[argIndex++]); \
_msg->_field ## X = ToPrimitive<int>(argv[argIndex++]); \
_msg->_field ## Y = ToPrimitive<int>(argv[argIndex++]); \
} catch (PSERROR_Scripting_ConversionFailed) { \
JS_ReportError(cx, "Invalid location"); \
return NULL; \

View File

@ -3,14 +3,15 @@
#include <map>
#ifndef _WIN32
#if !OS_WIN
#define Network_GetErrorString(_error, _buf, _buflen) strerror_r(_error, _buf, _buflen)
#define Network_LastError errno
#define closesocket(_fd) close(_fd)
#else
#else // i.e. #if OS_WIN
#define Network_GetErrorString(_error, _buf, _buflen) \
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, _error+WSABASEERR, 0, _buf, _buflen, NULL)
@ -36,7 +37,7 @@
#define MSG_SOCKET_READY WM_USER
#endif
#endif // #if OS_WIN
typedef int socket_t;
@ -80,7 +81,7 @@ struct CSocketSetInternal
uint m_NumSockets;
std::map <socket_t, CSocketBase * > m_HandleMap;
#ifdef _WIN32
#if OS_WIN
HWND m_hWnd;
#else
// [0] is for use by RunWaitLoop, [1] for SendWaitLoopAbort and SendWaitLoopUpdate
@ -93,7 +94,7 @@ struct CSocketSetInternal
public:
inline CSocketSetInternal()
{
#ifdef _WIN32
#if OS_WIN
m_hWnd=NULL;
#else
m_Pipe[0]=-1;

View File

@ -43,6 +43,7 @@ void CNetServer::OnAccept(const CSocketAddress &addr)
CSocketInternal *pInt=Accept();
CNetServerSession *pSession=CreateSession(pInt);
UNUSED2(pSession);
}
CNetServer::CNetServer(CGame *pGame, CGameAttributes *pGameAttribs):
@ -105,7 +106,7 @@ void CNetServer::ScriptingInit()
CJSObject<CNetServer>::ScriptingInit("NetServer");
}
bool CNetServer::JSI_Open(JSContext *cx, uintN argc, jsval *argv)
bool CNetServer::JSI_Open(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
CSocketAddress addr;
if (m_Port == -1)
@ -270,7 +271,7 @@ void CNetServer::PlayerSlotAssignmentCallback(void *userdata, CPlayerSlot *pSlot
pInstance->Broadcast(pMsg);
}
bool CNetServer::AllowObserver(CNetServerSession *pSession)
bool CNetServer::AllowObserver(CNetServerSession* UNUSED(pSession))
{
return m_Observers.size() < m_MaxObservers;
}

View File

@ -136,8 +136,6 @@ bool CNetServerSession::AuthenticateHandler(CNetMessage *pMsg, CNetSession *pNet
bool CNetServerSession::PreGameHandler(CNetMessage *pMsg, CNetSession *pNetSession)
{
CNetServerSession *pSession=(CNetServerSession *)pNetSession;
return ChatHandler(pMsg, pNetSession);
}
@ -211,7 +209,7 @@ void CNetServerSession::ScriptingInit()
AddProperty( L"name", (CStrW CNetServerSession::*)&CNetServerSession::m_Name );
}
bool CNetServerSession::JSI_Close(JSContext *cx, uintN argc, jsval *argv)
bool CNetServerSession::JSI_Close(JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv))
{
return false;
}

View File

@ -27,5 +27,5 @@ void CServerSocket::OnRead()
void CServerSocket::OnWrite()
{}
void CServerSocket::OnClose(PS_RESULT errorCode)
void CServerSocket::OnClose(PS_RESULT UNUSED(errorCode))
{}

View File

@ -1,6 +1,6 @@
#include "precompiled.h"
#ifdef _WIN32
#if OS_WIN
#include "sysdep/win/win_internal.h"
#endif
@ -238,6 +238,8 @@ void CSocketBase::Shutdown()
void *WaitLoopThreadMain(void *)
{
debug_set_thread_name("net_wait");
GLOBAL_LOCK();
CSocketBase::RunWaitLoop();
@ -313,7 +315,7 @@ void CSocketBase::Destroy()
void CSocketBase::SetNonBlocking(bool nonblocking)
{
#ifdef _WIN32
#if OS_WIN
unsigned long nb=nonblocking;
int res=ioctlsocket(m_pInternal->m_fd, FIONBIO, &nb);
if (res == -1)
@ -547,7 +549,7 @@ void CSocketBase::Reject()
}
// UNIX select loop
#ifndef _WIN32
#if !OS_WIN
// ConnectError is called on a socket the first time it selects as ready
// after the BeginConnect, to check errors on the socket and update the
// connection status information
@ -788,11 +790,8 @@ void CSocketBase::SendWaitLoopUpdate()
write(g_SocketSetInternal.m_Pipe[1], &msg, 1);
}
#endif
// Windows WindowProc for async event notification
#ifdef _WIN32
#else // i.e. #if OS_WIN
void WaitLoop_SocketUpdateProc(int fd, int error, uint event)
{
@ -956,7 +955,7 @@ void CSocketBase::SendWaitLoopUpdate()
GLOBAL_UNLOCK();
}
}
#endif
#endif // #if OS_WIN
void CSocketBase::AbortWaitLoop()
{

View File

@ -202,7 +202,7 @@ private:
*/
friend void *WaitLoopThreadMain(void *);
#ifdef _WIN32
#if OS_WIN
/**
* Used by the winsock AsyncSelect windowproc
*/

View File

@ -18,6 +18,8 @@ CStreamSocket::~CStreamSocket()
void *CStreamSocket_ConnectThread(void *data)
{
debug_set_thread_name("net_connect");
CStreamSocket *pSock=(CStreamSocket *)data;
PS_RESULT res=PS_OK;
CSocketAddress addr;

View File

@ -452,7 +452,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine)
// found and no further looking is required
CParserTaskTypeNode *CurNode=NULL; // Current node on task type
CParserTaskTypeNode *PrevNode=NULL; // Last node
UNUSED(PrevNode);
UNUSED2(PrevNode);
// Iterate all different TaskType, and all TaskTypeElements...
// start from left and go to the right (prog), comparing

View File

@ -60,7 +60,7 @@ void CPlayer::SetValue(CStrW name, CStrW value)
}
}
bool CPlayer::ValidateCommand(CNetMessage *pMsg)
bool CPlayer::ValidateCommand(CNetMessage* UNUSED(pMsg))
{
return true;
}
@ -75,7 +75,7 @@ std::vector<HEntity>* CPlayer::GetControlledEntities()
return( g_EntityManager.matches( ControllerPredicate, this ) );
}
jsval CPlayer::JSI_ToString( JSContext* cx, uintN argc, jsval* argv )
jsval CPlayer::JSI_ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
{
wchar_t buffer[256];
swprintf( buffer, 256, L"[object Player: %ls]", m_Name.c_str() );
@ -92,7 +92,7 @@ jsval CPlayer::JSI_GetControlledEntities()
return( vp );
}
jsval CPlayer::JSI_SetColour( JSContext* cx, uintN argc, jsval* argv )
jsval CPlayer::JSI_SetColour( JSContext* UNUSED(cx), uintN argc, jsval* argv )
{
if (argc != 1)
return JSVAL_NULL;

View File

@ -158,6 +158,10 @@ public:
private:
pthread_mutex_t &m_Mutex;
// squelch "unable to generate" warnings
CScopeLock(const CScopeLock& rhs);
const CScopeLock& operator=(const CScopeLock& rhs);
};
// CLocker

View File

@ -16,7 +16,7 @@ bool VFSUtil::FindFiles (const CStr& dirname, const char* filter, FileList& file
{
files.clear();
Handle dir = vfs_open_dir(dirname);
Handle dir = vfs_dir_open(dirname);
if (dir <= 0)
{
LOG(ERROR, LOG_CATEGORY, "Error opening directory '%s' (%lld)", dirname.c_str(), dir);
@ -24,8 +24,8 @@ bool VFSUtil::FindFiles (const CStr& dirname, const char* filter, FileList& file
}
int err;
vfsDirEnt entry;
while ((err = vfs_next_dirent(dir, &entry, filter)) == 0)
DirEnt entry;
while ((err = vfs_dir_next_ent(dir, &entry, filter)) == 0)
{
files.push_back(dirname+"/"+entry.name);
}
@ -36,7 +36,7 @@ bool VFSUtil::FindFiles (const CStr& dirname, const char* filter, FileList& file
return false;
}
vfs_close_dir(dir);
vfs_dir_close(dir);
return true;
@ -44,13 +44,16 @@ bool VFSUtil::FindFiles (const CStr& dirname, const char* filter, FileList& file
// call <cb> for each entry matching <user_filter> (see vfs_next_dirent) in
// directory <start_path>; if <recursive>, entries in subdirectories are
// directory <path>; if <recursive>, entries in subdirectories are
// also returned.
//
// note: EnumDirEntsCB path and ent are only valid during the callback.
int VFSUtil::EnumDirEnts(const CStr start_path, const char* user_filter,
bool recursive, EnumDirEntsCB cb, void* context)
int VFSUtil::EnumDirEnts(const CStr start_path, int flags, const char* user_filter,
EnumDirEntsCB cb, void* context)
{
debug_assert((flags & ~(RECURSIVE)) == 0);
const bool recursive = (flags & RECURSIVE) != 0;
// note: currently no need to return subdirectories,
// but enabling it isn't hard (we have to check for / anyway).
@ -85,12 +88,12 @@ int VFSUtil::EnumDirEnts(const CStr start_path, const char* user_filter,
// note: can't refer to the queue contents - those are invalidated
// as soon as a directory is pushed onto it.
char path[VFS_MAX_PATH];
path_append(path, dir_queue.front().c_str(), "");
vfs_path_append(path, dir_queue.front().c_str(), "");
// vfs_open_dir checks this, so ignore failure
const size_t path_len = strlen(path);
dir_queue.pop_front();
Handle hdir = vfs_open_dir(path);
Handle hdir = vfs_dir_open(path);
if(hdir <= 0)
{
debug_warn("EnumFiles: vfs_open_dir failed");
@ -98,13 +101,13 @@ int VFSUtil::EnumDirEnts(const CStr start_path, const char* user_filter,
}
// for each entry (file, subdir) in directory:
vfsDirEnt ent;
while(vfs_next_dirent(hdir, &ent, filter) == 0)
DirEnt ent;
while(vfs_dir_next_ent(hdir, &ent, filter) == 0)
{
// build complete path (vfsDirEnt only stores entry name)
// build complete path (DirEnt only stores entry name)
strcpy_s(path+path_len, VFS_MAX_PATH-path_len, ent.name);
if(VFS_ENT_IS_DIR(ent))
if(DIRENT_IS_DIR(&ent))
{
if(recursive)
dir_queue.push_back(path);
@ -116,7 +119,7 @@ int VFSUtil::EnumDirEnts(const CStr start_path, const char* user_filter,
cb(path, &ent, context);
}
vfs_close_dir(hdir);
vfs_dir_close(hdir);
}
while(!dir_queue.empty());

View File

@ -18,12 +18,18 @@ extern bool FindFiles(const CStr& dirname, const char* filter, FileList& files);
// its subdirectories as well), passing their complete path+name, the info
// that would be returned by vfs_next_dirent, and user-specified context.
// note: path and ent parameters are only valid during the callback.
typedef void (*EnumDirEntsCB)(const char* path, const vfsDirEnt* ent,
typedef void (*EnumDirEntsCB)(const char* path, const DirEnt* ent,
void* context);
// call <cb> for each file in the <start_path> directory;
// if <recursive>, files in subdirectories are also returned.
extern int EnumDirEnts(const CStr path, const char* filter, bool recursive,
enum EnumDirEntsFlags
{
RECURSIVE = 1
};
// call <cb> for each entry matching <user_filter> (see vfs_next_dirent) in
// directory <path>; if flags & RECURSIVE, entries in subdirectories are
// also returned.
extern int EnumDirEnts(const CStr path, int flags, const char* filter,
EnumDirEntsCB cb, void* context);
}; // namespace VFSUtil

View File

@ -45,6 +45,11 @@ public:
{ return &m_UnitManager; }
inline CProjectileManager *GetProjectileManager()
{ return &m_ProjectileManager; }
private:
// squelch "unable to generate" warnings
CWorld(const CWorld& rhs);
const CWorld& operator=(const CWorld& rhs);
};
#include "Game.h"

View File

@ -23,8 +23,12 @@
#define _XercesVFS_H
// Temporarily undefine new, because the Xerces headers don't like it
#ifdef HAVE_VC_DEBUG_ALLOC
# undef new
#include "nommgr.h"
// temporarily go down to W3 because Xerces (in addition to all its other
// failings) isn't W4-clean.
#if MSC_VERSION
#pragma warning(push, 3)
#endif
#include <xercesc/util/XMLString.hpp>
@ -37,10 +41,20 @@
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#ifdef HAVE_VC_DEBUG_ALLOC
# define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
// for Xeromyces.cpp (moved here so we only have to #undef new and
// revert to W3 once)
// The converter uses SAX2, so it should [theoretically]
// be fairly easy to swap Xerces for something else (if desired)
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#if MSC_VERSION
#pragma warning(pop) // back to W4
#endif
#include "mmgr.h" // restore malloc/new macros
#include "lib/res/handle.h"
#include "lib.h"
#include "XercesErrorHandler.h"

View File

@ -21,7 +21,7 @@
#endif
*/
#ifdef _MSC_VER
#if MSC_VERSION
# ifdef XERCES_STATIC_LIB
# ifndef NDEBUG
# pragma comment(lib, "xerces-c_2D-static.lib")
@ -35,7 +35,7 @@
# pragma comment(lib, "xerces-c_2.lib")
# endif // NDEBUG
# endif // XERCES_STATIC_LIB
#endif // _MSC_VER
#endif // MSC_VERSION
XERCES_CPP_NAMESPACE_USE
@ -108,7 +108,7 @@ const char *prevpathcomp(const char *end, const char *beginning)
return end;
}
InputSource *CVFSEntityResolver::resolveEntity(const XMLCh *const UNUSEDPARAM(publicId),
InputSource *CVFSEntityResolver::resolveEntity(const XMLCh *const UNUSED(publicId),
const XMLCh *const systemId)
{
CVFSInputSource *ret=new CVFSInputSource();

View File

@ -2,8 +2,6 @@
#include "precompiled.h"
#include "nommgr.h"
#include <vector>
#include <set>
#include <map>
@ -21,21 +19,6 @@
#include "XML.h"
// For Xerces headers:
#ifdef HAVE_VC_DEBUG_ALLOC
# undef new
#endif
// The converter uses SAX2, so it should [theoretically]
// be fairly easy to swap Xerces for something else (if desired)
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
// Reenable better memory-leak messages
#ifdef HAVE_VC_DEBUG_ALLOC
# define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
int CXeromyces::XercesLoaded = 0; // for once-only initialisation
@ -363,7 +346,7 @@ std::string lowercase_ascii(const XMLCh *a)
return b;
}
void XeroHandler::startElement(const XMLCh* const UNUSEDPARAM(uri), const XMLCh* const localname, const XMLCh* const UNUSEDPARAM(qname), const Attributes& attrs)
void XeroHandler::startElement(const XMLCh* const UNUSED(uri), const XMLCh* const localname, const XMLCh* const UNUSED(qname), const Attributes& attrs)
{
std::string elementName = lowercase_ascii(localname);
ElementNames.insert(elementName);
@ -392,12 +375,12 @@ void XeroHandler::startElement(const XMLCh* const UNUSEDPARAM(uri), const XMLCh*
ElementStack.push(e);
}
void XeroHandler::endElement(const XMLCh* const UNUSEDPARAM(uri), const XMLCh* const UNUSEDPARAM(localname), const XMLCh* const UNUSEDPARAM(qname))
void XeroHandler::endElement(const XMLCh* const UNUSED(uri), const XMLCh* const UNUSED(localname), const XMLCh* const UNUSED(qname))
{
ElementStack.pop();
}
void XeroHandler::characters(const XMLCh* const chars, const unsigned int UNUSEDPARAM(length))
void XeroHandler::characters(const XMLCh* const chars, const unsigned int UNUSED(length))
{
ElementStack.top()->text += utf16string(chars, chars+XMLString::stringLen(chars));
}

View File

@ -104,7 +104,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::A
if( ( index >= 0 ) && ( index < (int)set->size() ) )
return( JS_TRUE );
if( index != set->size() )
if( index != (int)set->size() )
{
// If you add something to the collection, it must be at the
// next empty array element; i.e. set->size()
@ -124,7 +124,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::A
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::RemoveProperty ( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::RemoveProperty (
JSContext* cx, JSObject* obj, jsval id, jsval* UNUSED(vp) )
{
if( !JSVAL_IS_INT( id ) )
return( JS_TRUE ); // Accessing a named property; nothing interesting.
@ -236,7 +237,8 @@ template<typename T, JSClass* ScriptType> bool CJSCollection<T, ScriptType>::Get
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::ToString( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::ToString(
JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
{
std::vector<T>* set = RetrieveSet( cx, obj );
@ -252,7 +254,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::T
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::GetLength( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::GetLength(
JSContext* cx, JSObject* obj, jsval UNUSED(id), jsval* vp )
{
std::vector<T>* set = RetrieveSet( cx, obj );
@ -263,7 +266,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::G
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::IsEmpty( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::IsEmpty(
JSContext* cx, JSObject* obj, jsval UNUSED(id), jsval* vp )
{
std::vector<T>* set = RetrieveSet( cx, obj );
@ -311,7 +315,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::E
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Subset( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Subset(
JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
{
debug_assert( argc > 0 );
@ -329,8 +334,6 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::S
JSObject* Collection = JS_NewObject( g_ScriptingHost.GetContext(), &JSI_class, NULL, NULL );
JS_SetPrivate( g_ScriptingHost.GetContext(), Collection, CollectionData );
int i = 0;
for( it = Set->begin(); it != Set->end(); it++ )
if( Predicate.Run( ToScript( (T*)&( *it ) ) ) )
CollectionData->m_Data->push_back( *it );
@ -340,7 +343,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::S
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Clear( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Clear(
JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
{
std::vector<T>* Set = RetrieveSet( cx, obj );
if( !Set )
@ -372,7 +376,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::P
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Pop( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Pop(
JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
{
std::vector<T>* Set = RetrieveSet( cx, obj );
if( !Set )
@ -390,7 +395,8 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::P
return( JS_TRUE );
}
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Remove( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::Remove(
JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* UNUSED(rval) )
{
debug_assert( argc > 0 );
@ -403,7 +409,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::R
int index;
try
{
index = g_ScriptingHost.ValueToInt( argv[0] );
index = ToPrimitive<int>( argv[0] );
}
catch( PSERROR_Scripting_ConversionFailed )
{

View File

@ -5,6 +5,7 @@
#include "precompiled.h"
#include "JSInterface_Console.h"
#include "CConsole.h"
#include "scripting/JSConversions.h"
extern CConsole* g_Console;
@ -30,7 +31,7 @@ JSFunctionSpec JSI_Console::JSI_methods[] =
{ 0 },
};
JSBool JSI_Console::getProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
JSBool JSI_Console::getProperty( JSContext* UNUSED(cx), JSObject* UNUSED(obj), jsval id, jsval* vp )
{
if( !JSVAL_IS_INT( id ) )
return( JS_TRUE );
@ -46,7 +47,7 @@ JSBool JSI_Console::getProperty( JSContext* cx, JSObject* obj, jsval id, jsval*
}
}
JSBool JSI_Console::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
JSBool JSI_Console::setProperty( JSContext* UNUSED(cx), JSObject* UNUSED(obj), jsval id, jsval* vp )
{
if( !JSVAL_IS_INT( id ) )
return( JS_TRUE );
@ -58,7 +59,7 @@ JSBool JSI_Console::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval*
case console_visible:
try
{
g_Console->SetVisible( g_ScriptingHost.ValueToBool( *vp ) );
g_Console->SetVisible( ToPrimitive<bool>( *vp ) );
return( JS_TRUE );
}
catch( PSERROR_Scripting_ConversionFailed )
@ -75,14 +76,14 @@ void JSI_Console::init()
g_ScriptingHost.DefineCustomObjectType( &JSI_class, NULL, 0, JSI_props, JSI_methods, NULL, NULL );
}
JSBool JSI_Console::getConsole( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
JSBool JSI_Console::getConsole( JSContext* cx, JSObject* UNUSED(obj), jsval UNUSED(id), jsval* vp )
{
JSObject* console = JS_NewObject( cx, &JSI_Console::JSI_class, NULL, NULL );
*vp = OBJECT_TO_JSVAL( console );
return( JS_TRUE );
}
JSBool JSI_Console::writeConsole( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
JSBool JSI_Console::writeConsole( JSContext* UNUSED(context), JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* UNUSED(rval) )
{
debug_assert( argc >= 1 );
CStrW output;

View File

@ -24,7 +24,7 @@ namespace JSI_Console
void init();
JSBool writeConsole( JSContext* context, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval );
JSBool writeConsole( JSContext* context, JSObject* obj, uint argc, jsval* argv, jsval* rval );
};
#endif

View File

@ -7,28 +7,31 @@
#include "scripting/JSCollection.h"
#include "Interact.h"
JSBool JSI_Selection::getSelection( JSContext* context, JSObject* globalObject, jsval id, jsval* vp )
JSBool JSI_Selection::getSelection( JSContext* UNUSED(cx), JSObject* UNUSED(obj),
jsval UNUSED(id), jsval* vp )
{
*vp = OBJECT_TO_JSVAL( EntityCollection::CreateReference( &( g_Selection.m_selected ) ) );
return( JS_TRUE );
}
JSBool JSI_Selection::setSelection( JSContext* context, JSObject* globalObject, jsval id, jsval* vp )
JSBool JSI_Selection::setSelection( JSContext* cx, JSObject* UNUSED(obj),
jsval UNUSED(id), jsval* vp )
{
if( !JSVAL_IS_OBJECT( *vp ) )
{
JS_ReportError( context, "Not a valid Collection" );
JS_ReportError( cx, "Not a valid Collection" );
*vp = JSVAL_NULL;
return( JS_TRUE );
}
JSObject* selectionArray = JSVAL_TO_OBJECT( *vp );
EntityCollection::CJSCollectionData* Info = (EntityCollection::CJSCollectionData*)JS_GetInstancePrivate( context, JSVAL_TO_OBJECT( *vp ), &EntityCollection::JSI_class, NULL );
UNUSED2(selectionArray);
EntityCollection::CJSCollectionData* Info = (EntityCollection::CJSCollectionData*)JS_GetInstancePrivate( cx, JSVAL_TO_OBJECT( *vp ), &EntityCollection::JSI_class, NULL );
if( !Info )
{
JS_ReportError( context, "Not a valid Collection" );
JS_ReportError( cx, "Not a valid Collection" );
*vp = JSVAL_NULL;
return( JS_TRUE );
}
@ -42,41 +45,43 @@ JSBool JSI_Selection::setSelection( JSContext* context, JSObject* globalObject,
return( JS_TRUE );
}
JSBool JSI_Selection::getGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp )
JSBool JSI_Selection::getGroups( JSContext* cx, JSObject* UNUSED(obj),
jsval UNUSED(id), jsval* vp )
{
JSObject* groupsArray = JS_NewArrayObject( context, 0, NULL );
JSObject* groupsArray = JS_NewArrayObject( cx, 0, NULL );
JS_AddRoot( context, &groupsArray );
JS_AddRoot( cx, &groupsArray );
for( i8 groupId = 0; groupId < MAX_GROUPS; groupId++ )
{
jsval v = OBJECT_TO_JSVAL( EntityCollection::CreateReference( &( g_Selection.m_groups[groupId] ) ) );
JS_SetElement( context, groupsArray, groupId, &v );
JS_SetElement( cx, groupsArray, groupId, &v );
}
*vp = OBJECT_TO_JSVAL( groupsArray );
JS_RemoveRoot( context, &groupsArray );
JS_RemoveRoot( cx, &groupsArray );
return( JS_TRUE );
}
JSBool JSI_Selection::setGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp )
JSBool JSI_Selection::setGroups( JSContext* cx, JSObject* UNUSED(obj),
jsval UNUSED(id), jsval* vp )
{
JSObject* groupsArray;
if( !JSVAL_IS_OBJECT( *vp ) || !JS_IsArrayObject( context, groupsArray = JSVAL_TO_OBJECT( *vp ) ) )
if( !JSVAL_IS_OBJECT( *vp ) || !JS_IsArrayObject( cx, groupsArray = JSVAL_TO_OBJECT( *vp ) ) )
{
JS_ReportError( context, "Not a valid group array" );
JS_ReportError( cx, "Not a valid group array" );
*vp = JSVAL_NULL;
return( JS_TRUE );
}
for( i8 groupId = 0; groupId < MAX_GROUPS; groupId++ )
{
jsval v;
if( JS_GetElement( context, groupsArray, groupId, &v ) && JSVAL_IS_OBJECT( v ) )
if( JS_GetElement( cx, groupsArray, groupId, &v ) && JSVAL_IS_OBJECT( v ) )
{
JSObject* group = JSVAL_TO_OBJECT( v );
EntityCollection::CJSCollectionData* Info = (EntityCollection::CJSCollectionData*)JS_GetInstancePrivate( context, group, &EntityCollection::JSI_class, NULL );
EntityCollection::CJSCollectionData* Info = (EntityCollection::CJSCollectionData*)JS_GetInstancePrivate( cx, group, &EntityCollection::JSI_class, NULL );
if( Info )
{
g_Selection.m_groups[groupId].clear();

View File

@ -18,7 +18,7 @@ namespace JSI_Selection
JSBool getGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp );
JSBool setGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp );
JSBool isValidContextOrder( JSContext* context, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval );
JSBool isValidContextOrder( JSContext* context, JSObject* obj, uint argc, jsval* argv, jsval* rval );
JSBool getContextOrder( JSContext* context, JSObject* obj, jsval id, jsval* vp );
JSBool setContextOrder( JSContext* context, JSObject* obj, jsval id, jsval* vp );
};

View File

@ -42,7 +42,7 @@ struct BuildFileListState
};
// called for each matching directory entry; add its full pathname to array.
static void BuildFileListCB(const char* path, const vfsDirEnt* ent, void* context)
static void BuildFileListCB(const char* path, const DirEnt* UNUSED(ent), void* context)
{
BuildFileListState* s = (BuildFileListState*)context;
@ -63,7 +63,7 @@ static void BuildFileListCB(const char* path, const vfsDirEnt* ent, void* contex
//
// note: full pathnames of each file/subdirectory are returned,
// ready for use as a "filename" for the other functions.
JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* argv, jsval* rval )
{
//
// get arguments
@ -92,11 +92,12 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval*
if( !ToPrimitive<bool>( cx, argv[2], recursive ) )
return( JS_FALSE );
}
int flags = recursive? VFSUtil::RECURSIVE : 0;
// build array in the callback function
BuildFileListState state(cx);
VFSUtil::EnumDirEnts( path, filter, recursive, BuildFileListCB, &state );
VFSUtil::EnumDirEnts( path, flags, filter, BuildFileListCB, &state );
*rval = OBJECT_TO_JSVAL( state.filename_array );
return( JS_TRUE );
@ -107,7 +108,7 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval*
//
// mtime = getFileMTime(filename);
// filename: VFS filename (may include path)
JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 1 );
CStr filename;
@ -127,7 +128,7 @@ JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* a
//
// size = getFileSize(filename);
// filename: VFS filename (may include path)
JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 1 );
CStr filename;
@ -147,7 +148,7 @@ JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* ar
//
// contents = readFile(filename);
// filename: VFS filename (may include path)
JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 1 );
CStr filename;
@ -171,7 +172,7 @@ JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv,
//
// lines = readFileLines(filename);
// filename: VFS filename (may include path)
JSBool JSI_VFS::ReadFileLines( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_VFS::ReadFileLines( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 1 );
CStr filename;

View File

@ -29,7 +29,7 @@ class CJSMap
return JS_TRUE;
}
static JSBool SetProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp )
static JSBool SetProperty( JSContext* UNUSED(cx), JSObject* UNUSED(obj), jsval UNUSED(id), jsval* UNUSED(vp) )
{
return JS_FALSE;
}

View File

@ -7,7 +7,7 @@
// On Windows, wchar_t is typedef'ed to unsigned short, which conflicts
// with uint16_t (which is also an unsigned short), so just use std::wstring
#ifdef _MSC_VER
#if MSC_VERSION
typedef wchar_t utf16_t;
typedef std::wstring utf16string;
@ -100,6 +100,6 @@ namespace std {
};
}
#endif // #ifdef _MSC_VER / #else
#endif // #if MSC_VERSION / #else
#endif

View File

@ -78,7 +78,7 @@ void CModelRData::BuildIndices()
u32 base=(u32)m_VB->m_Index;
u32 indices=0;
SModelFace* faces=mdef->GetFaces();
for (int j=0; j<mdef->GetNumFaces(); j++) {
for (size_t j=0; j<mdef->GetNumFaces(); j++) {
SModelFace& face=faces[j];
m_Indices[indices++]=face.m_Verts[0]+base;
m_Indices[indices++]=face.m_Verts[1]+base;
@ -149,14 +149,14 @@ void CModelRData::BuildVertices()
}
// build vertices
u32 numVertices=mdef->GetNumVertices();
size_t numVertices=mdef->GetNumVertices();
SModelVertex* vertices=mdef->GetVertices();
const CMatrix3D* bonematrices=m_Model->GetBoneMatrices();
if (bonematrices) {
// boned model - calculate skinned vertex positions/normals
PROFILE( "skinning bones" );
const CMatrix3D* invbonematrices=m_Model->GetInvBoneMatrices();
for (uint j=0; j<numVertices; j++) {
for (size_t j=0; j<numVertices; j++) {
SkinPoint(vertices[j],bonematrices,m_Vertices[j].m_Position);
SkinNormal(vertices[j],invbonematrices,m_Normals[j]);
}
@ -210,9 +210,9 @@ void CModelRData::RenderStreams(u32 streamflags, bool isplayer)
if (streamflags & STREAM_UV0) glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SVertex,m_UVs));
// render the lot
u32 numFaces=mdldef->GetNumFaces();
size_t numFaces=mdldef->GetNumFaces();
// glDrawRangeElements(GL_TRIANGLES,0,mdldef->GetNumVertices(),numFaces*3,GL_UNSIGNED_SHORT,m_Indices);
glDrawElements(GL_TRIANGLES,numFaces*3,GL_UNSIGNED_SHORT,m_Indices);
glDrawElements(GL_TRIANGLES,(GLsizei)numFaces*3,GL_UNSIGNED_SHORT,m_Indices);
if(streamflags & STREAM_UV0 & !isplayer)
m_Model->GetMaterial().Unbind();
@ -256,7 +256,7 @@ float CModelRData::BackToFrontIndexSort(CMatrix3D& objToCam)
SModelVertex* vtxs=mdldef->GetVertices();
u32 numFaces=mdldef->GetNumFaces();
size_t numFaces=mdldef->GetNumFaces();
SModelFace* faces=mdldef->GetFaces();
IndexSorter.reserve(numFaces);
@ -312,7 +312,7 @@ void CModelRData::RenderModels(u32 streamflags,u32 flags)
#if 1
// submit batches for each model to the vertex buffer
for (i=0;i<m_Models.size();++i) {
u32 mflags=m_Models[i]->GetFlags();
u32 mflags=m_Models[i]->GetFlags(); // TODO2
if (!flags || (m_Models[i]->GetFlags()&flags)) {
CModelRData* modeldata=(CModelRData*) m_Models[i]->GetRenderData();
modeldata->SubmitBatches();

View File

@ -96,9 +96,9 @@ void CPatchRData::BuildBlends()
m_BlendSplats.clear();
m_BlendVertices.clear();
// get index of this patch
int px=m_Patch->m_X;
int pz=m_Patch->m_Z;
// get index of this patch (unused)
//int px=m_Patch->m_X;
//int pz=m_Patch->m_Z;
CTerrain* terrain=m_Patch->m_Parent;
@ -375,7 +375,7 @@ void CPatchRData::BuildVertices()
u32 pz=m_Patch->m_Z;
CTerrain* terrain=m_Patch->m_Parent;
u32 mapSize=terrain->GetVerticesPerSide();
//u32 mapSize=terrain->GetVerticesPerSide(); // unused
// build vertices
for (int j=0;j<vsize;j++) {
@ -518,6 +518,7 @@ void CPatchRData::RenderOutline()
uint i;
uint vsize=PATCH_SIZE+1;
u8* base=m_VBBase->m_Owner->Bind();
UNUSED2(base);
glBegin(GL_LINES);
for (i=0;i<PATCH_SIZE;i++) {

View File

@ -35,71 +35,18 @@
#include "ogl.h"
#include "res/mem.h"
#include "res/tex.h"
#include "res/ogl_tex.h"
#include "timer.h"
#define LOG_CATEGORY "graphics"
struct TGAHeader {
// header stuff
unsigned char iif_size;
unsigned char cmap_type;
unsigned char image_type;
unsigned char pad[5];
// origin : unused
unsigned short d_x_origin;
unsigned short d_y_origin;
// dimensions
unsigned short width;
unsigned short height;
// bits per pixel : 16, 24 or 32
unsigned char bpp;
// image descriptor : Bits 3-0: size of alpha channel
// Bit 4: must be 0 (reserved)
// Bit 5: should be 0 (origin)
// Bits 6-7: should be 0 (interleaving)
unsigned char image_descriptor;
};
static bool saveTGA(const char* filename,int width,int height,int bpp,unsigned char* data)
{
FILE* fp=fopen(filename,"wb");
if (!fp) return false;
// fill file header
TGAHeader header;
header.iif_size=0;
header.cmap_type=0;
header.image_type=2;
memset(header.pad,0,sizeof(header.pad));
header.d_x_origin=0;
header.d_y_origin=0;
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) {
fclose(fp);
return false;
int err = tex_write(filename, width, height, bpp, TEX_BGR, data);
return (err == 0);
}
// write data
if (fwrite(data,width*height*bpp/8,1,fp)!=1) {
fclose(fp);
return false;
}
// return success ..
fclose(fp);
return true;
}
///////////////////////////////////////////////////////////////////////////////////
// CRenderer destructor
CRenderer::CRenderer()
@ -1007,15 +954,15 @@ void CRenderer::Submit(CModel* model)
CModelRData::Submit(model);
}
void CRenderer::Submit(CSprite* sprite)
void CRenderer::Submit(CSprite* UNUSED(sprite))
{
}
void CRenderer::Submit(CParticleSys* psys)
void CRenderer::Submit(CParticleSys* UNUSED(psys))
{
}
void CRenderer::Submit(COverlay* overlay)
void CRenderer::Submit(COverlay* UNUSED(overlay))
{
}
@ -1194,7 +1141,6 @@ int CRenderer::LoadAlphaMaps()
}
int base;
i=tex_info(textures[0], &base, NULL, NULL, NULL, NULL);
int size=(base+4)*NumAlphaMaps;
@ -1258,6 +1204,9 @@ int CRenderer::LoadAlphaMaps()
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
// GL_CLAMP_TO_EDGE
oglSquelchError(GL_INVALID_ENUM);
delete[] data;
return 0;

View File

@ -99,15 +99,15 @@ public:
return *this;
}
// count of the number of stats added together
u32 m_Counter;
size_t m_Counter;
// number of draw calls per frame - total DrawElements + Begin/End immediate mode loops
u32 m_DrawCalls;
size_t m_DrawCalls;
// number of terrain triangles drawn
u32 m_TerrainTris;
size_t m_TerrainTris;
// number of (non-transparent) model triangles drawn
u32 m_ModelTris;
size_t m_ModelTris;
// number of splat passes for alphamapping
u32 m_BlendSplats;
size_t m_BlendSplats;
};
public:

View File

@ -155,7 +155,7 @@ void CVertexBuffer::ClearBatchIndices()
///////////////////////////////////////////////////////////////////////////////
// AppendBatch: add a batch to the render list for this buffer
void CVertexBuffer::AppendBatch(VBChunk* UNUSEDPARAM(chunk),Handle texture,size_t numIndices,u16* indices)
void CVertexBuffer::AppendBatch(VBChunk* UNUSED(chunk),Handle texture,size_t numIndices,u16* indices)
{
// try and find a batch using this texture
size_t i;

View File

@ -56,7 +56,7 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t
if (!result)
{
LOG(ERROR, LOG_CATEGORY, "Failed to create VBOs");
debug_assert(!"Failed to create VBOs");
debug_warn("Failed to create VBOs");
}
return result;

View File

@ -102,7 +102,7 @@ bool IEventTarget::RemoveHandler( CStrW TypeString, DOMEventHandler handler )
return( false );
}
bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv )
bool IEventTarget::AddHandlerJS( JSContext* UNUSED(cx), uintN argc, jsval* argv )
{
debug_assert( argc >= 2 );
DOMEventHandler handler = new CScriptObject( argv[1] );
@ -119,7 +119,7 @@ bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv )
return( true );
}
bool IEventTarget::RemoveHandlerJS( JSContext* cx, uintN argc, jsval* argv )
bool IEventTarget::RemoveHandlerJS( JSContext* UNUSED(cx), uintN argc, jsval* argv )
{
debug_assert( argc >= 2 );
DOMEventHandler handler = new CScriptObject( argv[1] );
@ -160,21 +160,21 @@ void CScriptEvent::ScriptingInit()
CJSObject<CScriptEvent>::ScriptingInit( "Event" );
}
jsval CScriptEvent::PreventDefault( JSContext* cx, uintN argc, jsval* argv )
jsval CScriptEvent::PreventDefault( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
if( m_Cancelable )
m_Cancelled = true;
return( JSVAL_VOID );
}
jsval CScriptEvent::StopPropagation( JSContext* cx, uintN argc, jsval* argv )
jsval CScriptEvent::StopPropagation( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
if( m_Blockable )
m_Blocked = true;
return( JSVAL_VOID );
}
jsval CScriptEvent::ToString( JSContext* cx, uintN argc, jsval* argv )
jsval CScriptEvent::ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
{
wchar_t buffer[256];
swprintf( buffer, 256, L"[object Event: %ls]", m_Type.c_str() );

View File

@ -1,12 +1,12 @@
#ifndef EVENTTYPES_H__
#define EVENTTYPES_H__
// EventTypes.h
// Fairly game-specific event declarations for use with DOMEvent.
// Creates unique (for the current target) names for each event.
// DOMEvent currently uses a preallocated array of EVENT_LAST elements,
// so these must be consecutive integers starting with 0.
#ifndef EVENTTYPES_H__
#define EVENTTYPES_H__
enum EEventType
{
// Entity events

View File

@ -14,7 +14,7 @@
class CGameEvents : public IEventTarget, public Singleton<CGameEvents>
{
// Game events don't really run on an object
JSObject* GetScriptExecContext( IEventTarget* target ) { return( g_ScriptingHost.GetGlobalObject() ); }
JSObject* GetScriptExecContext( IEventTarget* UNUSED(target) ) { return( g_ScriptingHost.GetGlobalObject() ); }
// Some events
class CEventSelectionChanged : public CScriptEvent

View File

@ -5,6 +5,7 @@
#include "scripting/JSInterface_Vector3D.h"
#include "Parser.h"
#include "BaseEntity.h"
#include "lib/sysdep/sysdep.h" // finite
// HEntity
@ -79,7 +80,7 @@ template<> jsval ToJSVal<CScriptObject>( CScriptObject& Native )
return( OBJECT_TO_JSVAL( Native.GetFunctionObject() ) );
}
template<> bool ToPrimitive<CScriptObject>( JSContext* cx, jsval v, CScriptObject& Storage )
template<> bool ToPrimitive<CScriptObject>( JSContext* UNUSED(cx), jsval v, CScriptObject& Storage )
{
Storage.SetJSVal( v );
return( true );
@ -97,17 +98,16 @@ template<> jsval ToJSVal<int>( int& Native )
return( INT_TO_JSVAL( Native ) );
}
template<> bool ToPrimitive<int>( JSContext* cx, jsval v, int& Storage )
{
try
{
Storage = g_ScriptingHost.ValueToInt( v );
}
catch( PSERROR_Scripting_ConversionFailed )
{
return( false );
}
return( true );
JSBool ok = JS_ValueToInt32(cx, v, (int32*)&Storage);
return ok == JS_TRUE;
}
// uint
@ -124,17 +124,13 @@ template<> jsval ToJSVal<uint>( uint& Native )
template<> bool ToPrimitive<uint>( JSContext* cx, jsval v, uint& Storage )
{
try
{
int t = g_ScriptingHost.ValueToInt( v );
if( t < 0 ) return( false );
Storage = t;
}
catch( PSERROR_Scripting_ConversionFailed )
{
return( false );
}
return( true );
int temp;
if(!ToPrimitive<int>(cx, v, temp))
return false;
if(temp < 0)
return false;
Storage = temp;
return true;
}
// double
@ -151,15 +147,10 @@ template<> jsval ToJSVal<double>( double& Native )
template<> bool ToPrimitive<double>( JSContext* cx, jsval v, double& Storage )
{
try
{
Storage = g_ScriptingHost.ValueToDouble( v );
}
catch( PSERROR_Scripting_ConversionFailed )
{
return( false );
}
return( true );
JSBool ok = JS_ValueToNumber(cx, v, &Storage);
if (ok == JS_FALSE || !finite( Storage ) )
return false;
return true;
}
// float
@ -176,15 +167,11 @@ template<> jsval ToJSVal<float>( float& Native )
template<> bool ToPrimitive<float>( JSContext* cx, jsval v, float& Storage )
{
try
{
Storage = (float)g_ScriptingHost.ValueToDouble( v );
}
catch( PSERROR_Scripting_ConversionFailed )
{
return( false );
}
return( true );
double temp;
if(!ToPrimitive<double>(cx, v, temp))
return false;
Storage = (float)temp;
return true;
}
@ -202,19 +189,16 @@ template<> jsval ToJSVal<bool>( bool& Native )
template<> bool ToPrimitive<bool>( JSContext* cx, jsval v, bool& Storage )
{
try
{
Storage = g_ScriptingHost.ValueToBool( v );
}
catch( PSERROR_Scripting_ConversionFailed )
{
return( false );
}
return( true );
JSBool temp;
JSBool ok = JS_ValueToBoolean(cx, v, &temp);
if(ok == JS_FALSE)
return false;
Storage = (temp == JS_TRUE);
return true;
}
// CStrW
template<> bool ToPrimitive<CStrW>( JSContext* cx, jsval v, CStrW& Storage )
template<> bool ToPrimitive<CStrW>( JSContext* UNUSED(cx), jsval v, CStrW& Storage )
{
try
{
@ -239,7 +223,7 @@ template<> jsval ToJSVal<CStrW>( CStrW& Native )
// CStr/CStr8
template<> bool ToPrimitive<CStr8>( JSContext* cx, jsval v, CStr8& Storage )
template<> bool ToPrimitive<CStr8>( JSContext* UNUSED(cx), jsval v, CStr8& Storage )
{
try
{

View File

@ -40,7 +40,7 @@ template<typename T> T* ToNative( jsval v )
return( ToNative<T>( g_ScriptingHost.GetContext(), JSVAL_TO_OBJECT( v ) ) );
}
template<typename T> bool ToPrimitive( JSContext* cx, jsval v, T& Storage )
template<typename T> bool ToPrimitive( JSContext* UNUSED(cx), jsval v, T& Storage )
{
T* Native = ToNative<T>( v );
if( !Native ) return( false );
@ -49,7 +49,7 @@ template<typename T> bool ToPrimitive( JSContext* cx, jsval v, T& Storage )
}
// Handle pointer-to-objects sensibly (by automatically dereferencing them one level)
template<typename T> bool ToPrimitive( JSContext* cx, jsval v, T*& Storage )
template<typename T> bool ToPrimitive( JSContext* UNUSED(cx), jsval v, T*& Storage )
{
T* Native = ToNative<T>( v );
if( !Native ) return( false );

View File

@ -59,7 +59,7 @@ public:
case TAG_STRING:
return( 1 + (ToPrimitive<CStrW>(m_data)).GetSerializedLength() );
default:
debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
debug_warn("An attempt was made to serialize a jsval other than a number, boolean or string." );
return( 1 );
}
}
@ -88,7 +88,7 @@ public:
buffer = ( ToPrimitive<CStrW>( m_data ) ).Serialize( buffer );
break;
default:
debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." );
debug_warn("An attempt was made to serialize a jsval other than a number, boolean or string." );
break;
}
return( buffer );
@ -127,7 +127,7 @@ public:
}
break;
default:
debug_assert( 0 && "An attempt was made to deserialize a jsval other than a number, boolean or string." );
debug_warn("An attempt was made to deserialize a jsval other than a number, boolean or string." );
break;
}
return( buffer );

View File

@ -21,7 +21,7 @@ JSPropertySpec Point2dProperties[] =
{0}
};
JSBool Point2d_Constructor(JSContext* UNUSEDPARAM(cx), JSObject* obj, uintN argc, jsval* argv, jsval* UNUSEDPARAM(rval))
JSBool Point2d_Constructor(JSContext* UNUSED(cx), JSObject* obj, uintN argc, jsval* argv, jsval* UNUSED(rval))
{
if (argc == 2)
{
@ -56,7 +56,7 @@ void SColour::ScriptingInit()
CJSObject<SColour>::ScriptingInit( "Colour", SColour::Construct, 3 );
}
jsval SColour::ToString( JSContext* cx, uintN argc, jsval* argv )
jsval SColour::ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
{
wchar_t buffer[256];
@ -68,7 +68,7 @@ jsval SColour::ToString( JSContext* cx, uintN argc, jsval* argv )
}
JSBool SColour::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool SColour::Construct( JSContext* UNUSED(cx), JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 3 );
float alpha = 1.0;

View File

@ -27,7 +27,7 @@ public:
jsval ToString( JSContext* cx, uintN argc, jsval* argv );
static void ScriptingInit();
static JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval );
static JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval );
};
#endif

View File

@ -19,7 +19,7 @@ extern void StartGame();
extern void EndGame();
// .. other
extern CLightEnv g_LightEnv;
#ifdef _WIN32
#if OS_WIN
extern int GetVRAMInfo(int&, int&);
#endif

View File

@ -198,7 +198,7 @@ public:
}
return( JS_FALSE );
}
static JSBool JSPrimitive( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
static JSBool JSPrimitive( JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
{
CJSComplexPropertyAccessor* Instance = (CJSComplexPropertyAccessor*)JS_GetPrivate( cx, obj );
if( !Instance ) return( JS_TRUE );
@ -221,7 +221,7 @@ public:
return( JS_TRUE );
}
static JSBool JSToString( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
static JSBool JSToString( JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
{
CJSComplexPropertyAccessor* Instance = (CJSComplexPropertyAccessor*)JS_GetPrivate( cx, obj );
if( !Instance ) return( JS_TRUE );
@ -287,12 +287,12 @@ public:
m_Intrinsic = true;
m_Inherited = true;
}
jsval Get( JSContext* cx, IJSComplex* owner )
jsval Get( JSContext* UNUSED(cx), IJSComplex* owner )
{
if( m_Freshen ) (owner->*m_Freshen)();
return( ToJSVal( owner->*m_Data ) );
}
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
void ImmediateCopy( IJSComplex* UNUSED(CopyTo), IJSComplex* UNUSED(CopyFrom), IJSComplexProperty* UNUSED(CopyProperty) )
{
debug_warn( "Inheritance not supported for CJSSharedProperties" );
}
@ -327,12 +327,12 @@ public:
m_Freshen = Freshen;
m_Intrinsic = true;
}
jsval Get( JSContext* cx, IJSComplex* owner )
jsval Get( JSContext* UNUSED(cx), IJSComplex* owner )
{
if( m_Freshen ) (owner->*m_Freshen)();
return( ToJSVal( *m_Data ) );
}
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
void ImmediateCopy( IJSComplex* UNUSED(CopyTo), IJSComplex* UNUSED(CopyFrom), IJSComplexProperty* CopyProperty )
{
*m_Data = *( ( (CJSComplexProperty*)CopyProperty )->m_Data );
}
@ -399,19 +399,20 @@ public:
if( JSVAL_IS_GCTHING( m_Data ) )
JS_RemoveRoot( g_ScriptingHost.GetContext(), (void*)&m_Data );
}
jsval Get( JSContext* cx, IJSComplex* owner )
jsval Get( JSContext* UNUSED(cx), IJSComplex* UNUSED(owner) )
{
return( m_Data );
}
void Set( JSContext* cx, IJSComplex* owner, jsval Value )
void Set( JSContext* UNUSED(cx), IJSComplex* UNUSED(owner), jsval Value )
{
Uproot();
m_Data = Value;
Root();
}
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
void ImmediateCopy( IJSComplex* UNUSED(CopyTo), IJSComplex* UNUSED(CopyFrom),
IJSComplexProperty* UNUSED(CopyProperty) )
{
debug_assert( 0 && "ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" );
debug_warn("ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" );
}
};
@ -433,18 +434,18 @@ public:
// Must at least be able to read
debug_assert( m_Getter );
}
jsval Get( JSContext* cx, IJSComplex* owner )
jsval Get( JSContext* UNUSED(cx), IJSComplex* owner )
{
return( (owner->*m_Getter)() );
}
void Set( JSContext* cx, IJSComplex* owner, jsval Value )
void Set( JSContext* UNUSED(cx), IJSComplex* owner, jsval Value )
{
if( m_Setter )
(owner->*m_Setter)( Value );
}
void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty )
void ImmediateCopy( IJSComplex* UNUSED(CopyTo), IJSComplex* UNUSED(CopyFrom), IJSComplexProperty* UNUSED(CopyProperty) )
{
debug_assert( 0 && "ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" );
debug_warn("ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" );
}
};

View File

@ -58,7 +58,7 @@ public:
{
m_Data = Data;
}
jsval Get( JSContext* cx, IJSObject* owner )
jsval Get( JSContext* UNUSED(cx), IJSObject* owner )
{
return( ToJSVal( owner->*m_Data ) );
}
@ -80,11 +80,11 @@ public:
{
m_Data = Data;
}
jsval Get( JSContext* cx, IJSObject* owner )
jsval Get( JSContext* UNUSED(cx), IJSObject* UNUSED(owner) )
{
return( ToJSVal( *m_Data ) );
}
void Set( JSContext* cx, IJSObject* owner, jsval Value )
void Set( JSContext* cx, IJSObject* UNUSED(owner), jsval Value )
{
if( !ReadOnly )
ToPrimitive( cx, Value, *m_Data );
@ -109,11 +109,11 @@ public:
// Must at least be able to read
debug_assert( m_Getter );
}
jsval Get( JSContext* cx, IJSObject* obj )
jsval Get( JSContext* UNUSED(cx), IJSObject* obj )
{
return( (obj->*m_Getter)() );
}
void Set( JSContext* cx, IJSObject* obj, jsval value )
void Set( JSContext* UNUSED(cx), IJSObject* obj, jsval value )
{
if( m_Setter )
(obj->*m_Setter)( value );
@ -146,11 +146,11 @@ public:
if( JSVAL_IS_GCTHING( m_Data ))
JS_RemoveRoot( g_ScriptingHost.GetContext(), (void*)&m_Data );
}
jsval Get( JSContext* cx, IJSObject* object )
jsval Get( JSContext* UNUSED(cx), IJSObject* UNUSED(object))
{
return( m_Data );
}
void Set( JSContext* cx, IJSObject* owner, jsval value )
void Set( JSContext* UNUSED(cx), IJSObject* UNUSED(owner), jsval value )
{
Uproot();
m_Data = value;
@ -294,7 +294,7 @@ public:
template<typename ReturnType, ReturnType (T::*NativeFunction)( JSContext* cx, uintN argc, jsval* argv )>
static void AddMethod( const char* Name, uintN MinArgs )
{
JSFunctionSpec FnInfo = { Name, CNativeFunction<T, ReadOnly, ReturnType, NativeFunction>::JSFunction, MinArgs, 0, 0 };
JSFunctionSpec FnInfo = { Name, CNativeFunction<T, ReadOnly, ReturnType, NativeFunction>::JSFunction, (uint8)MinArgs, 0, 0 };
m_Methods.push_back( FnInfo );
}
template<typename PropType> static void AddProperty( CStrW PropertyName, PropType T::*Native, bool PropReadOnly = ReadOnly )

View File

@ -10,12 +10,6 @@
#include "res/res.h"
#ifdef _WIN32
# include "float.h" // <- MT: Just for _finite(), converting certain strings was causing weird bugs.
# define finite _finite
#else
# define finite __finite // PT: Need to use _finite in MSVC, __finite in gcc
#endif
#ifdef NDEBUG
# pragma comment (lib, "js32.lib")
@ -93,25 +87,37 @@ ScriptingHost::~ScriptingHost()
JS_ShutDown();
}
// unused
// TODO: this is valid; replace inlined versions in other code with this.
void ScriptingHost::LoadScriptFromDisk(const std::string & fileName)
// filename, line and globalObject default to 0 (in which case we execute
// the whole script / use our m_GlobalObject)
void ScriptingHost::RunMemScript(const char* script, size_t size, const char* filename, int line, JSObject* globalObject)
{
const char* fn = fileName.c_str();
void* script;
size_t script_len;
if(vfs_load(fn, script, script_len) <= 0) // ERRTODO: translate/pass it on
throw PSERROR_Scripting_LoadFile_OpenFailed();
if(!filename)
filename = "unspecified file";
if(!globalObject)
globalObject = m_GlobalObject;
jsval rval;
JSBool ok = JS_EvaluateScript(m_Context, m_GlobalObject, (const char*)script, (unsigned int)script_len, fn, 0, &rval);
int err = mem_free(script);
debug_assert(err == 0);
JSBool ok = JS_EvaluateScript(m_Context, globalObject, script,
(uint)size, filename, line, &rval);
if (ok == JS_FALSE)
throw PSERROR_Scripting_LoadFile_EvalErrors();
}
// globalObject defaults to 0 (in which case we use our m_GlobalObject).
void ScriptingHost::RunScript(const CStr& filename, JSObject* globalObject)
{
const char* fn = filename.c_str();
void* script;
size_t size;
if(vfs_load(fn, script, size) <= 0) // ERRTODO: translate/pass it on
throw PSERROR_Scripting_LoadFile_OpenFailed();
RunMemScript((const char*)script, size, fn, 0, globalObject);
WARN_ERR(mem_free(script));
}
jsval ScriptingHost::CallFunction(const std::string & functionName, jsval * params, int numParams)
@ -296,7 +302,7 @@ jsval ScriptingHost::GetGlobal(const std::string &globalName)
//----------------------------------------------------------------------------
// conversions
//----------------------------------------------------------------------------
/*
int ScriptingHost::ValueToInt(const jsval value)
{
int32 i = 0;
@ -321,6 +327,21 @@ bool ScriptingHost::ValueToBool(const jsval value)
return b == JS_TRUE;
}
double ScriptingHost::ValueToDouble(const jsval value)
{
jsdouble d;
JSBool ok = JS_ValueToNumber(m_Context, value, &d);
if (ok == JS_FALSE || !finite( d ) )
throw PSERROR_Scripting_ConversionFailed();
return d;
}
*/
std::string ScriptingHost::ValueToString(const jsval value)
{
JSString* string = JS_ValueToString(m_Context, value);
@ -341,6 +362,8 @@ jsval ScriptingHost::UCStringToValue( const CStrW &str )
return UTF16ToValue(utf16);
}
utf16string ScriptingHost::ValueToUTF16( const jsval value )
{
JSString* string = JS_ValueToString(m_Context, value);
@ -357,18 +380,6 @@ jsval ScriptingHost::UTF16ToValue(const utf16string &str)
return STRING_TO_JSVAL(JS_NewUCStringCopyZ(m_Context, str.c_str()));
}
double ScriptingHost::ValueToDouble(const jsval value)
{
jsdouble d;
JSBool ok = JS_ValueToNumber(m_Context, value, &d);
if (ok == JS_FALSE || !finite( d ) )
throw PSERROR_Scripting_ConversionFailed();
return d;
}
//----------------------------------------------------------------------------
@ -382,10 +393,8 @@ double ScriptingHost::ValueToDouble(const jsval value)
// called by SpiderMonkey whenever someone does JS_ReportError.
// prints that message as well as locus to log, debug output and console.
void ScriptingHost::ErrorReporter(JSContext* context, const char* message, JSErrorReport* report)
void ScriptingHost::ErrorReporter(JSContext* UNUSED(cx), const char* message, JSErrorReport* report)
{
UNUSED(context);
const char* file = report->filename;
const int line = report->lineno;
// apparently there is no further information in this struct we can use
@ -408,7 +417,8 @@ void ScriptingHost::ErrorReporter(JSContext* context, const char* message, JSErr
#ifndef NDEBUG
void* ScriptingHost::jshook_script( JSContext* cx, JSStackFrame* fp, JSBool before, JSBool* ok, void* closure )
void* ScriptingHost::jshook_script( JSContext* UNUSED(cx), JSStackFrame* UNUSED(fp),
JSBool before, JSBool* UNUSED(ok), void* closure )
{
if( before )
{
@ -420,7 +430,7 @@ void* ScriptingHost::jshook_script( JSContext* cx, JSStackFrame* fp, JSBool befo
return( closure );
}
void* ScriptingHost::jshook_function( JSContext* cx, JSStackFrame* fp, JSBool before, JSBool* ok, void* closure )
void* ScriptingHost::jshook_function( JSContext* cx, JSStackFrame* fp, JSBool before, JSBool* UNUSED(ok), void* closure )
{
JSFunction* fn = JS_GetFrameFunction( cx, fp );
if( before )

View File

@ -85,7 +85,9 @@ public:
inline JSContext *GetContext() { return m_Context; }
inline JSObject* GetGlobalObject() { return m_GlobalObject; }
void LoadScriptFromDisk(const std::string & fileName);
void RunMemScript(const char* script, size_t size, const char* filename = 0, int line = 0, JSObject* globalObject = 0);
void RunScript(const CStr& filename, JSObject* globalObject = 0);
jsval CallFunction(const std::string & functionName, jsval * params, int numParams);

View File

@ -13,11 +13,11 @@
// jstypes.h (included via jsapi.h) requires we define
// "one of XP_BEOS, XP_MAC, XP_OS2, XP_WIN or XP_UNIX".
#include "config.h"
#if defined(OS_WIN)
#if OS_WIN
# define XP_WIN
#elif defined(OS_MAC)
#elif OS_MAC
# define XP_MAC
#elif defined(OS_BEOS)
#elif OS_BEOS
# define XP_BEOS
#else
# define XP_UNIX

View File

@ -73,7 +73,7 @@ struct CSynchedJSObjectBase
CSynchedJSObjectBase *m_Owner;
UpdateFn m_Update;
virtual void Set(JSContext *cx, IJSObject* owner, jsval value)
virtual void Set(JSContext* cx, IJSObject* UNUSED(owner), jsval value)
{
if (!ReadOnly)
{
@ -85,12 +85,12 @@ struct CSynchedJSObjectBase
}
}
}
virtual jsval Get(JSContext *cx, IJSObject* owner)
virtual jsval Get(JSContext* UNUSED(cx), IJSObject* UNUSED(owner))
{
return ToJSVal(*m_Data);
}
virtual void ImmediateCopy(IJSObject* CopyFrom, IJSObject* CopyTo, IJSProperty *other)
virtual void ImmediateCopy(IJSObject* UNUSED(CopyFrom), IJSObject* UNUSED(CopyTo), IJSProperty* other)
{
*m_Data = *( ((CSynchedJSProperty<PropType, ReadOnly>*)other)->m_Data );
}

View File

@ -185,32 +185,19 @@ bool CBaseEntity::loadXML( CStr filename )
{
XMBElement Child = RootChildren.item(i);
unsigned int ChildName = Child.getNodeName();
int ChildName = Child.getNodeName();
if( ChildName == el_script )
{
CStr Include = Child.getAttributes().getNamedItem( at_file );
jsval dy;
// TODO: Probably try and determine if this file has already been loaded, and skip it.
if( Include.Length() )
{
CVFSFile IncludeFile;
if( IncludeFile.Load( Include ) != PSRETURN_OK )
{
LOG( WARNING, LOG_CATEGORY, "CBaseEntity::loadXML: Could not load script file %s specified in file %s; ignored.", Include.c_str(), filename.c_str() );
}
else
JS_EvaluateScript( g_ScriptingHost.getContext(), JS_GetGlobalObject( g_ScriptingHost.GetContext() ), (const char*)IncludeFile.GetBuffer(), (int)IncludeFile.GetBufferSize(), Include, 1, &dy );
}
g_ScriptingHost.RunScript(Include);
CStr Inline = Child.getText();
if( Inline.Length() )
JS_EvaluateScript( g_ScriptingHost.getContext(), JS_GetGlobalObject( g_ScriptingHost.GetContext() ), Inline.c_str(), (int)Inline.Length(), filename.c_str(), Child.getLineNumber(), &dy );
g_ScriptingHost.RunMemScript(Inline.c_str(), Inline.Length(), filename.c_str(), Child.getLineNumber());
}
else if (ChildName == el_footprint)
{
@ -358,7 +345,7 @@ JSObject* CBaseEntity::GetScriptExecContext( IEventTarget* target )
return( target->GetScriptExecContext( target ) );
}
jsval CBaseEntity::ToString( JSContext* cx, uintN argc, jsval* argv )
jsval CBaseEntity::ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
{
wchar_t buffer[256];
swprintf( buffer, 256, L"[object EntityTemplate: %ls]", m_Tag.c_str() );

View File

@ -77,6 +77,11 @@ public:
jsval ToString( JSContext* cx, uintN argc, jsval* argv );
static void ScriptingInit();
private:
// squelch "unable to generate" warnings
CBaseEntity(const CBaseEntity& rhs);
const CBaseEntity& operator=(const CBaseEntity& rhs);
};
#endif

View File

@ -21,7 +21,7 @@ void CBaseEntityCollection::LoadFile( const char* path )
m_templateFilenames[tag] = path;
}
static void LoadFileThunk( const char* path, const vfsDirEnt* ent, void* context )
static void LoadFileThunk( const char* path, const DirEnt* UNUSED(ent), void* context )
{
CBaseEntityCollection* this_ = (CBaseEntityCollection*)context;
this_->LoadFile(path);
@ -30,7 +30,8 @@ static void LoadFileThunk( const char* path, const vfsDirEnt* ent, void* context
int CBaseEntityCollection::loadTemplates()
{
// Load all files in entities/ and its subdirectories.
THROW_ERR( VFSUtil::EnumDirEnts( "entities/", "*.xml", true, LoadFileThunk, this ) );
THROW_ERR( VFSUtil::EnumDirEnts( "entities/", VFSUtil::RECURSIVE, "*.xml",
LoadFileThunk, this ) );
return 0;
}

View File

@ -61,7 +61,7 @@ void CBoundingCircle::setRadius( float radius )
m_radius = radius;
}
bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& delta )
bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& UNUSED(delta) )
{
debug_assert( obj->m_type == BOUND_CIRCLE );
// Easy enough. The only time this gets called is a circle-circle collision,
@ -69,7 +69,7 @@ bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& delta
return( true );
}
bool CBoundingCircle::_contains( const CVector2D& point, const CVector2D& delta )
bool CBoundingCircle::_contains( const CVector2D& UNUSED(point), const CVector2D& UNUSED(delta) )
{
return( true );
}
@ -246,7 +246,7 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
}
}
bool CBoundingBox::_contains( const CVector2D& point, const CVector2D& delta )
bool CBoundingBox::_contains( const CVector2D& UNUSED(point), const CVector2D& delta )
{
float deltad = fabs( delta.dot( m_u ) );
if( deltad > m_d ) return( false );

View File

@ -319,7 +319,7 @@ void CEntity::update( size_t timestep )
m_orderQueue.pop_front();
break;
default:
debug_assert( 0 && "Invalid entity order" );
debug_warn("Invalid entity order" );
}
}
@ -773,18 +773,18 @@ void CEntity::ScriptingInit()
// Script constructor
JSBool CEntity::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
{
debug_assert( argc >= 2 );
CBaseEntity* baseEntity = NULL;
CVector3D position;
float orientation = (float)( PI * ( (double)( rand() & 0x7fff ) / (double)0x4000 ) );
JSObject* jsBaseEntity = JSVAL_TO_OBJECT( argv[0] );
CStrW templateName;
if( !JSVAL_IS_OBJECT( argv[0] ) || !( baseEntity = ToNative<CBaseEntity>( cx, jsBaseEntity ) ) )
CBaseEntity* baseEntity = ToNative<CBaseEntity>( cx, jsBaseEntity );
if( !JSVAL_IS_OBJECT( argv[0] ) || !baseEntity )
{
try
{
@ -806,16 +806,17 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsva
return( JS_TRUE );
}
JSI_Vector3D::Vector3D_Info* jsVector3D = NULL;
if( JSVAL_IS_OBJECT( argv[1] ) && ( jsVector3D = (JSI_Vector3D::Vector3D_Info*)JS_GetInstancePrivate( cx, JSVAL_TO_OBJECT( argv[1] ), &JSI_Vector3D::JSI_class, NULL ) ) )
JSI_Vector3D::Vector3D_Info* jsVector3D = (JSI_Vector3D::Vector3D_Info*)JS_GetInstancePrivate( cx, JSVAL_TO_OBJECT( argv[1] ), &JSI_Vector3D::JSI_class, NULL );
if( JSVAL_IS_OBJECT( argv[1] ) && jsVector3D )
{
position = *( jsVector3D->vector );
}
if( argc >= 3 )
{
try
{
orientation = (float)g_ScriptingHost.ValueToDouble( argv[2] );
orientation = ToPrimitive<float>( argv[2] );
}
catch( PSERROR_Scripting_ConversionFailed )
{
@ -834,7 +835,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsva
// Script-bound methods
jsval CEntity::ToString( JSContext* cx, uintN argc, jsval* argv )
jsval CEntity::ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
{
wchar_t buffer[256];
swprintf( buffer, 256, L"[object Entity: %ls]", m_base->m_Tag.c_str() );
@ -852,7 +853,7 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued )
try
{
orderCode = g_ScriptingHost.ValueToInt( argv[0] );
orderCode = ToPrimitive<int>( argv[0] );
}
catch( PSERROR_Scripting_ConversionFailed )
{
@ -875,8 +876,8 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued )
}
try
{
newOrder.m_data[0].location.x = (float)g_ScriptingHost.ValueToDouble( argv[1] );
newOrder.m_data[0].location.y = (float)g_ScriptingHost.ValueToDouble( argv[2] );
newOrder.m_data[0].location.x = ToPrimitive<float>( argv[1] );
newOrder.m_data[0].location.y = ToPrimitive<float>( argv[2] );
}
catch( PSERROR_Scripting_ConversionFailed )
{
@ -951,7 +952,7 @@ bool CEntity::Damage( JSContext* cx, uintN argc, jsval* argv )
return( true );
}
bool CEntity::Kill( JSContext* cx, uintN argc, jsval* argv )
bool CEntity::Kill( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
// Change this entity's template to the corpse entity - but note
// we don't fiddle with the actors or bounding information that we
@ -983,7 +984,7 @@ bool CEntity::Kill( JSContext* cx, uintN argc, jsval* argv )
return( true );
}
jsval CEntity::GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv )
jsval CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
{
float spawn_clearance = 2.0f;
if( argc >= 1 )
@ -995,14 +996,14 @@ jsval CEntity::GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv )
{
case CBoundingObject::BOUND_CIRCLE: spawn_clearance = be->m_bound_circle->m_radius; break;
case CBoundingObject::BOUND_OABB: spawn_clearance = be->m_bound_box->m_radius; break;
default: debug_assert( 0 && "No bounding information for spawned object!" );
default: debug_warn("No bounding information for spawned object!" );
}
}
else
spawn_clearance = ToPrimitive<float>( argv[0] );
}
else
debug_assert( 0 && "No arguments to Entity::GetSpawnPoint()" );
debug_warn("No arguments to Entity::GetSpawnPoint()" );
// TODO: Make netsafe.
CBoundingCircle spawn( 0.0f, 0.0f, spawn_clearance, 0.0f );
@ -1092,7 +1093,7 @@ jsval CEntity::GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv )
float radius = m_bounds->m_radius + 1.0f + spawn_clearance;
float d_ang = spawn_clearance / ( 2.0f * radius );
float ang_end = ang + 2.0f * PI;
float x, y;
float x = 0.0f, y = 0.0f; // make sure they're initialized
for( ; ang < ang_end; ang += d_ang )
{
x = m_position.X + radius * cos( ang );

View File

@ -195,7 +195,7 @@ public:
// Script constructor
static JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval );
static JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval );
// Script-bound functions
@ -213,7 +213,7 @@ public:
bool Damage( JSContext* cx, uintN argc, jsval* argv );
bool Kill( JSContext* cx, uintN argc, jsval* argv );
jsval GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv );
bool IsIdle( JSContext* cx, uintN argc, jsval* argv )
bool IsIdle( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
return( m_orderQueue.empty() );
}
@ -223,6 +223,11 @@ public:
return( m_classes.IsMember( ToPrimitive<CStrW>( cx, argv[0] ) ) );
}
static void ScriptingInit();
private:
// squelch "unable to generate" warnings
CEntity(const CEntity& rhs);
const CEntity& operator=(const CEntity& rhs);
};
// General entity globals

View File

@ -114,7 +114,7 @@ u8 *HEntity::Serialize(u8 *buffer) const
return buffer;
}
const u8 *HEntity::Deserialize(const u8 *buffer, const u8 *end)
const u8* HEntity::Deserialize(const u8* buffer, const u8* UNUSED(end))
{
Deserialize_int_2(buffer, m_handle);
// We can't let addRef debug_assert just because someone sent us bogus data
@ -143,7 +143,7 @@ u8 *CEntityList::Serialize(u8 *buffer) const
return buffer;
}
const u8 *CEntityList::Deserialize(const u8 *buffer, const u8 *end)
const u8 *CEntityList::Deserialize(const u8* buffer, const u8* UNUSED(end))
{
u16 n=0, handle;
while (!(n & HANDLE_SENTINEL_BIT))

Some files were not shown because too many files have changed in this diff Show More