From 48e80bdfbce24abac7d28b132d8d5951561393ef Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sun, 6 Aug 2006 18:41:07 +0000 Subject: [PATCH] Fixed deunicodification of actor strings - need to be converted from CStr to std::wstring when passed to Atlas This was SVN commit r4200. --- source/graphics/ObjectBase.cpp | 18 ++++++------- source/graphics/ObjectBase.h | 6 ++--- source/scripting/ScriptableComplex.h | 2 +- .../GameInterface/Handlers/ObjectHandlers.cpp | 26 ++++++++++--------- source/tools/atlas/GameInterface/Messages.h | 4 +-- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 547a5a4a90..e41a2b52c0 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -214,7 +214,7 @@ bool CObjectBase::Load(const char* filename) return true; } -std::vector CObjectBase::CalculateVariationKey(const std::vector >& selections) +std::vector CObjectBase::CalculateVariationKey(const std::vector >& selections) { // (TODO: see CObjectManager::FindObjectVariation for an opportunity to // call this function a bit less frequently) @@ -252,7 +252,7 @@ std::vector CObjectBase::CalculateVariationKey(const std::vector >::const_iterator selset = selections.begin(); selset < selections.end(); ++selset) + for (std::vector >::const_iterator selset = selections.begin(); selset < selections.end(); ++selset) { debug_assert(grp->size() < 256); // else they won't fit in 'choices' @@ -367,9 +367,9 @@ const CObjectBase::Variation CObjectBase::BuildVariation(const std::vector& return variation; } -std::set CObjectBase::CalculateRandomVariation(const std::set& initialSelections) +std::set CObjectBase::CalculateRandomVariation(const std::set& initialSelections) { - std::set selections = initialSelections; + std::set selections = initialSelections; std::map chosenProps; @@ -471,9 +471,9 @@ std::set CObjectBase::CalculateRandomVariation(const std::set& ini CObjectBase* prop = g_ObjMan.FindObjectBase(it->second); if (prop) { - std::set propSelections = prop->CalculateRandomVariation(selections); + std::set propSelections = prop->CalculateRandomVariation(selections); // selections = union(propSelections, selections) - std::set newSelections; + std::set newSelections; std::set_union(propSelections.begin(), propSelections.end(), selections.begin(), selections.end(), std::inserter(newSelections, newSelections.begin())); @@ -484,9 +484,9 @@ std::set CObjectBase::CalculateRandomVariation(const std::set& ini return selections; } -std::vector > CObjectBase::GetVariantGroups() const +std::vector > CObjectBase::GetVariantGroups() const { - std::vector > groups; + std::vector > groups; // Queue of objects (main actor plus props (recursively)) to be processed std::queue objectsQueue; @@ -509,7 +509,7 @@ std::vector > CObjectBase::GetVariantGroups() const for (size_t i = 0; i < obj->m_VariantGroups.size(); ++i) { // Copy the group's variant names into a new vector - std::vector group; + std::vector group; group.reserve(obj->m_VariantGroups[i].size()); for (size_t j = 0; j < obj->m_VariantGroups[i].size(); ++j) group.push_back(obj->m_VariantGroups[i][j].m_VariantName); diff --git a/source/graphics/ObjectBase.h b/source/graphics/ObjectBase.h index c79e86d62f..d6c480fb61 100644 --- a/source/graphics/ObjectBase.h +++ b/source/graphics/ObjectBase.h @@ -62,7 +62,7 @@ public: // Get the variation key (indices of chosen variants from each group) // based on the selection strings - std::vector CalculateVariationKey(const std::vector >& selections); + std::vector CalculateVariationKey(const std::vector >& selections); // Get the final actor data, combining all selected variants const Variation BuildVariation(const std::vector& variationKey); @@ -70,12 +70,12 @@ public: // Get a set of selection strings that are complete enough to specify an // exact variation of the actor, using the initial selections wherever possible // and choosing randomly where a choice is necessary. - std::set CalculateRandomVariation(const std::set& initialSelections); + std::set CalculateRandomVariation(const std::set& initialSelections); // Get a list of variant groups for this object, plus for all possible // props. Duplicated groups are removed, if several props share the same // variant names. - std::vector > GetVariantGroups() const; + std::vector > GetVariantGroups() const; bool Load(const char* filename); diff --git a/source/scripting/ScriptableComplex.h b/source/scripting/ScriptableComplex.h index 140684715f..c966048636 100644 --- a/source/scripting/ScriptableComplex.h +++ b/source/scripting/ScriptableComplex.h @@ -10,7 +10,7 @@ a templated class, any source file that uses these methods directly must #include ScritpableComplex.inl to link to them. However, files that only need to know that something is a CJSComplex need not do this. This was done to speed up compile times after modifying CJSComplex's internals: -before, 30+ files had to be recompiled because they #included Entity.j +before, 30+ files had to be recompiled because they #included Entity.h which #includes ScriptableComplex.h. */ diff --git a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp index 8ee34b3905..3d92389d13 100644 --- a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -114,24 +114,24 @@ QUERYHANDLER(GetObjectSettings) settings.player = unit->GetPlayerID(); // Get the unit's possible variants and selected variants - std::vector > groups = unit->GetObject()->m_Base->GetVariantGroups(); - const std::set& selections = unit->GetActorSelections(); + std::vector > groups = unit->GetObject()->m_Base->GetVariantGroups(); + const std::set& selections = unit->GetActorSelections(); // Iterate over variant groups - std::vector > variantgroups; - std::set selections_set; + std::vector > variantgroups; + std::set selections_set; variantgroups.reserve(groups.size()); for (size_t i = 0; i < groups.size(); ++i) { // Copy variants into output structure - std::vector group; + std::vector group; group.reserve(groups[i].size()); int choice = -1; for (size_t j = 0; j < groups[i].size(); ++j) { - group.push_back(groups[i][j]); + group.push_back(CStrW(groups[i][j])); // Find the first string in 'selections' that matches one of this // group's variants @@ -143,20 +143,20 @@ QUERYHANDLER(GetObjectSettings) // Assuming one of the variants was selected (which it really ought // to be), remember that one's name if (choice != -1) - selections_set.insert(groups[i][choice]); + selections_set.insert(CStrW(groups[i][choice])); variantgroups.push_back(group); } settings.variantgroups = variantgroups; - settings.selections = std::vector (selections_set.begin(), selections_set.end()); // convert set->vector + settings.selections = std::vector (selections_set.begin(), selections_set.end()); // convert set->vector msg->settings = settings; } BEGIN_COMMAND(SetObjectSettings) { int m_PlayerOld, m_PlayerNew; - std::set m_SelectionsOld, m_SelectionsNew; + std::set m_SelectionsOld, m_SelectionsNew; void Do() { @@ -170,9 +170,11 @@ BEGIN_COMMAND(SetObjectSettings) m_SelectionsOld = unit->GetActorSelections(); - std::vector selections = *settings.selections; - copy(selections.begin(), selections.end(), - std::insert_iterator >(m_SelectionsNew, m_SelectionsNew.begin())); + std::vector selections = *settings.selections; + for (std::vector::iterator it = selections.begin(); it != selections.end(); ++it) + { + m_SelectionsNew.insert(CStr(*it)); + } Redo(); } diff --git a/source/tools/atlas/GameInterface/Messages.h b/source/tools/atlas/GameInterface/Messages.h index 1be3c824cf..002031e362 100644 --- a/source/tools/atlas/GameInterface/Messages.h +++ b/source/tools/atlas/GameInterface/Messages.h @@ -114,12 +114,12 @@ QUERY(GetObjectsList, struct sObjectSettings { Shareable player; - Shareable > selections; + Shareable > selections; // Some settings are immutable and therefore are ignored (and should be left // empty) when passed from the editor to the game: - Shareable > > variantgroups; + Shareable > > variantgroups; }; SHAREABLE_STRUCT(sObjectSettings);