From 913f619b590a1e3b57272acd32ca08173f7d2ae6 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 17:18:28 +0200 Subject: [PATCH 01/11] Fix TBB and Clang compiler issue --- cmake/FindTBB.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake index 82b1520e5ee..aad0d024088 100644 --- a/cmake/FindTBB.cmake +++ b/cmake/FindTBB.cmake @@ -98,6 +98,13 @@ if (UNIX) # has itanium/* set(_TBB_COMPILER ${TBB_COMPILER}) set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE}) + + # Fix for clang compiler + # https://www.threadingbuildingblocks.org/docs/help/reference/appendices/known_issues/linux_os.html + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + string(REPLACE "." "0" TBB_USE_GLIBCXX_VERSION ${CMAKE_CXX_COMPILER_VERSION}) + add_definitions(-DTBB_USE_GLIBCXX_VERSION=${TBB_USE_GLIBCXX_VERSION}) + endif() endif (APPLE) endif (UNIX) From d57d607fe57ea373961f48b7d59b046085a32d4d Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 17:24:24 +0200 Subject: [PATCH 02/11] Fix issues with inherited method from templated base classes --- src/utils/xrQSlim/src/MxDynBlock.h | 2 ++ .../ai/monsters/bloodsucker/bloodsucker_attack_state.h | 8 ++++++++ src/xrGame/ai/monsters/bloodsucker/bloodsucker_predator.h | 2 ++ .../monsters/bloodsucker/bloodsucker_state_capture_jump.h | 4 ++++ src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire.h | 3 +++ .../ai/monsters/bloodsucker/bloodsucker_vampire_hide.h | 3 +++ .../monsters/group_states/group_state_home_point_attack.h | 2 ++ .../ai/monsters/pseudodog/psy_dog_state_psy_attack.h | 1 + src/xrServerEntities/PropertiesListTypes.h | 4 ++-- 9 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/utils/xrQSlim/src/MxDynBlock.h b/src/utils/xrQSlim/src/MxDynBlock.h index e7e12e71bdc..a064484950c 100644 --- a/src/utils/xrQSlim/src/MxDynBlock.h +++ b/src/utils/xrQSlim/src/MxDynBlock.h @@ -18,6 +18,8 @@ class MxDynBlock : public MxBlock { private: int fill; + using MxBlock::resize; + using MxBlock::begin; public: MxDynBlock(int n = 2) : MxBlock(n) { fill = 0; } diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_attack_state.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_attack_state.h index 28a688e1506..df42948e198 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_attack_state.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_attack_state.h @@ -10,6 +10,14 @@ class CBloodsuckerStateAttack : public CStateMonsterAttack<_Object> using inherited::current_substate; using inherited::m_time_start_check_behinder; using inherited::object; + using inherited::check_steal_state; + using inherited::select_state; + using inherited::check_camp_state; + using inherited::check_home_point; + using inherited::check_find_enemy_state; + using inherited::get_state_current; + using inherited::get_state; + using inherited::check_run_attack_state; u32 m_time_stop_invis; Fvector m_dir_point; diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_predator.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_predator.h index 6c13507f33b..b1679583816 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_predator.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_predator.h @@ -10,6 +10,8 @@ class CStateBloodsuckerPredator : public CState<_Object> using inherited::prev_substate; using inherited::time_state_started; using inherited::current_substate; + using inherited::select_state; + using inherited::get_state_current; u32 m_target_node; u32 m_time_start_camp; diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_state_capture_jump.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_state_capture_jump.h index f5ccbb7de07..e65494e84b0 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_state_capture_jump.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_state_capture_jump.h @@ -10,6 +10,10 @@ class CStateCaptureJumpBloodsucker : public CState<_Object> typedef CState<_Object>* state_ptr; using inherited::prev_substate; using inherited::current_substate; + using inherited::get_state_current; + using inherited::check_home_point; + using inherited::check_find_enemy; + using inherited::select_state; public: CStateCaptureJumpBloodsucker(_Object* obj); diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire.h index c0c25927a7f..cbe9e550038 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire.h @@ -10,6 +10,9 @@ class CStateBloodsuckerVampire : public CState<_Object> using inherited::object; using inherited::current_substate; using inherited::prev_substate; + using inherited::get_state; + using inherited::select_state; + using inherited::get_state_current; const CEntityAlive* enemy; diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire_hide.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire_hide.h index 576b21c8c90..95f3f031f58 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire_hide.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_vampire_hide.h @@ -9,6 +9,9 @@ class CStateBloodsuckerVampireHide : public CState<_Object> using inherited::object; using inherited::prev_substate; using inherited::current_substate; + using inherited::select_state; + using inherited::get_state; + using inherited::get_state_current; public: CStateBloodsuckerVampireHide(_Object* obj); diff --git a/src/xrGame/ai/monsters/group_states/group_state_home_point_attack.h b/src/xrGame/ai/monsters/group_states/group_state_home_point_attack.h index d5548449668..08b520cb65d 100644 --- a/src/xrGame/ai/monsters/group_states/group_state_home_point_attack.h +++ b/src/xrGame/ai/monsters/group_states/group_state_home_point_attack.h @@ -10,6 +10,8 @@ class CStateGroupAttackMoveToHomePoint : public CState<_Object> using inherited::object; using inherited::prev_substate; using inherited::current_substate; + using inherited::select_state; + using inherited::get_state_current; u32 m_target_node; bool m_skip_camp; diff --git a/src/xrGame/ai/monsters/pseudodog/psy_dog_state_psy_attack.h b/src/xrGame/ai/monsters/pseudodog/psy_dog_state_psy_attack.h index 2237f7d7afa..fc602d18742 100644 --- a/src/xrGame/ai/monsters/pseudodog/psy_dog_state_psy_attack.h +++ b/src/xrGame/ai/monsters/pseudodog/psy_dog_state_psy_attack.h @@ -8,6 +8,7 @@ class CStatePsyDogPsyAttack : public CState<_Object> protected: typedef CState<_Object> inherited; typedef CState<_Object>* state_ptr; + using inherited::select_state; public: CStatePsyDogPsyAttack(_Object* obj); diff --git a/src/xrServerEntities/PropertiesListTypes.h b/src/xrServerEntities/PropertiesListTypes.h index 3c9e21e5da5..c17874afa7b 100644 --- a/src/xrServerEntities/PropertiesListTypes.h +++ b/src/xrServerEntities/PropertiesListTypes.h @@ -733,7 +733,7 @@ class TokenValue : public CustomValue, public TokenValueCustom OnDrawText(this, draw_val); else for (int i = 0; this->token[i].name; i++) - if (this->token[i].id == (int)GetValue()) + if (this->token[i].id == (int)this->GetValue()) return this->token[i].name; return draw_val; } @@ -765,7 +765,7 @@ class RTokenValue : public CustomValue, public RTokenValueCustom OnDrawText(this, draw_val); else for (u32 k = 0; k < token_count; k++) - if ((T)token[k].id == GetValue()) + if ((T)token[k].id == this->GetValue()) return *token[k].name; return draw_val; } From 6d2f0f9d0c645cd9620eac2ddace9d05e8d52e52 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 17:29:18 +0200 Subject: [PATCH 03/11] Fix various minor mistakes that clang doesn't like --- src/Common/PlatformLinux.inl | 4 ++-- src/xrCore/XML/XMLDocument.hpp | 2 +- src/xrCore/log.h | 2 +- src/xrCore/xrMemory.h | 4 ++-- src/xrCore/xr_trims.cpp | 6 +++--- src/xrEngine/xrSheduler.cpp | 2 +- src/xrGame/alife_registry_wrapper.h | 12 ++++++------ src/xrGame/ik/IKLimb.h | 5 ++++- src/xrScriptEngine/script_engine.cpp | 2 +- src/xrSound/xr_streamsnd.cpp | 2 +- src/xr_3da/entry_point.cpp | 2 +- 11 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Common/PlatformLinux.inl b/src/Common/PlatformLinux.inl index 989cc1d9052..3181f489894 100644 --- a/src/Common/PlatformLinux.inl +++ b/src/Common/PlatformLinux.inl @@ -115,7 +115,7 @@ inline void _splitpath ( } #include -inline void OutputDebugString(char *str) // for linux debugger +inline void OutputDebugString(const char *str) // for linux debugger { std::cerr << str; } @@ -202,7 +202,7 @@ typedef struct _EXCEPTION_POINTERS { #ifdef XR_X64 typedef int64_t INT_PTR; -typedef uint16_t UINT_PTR; +typedef uint64_t UINT_PTR; typedef int64_t LONG_PTR; #else typedef int INT_PTR; diff --git a/src/xrCore/XML/XMLDocument.hpp b/src/xrCore/XML/XMLDocument.hpp index b96531edf47..6a9c220193e 100644 --- a/src/xrCore/XML/XMLDocument.hpp +++ b/src/xrCore/XML/XMLDocument.hpp @@ -31,7 +31,7 @@ class XML_NODE return node; } - bool operator==(nullptr_t) = delete; + bool operator==(std::nullptr_t) = delete; XML_NODE firstChild() const { diff --git a/src/xrCore/log.h b/src/xrCore/log.h index 669dd756564..28e8ed7c764 100644 --- a/src/xrCore/log.h +++ b/src/xrCore/log.h @@ -30,7 +30,7 @@ struct LogCallback void* Context; LogCallback() : Log(nullptr), Context(nullptr) {} - LogCallback(nullptr_t) : Log(nullptr), Context(nullptr) {} + LogCallback(std::nullptr_t) : Log(nullptr), Context(nullptr) {} LogCallback(Func log, void* ctx) : Log(log), Context(ctx) {} void operator()(const char* s) { Log(Context, s); } operator bool() const { return !!Log; } diff --git a/src/xrCore/xrMemory.h b/src/xrCore/xrMemory.h index a5ee69e8860..38e05033ae6 100644 --- a/src/xrCore/xrMemory.h +++ b/src/xrCore/xrMemory.h @@ -3,8 +3,8 @@ #include "Common/Common.hpp" #include "_types.h" -#include "tbb/tbb_allocator.h" -#include "tbb/scalable_allocator.h" +#include +#include /* Можно заключить - прокси перехватывает не всегда и/или не всё используемые функции. diff --git a/src/xrCore/xr_trims.cpp b/src/xrCore/xr_trims.cpp index eecbe19b15f..dc652a67ca3 100644 --- a/src/xrCore/xr_trims.cpp +++ b/src/xrCore/xr_trims.cpp @@ -51,7 +51,7 @@ LPCSTR _CopyVal(LPCSTR src, LPSTR dst, char separator) LPCSTR p; size_t n; p = strchr(src, separator); - n = (p > 0) ? (p - src) : xr_strlen(src); + n = (p != nullptr) ? (p - src) : xr_strlen(src); strncpy(dst, src, n); dst[n] = 0; return dst; @@ -279,7 +279,7 @@ LPCSTR _CopyVal(LPCSTR src, AnsiString& dst, char separator) LPCSTR p; u32 n; p = strchr(src, separator); - n = (p > 0) ? (p - src) : xr_strlen(src); + n = (p != nullptr) ? (p - src) : xr_strlen(src); dst = src; dst = dst.Delete(n + 1, dst.Length()); return dst.c_str(); @@ -490,7 +490,7 @@ LPCSTR _CopyVal(LPCSTR src, xr_string& dst, char separator) LPCSTR p; std::ptrdiff_t n; p = strchr(src, separator); - n = (p > 0) ? (p - src) : xr_strlen(src); + n = (p != nullptr) ? (p - src) : xr_strlen(src); dst = src; dst = dst.erase(n, dst.length()); return dst.c_str(); diff --git a/src/xrEngine/xrSheduler.cpp b/src/xrEngine/xrSheduler.cpp index 35d187bea5a..98ff05e7365 100644 --- a/src/xrEngine/xrSheduler.cpp +++ b/src/xrEngine/xrSheduler.cpp @@ -702,7 +702,7 @@ void Scheduler::Unregister(ISheduled* object) Msg("SCHEDULERMT: unregister [%s][%x]", object->shedule_Name().c_str(), object); #endif - ItemReg item = { false, object->GetSchedulerData().b_RT, object }; + ItemReg item = { false, object->GetSchedulerData().b_RT != 0, object }; RegistrationQueue.emplace_back(std::move(item)); } diff --git a/src/xrGame/alife_registry_wrapper.h b/src/xrGame/alife_registry_wrapper.h index 0f08df989a6..cbc20530d93 100644 --- a/src/xrGame/alife_registry_wrapper.h +++ b/src/xrGame/alife_registry_wrapper.h @@ -40,9 +40,9 @@ const typename _registry_type::_data* CALifeRegistryWrapper<_registry_type>::obj if (I == local_registry.end()) { typename _registry_type::_data new_registry; - std::pair<_registry_type::iterator, bool> p = local_registry.insert(std::make_pair(id, new_registry)); - VERIFY(p.second); - return &(*local_registry.find(id)).second; + auto [iter, inserted] = local_registry.insert(std::make_pair(id, new_registry)); + VERIFY(inserted); + return &(iter->second); } return (&(*I).second); } @@ -63,9 +63,9 @@ typename _registry_type::_data& CALifeRegistryWrapper<_registry_type>::objects(u if (I == local_registry.end()) { typename _registry_type::_data new_registry; - std::pair<_registry_type::iterator, bool> p = local_registry.insert(std::make_pair(id, new_registry)); - VERIFY(p.second); - return (*local_registry.find(id)).second; + auto [iter, inserted] = local_registry.insert(std::make_pair(id, new_registry)); + VERIFY(inserted); + return (iter->second); } else return ((*I).second); diff --git a/src/xrGame/ik/IKLimb.h b/src/xrGame/ik/IKLimb.h index c102ecf70b6..19df2efe305 100644 --- a/src/xrGame/ik/IKLimb.h +++ b/src/xrGame/ik/IKLimb.h @@ -9,12 +9,15 @@ #include "ik_limb_state_predict.h" class IKinematics; -class CDB::TRI; struct SCalculateData; struct SIKCollideData; class CGameObject; class motion_marks; class ik_goal_matrix; +namespace CDB +{ +class TRI; +} namespace extrapolation { class points; diff --git a/src/xrScriptEngine/script_engine.cpp b/src/xrScriptEngine/script_engine.cpp index 62fc2b8682f..a7eee078517 100644 --- a/src/xrScriptEngine/script_engine.cpp +++ b/src/xrScriptEngine/script_engine.cpp @@ -1160,7 +1160,7 @@ CScriptProcess* CScriptEngine::script_process(const ScriptProcessor& process_id) void CScriptEngine::parse_script_namespace(const char* name, char* ns, u32 nsSize, char* func, u32 funcSize) { - auto p = strrchr(name, '.'); + const char* p = strrchr(name, '.'); if (!p) { xr_strcpy(ns, nsSize, GlobalNamespace); diff --git a/src/xrSound/xr_streamsnd.cpp b/src/xrSound/xr_streamsnd.cpp index dfe30a37c4a..55d8269d0bf 100644 --- a/src/xrSound/xr_streamsnd.cpp +++ b/src/xrSound/xr_streamsnd.cpp @@ -347,7 +347,7 @@ void CSoundStream::LoadADPCM() DataPos = NULL; hf = FS.r_open("$game_sounds$", fn); - R_ASSERT(hf >= 0); + VERIFY(hf); ZeroMemory(&riff, sizeof(riff)); XRead(riff); CopyMemory(buf, riff.id, 4); diff --git a/src/xr_3da/entry_point.cpp b/src/xr_3da/entry_point.cpp index fec03f96a9a..da74c45ea6d 100644 --- a/src/xr_3da/entry_point.cpp +++ b/src/xr_3da/entry_point.cpp @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) for(i = 1; i < argc; ++i) sum += strlen(argv[i]) + 1; - commandLine = malloc(sum); + commandLine = (char*)malloc(sum); memset(commandLine, 0, sum); for(i = 1; i < argc; ++i) From 2c243df101c013cc38bc59076fbb0f282de833eb Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 17:31:39 +0200 Subject: [PATCH 04/11] Do not use shared_str directly on printf --- src/xrGame/GameObject.cpp | 2 +- src/xrGame/ini_table_loader.h | 2 +- src/xrGame/ui/UIInvUpgradeProperty.cpp | 2 +- src/xrGame/ui/UITalkWnd.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xrGame/GameObject.cpp b/src/xrGame/GameObject.cpp index 1e746cbd54a..ef2586b2463 100644 --- a/src/xrGame/GameObject.cpp +++ b/src/xrGame/GameObject.cpp @@ -465,7 +465,7 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC) //R_ASSERT(Level().Objects.net_Find(E->ID) == nullptr); if (Level().Objects.net_Find(E->ID) != nullptr) { - GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CGameObject:net_Spawn() | Level().Objects.net_Find(E->ID) != nullptr (This mean object already exist on level by this ID) ID=%s s_name=%s", E->ID, E->s_name); + GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CGameObject:net_Spawn() | Level().Objects.net_Find(E->ID) != nullptr (This mean object already exist on level by this ID) ID=%s s_name=%s", E->ID, E->s_name.c_str()); return false; } } diff --git a/src/xrGame/ini_table_loader.h b/src/xrGame/ini_table_loader.h index 09152d7ffa2..f21014a4718 100644 --- a/src/xrGame/ini_table_loader.h +++ b/src/xrGame/ini_table_loader.h @@ -106,7 +106,7 @@ typename CSIni_Table::ITEM_TABLE& CSIni_Table::table() T_INI_LOADER::IdToIndex((*i).first, type_max); if (type_max == cur_index) - xrDebug::Fatal(DEBUG_INFO, "wrong community %s in section [%s]", (*i).first, table_sect); + xrDebug::Fatal(DEBUG_INFO, "wrong community %s in section [%s]", (*i).first.c_str(), table_sect); (*m_pTable)[cur_index].resize(cur_table_width); for (std::size_t j = 0; j < cur_table_width; j++) diff --git a/src/xrGame/ui/UIInvUpgradeProperty.cpp b/src/xrGame/ui/UIInvUpgradeProperty.cpp index f8367c15567..fad17914743 100644 --- a/src/xrGame/ui/UIInvUpgradeProperty.cpp +++ b/src/xrGame/ui/UIInvUpgradeProperty.cpp @@ -175,7 +175,7 @@ void UIInvUpgPropertiesWnd::init_from_xml(LPCSTR xml_name) property_id._set((*ib).first); if (!ui_property->init_property(property_id)) { - Msg("! Invalid property <%s> in inventory upgrade manager!", property_id); + Msg("! Invalid property <%s> in inventory upgrade manager!", property_id.c_str()); continue; } diff --git a/src/xrGame/ui/UITalkWnd.cpp b/src/xrGame/ui/UITalkWnd.cpp index 6bae4f162af..443c24459be 100644 --- a/src/xrGame/ui/UITalkWnd.cpp +++ b/src/xrGame/ui/UITalkWnd.cpp @@ -261,7 +261,7 @@ void CUITalkWnd::AskQuestion() { string128 s; xr_sprintf(s, "ID = [%s] of selected question is out of range of available dialogs ", - UITalkDialogWnd->m_ClickedQuestionID); + UITalkDialogWnd->m_ClickedQuestionID.c_str()); VERIFY2(FALSE, s); } From 04893d8b42ff4bc0b34c1d7ce12013b4001fddbc Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 18:20:06 +0200 Subject: [PATCH 05/11] Fix Clang's more sensitive header order and forward declarations --- src/utils/xrMiscMath/vector3d_ext.cpp | 2 +- src/xrAICore/AISpaceBase.cpp | 2 +- src/xrAICore/Components/problem_solver.h | 2 - .../Components/problem_solver_inline.h | 4 ++ .../bloodsucker/bloodsucker_state_manager.cpp | 2 +- .../ai/monsters/dog/dog_state_manager.cpp | 2 +- .../states/monster_state_rest_idle_inline.h | 2 + src/xrGame/aimers_base.h | 1 + src/xrGame/debug_text_tree.h | 42 +++++++++---------- src/xrGame/memory_manager.h | 3 +- src/xrGame/space_restriction_bridge.h | 3 +- src/xrPhysics/ActorCameraCollision.cpp | 4 +- src/xrPhysics/PhysicsExternalCommon.h | 1 + 13 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/utils/xrMiscMath/vector3d_ext.cpp b/src/utils/xrMiscMath/vector3d_ext.cpp index 2bc1a6dceef..5a2baadc08f 100644 --- a/src/utils/xrMiscMath/vector3d_ext.cpp +++ b/src/utils/xrMiscMath/vector3d_ext.cpp @@ -1,6 +1,6 @@ #include "pch.hpp" -#include "xrCore/_vector3d_ext.h" #include "xrCommon/math_funcs_inline.h" +#include "xrCore/_vector3d_ext.h" float dotproduct(const Fvector& v1, const Fvector& v2) { diff --git a/src/xrAICore/AISpaceBase.cpp b/src/xrAICore/AISpaceBase.cpp index 308981a5284..65c5578acba 100644 --- a/src/xrAICore/AISpaceBase.cpp +++ b/src/xrAICore/AISpaceBase.cpp @@ -2,8 +2,8 @@ #include "AISpaceBase.hpp" #include "Navigation/game_graph.h" #include "Navigation/level_graph.h" -#include "Navigation/graph_engine.h" #include "Navigation/PatrolPath/patrol_path_storage.h" +#include "Navigation/graph_engine.h" AISpaceBase::AISpaceBase() { GEnv.AISpace = this; } AISpaceBase::~AISpaceBase() diff --git a/src/xrAICore/Components/problem_solver.h b/src/xrAICore/Components/problem_solver.h index e34ac21449e..82c82c2e7bb 100644 --- a/src/xrAICore/Components/problem_solver.h +++ b/src/xrAICore/Components/problem_solver.h @@ -11,8 +11,6 @@ #include "xrCore/Containers/AssociativeVector.hpp" #include "Common/object_broker.h" -class CGraphEngine; - template diff --git a/src/xrAICore/Components/problem_solver_inline.h b/src/xrAICore/Components/problem_solver_inline.h index 032cb8dab2d..55dfc491fce 100644 --- a/src/xrAICore/Components/problem_solver_inline.h +++ b/src/xrAICore/Components/problem_solver_inline.h @@ -8,6 +8,10 @@ #pragma once +#ifndef AI_COMPILER +#include "xrAICore/Navigation/graph_engine.h" +#endif + #define TEMPLATE_SPECIALIZATION \ template Date: Mon, 24 Sep 2018 18:27:13 +0200 Subject: [PATCH 06/11] POSIX's 'open' returns int. Clang doesn't admit an int -> void* cast for this. --- src/xrCore/FS.h | 4 ++ src/xrCore/FS_internal.h | 4 ++ src/xrCore/LocatorAPI.cpp | 95 ++++++++++++++++++++++--------- src/xrCore/LocatorAPI.h | 15 +++-- src/xrCore/file_stream_reader.cpp | 6 +- src/xrCore/file_stream_reader.h | 4 ++ src/xrCore/stream_reader.cpp | 14 +++++ src/xrCore/stream_reader.h | 13 +++++ src/xrCore/stream_reader_inline.h | 5 ++ src/xrEngine/x_ray.cpp | 4 ++ 10 files changed, 131 insertions(+), 33 deletions(-) diff --git a/src/xrCore/FS.h b/src/xrCore/FS.h index 899092fcf14..6554d5bd417 100644 --- a/src/xrCore/FS.h +++ b/src/xrCore/FS.h @@ -410,7 +410,11 @@ class XRCORE_API IReader : public IReaderBase class XRCORE_API CVirtualFileRW : public IReader { private: +#if defined(WINDOWS) void *hSrcFile, *hSrcMap; +#elif defined(LINUX) + int hSrcFile; +#endif public: CVirtualFileRW(const char* cFileName); diff --git a/src/xrCore/FS_internal.h b/src/xrCore/FS_internal.h index 81b164eb5a0..f55feffe238 100644 --- a/src/xrCore/FS_internal.h +++ b/src/xrCore/FS_internal.h @@ -124,7 +124,11 @@ class CCompressedReader : public IReader class CVirtualFileReader : public IReader { private: +#if defined(WINDOWS) void *hSrcFile, *hSrcMap; +#elif defined(LINUX) + int hSrcFile; +#endif public: CVirtualFileReader(const char* cFileName); diff --git a/src/xrCore/LocatorAPI.cpp b/src/xrCore/LocatorAPI.cpp index 2589a856017..0129616a0f6 100644 --- a/src/xrCore/LocatorAPI.cpp +++ b/src/xrCore/LocatorAPI.cpp @@ -256,34 +256,24 @@ const CLocatorAPI::file* CLocatorAPI::Register( return &*result; } +#if defined(WINDOWS) IReader* open_chunk(void* ptr, u32 ID) { u32 dwType, dwSize; DWORD read_byte; -#ifdef WINDOWS u32 pt = SetFilePointer(ptr, 0, nullptr, FILE_BEGIN); VERIFY(pt != INVALID_SET_FILE_POINTER); -#else - ::lseek(ptr, 0L, SEEK_SET); -#endif + while (true) { -#ifdef WINDOWS bool res = ReadFile(ptr, &dwType, 4, &read_byte, nullptr); -#elif defined(LINUX) - read_byte = ::read(ptr, &dwType, 4); - bool res = (read_byte != -1); -#endif + if (read_byte == 0) return nullptr; //. VERIFY(res&&(read_byte==4)); -#ifdef WINDOWS res = ReadFile(ptr, &dwSize, 4, &read_byte, nullptr); -#else - read_byte = ::read(ptr, &dwSize, 4); - res = (read_byte != -1); -#endif + if (read_byte == 0) return nullptr; //. VERIFY(res&&(read_byte==4)); @@ -291,12 +281,8 @@ IReader* open_chunk(void* ptr, u32 ID) if ((dwType & ~CFS_CompressMark) == ID) { u8* src_data = xr_alloc(dwSize); -#ifdef WINDOWS res = ReadFile(ptr, src_data, dwSize, &read_byte, nullptr); -#else - read_byte = ::read(ptr, src_data, dwSize); - res = (read_byte != -1); -#endif + VERIFY(res && (read_byte == dwSize)); if (dwType & CFS_CompressMark) { @@ -308,17 +294,62 @@ IReader* open_chunk(void* ptr, u32 ID) } return new CTempReader(src_data, dwSize, 0); } -#ifdef WINDOWS + pt = SetFilePointer(ptr, dwSize, nullptr, FILE_CURRENT); if (pt == INVALID_SET_FILE_POINTER) return nullptr; -#else - if(-1 == ::lseek(ptr, dwSize, SEEK_CUR)) - return nullptr; + } + return nullptr; +}; #endif + +#if defined(LINUX) +IReader* open_chunk(int fd, u32 ID) +{ + u32 dwType, dwSize; + DWORD read_byte; + ::lseek(fd, 0L, SEEK_SET); + + while (true) + { + read_byte = ::read(fd, &dwType, 4); + bool res = (read_byte != -1); + + if (read_byte == 0) + return nullptr; + //. VERIFY(res&&(read_byte==4)); + + read_byte = ::read(fd, &dwSize, 4); + res = (read_byte != -1); + + if (read_byte == 0) + return nullptr; + //. VERIFY(res&&(read_byte==4)); + + if ((dwType & ~CFS_CompressMark) == ID) + { + u8* src_data = xr_alloc(dwSize); + read_byte = ::read(fd, src_data, dwSize); + res = (read_byte != -1); + + VERIFY(res && (read_byte == dwSize)); + if (dwType & CFS_CompressMark) + { + BYTE* dest; + unsigned dest_sz; + _decompressLZ(&dest, &dest_sz, src_data, dwSize); + xr_free(src_data); + return new CTempReader(dest, dest_sz, 0); + } + return new CTempReader(src_data, dwSize, 0); + } + + if(-1 == ::lseek(fd, dwSize, SEEK_CUR)) + return nullptr; } return nullptr; }; +#endif void CLocatorAPI::LoadArchive(archive& A, pcstr entrypoint) { @@ -416,17 +447,21 @@ void CLocatorAPI::LoadArchive(archive& A, pcstr entrypoint) void CLocatorAPI::archive::open() { +#if defined(WINDOWS) // Open the file if (hSrcFile && hSrcMap) return; -#if defined(WINDOWS) hSrcFile = CreateFile(*path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); R_ASSERT(hSrcFile != INVALID_HANDLE_VALUE); hSrcMap = CreateFileMapping(hSrcFile, nullptr, PAGE_READONLY, 0, 0, nullptr); R_ASSERT(hSrcMap != INVALID_HANDLE_VALUE); size = GetFileSize(hSrcFile, nullptr); #elif defined(LINUX) + // Open the file + if (hSrcFile) + return; + hSrcFile = ::open(*path, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); R_ASSERT(hSrcFile != -1); struct stat file_info; @@ -505,7 +540,11 @@ bool CLocatorAPI::load_all_unloaded_archives() bool res = false; for (auto& archive : m_archives) { +#if defined(WINDOWS) if (archive.hSrcFile == nullptr) +#elif defined(LINUX) + if (archive.hSrcFile == 0) +#endif { LoadArchive(archive); res = true; @@ -593,7 +632,7 @@ bool ignore_path(const char* _path) else return true; #elif defined(LINUX) - HANDLE h = ::open(_path, O_RDONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int h = ::open(_path, O_RDONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (h != -1) { ::close(h); @@ -1294,7 +1333,11 @@ void CLocatorAPI::file_from_archive(CStreamReader*& R, pcstr fname, const file& make_string("cannot use stream reading for compressed data %s, do not compress data to be streamed", fname)); R = new CStreamReader(); +#if defined(WINDOWS) R->construct(A.hSrcMap, desc.ptr, desc.size_compressed, A.size, BIG_FILE_READER_WINDOW_SIZE); +#elif defined(LINUX) + R->construct(A.hSrcFile, desc.ptr, desc.size_compressed, A.size, BIG_FILE_READER_WINDOW_SIZE); +#endif } void CLocatorAPI::copy_file_to_build(IWriter* W, IReader* r) { W->w(r->pointer(), r->length()); } @@ -1506,7 +1549,7 @@ void CLocatorAPI::w_close(IWriter*& S) Register(fname, 0xffffffff, 0, 0, st.st_size, st.st_size, (u32)st.st_mtime); #elif defined(LINUX) struct stat st; - ::fstat(fname, &st); + ::stat(fname, &st); Register(fname, 0xffffffff, 0, 0, st.st_size, st.st_size, (u32)st.st_mtime); #endif } diff --git a/src/xrCore/LocatorAPI.h b/src/xrCore/LocatorAPI.h index 358e685bd23..b36a0a5aff2 100644 --- a/src/xrCore/LocatorAPI.h +++ b/src/xrCore/LocatorAPI.h @@ -94,13 +94,18 @@ class XRCORE_API CLocatorAPI : Noncopyable struct archive { - u32 size; - u32 vfs_idx; + u32 size = 0; + u32 vfs_idx = u32(-1); shared_str path; - void *hSrcFile, *hSrcMap; - CInifile* header; +#if defined(WINDOWS) + void *hSrcFile = nullptr; + void *hSrcMap = nullptr +#elif defined(LINUX) + int hSrcFile = 0; +#endif + CInifile* header = nullptr; - archive() : size(0), vfs_idx(u32(-1)), hSrcFile(nullptr), hSrcMap(nullptr), header(nullptr) {} + archive() = default; void open(); void close(); }; diff --git a/src/xrCore/file_stream_reader.cpp b/src/xrCore/file_stream_reader.cpp index be3636dc9be..221d99235aa 100644 --- a/src/xrCore/file_stream_reader.cpp +++ b/src/xrCore/file_stream_reader.cpp @@ -22,18 +22,20 @@ void CFileStreamReader::construct(LPCSTR file_name, const u32& window_size) struct stat file_info; ::fstat(m_file_handle, &file_info); u32 file_size = (u32)file_info.st_size; - inherited::construct(&m_file_handle, 0, file_size, file_size, window_size); + inherited::construct(m_file_handle, 0, file_size, file_size, window_size); #endif } void CFileStreamReader::destroy() { +#if defined(WINDOWS) HANDLE file_mapping_handle = this->file_mapping_handle(); inherited::destroy(); -#if defined(WINDOWS) CloseHandle(file_mapping_handle); CloseHandle(m_file_handle); #elif defined(LINUX) + int file_mapping_handle = this->file_mapping_handle(); + inherited::destroy(); ::close(m_file_handle); m_file_handle = -1; #endif diff --git a/src/xrCore/file_stream_reader.h b/src/xrCore/file_stream_reader.h index c2df1b05244..ef130535855 100644 --- a/src/xrCore/file_stream_reader.h +++ b/src/xrCore/file_stream_reader.h @@ -9,7 +9,11 @@ class CFileStreamReader : public CStreamReader typedef CStreamReader inherited; private: +#if defined(WINDOWS) HANDLE m_file_handle; +#elif defined(LINUX) + int m_file_handle; +#endif public: virtual void construct(LPCSTR file_name, const u32& window_size); diff --git a/src/xrCore/stream_reader.cpp b/src/xrCore/stream_reader.cpp index df8e2834bcc..343793838cb 100644 --- a/src/xrCore/stream_reader.cpp +++ b/src/xrCore/stream_reader.cpp @@ -5,6 +5,7 @@ #include #endif +#if defined(WINDOWS) void CStreamReader::construct(const HANDLE& file_mapping_handle, const u32& start_offset, const u32& file_size, const u32& archive_size, const u32& window_size) { @@ -16,6 +17,19 @@ void CStreamReader::construct(const HANDLE& file_mapping_handle, const u32& star map(0); } +#elif defined(LINUX) +void CStreamReader::construct(int file_mapping_handle, const u32& start_offset, const u32& file_size, + const u32& archive_size, const u32& window_size) +{ + m_file_mapping_handle = file_mapping_handle; + m_start_offset = start_offset; + m_file_size = file_size; + m_archive_size = archive_size; + m_window_size = _max(window_size, FS.dwAllocGranularity); + + map(0); +} +#endif void CStreamReader::destroy() { unmap(); } void CStreamReader::map(const u32& new_offset) diff --git a/src/xrCore/stream_reader.h b/src/xrCore/stream_reader.h index 8e9cc6ec3c8..1045e234070 100644 --- a/src/xrCore/stream_reader.h +++ b/src/xrCore/stream_reader.h @@ -4,7 +4,11 @@ class XRCORE_API CStreamReader : public IReaderBase { private: +#if defined(WINDOWS) HANDLE m_file_mapping_handle; +#elif defined(LINUX) + int m_file_mapping_handle; +#endif u32 m_start_offset; u32 m_file_size; u32 m_archive_size; @@ -31,12 +35,21 @@ class XRCORE_API CStreamReader : public IReaderBase IC CStreamReader(); public: +#if defined(WINDOWS) virtual void construct(const HANDLE& file_mapping_handle, const u32& start_offset, const u32& file_size, const u32& archive_size, const u32& window_size); +#elif defined(LINUX) + virtual void construct(int file_mapping_handle, const u32& start_offset, const u32& file_size, + const u32& archive_size, const u32& window_size); +#endif virtual void destroy(); public: +#if defined(WINDOWS) IC const HANDLE& file_mapping_handle() const; +#elif defined(LINUX) + IC const int& file_mapping_handle() const; +#endif IC u32 elapsed() const; IC const u32& length() const; IC void seek(const int& offset); diff --git a/src/xrCore/stream_reader_inline.h b/src/xrCore/stream_reader_inline.h index 6bc23bad2de..d28c4573fca 100644 --- a/src/xrCore/stream_reader_inline.h +++ b/src/xrCore/stream_reader_inline.h @@ -18,7 +18,12 @@ IC CStreamReader& CStreamReader::operator=(const CStreamReader&) return (*this); } +#if defined(WINDOWS) IC const HANDLE& CStreamReader::file_mapping_handle() const { return (m_file_mapping_handle); } +#elif defined(LINUX) +IC const int& CStreamReader::file_mapping_handle() const { return (m_file_mapping_handle); } +#endif + #if defined(WINDOWS) IC void CStreamReader::unmap() { UnmapViewOfFile(m_current_map_view_of_file); } #else diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index bbde756c73a..1cd6354e14a 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -458,7 +458,11 @@ int CApplication::Level_ID(LPCSTR name, LPCSTR ver, bool bSet) for (; it != it_e; ++it) { CLocatorAPI::archive& A = *it; +#if defined(WINDOWS) if (A.hSrcFile == nullptr) +#elif defined(LINUX) + if (A.hSrcFile == 0) +#endif { LPCSTR ln = A.header->r_string("header", "level_name"); LPCSTR lv = A.header->r_string("header", "level_ver"); From 373d997f94c1dfac99bc730df9f1e3964cab1b99 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 18:34:07 +0200 Subject: [PATCH 07/11] Do not pass a pointer to an temporary IReader in CInifile Address of an rvalue may not be taken. --- src/xrGame/GameObject.cpp | 4 ++-- src/xrGame/alife_object.cpp | 3 ++- src/xrGame/alife_trader_abstract.cpp | 4 ++-- src/xrServerEntities/script_ini_file_script.cpp | 4 ++-- src/xrServerEntities/xrServer_Object_Base.cpp | 7 ++++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/xrGame/GameObject.cpp b/src/xrGame/GameObject.cpp index ef2586b2463..0fae1492885 100644 --- a/src/xrGame/GameObject.cpp +++ b/src/xrGame/GameObject.cpp @@ -491,8 +491,8 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC) { #pragma warning(push) #pragma warning(disable : 4238) - m_ini_file = new CInifile( - &IReader((void*)(*(O->m_ini_string)), O->m_ini_string.size()), FS.get_path("$game_config$")->m_Path); + IReader reader((void*)(*(O->m_ini_string)), O->m_ini_string.size()); + m_ini_file = new CInifile(&reader, FS.get_path("$game_config$")->m_Path); #pragma warning(pop) } diff --git a/src/xrGame/alife_object.cpp b/src/xrGame/alife_object.cpp index 85d3667913e..e994dbd7113 100644 --- a/src/xrGame/alife_object.cpp +++ b/src/xrGame/alife_object.cpp @@ -24,7 +24,8 @@ void CSE_ALifeObject::spawn_supplies(LPCSTR ini_string) #pragma warning(push) #pragma warning(disable : 4238) - CInifile ini(&IReader((void*)ini_string, xr_strlen(ini_string)), FS.get_path("$game_config$")->m_Path); + IReader reader((void*)ini_string, xr_strlen(ini_string)); + CInifile ini(&reader, FS.get_path("$game_config$")->m_Path); #pragma warning(pop) // Alundaio: This will spawn a single random section listed in [spawn_loadout] diff --git a/src/xrGame/alife_trader_abstract.cpp b/src/xrGame/alife_trader_abstract.cpp index af74a98c893..e4571f86706 100644 --- a/src/xrGame/alife_trader_abstract.cpp +++ b/src/xrGame/alife_trader_abstract.cpp @@ -49,8 +49,8 @@ void CSE_ALifeTraderAbstract::spawn_supplies() { #pragma warning(push) #pragma warning(disable : 4238) - CInifile ini(&IReader((void*)(*dynamic_object->m_ini_string), xr_strlen(dynamic_object->m_ini_string)), - FS.get_path("$game_config$")->m_Path); + IReader reader((void*)(*dynamic_object->m_ini_string), xr_strlen(dynamic_object->m_ini_string)); + CInifile ini(&reader, FS.get_path("$game_config$")->m_Path); #pragma warning(pop) if (ini.section_exist("dont_spawn_character_supplies")) diff --git a/src/xrServerEntities/script_ini_file_script.cpp b/src/xrServerEntities/script_ini_file_script.cpp index def72ee9360..3d0fc409329 100644 --- a/src/xrServerEntities/script_ini_file_script.cpp +++ b/src/xrServerEntities/script_ini_file_script.cpp @@ -37,8 +37,8 @@ bool r_line(CScriptIniFile* self, LPCSTR S, int L, luabind::string& N, luabind:: #pragma warning(disable : 4238) CScriptIniFile* create_ini_file(LPCSTR ini_string) { - return ((CScriptIniFile*)new CInifile( - &IReader((void*)ini_string, xr_strlen(ini_string)), FS.get_path("$game_config$")->m_Path)); + IReader reader((void*)ini_string, xr_strlen(ini_string)); + return ((CScriptIniFile*)new CInifile(&reader, FS.get_path("$game_config$")->m_Path)); } #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index 1425da566fb..487644bdf4b 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -157,13 +157,14 @@ IServerEntityShape* CSE_Abstract::shape() { return (nullptr); } CSE_Motion* CSE_Abstract::motion() { return (nullptr); } CInifile& CSE_Abstract::spawn_ini() { - if (!m_ini_file) + if (!m_ini_file) { #pragma warning(push) #pragma warning(disable : 4238) // XXX: what a casting mess.. Do we need to use shared_str for m_ini_string? - m_ini_file = - new CInifile(&IReader((void*)(*(m_ini_string)), m_ini_string.size()), FS.get_path(_game_config_)->m_Path); + IReader reader((void*)(*(m_ini_string)), m_ini_string.size()); + m_ini_file = new CInifile(&reader, FS.get_path(_game_config_)->m_Path); #pragma warning(pop) + } return (*m_ini_file); } From 9b8d3cbbaffd14424ed8b99159d0cb2d0d8776a3 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 18:35:29 +0200 Subject: [PATCH 08/11] Remove non defined and obsolete CXML_IdToIndex parameters --- src/xrServerEntities/xml_str_id_loader.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/xrServerEntities/xml_str_id_loader.h b/src/xrServerEntities/xml_str_id_loader.h index f2bd3fd1179..0301238200f 100644 --- a/src/xrServerEntities/xml_str_id_loader.h +++ b/src/xrServerEntities/xml_str_id_loader.h @@ -7,8 +7,6 @@ #include "Common/object_broker.h" #endif // XRGAME_EXPORTS -// T_ID - уникальный текстовый идентификатор (аттрибут id в XML файле) -// T_INDEX - уникальный числовой индекс // T_INIT - класс где определена статическая InitXmlIdToIndex // функция инициализации file_str и tag_name @@ -51,7 +49,7 @@ class CXML_IdToIndex static const ITEM_DATA* GetById(const shared_str& str_id, bool no_assert = false); static const ITEM_DATA* GetByIndex(int index, bool no_assert = false); - static const int IdToIndex(const shared_str& str_id, int default_index = T_INDEX(-1), bool no_assert = false) + static const int IdToIndex(const shared_str& str_id, int default_index = -1, bool no_assert = false) { const ITEM_DATA* item = GetById(str_id, no_assert); return item ? item->index : default_index; From 107f78ba7328e3e6742ba18a4ac96cf5c84fac09 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 18:36:32 +0200 Subject: [PATCH 09/11] Remove keyword 'register', which is obsolete and ignored --- src/xrGame/ik/math3d.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/xrGame/ik/math3d.cpp b/src/xrGame/ik/math3d.cpp index 62b59d5cf33..cac3c0cc046 100644 --- a/src/xrGame/ik/math3d.cpp +++ b/src/xrGame/ik/math3d.cpp @@ -77,9 +77,9 @@ void hmatmult(Matrix A, Matrix B, Matrix C) * A *CAN* point to the same matrix as B or C. */ { - register float *a, *b, *c, *bp, *cp; - register float *bmax, *cmax, *cpmax; - register float *b32, *c00, *c03; + float *a, *b, *c, *bp, *cp; + float *bmax, *cmax, *cpmax; + float *b32, *c00, *c03; Matrix Bt, Ct; if (A == B) @@ -159,7 +159,7 @@ void inverthomomatrix(Matrix N, Matrix M) * n = inverse of m */ { - register float *n, *m, *nmax, *C, *m3; + float *n, *m, *nmax, *C, *m3; nmax = &N[2][3]; n = &N[0][0]; @@ -196,7 +196,7 @@ void vecmult0(float y[], float x[], Matrix M) * y = x * M, with y[3] = 0 */ { - register int i, j; + int i, j; float Y[3]; for (i = 0; i < 3; i++) @@ -218,7 +218,7 @@ void vecmult(float y[], float x[], Matrix M) * y = x * M, with y[3] = 1 */ { - register int i, j; + int i, j; float Y[3]; for (i = 0; i < 3; i++) @@ -241,9 +241,9 @@ void axisangletomatrix(Matrix m, float axis[], float theta) * like the coordinate axes. */ { - register float s, v, c; - register float* p; - register float a01, a02, a12, a0s, a1s, a2s, a01v, a02v, a12v; + float s, v, c; + float* p; + float a01, a02, a12, a0s, a1s, a2s, a01v, a02v, a12v; c = _cos(theta); s = _sin(theta); @@ -584,9 +584,9 @@ void rmatmult(Matrix A, Matrix B, Matrix C) Matrix Temp1; Matrix Temp2; - register float* a = (float*)A; - register float* b; - register float* c; + float* a = (float*)A; + float* b; + float* c; if (A == B) { @@ -654,7 +654,7 @@ void invertrmatrix(Matrix N, Matrix M) * n = inverse of m */ { - register float *n, *m, *nmax, *C; + float *n, *m, *nmax, *C; nmax = &N[2][3]; n = &N[0][0]; From 5a5e0cca6233b8869329a28535d22b2bda0b552a Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 19:57:20 +0200 Subject: [PATCH 10/11] Remove unused ill-formed constructor that Clang complains about --- src/xrGame/action_base.h | 2 -- src/xrGame/action_base_inline.h | 8 -------- 2 files changed, 10 deletions(-) diff --git a/src/xrGame/action_base.h b/src/xrGame/action_base.h index 6d98ce23e0e..6a81559729d 100644 --- a/src/xrGame/action_base.h +++ b/src/xrGame/action_base.h @@ -60,8 +60,6 @@ class CActionBase : public GraphEngineSpace::CWorldOperator #endif public: - IC CActionBase(const xr_vector& conditions, const xr_vector& effects, - _object_type* object = 0, LPCSTR action_name = ""); IC CActionBase(_object_type* object, LPCSTR action_name = ""); virtual ~CActionBase(); IC void init(_object_type* object, LPCSTR action_name); diff --git a/src/xrGame/action_base_inline.h b/src/xrGame/action_base_inline.h index 21cdf2118c0..8c51701068a 100644 --- a/src/xrGame/action_base_inline.h +++ b/src/xrGame/action_base_inline.h @@ -14,14 +14,6 @@ #define TEMPLATE_SPECIALIZATION template #define CBaseAction CActionBase<_object_type> -TEMPLATE_SPECIALIZATION -IC CBaseAction::CActionBase(const xr_vector& conditions, - const xr_vector& effects, _object_type* object, LPCSTR action_name) - : inherited(conditions, effects) -{ - init(object, action_name); -} - TEMPLATE_SPECIALIZATION IC CBaseAction::CActionBase(_object_type* object, LPCSTR action_name) { init(object, action_name); } TEMPLATE_SPECIALIZATION From 5badae327f7a1d99bab6cc4fa63173c1f1505ae0 Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 24 Sep 2018 20:25:26 +0200 Subject: [PATCH 11/11] Reduce amount of warnings by moving CAI_ObjectLocation::init --- src/xrAICore/Navigation/ai_object_location_impl.h | 13 ------------- .../Navigation/ai_object_location_inline.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/xrAICore/Navigation/ai_object_location_impl.h b/src/xrAICore/Navigation/ai_object_location_impl.h index e1405c0a7e9..07ad1d20d09 100644 --- a/src/xrAICore/Navigation/ai_object_location_impl.h +++ b/src/xrAICore/Navigation/ai_object_location_impl.h @@ -12,19 +12,6 @@ #include "xrAICore/Navigation/game_graph.h" #include "xrAICore/Navigation/level_graph.h" -IC void CAI_ObjectLocation::init() -{ - if (ai().get_level_graph()) - ai().level_graph().set_invalid_vertex(m_level_vertex_id); - else - m_level_vertex_id = u32(-1); - - if (ai().get_game_graph()) - ai().game_graph().set_invalid_vertex(m_game_vertex_id); - else - m_game_vertex_id = GameGraph::_GRAPH_ID(-1); -} - IC void CAI_ObjectLocation::game_vertex(CVertex const* game_vertex) { VERIFY(ai().game_graph().valid_vertex_id(ai().game_graph().vertex_id(game_vertex))); diff --git a/src/xrAICore/Navigation/ai_object_location_inline.h b/src/xrAICore/Navigation/ai_object_location_inline.h index b23b5cafe12..0d6998a4e7a 100644 --- a/src/xrAICore/Navigation/ai_object_location_inline.h +++ b/src/xrAICore/Navigation/ai_object_location_inline.h @@ -8,6 +8,21 @@ #pragma once +#include "xrAICore/Navigation/level_graph.h" + +IC void CAI_ObjectLocation::init() +{ + if (ai().get_level_graph()) + ai().level_graph().set_invalid_vertex(m_level_vertex_id); + else + m_level_vertex_id = u32(-1); + + if (ai().get_game_graph()) + ai().game_graph().set_invalid_vertex(m_game_vertex_id); + else + m_game_vertex_id = GameGraph::_GRAPH_ID(-1); +} + IC CAI_ObjectLocation::CAI_ObjectLocation() { init(); } IC void CAI_ObjectLocation::reinit() { init(); } IC const GameGraph::_GRAPH_ID CAI_ObjectLocation::game_vertex_id() const { return (m_game_vertex_id); }