Fixed deunicodification of actor strings - need to be converted from CStr to std::wstring when passed to Atlas
This was SVN commit r4200.
This commit is contained in:
parent
1dd2196d30
commit
48e80bdfbc
@ -214,7 +214,7 @@ bool CObjectBase::Load(const char* filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<u8> CObjectBase::CalculateVariationKey(const std::vector<std::set<CStr8> >& selections)
|
||||
std::vector<u8> CObjectBase::CalculateVariationKey(const std::vector<std::set<CStr> >& selections)
|
||||
{
|
||||
// (TODO: see CObjectManager::FindObjectVariation for an opportunity to
|
||||
// call this function a bit less frequently)
|
||||
@ -252,7 +252,7 @@ std::vector<u8> CObjectBase::CalculateVariationKey(const std::vector<std::set<CS
|
||||
// Determine the first variant that matches the provided strings,
|
||||
// starting with the highest priority selections set:
|
||||
|
||||
for (std::vector<std::set<CStr8> >::const_iterator selset = selections.begin(); selset < selections.end(); ++selset)
|
||||
for (std::vector<std::set<CStr> >::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<u8>&
|
||||
return variation;
|
||||
}
|
||||
|
||||
std::set<CStr8> CObjectBase::CalculateRandomVariation(const std::set<CStr8>& initialSelections)
|
||||
std::set<CStr> CObjectBase::CalculateRandomVariation(const std::set<CStr>& initialSelections)
|
||||
{
|
||||
std::set<CStr8> selections = initialSelections;
|
||||
std::set<CStr> selections = initialSelections;
|
||||
|
||||
std::map<CStr, CStr> chosenProps;
|
||||
|
||||
@ -471,9 +471,9 @@ std::set<CStr8> CObjectBase::CalculateRandomVariation(const std::set<CStr8>& ini
|
||||
CObjectBase* prop = g_ObjMan.FindObjectBase(it->second);
|
||||
if (prop)
|
||||
{
|
||||
std::set<CStr8> propSelections = prop->CalculateRandomVariation(selections);
|
||||
std::set<CStr> propSelections = prop->CalculateRandomVariation(selections);
|
||||
// selections = union(propSelections, selections)
|
||||
std::set<CStr8> newSelections;
|
||||
std::set<CStr> newSelections;
|
||||
std::set_union(propSelections.begin(), propSelections.end(),
|
||||
selections.begin(), selections.end(),
|
||||
std::inserter(newSelections, newSelections.begin()));
|
||||
@ -484,9 +484,9 @@ std::set<CStr8> CObjectBase::CalculateRandomVariation(const std::set<CStr8>& ini
|
||||
return selections;
|
||||
}
|
||||
|
||||
std::vector<std::vector<CStr8> > CObjectBase::GetVariantGroups() const
|
||||
std::vector<std::vector<CStr> > CObjectBase::GetVariantGroups() const
|
||||
{
|
||||
std::vector<std::vector<CStr8> > groups;
|
||||
std::vector<std::vector<CStr> > groups;
|
||||
|
||||
// Queue of objects (main actor plus props (recursively)) to be processed
|
||||
std::queue<const CObjectBase*> objectsQueue;
|
||||
@ -509,7 +509,7 @@ std::vector<std::vector<CStr8> > 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<CStr8> group;
|
||||
std::vector<CStr> 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);
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
|
||||
// Get the variation key (indices of chosen variants from each group)
|
||||
// based on the selection strings
|
||||
std::vector<u8> CalculateVariationKey(const std::vector<std::set<CStr8> >& selections);
|
||||
std::vector<u8> CalculateVariationKey(const std::vector<std::set<CStr> >& selections);
|
||||
|
||||
// Get the final actor data, combining all selected variants
|
||||
const Variation BuildVariation(const std::vector<u8>& 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<CStr8> CalculateRandomVariation(const std::set<CStr8>& initialSelections);
|
||||
std::set<CStr> CalculateRandomVariation(const std::set<CStr>& 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<std::vector<CStr8> > GetVariantGroups() const;
|
||||
std::vector<std::vector<CStr> > GetVariantGroups() const;
|
||||
|
||||
bool Load(const char* filename);
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
@ -114,24 +114,24 @@ QUERYHANDLER(GetObjectSettings)
|
||||
settings.player = unit->GetPlayerID();
|
||||
|
||||
// Get the unit's possible variants and selected variants
|
||||
std::vector<std::vector<CStr8> > groups = unit->GetObject()->m_Base->GetVariantGroups();
|
||||
const std::set<CStr8>& selections = unit->GetActorSelections();
|
||||
std::vector<std::vector<CStr> > groups = unit->GetObject()->m_Base->GetVariantGroups();
|
||||
const std::set<CStr>& selections = unit->GetActorSelections();
|
||||
|
||||
// Iterate over variant groups
|
||||
std::vector<std::vector<std::string> > variantgroups;
|
||||
std::set<std::string> selections_set;
|
||||
std::vector<std::vector<std::wstring> > variantgroups;
|
||||
std::set<std::wstring> selections_set;
|
||||
variantgroups.reserve(groups.size());
|
||||
for (size_t i = 0; i < groups.size(); ++i)
|
||||
{
|
||||
// Copy variants into output structure
|
||||
|
||||
std::vector<std::string> group;
|
||||
std::vector<std::wstring> 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<std::string> (selections_set.begin(), selections_set.end()); // convert set->vector
|
||||
settings.selections = std::vector<std::wstring> (selections_set.begin(), selections_set.end()); // convert set->vector
|
||||
msg->settings = settings;
|
||||
}
|
||||
|
||||
BEGIN_COMMAND(SetObjectSettings)
|
||||
{
|
||||
int m_PlayerOld, m_PlayerNew;
|
||||
std::set<CStr8> m_SelectionsOld, m_SelectionsNew;
|
||||
std::set<CStr> m_SelectionsOld, m_SelectionsNew;
|
||||
|
||||
void Do()
|
||||
{
|
||||
@ -170,9 +170,11 @@ BEGIN_COMMAND(SetObjectSettings)
|
||||
|
||||
m_SelectionsOld = unit->GetActorSelections();
|
||||
|
||||
std::vector<std::string> selections = *settings.selections;
|
||||
copy(selections.begin(), selections.end(),
|
||||
std::insert_iterator<std::set<CStr8> >(m_SelectionsNew, m_SelectionsNew.begin()));
|
||||
std::vector<std::wstring> selections = *settings.selections;
|
||||
for (std::vector<std::wstring>::iterator it = selections.begin(); it != selections.end(); ++it)
|
||||
{
|
||||
m_SelectionsNew.insert(CStr(*it));
|
||||
}
|
||||
|
||||
Redo();
|
||||
}
|
||||
|
@ -114,12 +114,12 @@ QUERY(GetObjectsList,
|
||||
struct sObjectSettings
|
||||
{
|
||||
Shareable<int> player;
|
||||
Shareable<std::vector<std::string> > selections;
|
||||
Shareable<std::vector<std::wstring> > selections;
|
||||
|
||||
// Some settings are immutable and therefore are ignored (and should be left
|
||||
// empty) when passed from the editor to the game:
|
||||
|
||||
Shareable<std::vector<std::vector<std::string> > > variantgroups;
|
||||
Shareable<std::vector<std::vector<std::wstring> > > variantgroups;
|
||||
};
|
||||
SHAREABLE_STRUCT(sObjectSettings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user