From 7c1e417f9a4514b1e35cce760ccb58e7d8d2f128 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Fri, 6 Apr 2012 21:14:52 +0200 Subject: [PATCH] Niceify-ing it (Yes, that's a word) --- components/esm/loadacti.cpp | 5 +---- components/esm/loadalch.cpp | 9 +++------ components/esm/loadappa.cpp | 3 +-- components/esm/loadarmo.cpp | 15 +++++---------- components/esm/loadbook.cpp | 15 +++++---------- components/esm/loadbsgn.cpp | 6 ++---- components/esm/loadcell.cpp | 9 +++------ components/esm/loadclas.cpp | 3 +-- components/esm/loadclot.cpp | 12 ++++-------- components/esm/loadcont.cpp | 6 ++---- components/esm/loadcrea.cpp | 9 +++------ components/esm/loaddoor.cpp | 12 ++++-------- components/esm/loadinfo.cpp | 3 +-- components/esm/loadingr.cpp | 6 ++---- components/esm/loadligh.cpp | 12 ++++-------- components/esm/loadlocks.cpp | 6 ++---- 16 files changed, 43 insertions(+), 88 deletions(-) diff --git a/components/esm/loadacti.cpp b/components/esm/loadacti.cpp index a5e59a006..b62a46158 100644 --- a/components/esm/loadacti.cpp +++ b/components/esm/loadacti.cpp @@ -12,9 +12,6 @@ void Activator::save(ESMWriter &esm) { esm.writeHNString("MODL", model); esm.writeHNString("FNAM", name); - if (!script.empty()) - { - esm.writeHNString("SCRI", script); - } + esm.writeHNOString("SCRI", script); } } diff --git a/components/esm/loadalch.cpp b/components/esm/loadalch.cpp index 7db9ef9ac..e5d3d8e27 100644 --- a/components/esm/loadalch.cpp +++ b/components/esm/loadalch.cpp @@ -14,12 +14,9 @@ void Potion::load(ESMReader &esm) void Potion::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!icon.empty()) - esm.writeHNString("TEXT", icon); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!name.empty()) - esm.writeHNString("FNAM", name); + esm.writeHNOString("TEXT", icon); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("FNAM", name); esm.writeHNT("ALDT", data, 12); effects.save(esm); } diff --git a/components/esm/loadappa.cpp b/components/esm/loadappa.cpp index 17cc22087..6eb164ec2 100644 --- a/components/esm/loadappa.cpp +++ b/components/esm/loadappa.cpp @@ -15,8 +15,7 @@ void Apparatus::save(ESMWriter &esm) esm.writeHNString("MODL", model); esm.writeHNString("FNAM", name); esm.writeHNT("AADT", data, 16); - if (!script.empty()) - esm.writeHNString("SCRI", script); + esm.writeHNOString("SCRI", script); esm.writeHNString("ITEX", icon); } } diff --git a/components/esm/loadarmo.cpp b/components/esm/loadarmo.cpp index 14cb056bf..aecfc7e92 100644 --- a/components/esm/loadarmo.cpp +++ b/components/esm/loadarmo.cpp @@ -20,10 +20,8 @@ void PartReferenceList::save(ESMWriter &esm) for (std::vector::iterator it = parts.begin(); it != parts.end(); ++it) { esm.writeHT(it->part); - if (!it->male.empty()) - esm.writeHNString("BNAM", it->male); - if (!it->female.empty()) - esm.writeHNString("CNAM", it->female); + esm.writeHNOString("BNAM", it->male); + esm.writeHNOString("CNAM", it->female); } } @@ -42,14 +40,11 @@ void Armor::save(ESMWriter &esm) { esm.writeHNString("MODL", model); esm.writeHNString("FNAM", name); - if (!script.empty()) - esm.writeHNString("SCRI", script); + esm.writeHNOString("SCRI", script); esm.writeHNT("AODT", data, 24); - if (!icon.empty()) - esm.writeHNString("ITEX", icon); + esm.writeHNOString("ITEX", icon); parts.save(esm); - if (!enchant.empty()) - esm.writeHNString("ENAM", enchant); + esm.writeHNOString("ENAM", enchant); } } diff --git a/components/esm/loadbook.cpp b/components/esm/loadbook.cpp index 829b7d297..ed21d71e1 100644 --- a/components/esm/loadbook.cpp +++ b/components/esm/loadbook.cpp @@ -16,17 +16,12 @@ void Book::load(ESMReader &esm) void Book::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!name.empty()) - esm.writeHNString("FNAM", name); + esm.writeHNOString("FNAM", name); esm.writeHNT("BKDT", data, 20); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!icon.empty()) - esm.writeHNString("ITEX", icon); - if (!text.empty()) - esm.writeHNString("TEXT", text); - if (!enchant.empty()) - esm.writeHNString("ENAM", enchant); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("ITEX", icon); + esm.writeHNOString("TEXT", text); + esm.writeHNOString("ENAM", enchant); } } diff --git a/components/esm/loadbsgn.cpp b/components/esm/loadbsgn.cpp index 9488f355f..de76e1949 100644 --- a/components/esm/loadbsgn.cpp +++ b/components/esm/loadbsgn.cpp @@ -14,10 +14,8 @@ void BirthSign::load(ESMReader &esm) void BirthSign::save(ESMWriter &esm) { esm.writeHNString("FNAM", name); - if (!texture.empty()) - esm.writeHNString("TNAM", texture); - if (!description.empty()) - esm.writeHNString("DESC", description); + esm.writeHNOString("TNAM", texture); + esm.writeHNOString("DESC", description); powers.save(esm); } diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 8b3d09183..f6db5c70c 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -100,18 +100,15 @@ void Cell::save(ESMWriter &esm) { if (water != 0) esm.writeHNT("WHGT", water); + if (data.flags & QuasiEx) - { - if (!region.empty()) - esm.writeHNString("RGNN", region); - } + esm.writeHNOString("RGNN", region); else esm.writeHNT("AMBI", ambi, 16); } else { - if (!region.empty()) - esm.writeHNString("RGNN", region); + esm.writeHNOString("RGNN", region); if (mapColor != 0) esm.writeHNT("NAM5", mapColor); } diff --git a/components/esm/loadclas.cpp b/components/esm/loadclas.cpp index 05cbfe709..e13442dcf 100644 --- a/components/esm/loadclas.cpp +++ b/components/esm/loadclas.cpp @@ -29,8 +29,7 @@ void Class::save(ESMWriter &esm) { esm.writeHNString("FNAM", name); esm.writeHNT("CLDT", data, 60); - if (!description.empty()) - esm.writeHNString("DESC", description); + esm.writeHNOString("DESC", description); } } diff --git a/components/esm/loadclot.cpp b/components/esm/loadclot.cpp index b1c678348..cd884d206 100644 --- a/components/esm/loadclot.cpp +++ b/components/esm/loadclot.cpp @@ -19,19 +19,15 @@ void Clothing::load(ESMReader &esm) void Clothing::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!name.empty()) - esm.writeHNString("FNAM", name); + esm.writeHNOString("FNAM", name); esm.writeHNT("CTDT", data, 12); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!icon.empty()) - esm.writeHNString("ITEX", icon); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("ITEX", icon); parts.save(esm); - if (!enchant.empty()) - esm.writeHNString("ENAM", enchant); + esm.writeHNOString("ENAM", enchant); } } diff --git a/components/esm/loadcont.cpp b/components/esm/loadcont.cpp index ba90e52ce..176c4ec05 100644 --- a/components/esm/loadcont.cpp +++ b/components/esm/loadcont.cpp @@ -41,13 +41,11 @@ void Container::load(ESMReader &esm) void Container::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!name.empty()) - esm.writeHNString("FNAM", name); + esm.writeHNOString("FNAM", name); esm.writeHNT("CNDT", weight, 4); esm.writeHNT("FLAG", flags, 4); - if (!script.empty()) - esm.writeHNString("SCRI", script); + esm.writeHNOString("SCRI", script); inventory.save(esm); } diff --git a/components/esm/loadcrea.cpp b/components/esm/loadcrea.cpp index 0cab2761e..f5ffb694f 100644 --- a/components/esm/loadcrea.cpp +++ b/components/esm/loadcrea.cpp @@ -40,12 +40,9 @@ void Creature::load(ESMReader &esm, const std::string& id) void Creature::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!original.empty()) - esm.writeHNString("CNAM", original); - if (!name.empty()) - esm.writeHNString("FNAM", name); - if (!script.empty()) - esm.writeHNString("SCRI", script); + esm.writeHNOString("CNAM", original); + esm.writeHNOString("FNAM", name); + esm.writeHNOString("SCRI", script); esm.writeHNT("NPDT", data, 96); esm.writeHNT("FLAG", flags); if (scale != 1.0) diff --git a/components/esm/loaddoor.cpp b/components/esm/loaddoor.cpp index 513eac753..45af407e1 100644 --- a/components/esm/loaddoor.cpp +++ b/components/esm/loaddoor.cpp @@ -14,14 +14,10 @@ void Door::load(ESMReader &esm) void Door::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!name.empty()) - esm.writeHNString("FNAM", name); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!openSound.empty()) - esm.writeHNString("SNAM", openSound); - if (!closeSound.empty()) - esm.writeHNString("ANAM", closeSound); + esm.writeHNOString("FNAM", name); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("SNAM", openSound); + esm.writeHNOString("ANAM", closeSound); } } diff --git a/components/esm/loadinfo.cpp b/components/esm/loadinfo.cpp index c240aba87..63b3fe3a2 100644 --- a/components/esm/loadinfo.cpp +++ b/components/esm/loadinfo.cpp @@ -156,8 +156,7 @@ void DialInfo::save(ESMWriter &esm) } } - if (!resultScript.empty()) - esm.writeHNString("BNAM", resultScript); + esm.writeHNOString("BNAM", resultScript); switch(questStatus) { diff --git a/components/esm/loadingr.cpp b/components/esm/loadingr.cpp index b71f6f13d..b8b8aea06 100644 --- a/components/esm/loadingr.cpp +++ b/components/esm/loadingr.cpp @@ -16,10 +16,8 @@ void Ingredient::save(ESMWriter &esm) esm.writeHNString("MODL", model); esm.writeHNString("FNAM", name); esm.writeHNT("IRDT", data, 56); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!icon.empty()) - esm.writeHNString("ITEX", script); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("ITEX", script); } } diff --git a/components/esm/loadligh.cpp b/components/esm/loadligh.cpp index b7530eb6c..2b1d37461 100644 --- a/components/esm/loadligh.cpp +++ b/components/esm/loadligh.cpp @@ -16,15 +16,11 @@ void Light::load(ESMReader &esm) void Light::save(ESMWriter &esm) { esm.writeHNString("MODL", model); - if (!name.empty()) - esm.writeHNString("FNAM", name); - if (!icon.empty()) - esm.writeHNString("ITEX", icon); + esm.writeHNOString("FNAM", name); + esm.writeHNOString("ITEX", icon); esm.writeHNT("LHDT", data, 24); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!sound.empty()) - esm.writeHNString("SNAM", sound); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("SNAM", sound); } } diff --git a/components/esm/loadlocks.cpp b/components/esm/loadlocks.cpp index b9f1d35ca..ff01aac37 100644 --- a/components/esm/loadlocks.cpp +++ b/components/esm/loadlocks.cpp @@ -44,10 +44,8 @@ void Tool::save(ESMWriter &esm) } esm.writeT(data, 16); - if (!script.empty()) - esm.writeHNString("SCRI", script); - if (!icon.empty()) - esm.writeHNString("ITEX", icon); + esm.writeHNOString("SCRI", script); + esm.writeHNOString("ITEX", icon); }