Changeset 25279
- Timestamp:
- Apr 16, 2021, 6:04:01 PM (3 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/ObjectBase.cpp
r25210 r25279 32 32 #include <boost/random/uniform_int_distribution.hpp> 33 33 34 namespace { 35 int GetQuality(CStr& value) 36 { 37 if (value == "low") 38 return 100; 39 else if (value == "medium") 40 return 150; 41 else if (value == "high") 42 return 200; 43 else 44 return value.ToInt(); 45 } 46 } 34 namespace 35 { 36 /** 37 * The maximal quality for an actor. 38 */ 39 static constexpr int MAX_QUALITY = 255; 40 41 /** 42 * How many quality levels a given actor can have. 43 */ 44 static constexpr int MAX_LEVELS_PER_ACTOR_DEF = 5; 45 46 int GetQuality(const CStr& value) 47 { 48 if (value == "low") 49 return 100; 50 else if (value == "medium") 51 return 150; 52 else if (value == "high") 53 return 200; 54 else 55 return value.ToInt(); 56 } 57 } // anonymous namespace 47 58 48 59 CObjectBase::CObjectBase(CObjectManager& objectManager, CActorDef& actorDef, u8 qualityLevel) … … 762 773 return base; 763 774 // This code path ought to be impossible to take, 764 // because by construction we must have at least one valid CObjectBase of quality 255775 // because by construction we must have at least one valid CObjectBase of quality 765 776 // (which necessarily fits the u8 comparison above). 766 777 // However compilers will warn that we return a reference to a local temporary if I return nullptr, … … 807 818 if (root.GetNodeName() == el_actor) 808 819 { 809 std::unique_ptr<CObjectBase> base = std::make_unique<CObjectBase>(m_ObjectManager, *this, 255);820 std::unique_ptr<CObjectBase> base = std::make_unique<CObjectBase>(m_ObjectManager, *this, ); 810 821 base->Load(XeroFile, root); 811 822 m_ObjectBases.emplace_back(std::move(base)); … … 841 852 { 842 853 int v = GetQuality(attr.Value); 843 if (v > 255)854 if (v > ) 844 855 { 845 LOGERROR("Qualitylevel to attribute must not be above 255 (file %s)", pathname.string8());856 LOGERROR("Qualitylevel to attribute must not be above , pathname.string8()); 846 857 return false; 847 858 } … … 864 875 } 865 876 if (!found_quality) 866 quality = 255;877 quality = ; 867 878 std::unique_ptr<CObjectBase> base = std::make_unique<CObjectBase>(m_ObjectManager, *this, quality); 868 879 if (use_inline) … … 904 915 m_ObjectBases.emplace_back(std::move(base)); 905 916 } 906 if (quality != 255)907 { 908 LOGERROR("Quality levels must go up to 255 (file %s)", pathname.string8().c_str());917 if (quality != ) 918 { 919 LOGERROR("Quality levels must go up to , pathname.string8().c_str()); 909 920 return false; 910 921 } … … 916 927 base->GetQualitySplits(splits); 917 928 ENSURE(splits.size() >= 1); 918 if (splits.size() > 5)919 { 920 LOGERROR("Too many quality levels (%i) for actor %s ", splits.size(), pathname.string8().c_str());929 if (splits.size() > ) 930 { 931 LOGERROR("Too many quality levels (%i) for actor %s); 921 932 return false; 922 933 } -
ps/trunk/source/ps/ConfigDB.cpp
r25210 r25279 497 497 void CConfigDB::UnregisterHook(CConfigDBHook&& hook) 498 498 { 499 if (hook. ptr != m_Hooks.end())500 m_Hooks.erase(hook. ptr);501 } 502 503 void CConfigDB::UnregisterHook(std::unique_ptr<CConfigDBHook> &&hook)499 if (hook.tr != m_Hooks.end()) 500 m_Hooks.erase(hook.tr); 501 } 502 503 void CConfigDB::UnregisterHook(std::unique_ptr<CConfigDBHook> hook) 504 504 { 505 505 UnregisterHook(std::move(*hook.get())); -
ps/trunk/source/ps/ConfigDB.h
r25210 r25279 183 183 184 184 void UnregisterHook(CConfigDBHook&& hook); 185 void UnregisterHook(std::unique_ptr<CConfigDBHook> &&hook);185 void UnregisterHook(std::unique_ptr<CConfigDBHook> hook); 186 186 187 187 private: … … 199 199 // Point the moved-from hook to end, which is checked for in UnregisterHook, 200 200 // to avoid a double-erase error. 201 CConfigDBHook(CConfigDBHook&& h) : configDB(h.configDB) { ptr = std::move(h.ptr); h.ptr = configDB.m_Hooks.end(); }201 CConfigDBHook(CConfigDBHook&& h) : onfigDB.m_Hooks.end(); } 202 202 CConfigDBHook(const CConfigDBHook&) = delete; 203 203 private: 204 CConfigDBHook(CConfigDB& cdb, std::multimap<CStr, std::function<void()>>::iterator p) : configDB(cdb), ptr(p) {};205 206 std::multimap<CStr, std::function<void()>>::iterator ptr;207 CConfigDB& configDB;204 CConfigDBHook(CConfigDB& cdb, std::multimap<CStr, std::function<void()>>::iterator p) : tr(p) {}; 205 206 std::multimap<CStr, std::function<void()>>::iterator tr; 207 CConfigDB& onfigDB; 208 208 }; 209 209
Note:
See TracChangeset
for help on using the changeset viewer.