From 158fe402306a77be0d35b9ba98b212eaba0dc7fe Mon Sep 17 00:00:00 2001 From: tamlin-mike Date: Sat, 23 Jul 2016 14:36:41 +0200 Subject: [PATCH] Dependency reductions of and const-ify xr_token. Reduce compiler warnings. --- src/Layers/xrRender/ETextureParams.cpp | 11 ++-- src/Layers/xrRender/ETextureParams.h | 6 +- src/Layers/xrRender/HW.cpp | 1 + src/Layers/xrRender/NvTriStripObjects.cpp | 16 +++--- src/Layers/xrRender/R_Backend_DBG.cpp | 8 +++ src/Layers/xrRender/R_Backend_Runtime.cpp | 3 + .../xrRender/ResourceManager_Resources.cpp | 2 +- src/Layers/xrRender/SH_RT.cpp | 4 +- src/Layers/xrRender/SkeletonAnimated.cpp | 6 +- src/Layers/xrRender/SkeletonX.cpp | 2 +- .../xrRender/blenders/Blender_Recorder.cpp | 3 + src/Layers/xrRender/dxDebugRender.cpp | 1 + src/Layers/xrRender/r__dsgraph_build.cpp | 18 +++--- src/Layers/xrRender/r__screenshot.cpp | 16 +++--- src/Layers/xrRender/xrRender_console.cpp | 56 +++++++++---------- src/Layers/xrRender/xrRender_console.h | 14 ++--- .../xrRenderDX10/3DFluid/dx103DFluidData.cpp | 2 +- .../3DFluid/dx103DFluidManager.cpp | 2 +- src/Layers/xrRenderDX10/dx10HW.cpp | 3 +- src/Layers/xrRenderGL/glHW.cpp | 5 +- src/Layers/xrRenderPC_GL/gl_rendertarget.cpp | 8 +-- src/Layers/xrRenderPC_R2/r2_R_lights.cpp | 22 ++++---- src/Layers/xrRenderPC_R4/r4_rendertarget.h | 2 +- .../ECore/Editor/ParticleEffectActions.h | 10 +++- .../ParticleEffectActionsImpl.cpp | 2 +- src/utils/xrLC_Light/ETextureParams.cpp | 11 ++-- src/utils/xrLC_Light/ETextureParams.h | 6 +- src/xrCore/_std_extensions.h | 34 +---------- src/xrCore/xrCore.vcxproj | 2 + src/xrCore/xrCore.vcxproj.filters | 6 ++ src/xrCore/xr_ini.cpp | 1 + src/xrCore/xr_token.cpp | 18 ++++++ src/xrCore/xr_token.h | 13 +++++ src/xrCore/xr_trims.cpp | 1 + src/xrEngine/EngineAPI.cpp | 1 + src/xrEngine/IPhysicsShell.h | 11 ++-- src/xrEngine/XR_IOConsole.h | 2 +- src/xrEngine/XR_IOConsole_get.cpp | 2 +- src/xrEngine/xrSASH.cpp | 2 +- src/xrEngine/xr_ioc_cmd.cpp | 11 ++-- src/xrEngine/xr_ioc_cmd.h | 16 +++--- src/xrGame/Actor.cpp | 6 +- src/xrGame/PHDebug.cpp | 3 +- src/xrGame/PHMovementControl.cpp | 5 +- src/xrGame/Weapon.cpp | 1 + src/xrGame/ai_sounds.cpp | 3 +- src/xrGame/console_commands_mp.cpp | 2 +- src/xrGame/death_anims.cpp | 6 +- src/xrGame/death_anims_predicates.cpp | 13 +++-- src/xrGame/game_cl_single.cpp | 3 +- src/xrGame/game_cl_single.h | 2 +- src/xrGame/game_sv_base.cpp | 2 +- src/xrGame/game_sv_mp.cpp | 3 +- src/xrGame/ui/UIChangeMap.cpp | 2 - src/xrGame/ui/UIComboBox.cpp | 5 +- src/xrGame/ui/UIMPPlayersAdm.cpp | 3 +- src/xrGame/ui/UIMapList.cpp | 1 + src/xrGame/ui/UIOptionsItem.cpp | 2 +- src/xrGame/ui/UIOptionsItem.h | 2 +- src/xrGame/ui/UISpinText.cpp | 3 +- src/xrPhysics/PHShellSplitter.cpp | 4 +- src/xrServerEntities/ai_sounds.h | 2 +- src/xrServerEntities/alife_space.cpp | 1 + src/xrServerEntities/gametype_chooser.cpp | 4 +- src/xrServerEntities/script_token_list.h | 27 +++++---- .../script_token_list_inline.h | 14 ++--- src/xrServerEntities/xrEProps.h | 3 +- src/xrServerEntities/xrServer_Object_Base.cpp | 3 +- .../xrServer_Objects_ALife.cpp | 3 +- .../xrServer_Objects_ALife_Monsters.cpp | 8 +-- src/xrSound/OpenALDeviceList.cpp | 1 + 71 files changed, 277 insertions(+), 220 deletions(-) create mode 100644 src/xrCore/xr_token.cpp create mode 100644 src/xrCore/xr_token.h diff --git a/src/Layers/xrRender/ETextureParams.cpp b/src/Layers/xrRender/ETextureParams.cpp index 1c73008099f..8247156aacd 100644 --- a/src/Layers/xrRender/ETextureParams.cpp +++ b/src/Layers/xrRender/ETextureParams.cpp @@ -2,8 +2,9 @@ #pragma hdrstop #include "ETextureParams.h" +#include "xrCore/xr_token.h" -xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, +const xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, {"Point", STextureParams::kMIPFilterPoint}, {"Box", STextureParams::kMIPFilterBox}, {"Triangle", STextureParams::kMIPFilterTriangle}, {"Quadratic", STextureParams::kMIPFilterQuadratic}, @@ -17,21 +18,21 @@ xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, {"Hanning", STextureParams::kMIPFilterHanning}, {"Hamming", STextureParams::kMIPFilterHamming}, {"Blackman", STextureParams::kMIPFilterBlackman}, {"Kaiser", STextureParams::kMIPFilterKaiser}, {nullptr, 0}}; -xr_token ttype_token[] = {{"2D Texture", STextureParams::ttImage}, {"Cube Map", STextureParams::ttCubeMap}, +const xr_token ttype_token[] = {{"2D Texture", STextureParams::ttImage}, {"Cube Map", STextureParams::ttCubeMap}, {"Bump Map", STextureParams::ttBumpMap}, {"Normal Map", STextureParams::ttNormalMap}, {"Terrain", STextureParams::ttTerrain}, {nullptr, 0}}; -xr_token tfmt_token[] = {{"DXT1", STextureParams::tfDXT1}, {"DXT1 Alpha", STextureParams::tfADXT1}, +const xr_token tfmt_token[] = {{"DXT1", STextureParams::tfDXT1}, {"DXT1 Alpha", STextureParams::tfADXT1}, {"DXT3", STextureParams::tfDXT3}, {"DXT5", STextureParams::tfDXT5}, {"16 bit (1:5:5:5)", STextureParams::tf1555}, {"16 bit (5:6:5)", STextureParams::tf565}, {"32 bit (8:8:8:8)", STextureParams::tfRGBA}, {"8 bit (alpha)", STextureParams::tfA8}, {"8 bit (luminance)", STextureParams::tfL8}, {"16 bit (alpha:luminance)", STextureParams::tfA8L8}, {nullptr, 0}}; -xr_token tmtl_token[] = {{"OrenNayar <-> Blin", STextureParams::tmOrenNayar_Blin}, +const xr_token tmtl_token[] = {{"OrenNayar <-> Blin", STextureParams::tmOrenNayar_Blin}, {"Blin <-> Phong", STextureParams::tmBlin_Phong}, {"Phong <-> Metal", STextureParams::tmPhong_Metal}, {"Metal <-> OrenNayar", STextureParams::tmMetal_OrenNayar}, {nullptr, 0}}; -xr_token tbmode_token[] = {{"None", STextureParams::tbmNone}, {"Use", STextureParams::tbmUse}, +const xr_token tbmode_token[] = {{"None", STextureParams::tbmNone}, {"Use", STextureParams::tbmUse}, {"Use parallax", STextureParams::tbmUseParallax}, {nullptr, 0}}; void STextureParams::Load(IReader& F) diff --git a/src/Layers/xrRender/ETextureParams.h b/src/Layers/xrRender/ETextureParams.h index 81d95f222ab..05eff53ee2f 100644 --- a/src/Layers/xrRender/ETextureParams.h +++ b/src/Layers/xrRender/ETextureParams.h @@ -173,9 +173,9 @@ struct ECORE_API STextureParams #pragma pack(pop) struct xr_token; -extern xr_token tparam_token[]; -extern xr_token tfmt_token[]; -extern xr_token ttype_token[]; +extern const xr_token tparam_token[]; +extern const xr_token tfmt_token[]; +extern const xr_token ttype_token[]; //---------------------------------------------------- #define THM_CHUNK_VERSION 0x0810 diff --git a/src/Layers/xrRender/HW.cpp b/src/Layers/xrRender/HW.cpp index 21b7a0fe981..8ae0ed878f3 100644 --- a/src/Layers/xrRender/HW.cpp +++ b/src/Layers/xrRender/HW.cpp @@ -11,6 +11,7 @@ #include "HW.h" #include "xrEngine/XR_IOConsole.h" +#include "xrCore/xr_token.h" #ifndef _EDITOR void fill_vid_mode_list(CHW* _hw); diff --git a/src/Layers/xrRender/NvTriStripObjects.cpp b/src/Layers/xrRender/NvTriStripObjects.cpp index 12e8d5f16dd..8a83b1eb7db 100644 --- a/src/Layers/xrRender/NvTriStripObjects.cpp +++ b/src/Layers/xrRender/NvTriStripObjects.cpp @@ -429,7 +429,7 @@ bool NvStripInfo::Unique(NvFaceInfoVec& faceVec, NvFaceInfo* face) // // Builds a strip forward as far as we can go, then builds backwards, and joins the two lists // -void NvStripInfo::Build(NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& faceInfos) +void NvStripInfo::Build(NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& /*faceInfos*/) { // used in building the strips forward and backward static WordVec scratchIndices; @@ -606,7 +606,7 @@ void NvStripifier::CommitStrips(NvStripInfoVec& allStrips, const NvStripInfoVec& // Finds the next face to start the next strip on. // bool NvStripifier::FindTraversal( - NvFaceInfoVec& faceInfos, NvEdgeInfoVec& edgeInfos, NvStripInfo* strip, NvStripStartInfo& startInfo) + NvFaceInfoVec& /*faceInfos*/, NvEdgeInfoVec& edgeInfos, NvStripInfo* strip, NvStripStartInfo& startInfo) { // if the strip was v0->v1 on the edge, then v1 will be a vertex in the next edge. int v = (strip->m_startInfo.m_toV1 ? strip->m_startInfo.m_startEdge->m_v1 : strip->m_startInfo.m_startEdge->m_v0); @@ -1021,16 +1021,16 @@ void NvStripifier::SplitUpStripsAndOptimize( bestNumHits = -1.0f; // find best strip to add next, given the current cache - for (int i = 0; i < tempStrips2.size(); i++) + for (int i2 = 0; i2 < tempStrips2.size(); i2++) { - if (tempStrips2[i]->visited) + if (tempStrips2[i2]->visited) continue; - numHits = CalcNumHitsStrip(vcache, tempStrips2[i]); + numHits = CalcNumHitsStrip(vcache, tempStrips2[i2]); if (numHits > bestNumHits) { bestNumHits = numHits; - bestIndex = i; + bestIndex = i2; } } @@ -1276,14 +1276,14 @@ void NvStripifier::FindAllStrips( // build the first strip of the list experiments[i][0]->Build(allEdgeInfos, allFaceInfos); - int experimentId = experiments[i][0]->m_experimentId; + int experimentId2 = experiments[i][0]->m_experimentId; NvStripInfo* stripIter = experiments[i][0]; NvStripStartInfo startInfo(nullptr, nullptr, false); while (FindTraversal(allFaceInfos, allEdgeInfos, stripIter, startInfo)) { // create the _new strip info - stripIter = new NvStripInfo(startInfo, stripId++, experimentId); + stripIter = new NvStripInfo(startInfo, stripId++, experimentId2); // build the next strip stripIter->Build(allEdgeInfos, allFaceInfos); diff --git a/src/Layers/xrRender/R_Backend_DBG.cpp b/src/Layers/xrRender/R_Backend_DBG.cpp index 06a17c88368..46bbdec13e5 100644 --- a/src/Layers/xrRender/R_Backend_DBG.cpp +++ b/src/Layers/xrRender/R_Backend_DBG.cpp @@ -20,6 +20,11 @@ void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx, #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) // TODO: DX10: implement // VERIFY(!"CBackend::dbg_Draw not implemented."); + UNUSED(T); + UNUSED(pVerts); + UNUSED(vcnt); + UNUSED(pIdx); + UNUSED(pcnt); #else // USE_DX10 OnFrameEnd(); CHK_DX(HW.pDevice->SetFVF(FVF::F_L)); @@ -31,6 +36,9 @@ void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int pcnt) #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) // TODO: DX10: implement // VERIFY(!"CBackend::dbg_Draw not implemented."); + UNUSED(T); + UNUSED(pVerts); + UNUSED(pcnt); #else // USE_DX10 OnFrameEnd(); CHK_DX(HW.pDevice->SetFVF(FVF::F_L)); diff --git a/src/Layers/xrRender/R_Backend_Runtime.cpp b/src/Layers/xrRender/R_Backend_Runtime.cpp index 8c34ad923b0..5017e93f0c3 100644 --- a/src/Layers/xrRender/R_Backend_Runtime.cpp +++ b/src/Layers/xrRender/R_Backend_Runtime.cpp @@ -151,6 +151,9 @@ void CBackend::set_ClipPlanes(u32 _enable, Fplane* _planes /*=NULL */, u32 count // TODO: DX10: Implement in the corresponding vertex shaders // Use this to set up location, were shader setup code will get data // VERIFY(!"CBackend::set_ClipPlanes not implemented!"); + UNUSED(_enable); + UNUSED(_planes); + UNUSED(count); return; #else // USE_DX10 if (0 == HW.Caps.geometry.dwClipPlanes) diff --git a/src/Layers/xrRender/ResourceManager_Resources.cpp b/src/Layers/xrRender/ResourceManager_Resources.cpp index 403df8cf305..86a8cd4b333 100644 --- a/src/Layers/xrRender/ResourceManager_Resources.cpp +++ b/src/Layers/xrRender/ResourceManager_Resources.cpp @@ -366,7 +366,7 @@ void CResourceManager::_DeleteConstantTable(const R_constant_table* C) } //-------------------------------------------------------------------------------------------------------------- -CRT* CResourceManager::_CreateRT(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount) +CRT* CResourceManager::_CreateRT(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 /*SampleCount*/) { R_ASSERT(Name && Name[0] && w && h); diff --git a/src/Layers/xrRender/SH_RT.cpp b/src/Layers/xrRender/SH_RT.cpp index 08698950189..932913781b4 100644 --- a/src/Layers/xrRender/SH_RT.cpp +++ b/src/Layers/xrRender/SH_RT.cpp @@ -19,7 +19,7 @@ CRT::~CRT() RImplementation.Resources->_DeleteRT(this); } -void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount) +void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 /*SampleCount*/) { if (pSurface) return; @@ -104,7 +104,7 @@ void CRT::destroy() } void CRT::reset_begin() { destroy(); } void CRT::reset_end() { create(*cName, dwWidth, dwHeight, fmt); } -void resptrcode_crt::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount) +void resptrcode_crt::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 /*SampleCount*/) { _set(RImplementation.Resources->_CreateRT(Name, w, h, f)); } diff --git a/src/Layers/xrRender/SkeletonAnimated.cpp b/src/Layers/xrRender/SkeletonAnimated.cpp index 7369c643af2..062a4260149 100644 --- a/src/Layers/xrRender/SkeletonAnimated.cpp +++ b/src/Layers/xrRender/SkeletonAnimated.cpp @@ -7,11 +7,13 @@ #include "AnimationKeyCalculate.h" #include "SkeletonX.h" #include "xrCore/FMesh.hpp" +#include "xrCore/xr_token.h" #ifdef DEBUG #include "xrCore/dump_string.h" #endif extern int psSkeletonUpdate; using namespace animation; + ////////////////////////////////////////////////////////////////////////// // BoneInstance methods void CBlendInstance::construct() { Blend.clear(); } @@ -72,13 +74,13 @@ std::pair CKinematicsAnimated::LL_MotionDefName_dbg(MotionID ID) static LPCSTR name_bool(BOOL v) { - static xr_token token_bool[] = {{"false", 0}, {"true", 1}}; + static const xr_token token_bool[] = {{"false", 0}, {"true", 1}}; return get_token_name(token_bool, v); } static LPCSTR name_blend_type(CBlend::ECurvature blend) { - static xr_token token_blend[] = {{"eFREE_SLOT", CBlend::eFREE_SLOT}, {"eAccrue", CBlend::eAccrue}, + static const xr_token token_blend[] = {{"eFREE_SLOT", CBlend::eFREE_SLOT}, {"eAccrue", CBlend::eAccrue}, {"eFalloff", CBlend::eFalloff}, {"eFORCEDWORD", CBlend::eFORCEDWORD}}; return get_token_name(token_blend, blend); } diff --git a/src/Layers/xrRender/SkeletonX.cpp b/src/Layers/xrRender/SkeletonX.cpp index 55e69f6b32f..c54f80ef317 100644 --- a/src/Layers/xrRender/SkeletonX.cpp +++ b/src/Layers/xrRender/SkeletonX.cpp @@ -679,7 +679,7 @@ void CSkeletonX::_FillVerticesSoft4W(const Fmatrix& view, CSkeletonWallmark& wm, } #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) -void CSkeletonX::_DuplicateIndices(const char* N, IReader* data) +void CSkeletonX::_DuplicateIndices(const char* /*N*/, IReader* data) { // We will have trouble with container since don't know were to take readable indices VERIFY(!data->find_chunk(OGF_ICONTAINER)); diff --git a/src/Layers/xrRender/blenders/Blender_Recorder.cpp b/src/Layers/xrRender/blenders/Blender_Recorder.cpp index c7eb24bc9fa..bb47d4bb6cd 100644 --- a/src/Layers/xrRender/blenders/Blender_Recorder.cpp +++ b/src/Layers/xrRender/blenders/Blender_Recorder.cpp @@ -287,6 +287,9 @@ void CBlender_Compile::StageSET_XForm(u32 tf, u32 tc) #ifdef _EDITOR RS.SetTSS(Stage(), D3DTSS_TEXTURETRANSFORMFLAGS, tf); RS.SetTSS(Stage(), D3DTSS_TEXCOORDINDEX, tc); +#else + UNUSED(tf); + UNUSED(tc); #endif } void CBlender_Compile::StageSET_Color(u32 a1, u32 op, u32 a2) { RS.SetColor(Stage(), a1, op, a2); } diff --git a/src/Layers/xrRender/dxDebugRender.cpp b/src/Layers/xrRender/dxDebugRender.cpp index 465349dd3a8..cc605a75fea 100644 --- a/src/Layers/xrRender/dxDebugRender.cpp +++ b/src/Layers/xrRender/dxDebugRender.cpp @@ -95,6 +95,7 @@ void dxDebugRender::SetAmbient(u32 colour) #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) // TODO: DX10: Check if need this for DX10 VERIFY(!"Not implemented for DX10"); + UNUSED(colour); #else // USE_DX10 CHK_DX(HW.pDevice->SetRenderState(D3DRS_AMBIENT, colour)); #endif // USE_DX10 diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index a0d90d5882a..e358137b9f0 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -103,12 +103,12 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic(dxRender_Visual* pVisual, Fvector& #if RENDER != R_R1 if (sh->flags.bEmissive) { - mapSorted_Node* N = mapHUDEmissive.insertInAnyWay(distSQ); - N->val.ssa = SSA; - N->val.pObject = RI.val_pObject; - N->val.pVisual = pVisual; - N->val.Matrix = *RI.val_pTransform; - N->val.se = &*pVisual->shader->E[4]; // 4=L_special + mapSorted_Node* N2 = mapHUDEmissive.insertInAnyWay(distSQ); + N2->val.ssa = SSA; + N2->val.pObject = RI.val_pObject; + N2->val.pVisual = pVisual; + N2->val.Matrix = *RI.val_pTransform; + N2->val.se = &*pVisual->shader->E[4]; // 4=L_special } #endif // RENDER!=R_R1 return; @@ -627,10 +627,10 @@ BOOL CRender::add_Dynamic(dxRender_Visual* pVisual, u32 planes) BOOL _use_lod = FALSE; if (pV->m_lod) { - Fvector Tpos; + Fvector Tpos2; float D; - val_pTransform->transform_tiny(Tpos, pV->vis.sphere.P); - float ssa = CalcSSA(D, Tpos, pV->vis.sphere.R / 2.f); // assume dynamics never consume full sphere + val_pTransform->transform_tiny(Tpos2, pV->vis.sphere.P); + float ssa = CalcSSA(D, Tpos2, pV->vis.sphere.R / 2.f); // assume dynamics never consume full sphere if (ssa < r_ssaLOD_A) _use_lod = TRUE; } diff --git a/src/Layers/xrRender/r__screenshot.cpp b/src/Layers/xrRender/r__screenshot.cpp index 2cbc7c4b5d2..3d066cf6981 100644 --- a/src/Layers/xrRender/r__screenshot.cpp +++ b/src/Layers/xrRender/r__screenshot.cpp @@ -180,18 +180,18 @@ void CRender::ScreenshotImpl(ScreenshotMode mode, LPCSTR name, CMemoryWriter* me { // hq xr_sprintf(buf, sizeof buf, "ssq_%s_%s_(%s).tga", Core.UserName, timestamp(t_stemp), g_pGameLevel ? g_pGameLevel->name().c_str() : "mainmenu"); - ID3DBlob* saved = nullptr; + ID3DBlob* saved2 = nullptr; #ifdef USE_DX11 - CHK_DX(D3DX11SaveTextureToMemory(HW.pContext, pSrcTexture, D3DX11_IFF_BMP, &saved, 0)); + CHK_DX(D3DX11SaveTextureToMemory(HW.pContext, pSrcTexture, D3DX11_IFF_BMP, &saved2, 0)); #else - CHK_DX(D3DX10SaveTextureToMemory(pSrcTexture, D3DX10_IFF_BMP, &saved, 0)); + CHK_DX(D3DX10SaveTextureToMemory(pSrcTexture, D3DX10_IFF_BMP, &saved2, 0)); //CHK_DX(D3DXSaveSurfaceToFileInMemory(&saved, D3DXIFF_TGA, pFB, 0, 0)); #endif - IWriter* fs = FS.w_open("$screenshots$", buf); - R_ASSERT(fs); - fs->w(saved->GetBufferPointer(), (u32)saved->GetBufferSize()); - FS.w_close(fs); - _RELEASE(saved); + IWriter* fs2 = FS.w_open("$screenshots$", buf); + R_ASSERT(fs2); + fs2->w(saved2->GetBufferPointer(), (u32)saved2->GetBufferSize()); + FS.w_close(fs2); + _RELEASE(saved2); } } break; diff --git a/src/Layers/xrRender/xrRender_console.cpp b/src/Layers/xrRender/xrRender_console.cpp index ce558d38299..89985be33aa 100644 --- a/src/Layers/xrRender/xrRender_console.cpp +++ b/src/Layers/xrRender/xrRender_console.cpp @@ -2,41 +2,42 @@ #pragma hdrstop #include "xrRender_console.h" +#include "xrCore/xr_token.h" u32 ps_Preset = 2; -xr_token qpreset_token[] = {{"Minimum", 0}, {"Low", 1}, {"Default", 2}, {"High", 3}, {"Extreme", 4}, {nullptr, 0}}; +const xr_token qpreset_token[] = {{"Minimum", 0}, {"Low", 1}, {"Default", 2}, {"High", 3}, {"Extreme", 4}, {nullptr, 0}}; u32 ps_r_ssao_mode = 2; -xr_token qssao_mode_token[] = {{"disabled", 0}, {"default", 1}, {"hdao", 2}, {"hbao", 3}, {nullptr, 0}}; +const xr_token qssao_mode_token[] = {{"disabled", 0}, {"default", 1}, {"hdao", 2}, {"hbao", 3}, {nullptr, 0}}; u32 ps_r_sun_shafts = 2; -xr_token qsun_shafts_token[] = {{"st_opt_off", 0}, {"st_opt_low", 1}, {"st_opt_medium", 2}, {"st_opt_high", 3}, {nullptr, 0}}; +const xr_token qsun_shafts_token[] = {{"st_opt_off", 0}, {"st_opt_low", 1}, {"st_opt_medium", 2}, {"st_opt_high", 3}, {nullptr, 0}}; u32 ps_r_ssao = 3; -xr_token qssao_token[] = {{"st_opt_off", 0}, {"st_opt_low", 1}, {"st_opt_medium", 2}, {"st_opt_high", 3}, +const xr_token qssao_token[] = {{"st_opt_off", 0}, {"st_opt_low", 1}, {"st_opt_medium", 2}, {"st_opt_high", 3}, #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) {"st_opt_ultra", 4}, #endif {nullptr, 0}}; u32 ps_r_sun_quality = 1; // = 0; -xr_token qsun_quality_token[] = {{"st_opt_low", 0}, {"st_opt_medium", 1}, {"st_opt_high", 2}, +const xr_token qsun_quality_token[] = {{"st_opt_low", 0}, {"st_opt_medium", 1}, {"st_opt_high", 2}, #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) {"st_opt_ultra", 3}, {"st_opt_extreme", 4}, #endif // USE_DX10 {nullptr, 0}}; u32 ps_r3_msaa = 0; // = 0; -xr_token qmsaa_token[] = {{"st_opt_off", 0}, {"2x", 1}, {"4x", 2}, +const xr_token qmsaa_token[] = {{"st_opt_off", 0}, {"2x", 1}, {"4x", 2}, //{"8x", 3}, {nullptr, 0}}; u32 ps_r3_msaa_atest = 0; // = 0; -xr_token qmsaa__atest_token[] = { +const xr_token qmsaa__atest_token[] = { {"st_opt_off", 0}, {"st_opt_atest_msaa_dx10_0", 1}, {"st_opt_atest_msaa_dx10_1", 2}, {nullptr, 0}}; u32 ps_r3_minmax_sm = 3; // = 0; -xr_token qminmax_sm_token[] = {{"off", 0}, {"on", 1}, {"auto", 2}, {"autodetect", 3}, {nullptr, 0}}; +const xr_token qminmax_sm_token[] = {{"off", 0}, {"on", 1}, {"auto", 2}, {"autodetect", 3}, {nullptr, 0}}; int ps_r2_fxaa = 0; @@ -358,7 +359,7 @@ class CCC_ModelPoolStat : public IConsole_Command class CCC_SSAO_Mode : public CCC_Token { public: - CCC_SSAO_Mode(LPCSTR N, u32* V, xr_token* T) : CCC_Token(N, V, T){}; + CCC_SSAO_Mode(LPCSTR N, u32* V, const xr_token* T) : CCC_Token(N, V, T){}; virtual void Execute(LPCSTR args) { @@ -415,7 +416,7 @@ class CCC_SSAO_Mode : public CCC_Token class CCC_Preset : public CCC_Token { public: - CCC_Preset(LPCSTR N, u32* V, xr_token* T) : CCC_Token(N, V, T){}; + CCC_Preset(LPCSTR N, u32* V, const xr_token* T) : CCC_Token(N, V, T){}; virtual void Execute(LPCSTR args) { @@ -454,33 +455,26 @@ class CCC_memory_stats : public IConsole_Command Msg("memory usage mb \t \t video \t managed \t system \n"); - float vb_video = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_vertex][D3DPOOL_DEFAULT] / 1024 / 1024; - float vb_managed = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_vertex][D3DPOOL_MANAGED] / 1024 / 1024; - float vb_system = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_vertex][D3DPOOL_SYSTEMMEM] / 1024 / - 1024; + const float MiB = 1024*1024; // XXX: use it as common enum value (like in X-Ray 2.0) + const u32* mem_usage = HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_vertex]; + + float vb_video = mem_usage[D3DPOOL_DEFAULT] / MiB; + float vb_managed = mem_usage[D3DPOOL_MANAGED] / MiB; + float vb_system = mem_usage[D3DPOOL_SYSTEMMEM] / MiB; Msg("vertex buffer \t \t %f \t %f \t %f ", vb_video, vb_managed, vb_system); - float ib_video = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_index][D3DPOOL_DEFAULT] / 1024 / 1024; - float ib_managed = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_index][D3DPOOL_MANAGED] / 1024 / 1024; - float ib_system = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_index][D3DPOOL_SYSTEMMEM] / 1024 / 1024; + float ib_video = mem_usage[D3DPOOL_DEFAULT] / MiB; + float ib_managed = mem_usage[D3DPOOL_MANAGED] / MiB; + float ib_system = mem_usage[D3DPOOL_SYSTEMMEM] / MiB; Msg("index buffer \t \t %f \t %f \t %f ", ib_video, ib_managed, ib_system); - float textures_managed = (float)(m_base + m_lmaps) / 1024 / 1024; + float textures_managed = (m_base+m_lmaps)/MiB; Msg("textures \t \t %f \t %f \t %f ", 0.f, textures_managed, 0.f); - float rt_video = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_rtarget][D3DPOOL_DEFAULT] / 1024 / 1024; - float rt_managed = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_rtarget][D3DPOOL_MANAGED] / 1024 / 1024; - float rt_system = - (float)HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_rtarget][D3DPOOL_SYSTEMMEM] / 1024 / - 1024; + mem_usage = HW.stats_manager.memory_usage_summary[enum_stats_buffer_type_rtarget]; + float rt_video = mem_usage[D3DPOOL_DEFAULT] / MiB; + float rt_managed = mem_usage[D3DPOOL_MANAGED] / MiB; + float rt_system = mem_usage[D3DPOOL_SYSTEMMEM] / MiB; Msg("R-Targets \t \t %f \t %f \t %f ", rt_video, rt_managed, rt_system); Msg("\nTotal \t \t %f \t %f \t %f ", vb_video + ib_video + rt_video, diff --git a/src/Layers/xrRender/xrRender_console.h b/src/Layers/xrRender/xrRender_console.h index 3df2193b19e..1b093e64a3e 100644 --- a/src/Layers/xrRender/xrRender_console.h +++ b/src/Layers/xrRender/xrRender_console.h @@ -4,25 +4,25 @@ // Common extern ECORE_API u32 ps_r_sun_shafts; //= 0; -extern ECORE_API xr_token qsun_shafts_token[]; +extern ECORE_API const xr_token qsun_shafts_token[]; extern ECORE_API u32 ps_r_ssao; // = 0; -extern ECORE_API xr_token qssao_token[]; +extern ECORE_API const xr_token qssao_token[]; extern ECORE_API u32 ps_r_ssao_mode; -extern ECORE_API xr_token qssao_mode_token[]; +extern ECORE_API const xr_token qssao_mode_token[]; extern ECORE_API u32 ps_r_sun_quality; // = 0; -extern ECORE_API xr_token qsun_quality_token[]; +extern ECORE_API const xr_token qsun_quality_token[]; extern ECORE_API u32 ps_r3_msaa; // = 0; -extern ECORE_API xr_token qmsaa_token[]; +extern ECORE_API const xr_token qmsaa_token[]; extern ECORE_API u32 ps_r3_msaa_atest; //= 0; -extern ECORE_API xr_token qmsaa__atest_token[]; +extern ECORE_API const xr_token qmsaa__atest_token[]; extern ECORE_API u32 ps_r3_minmax_sm; // = 0; -extern ECORE_API xr_token qminmax_sm_token[]; +extern ECORE_API const xr_token qminmax_sm_token[]; extern ECORE_API int ps_r2_fxaa; diff --git a/src/Layers/xrRenderDX10/3DFluid/dx103DFluidData.cpp b/src/Layers/xrRenderDX10/3DFluid/dx103DFluidData.cpp index 9648b1d8625..fc89e46ac52 100644 --- a/src/Layers/xrRenderDX10/3DFluid/dx103DFluidData.cpp +++ b/src/Layers/xrRenderDX10/3DFluid/dx103DFluidData.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "dx103DFluidData.h" - #include "dx103DFluidManager.h" +#include "xrCore/xr_token.h" namespace { diff --git a/src/Layers/xrRenderDX10/3DFluid/dx103DFluidManager.cpp b/src/Layers/xrRenderDX10/3DFluid/dx103DFluidManager.cpp index cdd1ff06db3..53f82c10d42 100644 --- a/src/Layers/xrRenderDX10/3DFluid/dx103DFluidManager.cpp +++ b/src/Layers/xrRenderDX10/3DFluid/dx103DFluidManager.cpp @@ -602,7 +602,7 @@ void dx103DFluidManager::ApplyExternalForces(const dx103DFluidData& FluidData, f m_pEmittersHandler->RenderVelocity(FluidData); } -void dx103DFluidManager::ComputeVelocityDivergence(float timestep) +void dx103DFluidManager::ComputeVelocityDivergence(float /*timestep*/) { PIX_EVENT(ComputeVelocityDivergence); diff --git a/src/Layers/xrRenderDX10/dx10HW.cpp b/src/Layers/xrRenderDX10/dx10HW.cpp index cd8bb4b4a62..611b20340a7 100644 --- a/src/Layers/xrRenderDX10/dx10HW.cpp +++ b/src/Layers/xrRenderDX10/dx10HW.cpp @@ -10,6 +10,7 @@ #include "Layers/xrRender/HW.h" #include "xrEngine/XR_IOConsole.h" +#include "xrCore/xr_token.h" #include "StateManager/dx10SamplerStateCache.h" #include "StateManager/dx10StateCache.h" @@ -551,7 +552,7 @@ updateWindowProps (hwnd); */ } -D3DFORMAT CHW::selectDepthStencil(D3DFORMAT fTarget) +D3DFORMAT CHW::selectDepthStencil(D3DFORMAT /*fTarget*/) { // R3 hack #pragma todo("R3 need to specify depth format") diff --git a/src/Layers/xrRenderGL/glHW.cpp b/src/Layers/xrRenderGL/glHW.cpp index e9af26afc90..f0ec09db1c6 100644 --- a/src/Layers/xrRenderGL/glHW.cpp +++ b/src/Layers/xrRenderGL/glHW.cpp @@ -7,6 +7,7 @@ #include "Layers/xrRender/HW.h" #include "xrEngine/XR_IOConsole.h" #include "Include/xrAPI/xrAPI.h" +#include "xrCore/xr_token.h" #ifndef _EDITOR void fill_vid_mode_list (CHW* _hw); @@ -289,7 +290,7 @@ void free_vid_mode_list() GEnv.vid_mode_token = NULL; } -void fill_vid_mode_list(CHW* _hw) +void fill_vid_mode_list(CHW* /*_hw*/) { if (GEnv.vid_mode_token != NULL) return; xr_vector _tmp; @@ -403,7 +404,7 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT glPopAttrib(); } -HRESULT CHW::Present(UINT SyncInterval, UINT Flags) +HRESULT CHW::Present(UINT /*SyncInterval*/, UINT /*Flags*/) { RImplementation.Target->phase_flip(); return SwapBuffers(m_hDC) ? S_OK : E_FAIL; diff --git a/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp b/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp index f1971fe5cd1..fafc6c69838 100644 --- a/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp +++ b/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp @@ -92,7 +92,7 @@ void CRenderTarget::u_setrt(u32 W, u32 H, GLuint _1, GLuint _2, GLuint _3, GLuin CHK_GL(glDrawBuffers(3, buffers)); } -void CRenderTarget::u_stencil_optimize (eStencilOptimizeMode eSOM) +void CRenderTarget::u_stencil_optimize (eStencilOptimizeMode /*eSOM*/) { // TODO: OGL: should we implement stencil optimization? VERIFY (RImplementation.o.nvstencil); @@ -456,7 +456,7 @@ CRenderTarget::CRenderTarget () if( RImplementation.o.dx10_msaa ) { static LPCSTR SampleDefs[] = { "0","1","2","3","4","5","6","7" }; - CBlender_rain_msaa TempBlender[8]; + CBlender_rain_msaa TempBlender2[8]; int bound = RImplementation.o.dx10_msaa_samples; @@ -465,8 +465,8 @@ CRenderTarget::CRenderTarget () for( int i = 0; i < bound; ++i ) { - TempBlender[i].SetDefine( "ISAMPLE", SampleDefs[i] ); - s_rain_msaa[i].create( &TempBlender[i], "null"); + TempBlender2[i].SetDefine( "ISAMPLE", SampleDefs[i] ); + s_rain_msaa[i].create( &TempBlender2[i], "null"); s_accum_spot_msaa[i].create (b_accum_spot_msaa[i], "r2\\accum_spot_s", "lights\\lights_spot01"); s_accum_point_msaa[i].create (b_accum_point_msaa[i], "r2\\accum_point_s"); //s_accum_volume_msaa[i].create(b_accum_direct_volumetric_msaa[i], "lights\\lights_spot01"); diff --git a/src/Layers/xrRenderPC_R2/r2_R_lights.cpp b/src/Layers/xrRenderPC_R2/r2_R_lights.cpp index 899223d28e8..6b0ec7b6bb0 100644 --- a/src/Layers/xrRenderPC_R2/r2_R_lights.cpp +++ b/src/Layers/xrRenderPC_R2/r2_R_lights.cpp @@ -142,27 +142,27 @@ void CRender::render_lights(light_Package& LP) // if (has_point_unshadowed) -> accum point unshadowed if (!LP.v_point.empty()) { - light* L = LP.v_point.back(); + light* L2 = LP.v_point.back(); LP.v_point.pop_back(); - L->vis_update(); - if (L->vis.visible) + L2->vis_update(); + if (L2->vis.visible) { - Target->accum_point(L); - render_indirect(L); + Target->accum_point(L2); + render_indirect(L2); } } // if (has_spot_unshadowed) -> accum spot unshadowed if (!LP.v_spot.empty()) { - light* L = LP.v_spot.back(); + light* L2 = LP.v_spot.back(); LP.v_spot.pop_back(); - L->vis_update(); - if (L->vis.visible) + L2->vis_update(); + if (L2->vis.visible) { - LR.compute_xf_spot(L); - Target->accum_spot(L); - render_indirect(L); + LR.compute_xf_spot(L2); + Target->accum_spot(L2); + render_indirect(L2); } } diff --git a/src/Layers/xrRenderPC_R4/r4_rendertarget.h b/src/Layers/xrRenderPC_R4/r4_rendertarget.h index c711e00edbd..a9caa8efe10 100644 --- a/src/Layers/xrRenderPC_R4/r4_rendertarget.h +++ b/src/Layers/xrRenderPC_R4/r4_rendertarget.h @@ -346,7 +346,7 @@ class CRenderTarget : public IRender_Target dbg_lines.back().P1 = P1; dbg_lines.back().color = c; } - IC void dbg_addplane(Fplane& P0, u32 c) { dbg_planes.push_back(P0); } + IC void dbg_addplane(Fplane& P0, u32 /*c*/) { dbg_planes.push_back(P0); } #else IC void dbg_addline(Fvector& P0, Fvector& P1, u32 c) {} IC void dbg_addplane(Fplane& P0, u32 c) {} diff --git a/src/editors/ECore/Editor/ParticleEffectActions.h b/src/editors/ECore/Editor/ParticleEffectActions.h index ec75fe42018..c5b855c4e47 100644 --- a/src/editors/ECore/Editor/ParticleEffectActions.h +++ b/src/editors/ECore/Editor/ParticleEffectActions.h @@ -1,7 +1,15 @@ //--------------------------------------------------------------------------- +#pragma once #ifndef ParticleEffectActionsH #define ParticleEffectActionsH +struct xr_token2 +{ + pcstr name; + pcstr info; + int id; +}; + struct PBool { BOOL val; @@ -426,7 +434,7 @@ struct EPATurbulence : public EParticleAction virtual void Render(const Fmatrix& parent); }; -extern xr_token2 actions_token[]; +extern const xr_token2 actions_token[]; typedef EParticleAction* (*_CreateEAction)(PAPI::PActionEnum type); extern ECORE_API _CreateEAction pCreateEAction; diff --git a/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp b/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp index 97846b48dfd..3d3d2e5d448 100644 --- a/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp +++ b/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp @@ -11,7 +11,7 @@ using namespace PAPI; #define PARTICLE_ACTION_VERSION 0x0001 //--------------------------------------------------------------------------- -xr_token2 actions_token[] = {{"Avoid", "Steer particles away from a domain of space.", PAAvoidID}, +const xr_token2 actions_token[] = {{"Avoid", "Steer particles away from a domain of space.", PAAvoidID}, {"Bounce", "Bounce particles off a domain of space.", PABounceID}, {"Copy VertexB", "Set the secondary position from current position.", PACopyVertexBID}, {"Damping", "Simulate air by slowing down particle velocities.", PADampingID}, diff --git a/src/utils/xrLC_Light/ETextureParams.cpp b/src/utils/xrLC_Light/ETextureParams.cpp index 6f2d114750b..01f26bfd588 100644 --- a/src/utils/xrLC_Light/ETextureParams.cpp +++ b/src/utils/xrLC_Light/ETextureParams.cpp @@ -2,8 +2,9 @@ #pragma hdrstop #include "ETextureParams.h" +#include "xrCore/xr_token.h" -xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, +const xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, {"Point", STextureParams::kMIPFilterPoint}, {"Box", STextureParams::kMIPFilterBox}, {"Triangle", STextureParams::kMIPFilterTriangle}, {"Quadratic", STextureParams::kMIPFilterQuadratic}, @@ -17,21 +18,21 @@ xr_token tparam_token[] = {{"Advanced", STextureParams::kMIPFilterAdvanced}, {"Hanning", STextureParams::kMIPFilterHanning}, {"Hamming", STextureParams::kMIPFilterHamming}, {"Blackman", STextureParams::kMIPFilterBlackman}, {"Kaiser", STextureParams::kMIPFilterKaiser}, {nullptr, 0}}; -xr_token ttype_token[] = {{"2D Texture", STextureParams::ttImage}, {"Cube Map", STextureParams::ttCubeMap}, +const xr_token ttype_token[] = {{"2D Texture", STextureParams::ttImage}, {"Cube Map", STextureParams::ttCubeMap}, {"Bump Map", STextureParams::ttBumpMap}, {"Normal Map", STextureParams::ttNormalMap}, {"Terrain", STextureParams::ttTerrain}, {nullptr, 0}}; -xr_token tfmt_token[] = {{"DXT1", STextureParams::tfDXT1}, {"DXT1 Alpha", STextureParams::tfADXT1}, +const xr_token tfmt_token[] = {{"DXT1", STextureParams::tfDXT1}, {"DXT1 Alpha", STextureParams::tfADXT1}, {"DXT3", STextureParams::tfDXT3}, {"DXT5", STextureParams::tfDXT5}, {"16 bit (1:5:5:5)", STextureParams::tf1555}, {"16 bit (5:6:5)", STextureParams::tf565}, {"32 bit (8:8:8:8)", STextureParams::tfRGBA}, {"8 bit (alpha)", STextureParams::tfA8}, {"8 bit (luminance)", STextureParams::tfL8}, {"16 bit (alpha:luminance)", STextureParams::tfA8L8}, {nullptr, 0}}; -xr_token tmtl_token[] = {{"OrenNayar <-> Blin", STextureParams::tmOrenNayar_Blin}, +const xr_token tmtl_token[] = {{"OrenNayar <-> Blin", STextureParams::tmOrenNayar_Blin}, {"Blin <-> Phong", STextureParams::tmBlin_Phong}, {"Phong <-> Metal", STextureParams::tmPhong_Metal}, {"Metal <-> OrenNayar", STextureParams::tmMetal_OrenNayar}, {nullptr, 0}}; -xr_token tbmode_token[] = {{"None", STextureParams::tbmNone}, {"Use", STextureParams::tbmUse}, +const xr_token tbmode_token[] = {{"None", STextureParams::tbmNone}, {"Use", STextureParams::tbmUse}, {"Use parallax", STextureParams::tbmUseParallax}, {nullptr, 0}}; void STextureParams::Load(IReader& F) diff --git a/src/utils/xrLC_Light/ETextureParams.h b/src/utils/xrLC_Light/ETextureParams.h index 2e8aa9001b4..da649414e09 100644 --- a/src/utils/xrLC_Light/ETextureParams.h +++ b/src/utils/xrLC_Light/ETextureParams.h @@ -180,9 +180,9 @@ struct /*ECORE_API*/ STextureParams #pragma pack(pop) struct xr_token; -extern xr_token tparam_token[]; -extern xr_token tfmt_token[]; -extern xr_token ttype_token[]; +extern const xr_token tparam_token[]; +extern const xr_token tfmt_token[]; +extern const xr_token ttype_token[]; //---------------------------------------------------- #define THM_CHUNK_VERSION 0x0810 diff --git a/src/xrCore/_std_extensions.h b/src/xrCore/_std_extensions.h index f297e58ef01..38f5fc15648 100644 --- a/src/xrCore/_std_extensions.h +++ b/src/xrCore/_std_extensions.h @@ -6,6 +6,7 @@ #include #include #include "xrCommon/math_funcs_inline.h" +//#include "xr_token.h" #ifdef abs #undef abs @@ -57,39 +58,6 @@ IC int xr_sprintf(char* dest, size_t sizeOfBuffer, const char* format, ...) } #endif // _EDITOR -// token type definition -struct XRCORE_API xr_token -{ - xr_token(): name(nullptr), id(0) {} - xr_token(const pcstr _name, const int _id) : name(_name), id(_id) {} - - pcstr name; - int id; -}; - -IC LPCSTR get_token_name(const xr_token* tokens, int key) -{ - for (int k = 0; tokens[k].name; k++) - if (key == tokens[k].id) - return tokens[k].name; - return ""; -} - -IC int get_token_id(const xr_token* tokens, LPCSTR key) -{ - for (int k = 0; tokens[k].name; k++) - if (xr_stricmp(tokens[k].name, key) == 0) - return tokens[k].id; - return -1; -} - -struct XRCORE_API xr_token2 -{ - LPCSTR name; - LPCSTR info; - int id; -}; - // generic template IC T _min(T a, T b) diff --git a/src/xrCore/xrCore.vcxproj b/src/xrCore/xrCore.vcxproj index 741e6981327..a8c0ddf1009 100644 --- a/src/xrCore/xrCore.vcxproj +++ b/src/xrCore/xrCore.vcxproj @@ -250,6 +250,7 @@ + @@ -364,6 +365,7 @@ + diff --git a/src/xrCore/xrCore.vcxproj.filters b/src/xrCore/xrCore.vcxproj.filters index 7d79f847a2b..ead101cb355 100644 --- a/src/xrCore/xrCore.vcxproj.filters +++ b/src/xrCore/xrCore.vcxproj.filters @@ -339,6 +339,9 @@ Threading + + Math\Extensions + @@ -734,6 +737,9 @@ Kernel + + Math\Extensions + diff --git a/src/xrCore/xr_ini.cpp b/src/xrCore/xr_ini.cpp index be252db2d6f..891c269c875 100644 --- a/src/xrCore/xr_ini.cpp +++ b/src/xrCore/xr_ini.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "FileSystem.h" +#include "xrCore/xr_token.h" XRCORE_API CInifile const* pSettings = nullptr; XRCORE_API CInifile const* pSettingsAuth = nullptr; diff --git a/src/xrCore/xr_token.cpp b/src/xrCore/xr_token.cpp new file mode 100644 index 00000000000..c40221d43db --- /dev/null +++ b/src/xrCore/xr_token.cpp @@ -0,0 +1,18 @@ +#include "stdafx.h" +#include "xr_token.h" + +pcstr get_token_name(const xr_token* tokens, int key) +{ + for (int k = 0; tokens[k].name; k++) + if (key == tokens[k].id) + return tokens[k].name; + return ""; +} + +int get_token_id(const xr_token* tokens, pcstr key) +{ + for (int k = 0; tokens[k].name; k++) + if (xr_stricmp(tokens[k].name, key) == 0) + return tokens[k].id; + return -1; +} \ No newline at end of file diff --git a/src/xrCore/xr_token.h b/src/xrCore/xr_token.h new file mode 100644 index 00000000000..d514f7b7516 --- /dev/null +++ b/src/xrCore/xr_token.h @@ -0,0 +1,13 @@ +#pragma once + +struct XRCORE_API xr_token +{ + xr_token(): name(nullptr), id(-1) {} + xr_token(const pcstr _name, const int _id) : name(_name), id(_id) {} + + pcstr name; + int id; +}; + +XRCORE_API pcstr get_token_name(const xr_token* tokens, int key); +XRCORE_API int get_token_id(const xr_token* tokens, pcstr key); diff --git a/src/xrCore/xr_trims.cpp b/src/xrCore/xr_trims.cpp index 392742a28e0..c16b91a623d 100644 --- a/src/xrCore/xr_trims.cpp +++ b/src/xrCore/xr_trims.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #pragma hdrstop +#include "xrCore/xr_token.h" LPSTR _TrimLeft(LPSTR str) { diff --git a/src/xrEngine/EngineAPI.cpp b/src/xrEngine/EngineAPI.cpp index 8ddaff1a847..896591590ec 100644 --- a/src/xrEngine/EngineAPI.cpp +++ b/src/xrEngine/EngineAPI.cpp @@ -7,6 +7,7 @@ #include "XR_IOConsole.h" #include "xrCore/ModuleLookup.hpp" +#include "xrCore/xr_token.h" extern xr_vector vid_quality_token; diff --git a/src/xrEngine/IPhysicsShell.h b/src/xrEngine/IPhysicsShell.h index f2942835ab7..6b5ee046993 100644 --- a/src/xrEngine/IPhysicsShell.h +++ b/src/xrEngine/IPhysicsShell.h @@ -1,6 +1,11 @@ -#ifndef __IPHYSICSSHELL_H__ -#define __IPHYSICSSHELL_H__ #pragma once +#include "xrCore/_types.h" + +// fwd. decl. +template struct _vector3; +using Fvector = _vector3; +template struct _matrix; +using Fmatrix = _matrix; class IPhysicsGeometry; class IPhysicsElement @@ -22,5 +27,3 @@ class IPhysicsShell virtual const IPhysicsElement& Element(u16 index) const = 0; virtual u16 get_ElementsNumber() const = 0; }; - -#endif //__IPHYSICSSHELL_H__ diff --git a/src/xrEngine/XR_IOConsole.h b/src/xrEngine/XR_IOConsole.h index 1fd2ee3b4fb..14260943616 100644 --- a/src/xrEngine/XR_IOConsole.h +++ b/src/xrEngine/XR_IOConsole.h @@ -130,7 +130,7 @@ class ENGINE_API CConsole : public pureRender, public pureFrame, public pureScre int GetInteger(LPCSTR cmd, int& min, int& max) const; LPCSTR GetString(LPCSTR cmd) const; LPCSTR GetToken(LPCSTR cmd) const; - xr_token* GetXRToken(LPCSTR cmd) const; + const xr_token* GetXRToken(LPCSTR cmd) const; Fvector GetFVector(LPCSTR cmd) const; Fvector* GetFVectorPtr(LPCSTR cmd) const; IConsole_Command* GetCommand(LPCSTR cmd) const; diff --git a/src/xrEngine/XR_IOConsole_get.cpp b/src/xrEngine/XR_IOConsole_get.cpp index a6cab915453..313f851982a 100644 --- a/src/xrEngine/XR_IOConsole_get.cpp +++ b/src/xrEngine/XR_IOConsole_get.cpp @@ -83,7 +83,7 @@ LPCSTR CConsole::GetString(LPCSTR cmd) const } LPCSTR CConsole::GetToken(LPCSTR cmd) const { return GetString(cmd); } -xr_token* CConsole::GetXRToken(LPCSTR cmd) const +const xr_token* CConsole::GetXRToken(LPCSTR cmd) const { IConsole_Command* cc = GetCommand(cmd); diff --git a/src/xrEngine/xrSASH.cpp b/src/xrEngine/xrSASH.cpp index 6e62be0c5c7..b63a7a7fae6 100644 --- a/src/xrEngine/xrSASH.cpp +++ b/src/xrEngine/xrSASH.cpp @@ -581,7 +581,7 @@ void xrSASH::DescribeOption(pcstr pszOptionName, const oaOptionDependency& Depen else if (pToken) { Option.DataType = OA_TYPE_ENUM; - xr_token* pXRToken = pToken->GetToken(); + const xr_token* pXRToken = pToken->GetToken(); while (pXRToken->name) { diff --git a/src/xrEngine/xr_ioc_cmd.cpp b/src/xrEngine/xr_ioc_cmd.cpp index 48e77aa9e52..8fa39e927a8 100644 --- a/src/xrEngine/xr_ioc_cmd.cpp +++ b/src/xrEngine/xr_ioc_cmd.cpp @@ -15,7 +15,7 @@ xr_vector vid_quality_token; -xr_token vid_bpp_token[] = {{"16", 16}, {"32", 32}, {0, 0}}; +const xr_token vid_bpp_token[] = {{"16", 16}, {"32", 32}, {0, 0}}; //----------------------------------------------------------------------- void IConsole_Command::add_to_LRU(shared_str const& arg) @@ -415,7 +415,7 @@ class CCC_VidMode : public CCC_Token } } virtual void Status(TStatus& S) { xr_sprintf(S, sizeof(S), "%dx%d", psCurrentVidMode[0], psCurrentVidMode[1]); } - virtual xr_token* GetToken() { return GEnv.vid_mode_token; } + const xr_token* GetToken() throw() override { return GEnv.vid_mode_token; } virtual void Info(TInfo& I) { xr_strcpy(I, sizeof(I), "change screen resolution WxH"); } virtual void fill_tips(vecTips& tips, u32 mode) { @@ -423,7 +423,7 @@ class CCC_VidMode : public CCC_Token Status(cur); bool res = false; - xr_token* tok = GetToken(); + const xr_token* tok = GetToken(); while (tok->name && !res) { if (!xr_strcmp(tok->name, cur)) @@ -562,7 +562,8 @@ class CCC_r2 : public CCC_Token tokens = vid_quality_token.data(); inherited::Save(F); } - virtual xr_token* GetToken() + + const xr_token* GetToken() throw() override { tokens = vid_quality_token.data(); return inherited::GetToken(); @@ -592,7 +593,7 @@ class CCC_soundDevice : public CCC_Token inherited::Status(S); } - virtual xr_token* GetToken() + const xr_token* GetToken() throw() override { tokens = snd_devices_token; return inherited::GetToken(); diff --git a/src/xrEngine/xr_ioc_cmd.h b/src/xrEngine/xr_ioc_cmd.h index b70b2057456..0348d17a8df 100644 --- a/src/xrEngine/xr_ioc_cmd.h +++ b/src/xrEngine/xr_ioc_cmd.h @@ -27,6 +27,8 @@ } #include "xrSASH.h" +#include "xrCore/xrCore_benchmark_macros.h" +#include "xrCore/xr_token.h" class ENGINE_API IConsole_Command { @@ -158,14 +160,14 @@ class ENGINE_API CCC_Token : public IConsole_Command { protected: u32* value; - xr_token* tokens; + const xr_token* tokens; public: - CCC_Token(LPCSTR N, u32* V, xr_token* T) : IConsole_Command(N), value(V), tokens(T){}; + CCC_Token(LPCSTR N, u32* V, const xr_token* T) : IConsole_Command(N), value(V), tokens(T){}; virtual void Execute(LPCSTR args) { - xr_token* tok = tokens; + const xr_token* tok = tokens; while (tok->name) { if (xr_stricmp(tok->name, args) == 0) @@ -180,7 +182,7 @@ class ENGINE_API CCC_Token : public IConsole_Command } virtual void Status(TStatus& S) { - xr_token* tok = tokens; + const xr_token* tok = tokens; while (tok->name) { if (tok->id == (int)(*value)) @@ -196,7 +198,7 @@ class ENGINE_API CCC_Token : public IConsole_Command virtual void Info(TInfo& I) { I[0] = 0; - xr_token* tok = tokens; + const xr_token* tok = tokens; while (tok->name) { if (I[0]) @@ -205,12 +207,12 @@ class ENGINE_API CCC_Token : public IConsole_Command tok++; } } - virtual xr_token* GetToken() { return tokens; } + virtual const xr_token* GetToken() { return tokens; } virtual void fill_tips(vecTips& tips, u32 /*mode*/) { TStatus str; bool res = false; - xr_token* tok = GetToken(); + const xr_token* tok = GetToken(); while (tok->name && !res) { if (tok->id == (int)(*value)) diff --git a/src/xrGame/Actor.cpp b/src/xrGame/Actor.cpp index 5f53dad1d49..bf839f6a6d5 100644 --- a/src/xrGame/Actor.cpp +++ b/src/xrGame/Actor.cpp @@ -1,10 +1,11 @@ - #include "pch_script.h" +#include "pch_script.h" #include "Actor_Flags.h" #include "hudmanager.h" -#ifdef DEBUG +#ifdef DEBUG #include "PHDebug.h" #endif // DEBUG + #include "alife_space.h" #include "hit.h" #include "PHDestroyable.h" @@ -72,6 +73,7 @@ #include "ui/UIActorMenu.h" #include "ActorHelmet.h" #include "UI/UIDragDropReferenceList.h" +#include "xrCore/xr_token.h" const u32 patch_frames = 50; const float respawn_delay = 1.f; diff --git a/src/xrGame/PHDebug.cpp b/src/xrGame/PHDebug.cpp index 854e1a9e660..19084902755 100644 --- a/src/xrGame/PHDebug.cpp +++ b/src/xrGame/PHDebug.cpp @@ -19,6 +19,7 @@ #include "Include/xrRender/KinematicsAnimated.h" #include "xrCore/Animation/Bone.hpp" #include "xrEngine/iphdebug.h" +#include "xrCore/xr_token.h" #include "ui_base.h" @@ -699,7 +700,7 @@ void PH_DBG_SetTrackObject() static LPCSTR name_bool(BOOL v) { - static xr_token token_bool[] = {{"false", 0}, {"true", 1}}; + static const xr_token token_bool[] = {{"false", 0}, {"true", 1}}; return get_token_name(token_bool, v); } diff --git a/src/xrGame/PHMovementControl.cpp b/src/xrGame/PHMovementControl.cpp index cb5ebf727f4..a2b4f579581 100644 --- a/src/xrGame/PHMovementControl.cpp +++ b/src/xrGame/PHMovementControl.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#include "phmovementcontrol.h" +#include "phmovementcontrol.h" #include "xrCDB/Intersect.hpp" #include "xrServerEntities/alife_space.h" @@ -20,6 +20,7 @@ #include "CaptureBoneCallback.h" #include "Level.h" #include "physicsshellholder.h" +#include "xrCore/xr_token.h" #ifdef DEBUG #include "phdebug.h" #endif @@ -907,7 +908,7 @@ void CPHMovementControl::Load(LPCSTR section) float cs_min = pSettings->r_float(section, "ph_crash_speed_min"); float cs_max = pSettings->r_float(section, "ph_crash_speed_max"); float mass = pSettings->r_float(section, "ph_mass"); - xr_token retrictor_types[] = { + static const xr_token retrictor_types[] = { {"actor", rtActor}, {"medium_monster", rtMonsterMedium}, {"stalker", rtStalker}, {"none", rtNone}, {0, 0}}; if (pSettings->line_exist(section, "actor_restrictor")) diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index ce53e957f20..8a1a2503ed4 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -25,6 +25,7 @@ #include "ui/UIXmlInit.h" #include "Torch.h" #include "xrNetServer/NET_Messages.h" +#include "xrCore/xr_token.h" #define WEAPON_REMOVE_TIME 60000 #define ROTATION_TIME 0.25f diff --git a/src/xrGame/ai_sounds.cpp b/src/xrGame/ai_sounds.cpp index bb57e52c337..502b022803a 100644 --- a/src/xrGame/ai_sounds.cpp +++ b/src/xrGame/ai_sounds.cpp @@ -2,8 +2,9 @@ #pragma hdrstop #include "ai_sounds.h" +#include "xrCore/xr_token.h" -xr_token anomaly_type_token[] = {{"undefined", sg_Undefined}, {"Item picking up", SOUND_TYPE_ITEM_PICKING_UP}, +const xr_token anomaly_type_token[] = {{"undefined", sg_Undefined}, {"Item picking up", SOUND_TYPE_ITEM_PICKING_UP}, {"Item dropping", SOUND_TYPE_ITEM_DROPPING}, {"Item taking", SOUND_TYPE_ITEM_TAKING}, {"Item hiding", SOUND_TYPE_ITEM_HIDING}, {"Item using", SOUND_TYPE_ITEM_USING}, {"Weapon shooting", SOUND_TYPE_WEAPON_SHOOTING}, {"Weapon empty clicking", SOUND_TYPE_WEAPON_EMPTY_CLICKING}, diff --git a/src/xrGame/console_commands_mp.cpp b/src/xrGame/console_commands_mp.cpp index 31547f9ea60..0b8c615920b 100644 --- a/src/xrGame/console_commands_mp.cpp +++ b/src/xrGame/console_commands_mp.cpp @@ -91,7 +91,7 @@ extern u32 g_sv_Client_Reconnect_Time; int g_dwEventDelay = 0; extern u32 g_sv_adm_menu_ban_time; -extern xr_token g_ban_times[]; +extern const xr_token g_ban_times[]; extern int g_sv_adm_menu_ping_limit; extern u32 g_sv_cta_dwInvincibleTime; diff --git a/src/xrGame/death_anims.cpp b/src/xrGame/death_anims.cpp index 876dd3e6dbe..87c1df925de 100644 --- a/src/xrGame/death_anims.cpp +++ b/src/xrGame/death_anims.cpp @@ -1,10 +1,8 @@ #include "stdafx.h" - #include "death_anims.h" - #include "Include/xrRender/KinematicsAnimated.h" - #include "entity_alive.h" +#include "xrCore/xr_token.h" #ifdef DEBUG BOOL death_anim_debug = FALSE; @@ -47,7 +45,7 @@ void type_motion::set_motion( IKinematicsAnimated* k, CInifile* ini, LPCSTR type anims[ u16( id_dir ) ] = new rnd_motion()->setup( k, ini->r_string( type, dir ) ); } */ -xr_token motion_dirs[] = {{"front", type_motion::front}, {"back", type_motion::back}, {"left", type_motion::left}, +extern const xr_token motion_dirs[] = {{"front", type_motion::front}, {"back", type_motion::back}, {"left", type_motion::left}, {"right", type_motion::right}, {0, 0}}; void type_motion::set_motion(IKinematicsAnimated* k, u16 id_motion, LPCSTR dir_anim) diff --git a/src/xrGame/death_anims_predicates.cpp b/src/xrGame/death_anims_predicates.cpp index 613313041d1..a2fa8d37408 100644 --- a/src/xrGame/death_anims_predicates.cpp +++ b/src/xrGame/death_anims_predicates.cpp @@ -2,16 +2,17 @@ #include "death_anims.h" -#include "actor.h" -#include "ai/stalker/ai_stalker.h" +#include "Actor.h" +#include "Ai/Stalker/ai_stalker.h" #include "stalker_movement_manager_smart_cover.h" -#include "weaponshotgun.h" -#include "explosive.h" -#include "weaponmagazined.h" +#include "WeaponShotgun.h" +#include "Explosive.h" +#include "WeaponMagazined.h" #include "CharacterPhysicsSupport.h" #include "animation_utils.h" +#include "xrCore/xr_token.h" #ifdef DEBUG -extern xr_token motion_dirs[]; +extern const xr_token motion_dirs[]; #endif Fvector& global_hit_position(Fvector& gp, CEntityAlive& ea, const SHit& H) diff --git a/src/xrGame/game_cl_single.cpp b/src/xrGame/game_cl_single.cpp index 3ca57bdf9fe..e57752dfc60 100644 --- a/src/xrGame/game_cl_single.cpp +++ b/src/xrGame/game_cl_single.cpp @@ -7,12 +7,13 @@ #include "alife_simulator.h" #include "alife_time_manager.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "xrCore/xr_token.h" using namespace luabind; ESingleGameDifficulty g_SingleGameDifficulty = egdStalker; -xr_token difficulty_type_token[] = { +extern const xr_token difficulty_type_token[] = { {"gd_novice", egdNovice}, {"gd_stalker", egdStalker}, {"gd_veteran", egdVeteran}, {"gd_master", egdMaster}, {0, 0}}; game_cl_Single::game_cl_Single() {} diff --git a/src/xrGame/game_cl_single.h b/src/xrGame/game_cl_single.h index ffa94ec5d84..593bf472601 100644 --- a/src/xrGame/game_cl_single.h +++ b/src/xrGame/game_cl_single.h @@ -34,4 +34,4 @@ enum ESingleGameDifficulty }; extern ESingleGameDifficulty g_SingleGameDifficulty; -xr_token difficulty_type_token[]; +extern const xr_token difficulty_type_token[]; diff --git a/src/xrGame/game_sv_base.cpp b/src/xrGame/game_sv_base.cpp index ba56358c223..ca0dc86256f 100644 --- a/src/xrGame/game_sv_base.cpp +++ b/src/xrGame/game_sv_base.cpp @@ -24,7 +24,7 @@ u32 g_sv_base_dwRPointFreezeTime = 0; int g_sv_base_iVotingEnabled = 0x00ff; //----------------------------------------------------------------- -xr_token round_end_result_str[] = {{"Finish", eRoundEnd_Finish}, {"Game restarted", eRoundEnd_GameRestarted}, +extern const xr_token round_end_result_str[] = {{"Finish", eRoundEnd_Finish}, {"Game restarted", eRoundEnd_GameRestarted}, {"Game restarted fast", eRoundEnd_GameRestartedFast}, {"Time limit", eRoundEnd_TimeLimit}, {"Frag limit", eRoundEnd_FragLimit}, {"Artefact limit", eRoundEnd_ArtrefactLimit}, {"Unknown", eRoundEnd_Force}, {0, 0}}; diff --git a/src/xrGame/game_sv_mp.cpp b/src/xrGame/game_sv_mp.cpp index 32981f355ac..0982a849680 100644 --- a/src/xrGame/game_sv_mp.cpp +++ b/src/xrGame/game_sv_mp.cpp @@ -20,6 +20,7 @@ #include "game_cl_base_weapon_usage_statistic.h" #include "xrGameSpyServer.h" #include "xrNetServer/NET_Messages.h" +#include "xrCore/xr_token.h" #include "game_sv_mp_vote_flags.h" #include "player_name_modifyer.h" @@ -43,7 +44,7 @@ u32 g_sv_adm_menu_ban_time = 1; int g_sv_adm_menu_ping_limit = 25; //----------------------------------------------------------------- -extern xr_token round_end_result_str[]; +extern const xr_token round_end_result_str[]; #include "ui\UIBuyWndShared.h" diff --git a/src/xrGame/ui/UIChangeMap.cpp b/src/xrGame/ui/UIChangeMap.cpp index 5e217a8b85d..699a9022d7b 100644 --- a/src/xrGame/ui/UIChangeMap.cpp +++ b/src/xrGame/ui/UIChangeMap.cpp @@ -13,8 +13,6 @@ #include "UIGameCustom.h" #include "UIDialogHolder.h" -xr_token game_types[]; - CUIChangeMap::CUIChangeMap() { m_prev_upd_time = 0; diff --git a/src/xrGame/ui/UIComboBox.cpp b/src/xrGame/ui/UIComboBox.cpp index 3afe5339d00..705e8676688 100644 --- a/src/xrGame/ui/UIComboBox.cpp +++ b/src/xrGame/ui/UIComboBox.cpp @@ -4,6 +4,7 @@ #include "UIScrollBar.h" #include "uilistboxitem.h" #include "string_table.h" +#include "xrCore/xr_token.h" #define CB_HEIGHT 20.0f @@ -120,7 +121,7 @@ void CUIComboBox::SetCurrentOptValue() CUIOptionsItem::SetCurrentOptValue(); m_list_box.Clear(); - xr_token* tok = GetOptToken(); + const xr_token* tok = GetOptToken(); while (tok->name) { @@ -159,7 +160,7 @@ void CUIComboBox::UndoOptValue() void CUIComboBox::SaveOptValue() { CUIOptionsItem::SaveOptValue(); - xr_token* tok = GetOptToken(); + const xr_token* tok = GetOptToken(); if (tok) { LPCSTR cur_val = get_token_name(tok, m_itoken_id); diff --git a/src/xrGame/ui/UIMPPlayersAdm.cpp b/src/xrGame/ui/UIMPPlayersAdm.cpp index c64dcc15b3e..cd25d3a65d0 100644 --- a/src/xrGame/ui/UIMPPlayersAdm.cpp +++ b/src/xrGame/ui/UIMPPlayersAdm.cpp @@ -13,9 +13,10 @@ #include "game_cl_mp.h" #include "xrEngine/xr_ioconsole.h" #include "string_table.h" +#include "xrCore/xr_token.h" extern int g_sv_adm_menu_ping_limit; -xr_token g_ban_times[] = {{"ui_mp_am_10_minutes", 600}, {"ui_mp_am_30_minutes", 1800}, {"ui_mp_am_1_hour", 3600}, +extern const xr_token g_ban_times[] = {{"ui_mp_am_10_minutes", 600}, {"ui_mp_am_30_minutes", 1800}, {"ui_mp_am_1_hour", 3600}, {"ui_mp_am_6_hours", 21600}, {"ui_mp_am_1_day", 86400}, {"ui_mp_am_1_week", 604800}, {"ui_mp_am_1_month", 2592000}, {"ui_mp_am_3_monthes", 7776000}, {"ui_mp_am_forever", 999999999}, {0, 0}}; diff --git a/src/xrGame/ui/UIMapList.cpp b/src/xrGame/ui/UIMapList.cpp index 01749975920..a27b82fe6a5 100644 --- a/src/xrGame/ui/UIMapList.cpp +++ b/src/xrGame/ui/UIMapList.cpp @@ -14,6 +14,7 @@ #include "Common/object_broker.h" #include "game_base.h" #include "ui/UICDkey.h" +#include "xrCore/xr_token.h" extern ENGINE_API string512 g_sLaunchOnExit_app; extern ENGINE_API string512 g_sLaunchOnExit_params; diff --git a/src/xrGame/ui/UIOptionsItem.cpp b/src/xrGame/ui/UIOptionsItem.cpp index 0715f360e00..7b197e473fa 100644 --- a/src/xrGame/ui/UIOptionsItem.cpp +++ b/src/xrGame/ui/UIOptionsItem.cpp @@ -65,7 +65,7 @@ void CUIOptionsItem::SaveOptBoolValue(bool val) } LPCSTR CUIOptionsItem::GetOptTokenValue() { return Console->GetToken(m_entry.c_str()); } -xr_token* CUIOptionsItem::GetOptToken() { return Console->GetXRToken(m_entry.c_str()); } +const xr_token* CUIOptionsItem::GetOptToken() { return Console->GetXRToken(m_entry.c_str()); } void CUIOptionsItem::SaveOptValue() { if (!IsChangedOptValue()) diff --git a/src/xrGame/ui/UIOptionsItem.h b/src/xrGame/ui/UIOptionsItem.h index bf5eed5622e..ce6141efac3 100644 --- a/src/xrGame/ui/UIOptionsItem.h +++ b/src/xrGame/ui/UIOptionsItem.h @@ -45,7 +45,7 @@ class CUIOptionsItem void SaveOptBoolValue(bool val); // token LPCSTR GetOptTokenValue(); - xr_token* GetOptToken(); + const xr_token* GetOptToken(); shared_str m_entry; ESystemDepends m_dep; diff --git a/src/xrGame/ui/UISpinText.cpp b/src/xrGame/ui/UISpinText.cpp index 08835f2eb5a..a296c433f76 100644 --- a/src/xrGame/ui/UISpinText.cpp +++ b/src/xrGame/ui/UISpinText.cpp @@ -2,6 +2,7 @@ #include "UISpinText.h" #include "UILines.h" #include "string_table.h" +#include "xrCore/xr_token.h" CUISpinText::CUISpinText() : m_curItem(-1) {} void CUISpinText::AddItem_(const char* item, int id) @@ -35,7 +36,7 @@ void CUISpinText::SetCurrentOptValue() { CUIOptionsItem::SetCurrentOptValue(); - xr_token* tok = GetOptToken(); + const xr_token* tok = GetOptToken(); while (tok->name) { diff --git a/src/xrPhysics/PHShellSplitter.cpp b/src/xrPhysics/PHShellSplitter.cpp index 48fbb2d03aa..f0c1125f69b 100644 --- a/src/xrPhysics/PHShellSplitter.cpp +++ b/src/xrPhysics/PHShellSplitter.cpp @@ -404,8 +404,8 @@ void CPHShellSplitterHolder::SplitElement(u16 aspl, PHSHELL_PAIR_VECTOR& out_she CPhysicsElement* ee = out_shels.back().first->get_ElementByStoreOrder(0); VERIFY(ee); VERIFY(smart_cast(ee)); - CPHElement* e = static_cast(ee); - VERIFY(dBodyStateValide(e->get_body())); + CPHElement* e2 = static_cast(ee); + VERIFY(dBodyStateValide(e2->get_body())); } if (!E->FracturesHolder()) diff --git a/src/xrServerEntities/ai_sounds.h b/src/xrServerEntities/ai_sounds.h index 42d8a82b28e..39d8a9a055c 100644 --- a/src/xrServerEntities/ai_sounds.h +++ b/src/xrServerEntities/ai_sounds.h @@ -81,6 +81,6 @@ enum ESoundTypes #define CROUCH_SOUND_FACTOR .3f #define ACCELERATED_SOUND_FACTOR .5f -extern xr_token anomaly_type_token[]; +extern const xr_token anomaly_type_token[]; #endif diff --git a/src/xrServerEntities/alife_space.cpp b/src/xrServerEntities/alife_space.cpp index 4e153f3abdc..898abcde096 100644 --- a/src/xrServerEntities/alife_space.cpp +++ b/src/xrServerEntities/alife_space.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "alife_space.h" +#include "xrCore/xr_token.h" namespace ALife { diff --git a/src/xrServerEntities/gametype_chooser.cpp b/src/xrServerEntities/gametype_chooser.cpp index ea8a42b190b..966680e2b60 100644 --- a/src/xrServerEntities/gametype_chooser.cpp +++ b/src/xrServerEntities/gametype_chooser.cpp @@ -3,6 +3,8 @@ #include "gametype_chooser.h" #include "xrServer_Objects_Abstract.h" +#include "xrCore/xr_token.h" + // old enum ERPGameType { // [0..255] @@ -14,7 +16,7 @@ enum ERPGameType rpgtGameCount, }; -xr_token rpoint_game_type[] = {{"Any game", rpgtGameAny}, {"Deathmatch", rpgtGameDeathmatch}, +const xr_token rpoint_game_type[] = {{"Any game", rpgtGameAny}, {"Deathmatch", rpgtGameDeathmatch}, {"TeamDeathmatch", rpgtGameTeamDeathmatch}, {"ArtefactHunt", rpgtGameArtefactHunt}, {"CaptureTheArtefact", rpgtGameCaptureTheArtefact}, {nullptr, 0}}; diff --git a/src/xrServerEntities/script_token_list.h b/src/xrServerEntities/script_token_list.h index 4cd2175f7f7..e064403112c 100644 --- a/src/xrServerEntities/script_token_list.h +++ b/src/xrServerEntities/script_token_list.h @@ -7,6 +7,9 @@ //////////////////////////////////////////////////////////////////////////// #pragma once +#include "xrCommon/xr_vector.h" +#include "xrCore/xrstring.h" +#include "xrCore/xr_token.h" class CScriptTokenList { @@ -18,37 +21,37 @@ class CScriptTokenList protected: struct CTokenPredicateName { - LPCSTR m_name; + pcstr m_name; - IC CTokenPredicateName(LPCSTR name) { m_name = name; } - IC bool operator()(const xr_token& token) const { return (token.name && !xr_strcmp(token.name, m_name)); } + CTokenPredicateName(pcstr name) throw() : m_name(name) {} + IC bool operator()(const xr_token& token) const throw() { return token.name && !xr_strcmp(token.name, m_name); } }; struct CTokenPredicateID { int m_id; - IC CTokenPredicateID(int id) { m_id = id; } - IC bool operator()(const xr_token& token) const { return (token.name && (token.id == m_id)); } + CTokenPredicateID(int id) throw() : m_id(id) {} + IC bool operator()(const xr_token& token) const { return token.name && (token.id == m_id); } }; protected: TOKEN_LIST m_token_list; protected: - IC iterator token(LPCSTR name); + IC iterator token(pcstr name); IC iterator token(int id); public: IC CScriptTokenList(); ~CScriptTokenList(); - IC void add(LPCSTR name, int id); - IC void remove(LPCSTR name); + IC void add(pcstr name, int id); + IC void remove(pcstr name); IC void clear(); - IC int id(LPCSTR name); - IC LPCSTR name(int id); - IC const TOKEN_LIST& tokens() const; - IC TOKEN_LIST& tokens(); + IC int id(pcstr name); + IC pcstr name(int id); + const TOKEN_LIST& tokens() const throw() { return m_token_list; } + TOKEN_LIST& tokens() throw() { return m_token_list; } }; #include "script_token_list_inline.h" diff --git a/src/xrServerEntities/script_token_list_inline.h b/src/xrServerEntities/script_token_list_inline.h index b27463fa4a9..a906ee5fa01 100644 --- a/src/xrServerEntities/script_token_list_inline.h +++ b/src/xrServerEntities/script_token_list_inline.h @@ -7,9 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #pragma once +#include IC CScriptTokenList::CScriptTokenList() { clear(); } -IC void CScriptTokenList::add(LPCSTR name, int id) +IC void CScriptTokenList::add(pcstr name, int id) { VERIFY((token(name) == m_token_list.end()) && (token(id) == m_token_list.end())); xr_token temp; @@ -22,7 +23,7 @@ IC void CScriptTokenList::add(LPCSTR name, int id) m_token_list.push_back(temp); } -IC void CScriptTokenList::remove(LPCSTR name) +IC void CScriptTokenList::remove(pcstr name) { iterator I = token(name); VERIFY(I != m_token_list.end()); @@ -37,21 +38,21 @@ IC void CScriptTokenList::clear() m_token_list.push_back(temp); } -IC int CScriptTokenList::id(LPCSTR name) +IC int CScriptTokenList::id(pcstr name) { iterator I = token(name); VERIFY(I != m_token_list.end()); return ((*I).id); } -IC LPCSTR CScriptTokenList::name(int id) +IC pcstr CScriptTokenList::name(int id) { iterator I = token(id); VERIFY(I != m_token_list.end()); return ((*I).name); } -IC CScriptTokenList::iterator CScriptTokenList::token(LPCSTR name) +IC CScriptTokenList::iterator CScriptTokenList::token(pcstr name) { return (std::find_if(m_token_list.begin(), m_token_list.end(), CTokenPredicateName(name))); } @@ -60,6 +61,3 @@ IC CScriptTokenList::iterator CScriptTokenList::token(int id) { return (std::find_if(m_token_list.begin(), m_token_list.end(), CTokenPredicateID(id))); } - -IC const CScriptTokenList::TOKEN_LIST& CScriptTokenList::tokens() const { return (m_token_list); } -IC CScriptTokenList::TOKEN_LIST& CScriptTokenList::tokens() { return (m_token_list); } diff --git a/src/xrServerEntities/xrEProps.h b/src/xrServerEntities/xrEProps.h index 2cc257bef93..4532941e7b0 100644 --- a/src/xrServerEntities/xrEProps.h +++ b/src/xrServerEntities/xrEProps.h @@ -1,3 +1,4 @@ +#pragma once #ifndef xrEPropsH #define xrEPropsH @@ -116,7 +117,7 @@ class XR_EPROPS_API IPropHelper PropItemVec& items, shared_str key, Flags16* val, u16 mask, LPCSTR c0 = nullptr, LPCSTR c1 = nullptr, u32 flags = 0) = 0; virtual Flag32Value* __stdcall CreateFlag32( PropItemVec& items, shared_str key, Flags32* val, u32 mask, LPCSTR c0 = nullptr, LPCSTR c1 = nullptr, u32 flags = 0) = 0; - virtual Token8Value* __stdcall CreateToken8(PropItemVec& items, shared_str key, u8* val, xr_token* token) = 0; + virtual Token8Value* __stdcall CreateToken8(PropItemVec& items, shared_str key, u8* val, const xr_token* token) = 0; virtual Token16Value* __stdcall CreateToken16(PropItemVec& items, shared_str key, u16* val, xr_token* token) = 0; virtual Token32Value* __stdcall CreateToken32(PropItemVec& items, shared_str key, u32* val, xr_token* token) = 0; virtual RToken8Value* __stdcall CreateRToken8( diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index 0f872102aeb..4eb6e5fb543 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -12,6 +12,7 @@ #include "game_base_space.h" #include "script_value_container_impl.h" #include "clsid_game.h" +#include "xrCore/xr_token.h" #pragma warning(push) #pragma warning(disable : 4995) @@ -375,7 +376,7 @@ LPCSTR CSE_Abstract::name_replace() const { return (s_name_replace); } Fvector& CSE_Abstract::position() { return (o_Position); } Fvector& CSE_Abstract::angle() { return (o_Angle); } Flags16& CSE_Abstract::flags() { return (s_flags); } -xr_token game_types[] = {{"any_game", eGameIDNoGame}, {"single", eGameIDSingle}, {"deathmatch", eGameIDDeathmatch}, +const xr_token game_types[] = {{"any_game", eGameIDNoGame}, {"single", eGameIDSingle}, {"deathmatch", eGameIDDeathmatch}, {"team_deathmatch", eGameIDTeamDeathmatch}, {"artefacthunt", eGameIDArtefactHunt}, {"capture_the_artefact", eGameIDCaptureTheArtefact}, // eGameIDDominationZone diff --git a/src/xrServerEntities/xrServer_Objects_ALife.cpp b/src/xrServerEntities/xrServer_Objects_ALife.cpp index ddaa2d45c2d..e62146eb96c 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife.cpp @@ -12,6 +12,7 @@ #include "game_base_space.h" #include "Common/object_broker.h" #include "restriction_space.h" +#include "xrCore/xr_token.h" #ifdef _MSC_VER #pragma warning(disable: 4100) // unreferenced formal parameter @@ -745,7 +746,7 @@ void CSE_ALifeSpaceRestrictor::STATE_Write(NET_Packet& tNetPacket) void CSE_ALifeSpaceRestrictor::UPDATE_Read(NET_Packet& tNetPacket) { inherited1::UPDATE_Read(tNetPacket); } void CSE_ALifeSpaceRestrictor::UPDATE_Write(NET_Packet& tNetPacket) { inherited1::UPDATE_Write(tNetPacket); } -xr_token defaul_retrictor_types[] = {{"NOT A restrictor", RestrictionSpace::eRestrictorTypeNone}, +const xr_token defaul_retrictor_types[] = {{"NOT A restrictor", RestrictionSpace::eRestrictorTypeNone}, {"NONE default restrictor", RestrictionSpace::eDefaultRestrictorTypeNone}, {"OUT default restrictor", RestrictionSpace::eDefaultRestrictorTypeOut}, {"IN default restrictor", RestrictionSpace::eDefaultRestrictorTypeIn}, {nullptr, 0}}; diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp index 5bdb335b313..ecba4f79c99 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp @@ -49,14 +49,14 @@ void setup_location_types_section(GameGraph::TERRAIN_VECTOR& m_vertex_types, CIn for (; I != E; ++I) { pcstr S = *(*I).first; - string16 I; + string16 I2; u32 N = _GetItemCount(S); if (N != GameGraph::LOCATION_TYPE_COUNT) continue; for (u32 j = 0; j < GameGraph::LOCATION_TYPE_COUNT; ++j) - terrain_mask.tMask[j] = GameGraph::_LOCATION_ID(atoi(_GetItem(S, j, I))); + terrain_mask.tMask[j] = GameGraph::_LOCATION_ID(atoi(_GetItem(S, j, I2))); m_vertex_types.push_back(terrain_mask); } @@ -545,12 +545,12 @@ void CSE_ALifeTrader::STATE_Read(NET_Packet& tNetPacket, u16 size) if ((m_wVersion > 29) && (m_wVersion < 118)) { u32 l_dwCount = tNetPacket.r_u32(); + shared_str temp; for (int i = 0; i < (int)l_dwCount; ++i) { - shared_str temp; tNetPacket.r_stringZ(temp); tNetPacket.r_u32(); - for (int i = 0, n = tNetPacket.r_u32(); i < n; ++i) + for (int i2 = 0, n = tNetPacket.r_u32(); i2 < n; ++i2) { tNetPacket.r_stringZ(temp); tNetPacket.r_u32(); diff --git a/src/xrSound/OpenALDeviceList.cpp b/src/xrSound/OpenALDeviceList.cpp index 8b0b6da1057..89d3e13df36 100644 --- a/src/xrSound/OpenALDeviceList.cpp +++ b/src/xrSound/OpenALDeviceList.cpp @@ -24,6 +24,7 @@ #include "stdafx.h" #include "OpenALDeviceList.h" +#include "xrCore/xr_token.h" #pragma warning(push) #pragma warning(disable : 4995)