From a69ac0dee9eb3fccca15b4b98a6858410aad078a Mon Sep 17 00:00:00 2001 From: janwas Date: Tue, 9 Aug 2005 15:55:44 +0000 Subject: [PATCH] - 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. --- source/graphics/GameView.cpp | 41 ++++----- source/graphics/MapReader.cpp | 4 + source/graphics/MapWriter.cpp | 8 +- source/graphics/Model.cpp | 18 ++-- source/graphics/ModelDef.cpp | 4 +- source/graphics/ModelDef.h | 6 +- source/graphics/ObjectBase.cpp | 4 +- source/graphics/ObjectManager.cpp | 7 +- source/graphics/SkeletonAnimDef.h | 4 +- source/graphics/Terrain.cpp | 6 +- source/graphics/TextureEntry.cpp | 2 +- source/graphics/TextureManager.cpp | 29 ++++--- source/graphics/TextureManager.h | 4 +- source/gui/CInput.cpp | 53 ++++++------ source/gui/CList.cpp | 4 +- source/gui/GUIutil.cpp | 2 +- source/gui/IGUIObject.h | 10 +-- source/gui/IGUIScrollBar.h | 4 +- source/gui/scripting/JSInterface_GUITypes.cpp | 13 +-- source/gui/scripting/JSInterface_GUITypes.h | 8 +- .../gui/scripting/JSInterface_IGUIObject.cpp | 6 +- source/gui/scripting/JSInterface_IGUIObject.h | 6 +- source/i18n/CLocale.cpp | 8 +- source/i18n/CLocale.h | 6 +- source/i18n/ScriptInterface.cpp | 8 +- source/i18n/StrImmutable.h | 2 +- source/i18n/TSComponent.cpp | 2 +- source/i18n/TSComponent.h | 8 ++ source/lib/byte_order.h | 2 +- source/ps/CConsole.cpp | 10 ++- source/ps/CConsole.h | 4 +- source/ps/CLogger.h | 6 +- source/ps/CStr.cpp | 3 +- source/ps/CStr.h | 6 +- source/ps/ConfigDB.cpp | 12 +-- source/ps/ConfigDB.h | 18 ++++ source/ps/Game.cpp | 6 +- source/ps/Game.h | 4 + source/ps/GameAttributes.cpp | 19 ++-- source/ps/GameRecord.cpp | 3 +- source/ps/Hotkey.cpp | 2 +- source/ps/Interact.cpp | 10 +-- source/ps/Loader.cpp | 4 +- source/ps/LoaderThunks.h | 16 +++- source/ps/Network/Client.cpp | 6 +- source/ps/Network/JSEvents.h | 6 +- source/ps/Network/NMTCreator.h | 28 ++++-- source/ps/Network/NetMessage.cpp | 12 +-- source/ps/Network/NetworkInternal.h | 11 +-- source/ps/Network/Server.cpp | 5 +- source/ps/Network/ServerSession.cpp | 4 +- source/ps/Network/ServerSocket.cpp | 2 +- source/ps/Network/SocketBase.cpp | 15 ++-- source/ps/Network/SocketBase.h | 2 +- source/ps/Network/StreamSocket.cpp | 2 + source/ps/Parser.cpp | 2 +- source/ps/Player.cpp | 8 +- source/ps/ThreadUtil.h | 4 + source/ps/VFSUtil.cpp | 31 ++++--- source/ps/VFSUtil.h | 14 ++- source/ps/World.h | 5 ++ source/ps/XML.h | 22 ++++- source/ps/XMLUtils.cpp | 6 +- source/ps/Xeromyces.cpp | 23 +---- source/ps/scripting/JSCollection.h | 30 ++++--- source/ps/scripting/JSInterface_Console.cpp | 11 +-- source/ps/scripting/JSInterface_Console.h | 2 +- source/ps/scripting/JSInterface_Selection.cpp | 35 ++++---- source/ps/scripting/JSInterface_Selection.h | 2 +- source/ps/scripting/JSInterface_VFS.cpp | 15 ++-- source/ps/scripting/JSMap.h | 2 +- source/ps/utf16string.h | 4 +- source/renderer/ModelRData.cpp | 14 +-- source/renderer/PatchRData.cpp | 9 +- source/renderer/Renderer.cpp | 69 ++------------- source/renderer/Renderer.h | 10 +-- source/renderer/VertexBuffer.cpp | 2 +- source/renderer/VertexBufferManager.cpp | 2 +- source/scripting/DOMEvent.cpp | 10 +-- source/scripting/EventTypes.h | 6 +- source/scripting/GameEvents.h | 2 +- source/scripting/JSConversions.cpp | 84 ++++++++---------- source/scripting/JSConversions.h | 4 +- source/scripting/JSSerialization.h | 6 +- source/scripting/ScriptCustomTypes.cpp | 6 +- source/scripting/ScriptCustomTypes.h | 2 +- source/scripting/ScriptGlue.h | 2 +- source/scripting/ScriptableComplex.h | 29 ++++--- source/scripting/ScriptableObject.h | 16 ++-- source/scripting/ScriptingHost.cpp | 86 +++++++++++-------- source/scripting/ScriptingHost.h | 4 +- source/scripting/SpiderMonkey.h | 6 +- source/scripting/SynchedJSObject.h | 6 +- source/simulation/BaseEntity.cpp | 21 +---- source/simulation/BaseEntity.h | 5 ++ source/simulation/BaseEntityCollection.cpp | 5 +- source/simulation/BoundingObjects.cpp | 6 +- source/simulation/Entity.cpp | 33 +++---- source/simulation/Entity.h | 9 +- source/simulation/EntityHandles.cpp | 6 +- source/simulation/EntityProperties.cpp | 6 +- source/simulation/EntityProperties.h | 2 +- source/simulation/EntityStateProcessing.cpp | 13 +-- source/simulation/EntitySupport.h | 2 +- source/simulation/Projectile.cpp | 17 ++-- source/simulation/Projectile.h | 4 +- source/simulation/Scheduler.cpp | 2 +- source/simulation/Scheduler.h | 2 +- source/simulation/ScriptObject.cpp | 2 +- source/simulation/Simulation.cpp | 9 +- .../scripting/JSInterface_Entity.cpp | 6 +- .../simulation/scripting/JSInterface_Entity.h | 2 +- source/sound/CMusicPlayer.cpp | 4 +- source/sound/JSI_Sound.cpp | 10 +-- source/sound/JSI_Sound.h | 2 +- 115 files changed, 654 insertions(+), 600 deletions(-) diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index a75a690ecc..5aa9dc6a27 100755 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -84,28 +84,23 @@ void CGameView::ScriptingInit() CJSObject::ScriptingInit("GameView"); } -int CGameView::Initialize(CGameAttributes *pAttribs) +int CGameView::Initialize(CGameAttributes* UNUSED(pAttribs)) { - CConfigValue* cfg; - -#define getViewParameter( name, value ) STMT( \ - cfg = g_ConfigDB.GetValue( CFG_SYSTEM, name );\ - if( cfg ) cfg->GetFloat( value ); ) + 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 ); - 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; diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index 2b16905d0a..e79d030b16 100755 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -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); }; diff --git a/source/graphics/MapWriter.cpp b/source/graphics/MapWriter.cpp index 921431cdee..a8e5c6d777 100755 --- a/source/graphics/MapWriter.cpp +++ b/source/graphics/MapWriter.cpp @@ -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& handles) { - for (uint i=0;i<(uint)handles.size();i++) { + const uint limit = MIN((uint)handles.size(), 0xFFFE); // paranoia + for (uint i=0;iGetNumBones(); - 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;iGetNumVertices(); + 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;jGetNumFrames();j++) { + for (size_t j=0;jGetNumFrames();j++) { // extend bounds by vertex positions at the frame - for (int i=0;im_AnimDef->BuildBoneMatrices(m_AnimTime,m_BoneMatrices); const CMatrix3D& transform=GetTransform(); - for (int i=0;iGetNumBones();i++) { + for (size_t i=0;iGetNumBones();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;iGetNumVertices(); + 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); diff --git a/source/graphics/ModelDef.h b/source/graphics/ModelDef.h index ba0775c3ba..987e99b0ea 100755 --- a/source/graphics/ModelDef.h +++ b/source/graphics/ModelDef.h @@ -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; } diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 62d6b20388..e8a192472c 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -352,7 +352,7 @@ void CObjectBase::CalculateVariation(std::set& 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& 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; diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp index fb5bd7618c..8cf872ace6 100755 --- a/source/graphics/ObjectManager.cpp +++ b/source/graphics/ObjectManager.cpp @@ -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* names = (std::vector*)context; CStr name (path); @@ -188,7 +188,8 @@ static void GetObjectThunk(const char* path, const vfsDirEnt* ent, void* context } void CObjectManager::GetAllObjectNames(std::vector& 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); diff --git a/source/graphics/SkeletonAnimDef.h b/source/graphics/SkeletonAnimDef.h index c11e78d2d7..1d951496b0 100755 --- a/source/graphics/SkeletonAnimDef.h +++ b/source/graphics/SkeletonAnimDef.h @@ -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; diff --git a/source/graphics/Terrain.cpp b/source/graphics/Terrain.cpp index c82ecfc35b..e1628b61fb 100755 --- a/source/graphics/Terrain.cpp +++ b/source/graphics/Terrain.cpp @@ -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) diff --git a/source/graphics/TextureEntry.cpp b/source/graphics/TextureEntry.cpp index 35f4ffbb12..e7925a0e04 100755 --- a/source/graphics/TextureEntry.cpp +++ b/source/graphics/TextureEntry.cpp @@ -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); } diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index 8954130122..c0c822f35e 100755 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -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;iLength()) + 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::iterator ¤t, 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; diff --git a/source/gui/CList.cpp b/source/gui/CList.cpp index 061ac0e740..124dbc75e3 100644 --- a/source/gui/CList.cpp +++ b/source/gui/CList.cpp @@ -436,7 +436,7 @@ void CList::SelectNextElement() CGUIList *pList; GUI::GetSettingPointer(this, "list", pList); - if (selected != pList->m_Items.size()-1) + if (selected != (int)pList->m_Items.size()-1) { ++selected; GUI::SetSetting(this, "selected", selected); @@ -474,7 +474,7 @@ void CList::SelectLastElement() CGUIList *pList; GUI::GetSettingPointer(this, "list", pList); - if (selected != pList->m_Items.size()-1) + if (selected != (int)pList->m_Items.size()-1) { GUI::SetSetting(this, "selected", (int)pList->m_Items.size()-1); } diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index 4d9382191b..45548d06dd 100755 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -228,7 +228,7 @@ bool __ParseString(const CStr& Value, CGUISpriteInstance &Ou } template <> -bool __ParseString(const CStr& Value, CGUIList &Output) +bool __ParseString(const CStr& UNUSED(Value), CGUIList& UNUSED(Output)) { //LOG(WARNING, LOG_CATEGORY, "Cannot set a 'list' from a string."); return false; diff --git a/source/gui/IGUIObject.h b/source/gui/IGUIObject.h index 3e62c1a02b..30e9fc5ad6 100755 --- a/source/gui/IGUIObject.h +++ b/source/gui/IGUIObject.h @@ -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; } diff --git a/source/gui/IGUIScrollBar.h b/source/gui/IGUIScrollBar.h index bc54bd0309..70cfb4a92d 100755 --- a/source/gui/IGUIScrollBar.h +++ b/source/gui/IGUIScrollBar.h @@ -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 diff --git a/source/gui/scripting/JSInterface_GUITypes.cpp b/source/gui/scripting/JSInterface_GUITypes.cpp index ba9f494445..09c57134c3 100755 --- a/source/gui/scripting/JSInterface_GUITypes.cpp +++ b/source/gui/scripting/JSInterface_GUITypes.cpp @@ -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", diff --git a/source/gui/scripting/JSInterface_GUITypes.h b/source/gui/scripting/JSInterface_GUITypes.h index 8ef6bf29cf..f59951235c 100755 --- a/source/gui/scripting/JSInterface_GUITypes.h +++ b/source/gui/scripting/JSInterface_GUITypes.h @@ -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) diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index 6418382f11..0c95e84f36 100755 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -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 ); diff --git a/source/gui/scripting/JSInterface_IGUIObject.h b/source/gui/scripting/JSInterface_IGUIObject.h index 26d776f60c..90e11b6020 100755 --- a/source/gui/scripting/JSInterface_IGUIObject.h +++ b/source/gui/scripting/JSInterface_IGUIObject.h @@ -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(); } diff --git a/source/i18n/CLocale.cpp b/source/i18n/CLocale.cpp index e5724741bf..49401a477b 100755 --- a/source/i18n/CLocale.cpp +++ b/source/i18n/CLocale.cpp @@ -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); @@ -317,7 +317,7 @@ bool CLocale::ReadCached(StringBuffer* sb, Str& str) { // Look for a string with the right key in the cache std::map::iterator it = - TranslationCache.find(&sb->String); + TranslationCache.find(sb->String); // See if it actually exists if (it == TranslationCache.end()) diff --git a/source/i18n/CLocale.h b/source/i18n/CLocale.h index 64d24eb25a..e18a09ae9a 100755 --- a/source/i18n/CLocale.h +++ b/source/i18n/CLocale.h @@ -24,7 +24,7 @@ All other methods are used internally by other I18n components. #include // GCC requires an explicit hash function for wide strings -#ifdef __GNUC__ +#if GCC_VERSION namespace __gnu_cxx { template<> struct hash @@ -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 diff --git a/source/i18n/ScriptInterface.cpp b/source/i18n/ScriptInterface.cpp index e8ba34b918..2dc317a9c0 100755 --- a/source/i18n/ScriptInterface.cpp +++ b/source/i18n/ScriptInterface.cpp @@ -69,7 +69,7 @@ namespace JSI_LookedupWord { namespace JSI_i18n { #define TYPE(x) \ - static JSBool Create_##x(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) \ + static JSBool Create_##x(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) \ { \ /* Set *rval = { type => "Name", value => argv[0] } */ \ \ @@ -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& vars) +jsval ScriptValueString::GetJsval(const std::vector& 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& vars) +jsval ScriptValueInteger::GetJsval(const std::vector& UNUSED(vars)) { return Value; } diff --git a/source/i18n/StrImmutable.h b/source/i18n/StrImmutable.h index 7b057c7c3f..da93537617 100755 --- a/source/i18n/StrImmutable.h +++ b/source/i18n/StrImmutable.h @@ -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; diff --git a/source/i18n/TSComponent.cpp b/source/i18n/TSComponent.cpp index ec70ad720f..0acf09a165 100755 --- a/source/i18n/TSComponent.cpp +++ b/source/i18n/TSComponent.cpp @@ -8,7 +8,7 @@ using namespace I18n; // Vaguely useful utility function for deleting stuff template void delete_fn(T* v) { delete v; } -const StrImW TSComponentString::ToString(CLocale* locale, std::vector& vars) const +const StrImW TSComponentString::ToString(CLocale* UNUSED(locale), std::vector& UNUSED(vars)) const { return String; } diff --git a/source/i18n/TSComponent.h b/source/i18n/TSComponent.h index 2ebeb022c2..cdc1eb52db 100755 --- a/source/i18n/TSComponent.h +++ b/source/i18n/TSComponent.h @@ -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 Params; + + // squelch "unable to generate" warnings + TSComponentFunction(const TSComponentFunction& rhs); + const TSComponentFunction& operator=(const TSComponentFunction& rhs); }; diff --git a/source/lib/byte_order.h b/source/lib/byte_order.h index 380bfa9461..10fe0355b4 100644 --- a/source/lib/byte_order.h +++ b/source/lib/byte_order.h @@ -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 diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index b47bbcfe7a..f8081ed227 100755 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -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::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 ); diff --git a/source/ps/CConsole.h b/source/ps/CConsole.h index 5a1ae2ee2b..5fed084fca 100755 --- a/source/ps/CConsole.h +++ b/source/ps/CConsole.h @@ -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(); diff --git a/source/ps/CLogger.h b/source/ps/CLogger.h index 5b10559385..7998253f01 100755 --- a/source/ps/CLogger.h +++ b/source/ps/CLogger.h @@ -40,7 +40,7 @@ public: void QuickLog(const char *fmt, ...); private: - + void LogUsingMethod(ELogMethod method, const char* category, const char* message); //the three filestreams @@ -64,6 +64,10 @@ private: // Used to remember LogOnce messages std::set m_LoggedOnce; + + // squelch "unable to generate" warnings + CLogger(const CLogger& rhs); + const CLogger& operator=(const CLogger& rhs); }; #endif diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 9cce436e80..343356fc70 100755 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -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(); diff --git a/source/ps/CStr.h b/source/ps/CStr.h index 1729727e86..cae981da2d 100755 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -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 @@ -212,8 +212,8 @@ public: operator const tchar*() const; // 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[](size_t n) { debug_assert(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 diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index affc123003..2ddefd9616 100755 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -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(); diff --git a/source/ps/ConfigDB.h b/source/ps/ConfigDB.h index ccaae435ca..e79a34dc5a 100755 --- a/source/ps/ConfigDB.h +++ b/source/ps/ConfigDB.h @@ -120,4 +120,22 @@ public: bool WriteFile(EConfigNamespace ns, bool useVFS, CStr path); }; + +// stores the value of the given key into . 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 diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index 11e3df00b5..92d616e4db 100755 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -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 } diff --git a/source/ps/Game.h b/source/ps/Game.h index d8f09b4a01..8e5a306cb1 100755 --- a/source/ps/Game.h +++ b/source/ps/Game.h @@ -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; diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index 46196c546a..20c72cadc6 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -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(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(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::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 ::iterator it; for (it = m_PlayerSlots.begin();it != m_PlayerSlots.end();++it) diff --git a/source/ps/GameRecord.cpp b/source/ps/GameRecord.cpp index d4784a0c14..464cfa0d18 100755 --- a/source/ps/GameRecord.cpp +++ b/source/ps/GameRecord.cpp @@ -2,7 +2,6 @@ #include "GameRecord.h" -void CGameRecord::WriteMessage(CNetMessage *pMsg) +void CGameRecord::WriteMessage(CNetMessage* UNUSED(pMsg)) { - } diff --git a/source/ps/Hotkey.cpp b/source/ps/Hotkey.cpp index 8498ca8af4..7d02417aca 100755 --- a/source/ps/Hotkey.cpp +++ b/source/ps/Hotkey.cpp @@ -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++ ) diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index f4cb62d011..58cb28e57d 100755 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -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::iterator it; for( it = g_Mouseover.m_mouseover.begin(); it < g_Mouseover.m_mouseover.end(); it++ ) diff --git a/source/ps/Loader.cpp b/source/ps/Loader.cpp index 813de5610b..d10c7caea4 100644 --- a/source/ps/Loader.cpp +++ b/source/ps/Loader.cpp @@ -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*. diff --git a/source/ps/LoaderThunks.h b/source/ps/LoaderThunks.h index 9046ba260f..7da870956f 100644 --- a/source/ps/LoaderThunks.h +++ b/source/ps/LoaderThunks.h @@ -13,9 +13,13 @@ template 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 static int MemFunThunk(void* param, double time_left) +template static int MemFunThunk(void* param, double UNUSED(time_left)) { MemFun_t* const mf = (MemFun_t*)param; int ret = (mf->this_->*mf->func)(); @@ -25,7 +29,7 @@ template static int MemFunThunk(void* param, double time_left) } template void RegMemFun(T* this_, int(T::*func)(void), - const wchar_t* description, int estimated_duration_ms) + const wchar_t* description, int estimated_duration_ms) { void* param = new MemFun_t(this_, func); THROW_ERR(LDR_Register(MemFunThunk, param, description, estimated_duration_ms)); @@ -42,9 +46,13 @@ template 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 static int MemFun1Thunk(void* param, double time_left) +template static int MemFun1Thunk(void* param, double UNUSED(time_left)) { MemFun1_t* const mf = (MemFun1_t*)param; int ret = (mf->this_->*mf->func)(mf->arg); @@ -54,7 +62,7 @@ template static int MemFun1Thunk(void* param, double time_le } template void RegMemFun1(T* this_, int(T::*func)(Arg), Arg arg, - const wchar_t* description, int estimated_duration_ms) + const wchar_t* description, int estimated_duration_ms) { void* param = new MemFun1_t(this_, func, arg); THROW_ERR(LDR_Register(MemFun1Thunk, param, description, estimated_duration_ms)); diff --git a/source/ps/Network/Client.cpp b/source/ps/Network/Client.cpp index 390278b77b..2a15d8e10a 100755 --- a/source/ps/Network/Client.cpp +++ b/source/ps/Network/Client.cpp @@ -80,7 +80,7 @@ void CNetClient::ScriptingInit() CJSObject::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(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; diff --git a/source/ps/Network/JSEvents.h b/source/ps/Network/JSEvents.h index 8bd160366e..379c479d9a 100644 --- a/source/ps/Network/JSEvents.h +++ b/source/ps/Network/JSEvents.h @@ -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) diff --git a/source/ps/Network/NMTCreator.h b/source/ps/Network/NMTCreator.h index 89a3226647..132b85e554 100755 --- a/source/ps/Network/NMTCreator.h +++ b/source/ps/Network/NMTCreator.h @@ -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 ::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 ::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; \ diff --git a/source/ps/Network/NetMessage.cpp b/source/ps/Network/NetMessage.cpp index 5c0cc2a3b7..da7c670622 100755 --- a/source/ps/Network/NetMessage.cpp +++ b/source/ps/Network/NetMessage.cpp @@ -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( 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(argv[argIndex++]); \ + _msg->_field ## Y = ToPrimitive(argv[argIndex++]); \ } catch (PSERROR_Scripting_ConversionFailed) { \ JS_ReportError(cx, "Invalid location"); \ return NULL; \ diff --git a/source/ps/Network/NetworkInternal.h b/source/ps/Network/NetworkInternal.h index e24656303a..a0bff0b127 100755 --- a/source/ps/Network/NetworkInternal.h +++ b/source/ps/Network/NetworkInternal.h @@ -3,14 +3,15 @@ #include -#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 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; diff --git a/source/ps/Network/Server.cpp b/source/ps/Network/Server.cpp index 383acc4ae3..40a5e926cf 100755 --- a/source/ps/Network/Server.cpp +++ b/source/ps/Network/Server.cpp @@ -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::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; } diff --git a/source/ps/Network/ServerSession.cpp b/source/ps/Network/ServerSession.cpp index a0407ca42d..ec319d7715 100644 --- a/source/ps/Network/ServerSession.cpp +++ b/source/ps/Network/ServerSession.cpp @@ -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; } diff --git a/source/ps/Network/ServerSocket.cpp b/source/ps/Network/ServerSocket.cpp index 6ecb6b4dd9..bed79a9d9b 100755 --- a/source/ps/Network/ServerSocket.cpp +++ b/source/ps/Network/ServerSocket.cpp @@ -27,5 +27,5 @@ void CServerSocket::OnRead() void CServerSocket::OnWrite() {} -void CServerSocket::OnClose(PS_RESULT errorCode) +void CServerSocket::OnClose(PS_RESULT UNUSED(errorCode)) {} diff --git a/source/ps/Network/SocketBase.cpp b/source/ps/Network/SocketBase.cpp index 0c6dcf3601..b661b886ff 100755 --- a/source/ps/Network/SocketBase.cpp +++ b/source/ps/Network/SocketBase.cpp @@ -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() { diff --git a/source/ps/Network/SocketBase.h b/source/ps/Network/SocketBase.h index bc0f184031..59c965818a 100755 --- a/source/ps/Network/SocketBase.h +++ b/source/ps/Network/SocketBase.h @@ -202,7 +202,7 @@ private: */ friend void *WaitLoopThreadMain(void *); -#ifdef _WIN32 +#if OS_WIN /** * Used by the winsock AsyncSelect windowproc */ diff --git a/source/ps/Network/StreamSocket.cpp b/source/ps/Network/StreamSocket.cpp index 410c38a5e2..9c2e97accf 100755 --- a/source/ps/Network/StreamSocket.cpp +++ b/source/ps/Network/StreamSocket.cpp @@ -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; diff --git a/source/ps/Parser.cpp b/source/ps/Parser.cpp index d0174c443e..4abef2cbe5 100755 --- a/source/ps/Parser.cpp +++ b/source/ps/Parser.cpp @@ -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 diff --git a/source/ps/Player.cpp b/source/ps/Player.cpp index 37e7df9440..c8df6a1414 100755 --- a/source/ps/Player.cpp +++ b/source/ps/Player.cpp @@ -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* 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,11 +92,11 @@ 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; - + m_Colour=*( ToNative(argv[0]) ); ISynchedJSProperty *prop=GetSynchedProperty(L"colour"); Update(L"colour", prop); diff --git a/source/ps/ThreadUtil.h b/source/ps/ThreadUtil.h index a3dfb79374..82cf476c6e 100755 --- a/source/ps/ThreadUtil.h +++ b/source/ps/ThreadUtil.h @@ -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 diff --git a/source/ps/VFSUtil.cpp b/source/ps/VFSUtil.cpp index 6bb58e2aa8..76bad2f648 100755 --- a/source/ps/VFSUtil.cpp +++ b/source/ps/VFSUtil.cpp @@ -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 for each entry matching (see vfs_next_dirent) in -// directory ; if , entries in subdirectories are +// directory ; if , 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()); diff --git a/source/ps/VFSUtil.h b/source/ps/VFSUtil.h index beebbe5f37..9f3516c6af 100755 --- a/source/ps/VFSUtil.h +++ b/source/ps/VFSUtil.h @@ -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 for each file in the directory; -// if , files in subdirectories are also returned. -extern int EnumDirEnts(const CStr path, const char* filter, bool recursive, +enum EnumDirEntsFlags +{ + RECURSIVE = 1 +}; + +// call for each entry matching (see vfs_next_dirent) in +// directory ; 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 diff --git a/source/ps/World.h b/source/ps/World.h index 9837ab631b..df7aa3f66f 100755 --- a/source/ps/World.h +++ b/source/ps/World.h @@ -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" diff --git a/source/ps/XML.h b/source/ps/XML.h index f49ef16f90..ea4c3bd9c4 100755 --- a/source/ps/XML.h +++ b/source/ps/XML.h @@ -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 @@ -37,10 +41,20 @@ #include #include -#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 +#include + + +#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" diff --git a/source/ps/XMLUtils.cpp b/source/ps/XMLUtils.cpp index 6af60cbaa9..d1a8c9d81b 100755 --- a/source/ps/XMLUtils.cpp +++ b/source/ps/XMLUtils.cpp @@ -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(); diff --git a/source/ps/Xeromyces.cpp b/source/ps/Xeromyces.cpp index 4445d9992b..116704b95e 100755 --- a/source/ps/Xeromyces.cpp +++ b/source/ps/Xeromyces.cpp @@ -2,8 +2,6 @@ #include "precompiled.h" -#include "nommgr.h" - #include #include #include @@ -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 -#include - -// 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)); } diff --git a/source/ps/scripting/JSCollection.h b/source/ps/scripting/JSCollection.h index b35b0eec01..2fc9e73db7 100755 --- a/source/ps/scripting/JSCollection.h +++ b/source/ps/scripting/JSCollection.h @@ -104,7 +104,7 @@ template JSBool CJSCollection::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 JSBool CJSCollection::A } -template JSBool CJSCollection::RemoveProperty ( JSContext* cx, JSObject* obj, jsval id, jsval* vp ) +template JSBool CJSCollection::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 bool CJSCollection::Get } -template JSBool CJSCollection::ToString( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) +template JSBool CJSCollection::ToString( + JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval ) { std::vector* set = RetrieveSet( cx, obj ); @@ -252,7 +254,8 @@ template JSBool CJSCollection::T return( JS_TRUE ); } -template JSBool CJSCollection::GetLength( JSContext* cx, JSObject* obj, jsval id, jsval* vp ) +template JSBool CJSCollection::GetLength( + JSContext* cx, JSObject* obj, jsval UNUSED(id), jsval* vp ) { std::vector* set = RetrieveSet( cx, obj ); @@ -263,7 +266,8 @@ template JSBool CJSCollection::G return( JS_TRUE ); } -template JSBool CJSCollection::IsEmpty( JSContext* cx, JSObject* obj, jsval id, jsval* vp ) +template JSBool CJSCollection::IsEmpty( + JSContext* cx, JSObject* obj, jsval UNUSED(id), jsval* vp ) { std::vector* set = RetrieveSet( cx, obj ); @@ -311,7 +315,8 @@ template JSBool CJSCollection::E return( JS_TRUE ); } -template JSBool CJSCollection::Subset( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) +template JSBool CJSCollection::Subset( + JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { debug_assert( argc > 0 ); @@ -329,8 +334,6 @@ template JSBool CJSCollection::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 JSBool CJSCollection::S return( JS_TRUE ); } -template JSBool CJSCollection::Clear( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) +template JSBool CJSCollection::Clear( + JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval ) { std::vector* Set = RetrieveSet( cx, obj ); if( !Set ) @@ -372,7 +376,8 @@ template JSBool CJSCollection::P return( JS_TRUE ); } -template JSBool CJSCollection::Pop( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) +template JSBool CJSCollection::Pop( + JSContext* cx, JSObject* obj, uintN UNUSED(argc), jsval* UNUSED(argv), jsval* rval ) { std::vector* Set = RetrieveSet( cx, obj ); if( !Set ) @@ -390,7 +395,8 @@ template JSBool CJSCollection::P return( JS_TRUE ); } -template JSBool CJSCollection::Remove( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) +template JSBool CJSCollection::Remove( + JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* UNUSED(rval) ) { debug_assert( argc > 0 ); @@ -403,7 +409,7 @@ template JSBool CJSCollection::R int index; try { - index = g_ScriptingHost.ValueToInt( argv[0] ); + index = ToPrimitive( argv[0] ); } catch( PSERROR_Scripting_ConversionFailed ) { diff --git a/source/ps/scripting/JSInterface_Console.cpp b/source/ps/scripting/JSInterface_Console.cpp index 08425484f2..c083928583 100755 --- a/source/ps/scripting/JSInterface_Console.cpp +++ b/source/ps/scripting/JSInterface_Console.cpp @@ -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( *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; diff --git a/source/ps/scripting/JSInterface_Console.h b/source/ps/scripting/JSInterface_Console.h index 3bf26bf3b1..f9ff6d55a1 100755 --- a/source/ps/scripting/JSInterface_Console.h +++ b/source/ps/scripting/JSInterface_Console.h @@ -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 diff --git a/source/ps/scripting/JSInterface_Selection.cpp b/source/ps/scripting/JSInterface_Selection.cpp index 855635d94e..46d009a564 100755 --- a/source/ps/scripting/JSInterface_Selection.cpp +++ b/source/ps/scripting/JSInterface_Selection.cpp @@ -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(); diff --git a/source/ps/scripting/JSInterface_Selection.h b/source/ps/scripting/JSInterface_Selection.h index a13c4ab604..e854e399af 100755 --- a/source/ps/scripting/JSInterface_Selection.h +++ b/source/ps/scripting/JSInterface_Selection.h @@ -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 ); }; diff --git a/source/ps/scripting/JSInterface_VFS.cpp b/source/ps/scripting/JSInterface_VFS.cpp index b8dff1d408..dadf2b0d17 100644 --- a/source/ps/scripting/JSInterface_VFS.cpp +++ b/source/ps/scripting/JSInterface_VFS.cpp @@ -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( 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; diff --git a/source/ps/scripting/JSMap.h b/source/ps/scripting/JSMap.h index 8912f29a37..a7cfaedb34 100644 --- a/source/ps/scripting/JSMap.h +++ b/source/ps/scripting/JSMap.h @@ -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; } diff --git a/source/ps/utf16string.h b/source/ps/utf16string.h index 97b145b9f8..05bf53f9ea 100755 --- a/source/ps/utf16string.h +++ b/source/ps/utf16string.h @@ -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 diff --git a/source/renderer/ModelRData.cpp b/source/renderer/ModelRData.cpp index 2b833a1083..ee75c17a63 100755 --- a/source/renderer/ModelRData.cpp +++ b/source/renderer/ModelRData.cpp @@ -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; jGetNumFaces(); j++) { + for (size_t j=0; jGetNumFaces(); 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; jGetNumFaces(); + 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;iGetFlags(); + u32 mflags=m_Models[i]->GetFlags(); // TODO2 if (!flags || (m_Models[i]->GetFlags()&flags)) { CModelRData* modeldata=(CModelRData*) m_Models[i]->GetRenderData(); modeldata->SubmitBatches(); diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp index 6eab139a81..d8fe6b8c64 100755 --- a/source/renderer/PatchRData.cpp +++ b/source/renderer/PatchRData.cpp @@ -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;jm_Owner->Bind(); + UNUSED2(base); glBegin(GL_LINES); for (i=0;i= 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::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() ); diff --git a/source/scripting/EventTypes.h b/source/scripting/EventTypes.h index 8bb85220cc..8e98447605 100644 --- a/source/scripting/EventTypes.h +++ b/source/scripting/EventTypes.h @@ -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 diff --git a/source/scripting/GameEvents.h b/source/scripting/GameEvents.h index a313088104..c7f60b537d 100644 --- a/source/scripting/GameEvents.h +++ b/source/scripting/GameEvents.h @@ -14,7 +14,7 @@ class CGameEvents : public IEventTarget, public Singleton { // 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 diff --git a/source/scripting/JSConversions.cpp b/source/scripting/JSConversions.cpp index 06c024c865..ffb11c145e 100755 --- a/source/scripting/JSConversions.cpp +++ b/source/scripting/JSConversions.cpp @@ -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& Native ) return( OBJECT_TO_JSVAL( Native.GetFunctionObject() ) ); } -template<> bool ToPrimitive( JSContext* cx, jsval v, CScriptObject& Storage ) +template<> bool ToPrimitive( JSContext* UNUSED(cx), jsval v, CScriptObject& Storage ) { Storage.SetJSVal( v ); return( true ); @@ -97,17 +98,16 @@ template<> jsval ToJSVal( int& Native ) return( INT_TO_JSVAL( Native ) ); } + + + + + + template<> bool ToPrimitive( 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& Native ) template<> bool ToPrimitive( 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(cx, v, temp)) + return false; + if(temp < 0) + return false; + Storage = temp; + return true; } // double @@ -151,15 +147,10 @@ template<> jsval ToJSVal( double& Native ) template<> bool ToPrimitive( 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& Native ) template<> bool ToPrimitive( 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(cx, v, temp)) + return false; + Storage = (float)temp; + return true; } @@ -202,19 +189,16 @@ template<> jsval ToJSVal( bool& Native ) template<> bool ToPrimitive( 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( JSContext* cx, jsval v, CStrW& Storage ) +template<> bool ToPrimitive( JSContext* UNUSED(cx), jsval v, CStrW& Storage ) { try { @@ -239,7 +223,7 @@ template<> jsval ToJSVal( CStrW& Native ) // CStr/CStr8 -template<> bool ToPrimitive( JSContext* cx, jsval v, CStr8& Storage ) +template<> bool ToPrimitive( JSContext* UNUSED(cx), jsval v, CStr8& Storage ) { try { diff --git a/source/scripting/JSConversions.h b/source/scripting/JSConversions.h index c2fbd47096..5bfc0fd34f 100755 --- a/source/scripting/JSConversions.h +++ b/source/scripting/JSConversions.h @@ -40,7 +40,7 @@ template T* ToNative( jsval v ) return( ToNative( g_ScriptingHost.GetContext(), JSVAL_TO_OBJECT( v ) ) ); } -template bool ToPrimitive( JSContext* cx, jsval v, T& Storage ) +template bool ToPrimitive( JSContext* UNUSED(cx), jsval v, T& Storage ) { T* Native = ToNative( v ); if( !Native ) return( false ); @@ -49,7 +49,7 @@ template bool ToPrimitive( JSContext* cx, jsval v, T& Storage ) } // Handle pointer-to-objects sensibly (by automatically dereferencing them one level) -template bool ToPrimitive( JSContext* cx, jsval v, T*& Storage ) +template bool ToPrimitive( JSContext* UNUSED(cx), jsval v, T*& Storage ) { T* Native = ToNative( v ); if( !Native ) return( false ); diff --git a/source/scripting/JSSerialization.h b/source/scripting/JSSerialization.h index 1e16e0cd86..881ecc0687 100755 --- a/source/scripting/JSSerialization.h +++ b/source/scripting/JSSerialization.h @@ -59,7 +59,7 @@ public: case TAG_STRING: return( 1 + (ToPrimitive(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( 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 ); diff --git a/source/scripting/ScriptCustomTypes.cpp b/source/scripting/ScriptCustomTypes.cpp index 1aa3802850..95130281c2 100755 --- a/source/scripting/ScriptCustomTypes.cpp +++ b/source/scripting/ScriptCustomTypes.cpp @@ -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::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; diff --git a/source/scripting/ScriptCustomTypes.h b/source/scripting/ScriptCustomTypes.h index fa92778074..d3aa68538d 100755 --- a/source/scripting/ScriptCustomTypes.h +++ b/source/scripting/ScriptCustomTypes.h @@ -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 diff --git a/source/scripting/ScriptGlue.h b/source/scripting/ScriptGlue.h index 23129e0c2b..1a66218ed6 100755 --- a/source/scripting/ScriptGlue.h +++ b/source/scripting/ScriptGlue.h @@ -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 diff --git a/source/scripting/ScriptableComplex.h b/source/scripting/ScriptableComplex.h index 2d8fb36848..af46c6a195 100644 --- a/source/scripting/ScriptableComplex.h +++ b/source/scripting/ScriptableComplex.h @@ -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)" ); } }; diff --git a/source/scripting/ScriptableObject.h b/source/scripting/ScriptableObject.h index eb5f35530b..61d543e09b 100755 --- a/source/scripting/ScriptableObject.h +++ b/source/scripting/ScriptableObject.h @@ -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 static void AddMethod( const char* Name, uintN MinArgs ) { - JSFunctionSpec FnInfo = { Name, CNativeFunction::JSFunction, MinArgs, 0, 0 }; + JSFunctionSpec FnInfo = { Name, CNativeFunction::JSFunction, (uint8)MinArgs, 0, 0 }; m_Methods.push_back( FnInfo ); } template static void AddProperty( CStrW PropertyName, PropType T::*Native, bool PropReadOnly = ReadOnly ) diff --git a/source/scripting/ScriptingHost.cpp b/source/scripting/ScriptingHost.cpp index f5a369e266..a4a7da75ee 100755 --- a/source/scripting/ScriptingHost.cpp +++ b/source/scripting/ScriptingHost.cpp @@ -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(); + if(!filename) + filename = "unspecified file"; + if(!globalObject) + globalObject = m_GlobalObject; - void* script; - size_t script_len; - if(vfs_load(fn, script, script_len) <= 0) // ERRTODO: translate/pass it on - throw PSERROR_Scripting_LoadFile_OpenFailed(); - - 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); + jsval rval; + 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 ) diff --git a/source/scripting/ScriptingHost.h b/source/scripting/ScriptingHost.h index 10812e706d..a0547bdcc6 100755 --- a/source/scripting/ScriptingHost.h +++ b/source/scripting/ScriptingHost.h @@ -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); diff --git a/source/scripting/SpiderMonkey.h b/source/scripting/SpiderMonkey.h index e831607199..7c97062011 100644 --- a/source/scripting/SpiderMonkey.h +++ b/source/scripting/SpiderMonkey.h @@ -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 diff --git a/source/scripting/SynchedJSObject.h b/source/scripting/SynchedJSObject.h index de4ac2b667..a795030a30 100644 --- a/source/scripting/SynchedJSObject.h +++ b/source/scripting/SynchedJSObject.h @@ -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*)other)->m_Data ); } diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index 9a495066c5..291f9217cd 100755 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -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() ); diff --git a/source/simulation/BaseEntity.h b/source/simulation/BaseEntity.h index 2d91f1bb26..8c720af0c7 100755 --- a/source/simulation/BaseEntity.h +++ b/source/simulation/BaseEntity.h @@ -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 diff --git a/source/simulation/BaseEntityCollection.cpp b/source/simulation/BaseEntityCollection.cpp index 52f42d3889..3836576e86 100755 --- a/source/simulation/BaseEntityCollection.cpp +++ b/source/simulation/BaseEntityCollection.cpp @@ -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; } diff --git a/source/simulation/BoundingObjects.cpp b/source/simulation/BoundingObjects.cpp index 71a37eb19e..4be0cfce98 100755 --- a/source/simulation/BoundingObjects.cpp +++ b/source/simulation/BoundingObjects.cpp @@ -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 ); diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 4e6a513bf5..46a23740a3 100755 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -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( cx, jsBaseEntity ) ) ) + CBaseEntity* baseEntity = ToNative( 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( 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( 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( argv[1] ); + newOrder.m_data[0].location.y = ToPrimitive( 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( 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 ); diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h index b38b6e51b4..b4f0778fc1 100755 --- a/source/simulation/Entity.h +++ b/source/simulation/Entity.h @@ -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( 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 diff --git a/source/simulation/EntityHandles.cpp b/source/simulation/EntityHandles.cpp index 8cf9d2eb65..f35aaf372c 100755 --- a/source/simulation/EntityHandles.cpp +++ b/source/simulation/EntityHandles.cpp @@ -108,13 +108,13 @@ uint HEntity::GetSerializedLength() const return 2; } -u8 *HEntity::Serialize(u8 *buffer) const +u8 *HEntity::Serialize(u8* buffer) const { Serialize_int_2(buffer, m_handle); 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)) diff --git a/source/simulation/EntityProperties.cpp b/source/simulation/EntityProperties.cpp index b603052457..c9a5a62829 100755 --- a/source/simulation/EntityProperties.cpp +++ b/source/simulation/EntityProperties.cpp @@ -38,7 +38,7 @@ void CBoundProperty::set( const jsval value ) { try { - m_data = g_ScriptingHost.ValueToInt( value ); + m_data = ToPrimitive( value ); m_inherited = false; } catch( ... ) @@ -55,7 +55,7 @@ void CBoundProperty::set( const jsval value ) { try { - m_data = g_ScriptingHost.ValueToBool( value ); + m_data = ToPrimitive( value ); m_inherited = false; } catch( ... ) @@ -72,7 +72,7 @@ void CBoundProperty::set( const jsval value ) { try { - m_data = (float)g_ScriptingHost.ValueToDouble( value ); + m_data = ToPrimitive( value ); m_inherited = false; } catch( ... ) diff --git a/source/simulation/EntityProperties.h b/source/simulation/EntityProperties.h index 410e372921..5556cb3085 100755 --- a/source/simulation/EntityProperties.h +++ b/source/simulation/EntityProperties.h @@ -22,7 +22,7 @@ #include "scripting/JSInterface_Entity.h" #include "scripting/JSInterface_Vector3D.h" -#ifndef __GNUC__ +#if !GCC_VERSION diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index 1a42599a48..82bad792bd 100755 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -271,7 +271,7 @@ bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_milli } // Handles processing common to (at the moment) gather and melee attack actions -bool CEntity::processContactAction( CEntityOrder* current, size_t timestep_millis, int transition, SEntityAction* action ) +bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timestep_millis), int transition, SEntityAction* action ) { m_orderQueue.pop_front(); @@ -505,9 +505,11 @@ bool CEntity::processGatherNoPathing( CEntityOrder* current, size_t timestep_mil return( processContactActionNoPathing( current, timestep_millis, "gather", &evt, &m_gather ) ); } -bool CEntity::processGoto( CEntityOrder* current, size_t timestep_millis ) +bool CEntity::processGoto( CEntityOrder* current, size_t UNUSED(timestep_millis) ) { - float timestep=timestep_millis/1000.0f; + // float timestep=timestep_millis/1000.0f; + // janwas: currently unused + CVector2D pos( m_position.X, m_position.Z ); CVector2D path_to = current->m_data[0].location; @@ -533,9 +535,10 @@ bool CEntity::processGoto( CEntityOrder* current, size_t timestep_millis ) return( true ); } -bool CEntity::processPatrol( CEntityOrder* current, size_t timestep_millis ) +bool CEntity::processPatrol( CEntityOrder* current, size_t UNUSED(timestep_millis) ) { - float timestep=timestep_millis/1000.0f; + // float timestep=timestep_millis/1000.0f; + // janwas: currently unused CEntityOrder this_segment; CEntityOrder repeat_patrol; diff --git a/source/simulation/EntitySupport.h b/source/simulation/EntitySupport.h index b79ee15666..f64730153e 100755 --- a/source/simulation/EntitySupport.h +++ b/source/simulation/EntitySupport.h @@ -47,7 +47,7 @@ public: AddProperty( L"typeless", &CDamageType::m_Typeless ); CJSObject::ScriptingInit( "DamageType", Construct, 3 ); } - static JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) + static JSBool Construct( JSContext* UNUSED(cx), JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval ) { CDamageType* dt; diff --git a/source/simulation/Projectile.cpp b/source/simulation/Projectile.cpp index f5b01d941e..5b3ab2023a 100644 --- a/source/simulation/Projectile.cpp +++ b/source/simulation/Projectile.cpp @@ -124,7 +124,7 @@ void CProjectile::ScriptingInit() CJSObject::ScriptingInit( "Projectile", Construct, 4 ); } -JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) +JSBool CProjectile::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval ) { debug_assert( argc >= 4 ); CStr ModelString; @@ -137,7 +137,8 @@ JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, const char* err = NULL; - if( Temp = ToNative( argv[0] ) ) + Temp = ToNative( argv[0] ); + if(Temp) { Model = Temp->m_actor->GetObject()->m_ProjectileModel; if( !Model ) @@ -151,7 +152,9 @@ JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, err = "Invalid actor"; goto fail; } - if( Temp = ToNative( argv[1] ) ) + + Temp = ToNative( argv[1] ); + if(Temp) { // Use the position vector of this entity, add a bit (so the arrow doesn't appear out of the ground) // In future, find the appropriate position from the entity (location of a specific prop point?) @@ -163,7 +166,9 @@ JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, err = "Invalid vector"; goto fail; } - if( Temp = ToNative( argv[2] ) ) + + Temp = ToNative( argv[2] ); + if(Temp) { // Use the position vector of this entity. // TODO: Maybe: Correct for the movement of this entity. @@ -176,7 +181,9 @@ JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, err = "Invalid vector"; goto fail; } - if( ( Speed = ToPrimitive( cx, argv[3] ) ) == 0.0f ) + + Speed = ToPrimitive( cx, argv[3] ); + if( Speed == 0.0f ) { // Either wasn't specified, or was zero. In either case, // can't allow it: div/0 errors in the physics diff --git a/source/simulation/Projectile.h b/source/simulation/Projectile.h index bb37307f95..8fd546118a 100644 --- a/source/simulation/Projectile.h +++ b/source/simulation/Projectile.h @@ -51,8 +51,8 @@ class CProjectile : public CJSObject, public IEventTarget // Scripty things. public: static void ScriptingInit(); - static JSBool Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ); - JSObject* GetScriptExecContext( IEventTarget* target ) { return( GetScript() ); } + static JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ); + JSObject* GetScriptExecContext( IEventTarget* UNUSED(target) ) { return( GetScript() ); } inline CModel* GetModel() const { return( m_Actor ); } }; diff --git a/source/simulation/Scheduler.cpp b/source/simulation/Scheduler.cpp index ed3bcd6cd7..e9d6e2290b 100755 --- a/source/simulation/Scheduler.cpp +++ b/source/simulation/Scheduler.cpp @@ -128,7 +128,7 @@ void CJSProgressTimer::ScriptingInit() CJSObject::ScriptingInit( "ProgressTimer", Construct, 2 ); } -JSBool CJSProgressTimer::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) +JSBool CJSProgressTimer::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval ) { debug_assert( argc >= 2 ); double max = ToPrimitive( argv[0] ); diff --git a/source/simulation/Scheduler.h b/source/simulation/Scheduler.h index 38b0d4f163..be558991f1 100755 --- a/source/simulation/Scheduler.h +++ b/source/simulation/Scheduler.h @@ -80,7 +80,7 @@ class CJSProgressTimer : public CJSObject JSFunction* m_Callback; JSObject* m_OperateOn; CJSProgressTimer( double Max, double Increment, JSFunction* Callback, JSObject* OperateOn ); - 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 ); public: static void ScriptingInit(); }; diff --git a/source/simulation/ScriptObject.cpp b/source/simulation/ScriptObject.cpp index 62d5cd0ac2..f313060846 100755 --- a/source/simulation/ScriptObject.cpp +++ b/source/simulation/ScriptObject.cpp @@ -96,7 +96,7 @@ bool CScriptObject::Run( JSObject* Context, uintN argc, jsval* argv ) jsval Temp; if( !Run( Context, &Temp, argc, argv ) ) return( false ); - return( g_ScriptingHost.ValueToBool( Temp ) ); + return( ToPrimitive( Temp ) ); } // Treat this as an event handler and dispatch an event to it. Return !evt->m_cancelled, as a convenience. diff --git a/source/simulation/Simulation.cpp b/source/simulation/Simulation.cpp index c4380fd9c6..55b4de0dc7 100755 --- a/source/simulation/Simulation.cpp +++ b/source/simulation/Simulation.cpp @@ -38,7 +38,7 @@ CSimulation::~CSimulation() g_SinglePlayerTurnManager=NULL; } -int CSimulation::Initialize(CGameAttributes *pAttribs) +int CSimulation::Initialize(CGameAttributes* UNUSED(pAttribs)) { m_pTurnManager->Initialize(m_pGame->GetNumPlayers()); @@ -184,7 +184,7 @@ void QueueOrder(CEntityOrder order, const vector &entities, bool clear } } -uint CSimulation::TranslateMessage(CNetMessage *pMsg, uint clientMask, void *userdata) +uint CSimulation::TranslateMessage(CNetMessage* pMsg, uint clientMask, void* UNUSED(userdata)) { CEntityOrder order; bool clearQueue = true; @@ -257,9 +257,10 @@ uint CSimulation::TranslateMessage(CNetMessage *pMsg, uint clientMask, void *use return clientMask; } -uint CSimulation::GetMessageMask(CNetMessage *pMsg, uint oldMask, void *userdata) +uint CSimulation::GetMessageMask(CNetMessage* UNUSED(pMsg), uint UNUSED(oldMask), void* UNUSED(userdata)) { - CSimulation *pSimulation=(CSimulation *)userdata; + //CSimulation *pSimulation=(CSimulation *)userdata; + // Pending a complete visibility/minimal-update implementation, we'll // simply select the first 32 connected clients ;-) return 0xffffffff; diff --git a/source/simulation/scripting/JSInterface_Entity.cpp b/source/simulation/scripting/JSInterface_Entity.cpp index 2247b0a79e..059ba0f347 100755 --- a/source/simulation/scripting/JSInterface_Entity.cpp +++ b/source/simulation/scripting/JSInterface_Entity.cpp @@ -80,7 +80,7 @@ JSBool JSI_Entity::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* v return( JS_TRUE ); } -JSBool JSI_Entity::construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) +JSBool JSI_Entity::construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ) { debug_assert( argc >= 2 ); CBaseEntity* baseEntity = NULL; @@ -118,7 +118,7 @@ JSBool JSI_Entity::construct( JSContext* cx, JSObject* obj, unsigned int argc, j { try { - orientation = (float)g_ScriptingHost.ValueToDouble( argv[2] ); + orientation = ToPrimitive( argv[2] ); } catch( PSERROR_Scripting_ConversionFailed ) { @@ -181,7 +181,7 @@ JSBool JSI_Entity::order( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, try { - orderCode = g_ScriptingHost.ValueToInt( argv[0] ); + orderCode = ToPrimitive( argv[0] ); } catch( PSERROR_Scripting_ConversionFailed ) { diff --git a/source/simulation/scripting/JSInterface_Entity.h b/source/simulation/scripting/JSInterface_Entity.h index 3c17f06fee..3fa0031671 100755 --- a/source/simulation/scripting/JSInterface_Entity.h +++ b/source/simulation/scripting/JSInterface_Entity.h @@ -23,7 +23,7 @@ namespace JSI_Entity extern JSFunctionSpec JSI_methods[]; 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 construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval ); void finalize( JSContext* cx, JSObject* obj ); void init(); } diff --git a/source/sound/CMusicPlayer.cpp b/source/sound/CMusicPlayer.cpp index cb2156a776..c16c22dd0b 100755 --- a/source/sound/CMusicPlayer.cpp +++ b/source/sound/CMusicPlayer.cpp @@ -32,7 +32,7 @@ CMusicPlayer::~CMusicPlayer(void) release(); } -void CMusicPlayer::open(char *filename) +void CMusicPlayer::open(char* UNUSED(filename)) { // If a new file is opened while another is already in memory, // close the old one first. @@ -242,7 +242,7 @@ void CMusicPlayer::empty() -std::string CMusicPlayer::errorString(int errorcode) +std::string CMusicPlayer::errorString(int UNUSED(errorcode)) { /* switch(errorcode) diff --git a/source/sound/JSI_Sound.cpp b/source/sound/JSI_Sound.cpp index c459d51b11..f10be8b3d7 100755 --- a/source/sound/JSI_Sound.cpp +++ b/source/sound/JSI_Sound.cpp @@ -76,14 +76,14 @@ bool JSI_Sound::SetPosition( JSContext* cx, uintN argc, jsval* argv ) // start playing the sound (one-shot). // it will automatically be freed when done. -bool JSI_Sound::Play( JSContext* cx, uintN argc, jsval* argv ) +bool JSI_Sound::Play( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { snd_play(m_Handle); return true; } // request the sound be played until free() is called. returns immediately. -bool JSI_Sound::Loop( JSContext* cx, uintN argc, jsval* argv ) +bool JSI_Sound::Loop( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { snd_set_loop(m_Handle, true); snd_play(m_Handle); @@ -93,7 +93,7 @@ bool JSI_Sound::Loop( JSContext* cx, uintN argc, jsval* argv ) // stop sound if currently playing and free resources. // doesn't need to be called unless played via loop() - // sounds are freed automatically when done playing. -bool JSI_Sound::Free( JSContext* cx, uintN argc, jsval* argv ) +bool JSI_Sound::Free( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { snd_free(m_Handle); // resets it to 0 return true; @@ -116,7 +116,7 @@ void JSI_Sound::ScriptingInit() CJSObject::ScriptingInit( "Sound", &JSI_Sound::Construct, 1 ); } -jsval JSI_Sound::ToString( JSContext* cx, uintN argc, jsval* argv ) +jsval JSI_Sound::ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) ) { const char* Filename = h_filename(m_Handle); wchar_t buffer[256]; @@ -126,7 +126,7 @@ jsval JSI_Sound::ToString( JSContext* cx, uintN argc, jsval* argv ) return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, str16.c_str() ) ) ); } -JSBool JSI_Sound::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) +JSBool JSI_Sound::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval ) { debug_assert( argc >= 1 ); CStrW filename; diff --git a/source/sound/JSI_Sound.h b/source/sound/JSI_Sound.h index 81f07896d9..1c8cf525b8 100755 --- a/source/sound/JSI_Sound.h +++ b/source/sound/JSI_Sound.h @@ -53,7 +53,7 @@ public: bool SetPosition( JSContext* cx, uintN argc, jsval* argv ); - 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 ); static void ScriptingInit();