1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 17:39:40 +00:00

Merge pull request #2555 from akortunov/encoding

Encode ID's in all places to UTF-8
This commit is contained in:
Bret Curtis 2019-10-24 00:48:12 +02:00 committed by GitHub
commit 2040ca5637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 41 additions and 33 deletions

View file

@ -19,6 +19,7 @@
Bug #3778: [Mod] Improved Thrown Weapon Projectiles - weapons have wrong transformation during throw animation Bug #3778: [Mod] Improved Thrown Weapon Projectiles - weapons have wrong transformation during throw animation
Bug #3812: Wrong multiline tooltips width when word-wrapping is enabled Bug #3812: Wrong multiline tooltips width when word-wrapping is enabled
Bug #3894: Hostile spell effects not detected/present on first frame of OnPCHitMe Bug #3894: Hostile spell effects not detected/present on first frame of OnPCHitMe
Bug #3977: Non-ASCII characters in object ID's are not supported
Bug #4077: Enchanted items are not recharged if they are not in the player's inventory Bug #4077: Enchanted items are not recharged if they are not in the player's inventory
Bug #4202: Open .omwaddon files without needing toopen openmw-cs first Bug #4202: Open .omwaddon files without needing toopen openmw-cs first
Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect

View file

@ -607,7 +607,7 @@ void Record<ESM::Container>::print()
std::cout << " Weight: " << mData.mWeight << std::endl; std::cout << " Weight: " << mData.mWeight << std::endl;
for (const ESM::ContItem &item : mData.mInventory.mList) for (const ESM::ContItem &item : mData.mInventory.mList)
std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount) std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount)
<< " Item: " << item.mItem.toString() << std::endl; << " Item: " << item.mItem << std::endl;
std::cout << " Deleted: " << mIsDeleted << std::endl; std::cout << " Deleted: " << mIsDeleted << std::endl;
} }
@ -653,7 +653,7 @@ void Record<ESM::Creature>::print()
for (const ESM::ContItem &item : mData.mInventory.mList) for (const ESM::ContItem &item : mData.mInventory.mList)
std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount) std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount)
<< " Item: " << item.mItem.toString() << std::endl; << " Item: " << item.mItem << std::endl;
for (const std::string &spell : mData.mSpells.mList) for (const std::string &spell : mData.mSpells.mList)
std::cout << " Spell: " << spell << std::endl; std::cout << " Spell: " << spell << std::endl;
@ -1073,7 +1073,7 @@ void Record<ESM::NPC>::print()
for (const ESM::ContItem &item : mData.mInventory.mList) for (const ESM::ContItem &item : mData.mInventory.mList)
std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount) std::cout << " Inventory: Count: " << Misc::StringUtils::format("%4d", item.mCount)
<< " Item: " << item.mItem.toString() << std::endl; << " Item: " << item.mItem << std::endl;
for (const std::string &spell : mData.mSpells.mList) for (const std::string &spell : mData.mSpells.mList)
std::cout << " Spell: " << spell << std::endl; std::cout << " Spell: " << spell << std::endl;
@ -1192,7 +1192,7 @@ void Record<ESM::Region>::print()
if (!mData.mSleepList.empty()) if (!mData.mSleepList.empty())
std::cout << " Sleep List: " << mData.mSleepList << std::endl; std::cout << " Sleep List: " << mData.mSleepList << std::endl;
for (const ESM::Region::SoundRef &soundref : mData.mSoundList) for (const ESM::Region::SoundRef &soundref : mData.mSoundList)
std::cout << " Sound: " << (int)soundref.mChance << " = " << soundref.mSound.toString() << std::endl; std::cout << " Sound: " << (int)soundref.mChance << " = " << soundref.mSound << std::endl;
} }
template<> template<>

View file

@ -9,7 +9,7 @@ namespace ESSImport
void convertSCPT(const SCPT &scpt, ESM::GlobalScript &out) void convertSCPT(const SCPT &scpt, ESM::GlobalScript &out)
{ {
out.mId = Misc::StringUtils::lowerCase(scpt.mSCHD.mName.toString()); out.mId = Misc::StringUtils::lowerCase(scpt.mSCHD.mName);
out.mRunning = scpt.mRunning; out.mRunning = scpt.mRunning;
convertSCRI(scpt.mSCRI, out.mLocals); convertSCRI(scpt.mSCRI, out.mLocals);
} }

View file

@ -17,7 +17,7 @@ namespace ESSImport
esm.getHT(contItem); esm.getHT(contItem);
InventoryItem item; InventoryItem item;
item.mId = contItem.mItem.toString(); item.mId = contItem.mItem;
item.mCount = contItem.mCount; item.mCount = contItem.mCount;
item.mRelativeEquipmentSlot = -1; item.mRelativeEquipmentSlot = -1;
item.mLockLevel = 0; item.mLockLevel = 0;

View file

@ -910,7 +910,7 @@ void CSMTools::ReferenceableCheckStage::inventoryListCheck(
{ {
for (size_t i = 0; i < itemList.size(); ++i) for (size_t i = 0; i < itemList.size(); ++i)
{ {
std::string itemName = itemList[i].mItem.toString(); std::string itemName = itemList[i].mItem;
CSMWorld::RefIdData::LocalIndex localIndex = mReferencables.searchId(itemName); CSMWorld::RefIdData::LocalIndex localIndex = mReferencables.searchId(itemName);
if (localIndex.first == -1) if (localIndex.first == -1)

View file

@ -45,7 +45,7 @@ void CSMTools::RegionCheckStage::perform (int stage, CSMDoc::Messages& messages)
for (const ESM::Region::SoundRef& sound : region.mSoundList) for (const ESM::Region::SoundRef& sound : region.mSoundList)
{ {
if (sound.mChance > 100) if (sound.mChance > 100)
messages.add(id, "Chance of '" + sound.mSound.toString() + "' sound to play is over 100 percent", "", CSMDoc::Message::Severity_Warning); messages.add(id, "Chance of '" + sound.mSound + "' sound to play is over 100 percent", "", CSMDoc::Message::Severity_Warning);
} }
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view

View file

@ -538,7 +538,7 @@ namespace CSMWorld
for (auto& item : npc.mInventory.mList) for (auto& item : npc.mInventory.mList)
{ {
if (item.mCount <= 0) continue; if (item.mCount <= 0) continue;
std::string itemId = item.mItem.toString(); std::string itemId = item.mItem;
addNpcItem(itemId, data); addNpcItem(itemId, data);
} }
} }

View file

@ -396,7 +396,7 @@ namespace CSMWorld
ESM::Region::SoundRef soundRef = soundList[subRowIndex]; ESM::Region::SoundRef soundRef = soundList[subRowIndex];
switch (subColIndex) switch (subColIndex)
{ {
case 0: return QString(soundRef.mSound.toString().c_str()); case 0: return QString(soundRef.mSound.c_str());
case 1: return soundRef.mChance; case 1: return soundRef.mChance;
default: throw std::runtime_error("Region sounds subcolumn index out of range"); default: throw std::runtime_error("Region sounds subcolumn index out of range");
} }

View file

@ -1257,7 +1257,7 @@ namespace CSMWorld
switch (subColIndex) switch (subColIndex)
{ {
case 0: return QString::fromUtf8(content.mItem.toString().c_str()); case 0: return QString::fromUtf8(content.mItem.c_str());
case 1: return content.mCount; case 1: return content.mCount;
default: default:
throw std::runtime_error("Trying to access non-existing column in the nested table!"); throw std::runtime_error("Trying to access non-existing column in the nested table!");

View file

@ -924,7 +924,7 @@ namespace MWSound
{ {
if(r - pos < sndref.mChance) if(r - pos < sndref.mChance)
{ {
playSound(sndref.mSound.toString(), 1.0f, 1.0f); playSound(sndref.mSound, 1.0f, 1.0f);
break; break;
} }
pos += sndref.mChance; pos += sndref.mChance;

View file

@ -495,7 +495,7 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const std::
for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end(); for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end();
++iter) ++iter)
{ {
std::string id = Misc::StringUtils::lowerCase(iter->mItem.toString()); std::string id = Misc::StringUtils::lowerCase(iter->mItem);
addInitialItem(id, owner, iter->mCount); addInitialItem(id, owner, iter->mCount);
} }
@ -626,10 +626,10 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW
if (it->mCount >= 0) if (it->mCount >= 0)
continue; continue;
std::string itemOrList = Misc::StringUtils::lowerCase(it->mItem.toString()); std::string itemOrList = Misc::StringUtils::lowerCase(it->mItem);
//If it's levelled list, restock if there's need to do so. //If it's levelled list, restock if there's need to do so.
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().search(it->mItem.toString())) if (MWBase::Environment::get().getWorld()->getStore().get<ESM::ItemLevList>().search(it->mItem))
{ {
std::map<std::string, int>::iterator listInMap = allowedForReplace.find(itemOrList); std::map<std::string, int>::iterator listInMap = allowedForReplace.find(itemOrList);

View file

@ -9,8 +9,10 @@ namespace ESM
void InventoryList::add(ESMReader &esm) void InventoryList::add(ESMReader &esm)
{ {
esm.getSubHeader();
ContItem ci; ContItem ci;
esm.getHT(ci, 36); esm.getT(ci.mCount);
ci.mItem.assign(esm.getString(32));
mList.push_back(ci); mList.push_back(ci);
} }
@ -18,7 +20,10 @@ namespace ESM
{ {
for (std::vector<ContItem>::const_iterator it = mList.begin(); it != mList.end(); ++it) for (std::vector<ContItem>::const_iterator it = mList.begin(); it != mList.end(); ++it)
{ {
esm.writeHNT("NPCO", *it, 36); esm.startSubRecord("NPCO");
esm.writeT(it->mCount);
esm.writeFixedSizeString(it->mItem, 32);
esm.endRecord("NPCO");
} }
} }

View file

@ -19,7 +19,7 @@ class ESMWriter;
struct ContItem struct ContItem
{ {
int mCount; int mCount;
NAME32 mItem; std::string mItem;
}; };
/// InventoryList, NPCO subrecord /// InventoryList, NPCO subrecord

View file

@ -62,8 +62,10 @@ namespace ESM
break; break;
case ESM::FourCC<'S','N','A','M'>::value: case ESM::FourCC<'S','N','A','M'>::value:
{ {
esm.getSubHeader();
SoundRef sr; SoundRef sr;
esm.getHT(sr, 33); sr.mSound.assign(esm.getString(32));
esm.getT(sr.mChance);
mSoundList.push_back(sr); mSoundList.push_back(sr);
break; break;
} }
@ -103,7 +105,10 @@ namespace ESM
esm.writeHNT("CNAM", mMapColor); esm.writeHNT("CNAM", mMapColor);
for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it) for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it)
{ {
esm.writeHNT<SoundRef>("SNAM", *it); esm.startSubRecord("SNAM");
esm.writeFixedSizeString(it->mSound, 32);
esm.writeT(it->mChance);
esm.endRecord("NPCO");
} }
} }

View file

@ -37,7 +37,7 @@ struct Region
// Reference to a sound that is played randomly in this region // Reference to a sound that is played randomly in this region
struct SoundRef struct SoundRef
{ {
NAME32 mSound; std::string mSound;
unsigned char mChance; unsigned char mChance;
}; // 33 bytes }; // 33 bytes
#pragma pack(pop) #pragma pack(pop)

View file

@ -77,10 +77,10 @@ namespace ESM
{ {
case ESM::FourCC<'S','C','H','D'>::value: case ESM::FourCC<'S','C','H','D'>::value:
{ {
SCHD data; esm.getSubHeader();
esm.getHT(data, 52); mId = esm.getString(32);
mData = data.mData; esm.getT(mData);
mId = data.mName.toString();
hasHeader = true; hasHeader = true;
break; break;
} }
@ -131,13 +131,10 @@ namespace ESM
for (std::vector<std::string>::const_iterator it = mVarNames.begin(); it != mVarNames.end(); ++it) for (std::vector<std::string>::const_iterator it = mVarNames.begin(); it != mVarNames.end(); ++it)
varNameString.append(*it); varNameString.append(*it);
SCHD data; esm.startSubRecord("SCHD");
memset(&data, 0, sizeof(data)); esm.writeFixedSizeString(mId, 32);
esm.writeT(mData, 20);
data.mData = mData; esm.endRecord("SCHD");
data.mName.assign(mId);
esm.writeHNT("SCHD", data, 52);
if (isDeleted) if (isDeleted)
{ {

View file

@ -31,7 +31,7 @@ public:
}; };
struct SCHD struct SCHD
{ {
NAME32 mName; std::string mName;
Script::SCHDstruct mData; Script::SCHDstruct mData;
}; // 52 bytes }; // 52 bytes