From a48b6c94266f87c7889c44ea864a63f1de4beab8 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Thu, 14 May 2015 17:36:58 +0200 Subject: [PATCH] Fixed namespace issues. Removed static --- extensions/medical/DamageType.cpp | 6 +- extensions/medical/InjuryType.cpp | 5 +- extensions/medical/OpenWound.cpp | 8 +- extensions/medical/handleDamage.cpp | 175 ++++++++++++++-------------- extensions/medical/handleDamage.h | 22 ++-- 5 files changed, 107 insertions(+), 109 deletions(-) diff --git a/extensions/medical/DamageType.cpp b/extensions/medical/DamageType.cpp index 2b3a5b2e61..aeccfa6896 100644 --- a/extensions/medical/DamageType.cpp +++ b/extensions/medical/DamageType.cpp @@ -1,13 +1,11 @@ #include "DamageType.h" -using namespace ace::medical; - -injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, double minDamage, double maxDamage) +ace::medical::injuries::DamageType::DamageType(std::string aTypeName, double minimalLethalDamage, double minDamage, double maxDamage) : typeName(aTypeName), minLethalDamage(minimalLethalDamage), minDamageThreshold(minDamage), maxDamageThreshold(maxDamage) { } -injuries::DamageType::~DamageType() +ace::medical::injuries::DamageType::~DamageType() { } diff --git a/extensions/medical/InjuryType.cpp b/extensions/medical/InjuryType.cpp index cca9b20fd3..a959e5dd70 100644 --- a/extensions/medical/InjuryType.cpp +++ b/extensions/medical/InjuryType.cpp @@ -1,14 +1,13 @@ #include "InjuryType.h" #include "DamageType.h" -using namespace ace::medical; -injuries::InjuryType::InjuryType(signed int anId, const std::string& aClassname, std::vector& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector& possibleCauses, std::string& aDisplayname) +ace::medical::injuries::InjuryType::InjuryType(signed int anId, const std::string& aClassname, std::vector& allowedSelections, double theBloodLoss, double thePain, double minimumDamage, double maximumDamage, std::vector& possibleCauses, std::string& aDisplayname) : ID(anId), className(aClassname), selections(allowedSelections), bloodLoss(theBloodLoss), pain(thePain), minDamage(minimumDamage), maxDamage(maximumDamage), causes(possibleCauses), displayName(aDisplayname) { } -injuries::InjuryType::~InjuryType() +ace::medical::injuries::InjuryType::~InjuryType() { } diff --git a/extensions/medical/OpenWound.cpp b/extensions/medical/OpenWound.cpp index 268929fc92..6675704f03 100644 --- a/extensions/medical/OpenWound.cpp +++ b/extensions/medical/OpenWound.cpp @@ -1,17 +1,15 @@ #include "OpenWound.h" #include -using namespace ace::medical; - -injuries::OpenWound::OpenWound(double anID, double aBodyPart, double bloodloss) : classID(anID), bodyPart(aBodyPart), bloodlossRate(bloodloss) +ace::medical::injuries::OpenWound::OpenWound(double anID, double aBodyPart, double bloodloss) : classID(anID), bodyPart(aBodyPart), bloodlossRate(bloodloss) { } -injuries::OpenWound::~OpenWound() +ace::medical::injuries::OpenWound::~OpenWound() { } -std::string injuries::OpenWound::AsString() +std::string ace::medical::injuries::OpenWound::AsString() { std::stringstream stream; stream << classID << "," << bodyPart << "," << 1 << "," << bloodlossRate; diff --git a/extensions/medical/handleDamage.cpp b/extensions/medical/handleDamage.cpp index 1a6612c107..8ee929165e 100644 --- a/extensions/medical/handleDamage.cpp +++ b/extensions/medical/handleDamage.cpp @@ -4,91 +4,94 @@ #include "InjuryType.h" #include -using namespace ace::medical; +namespace ace { + namespace medical { -handleDamage::handleDamage() -{ -} - - -handleDamage::~handleDamage() -{ -} - -/* static */ std::vector handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage) -{ - std::vector wounds; - int selectionN = SelectionToNumber(selectionName); - if (selectionN >= 0) - { - std::vector> injuryTypeInfo = GetInjuryInfoFor(typeOfDamage); - } - - return wounds; -} - -/* static */ void handleDamage::AddDamageType(const std::vector& input) -{ - if (input.size() == 4) - { - std::string typeName = input[0]; - double minimalLethalDamage = std::stod(input[1]); - double minDamageThreshold = std::stod(input[2]); - double maxDamageThreshold = std::stod(input[3]); - - std::shared_ptr type(new injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, maxDamageThreshold)); - damageTypes.push_back(type); - } -} - -/* static */ void handleDamage::AddInjuryType(const std::vector& input) -{ - if (input.size() == 9) - { - // TODO parse arrays from string input - - int ID = std::stod(input[0]); - std::string className = input[1]; - std::vector allowedSelections; // input[2]; - double bloodLoss = std::stod(input[3]); - double pain = std::stod(input[4]); - - double minDamage = std::stod(input[5]); - double maxDamage = std::stod(input[6]); - std::vector possibleCauses; // input[7]; - std::string displayName = input[8]; - - std::shared_ptr type(new injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName)); - injuryTypes.push_back(type); - } -} - -/* static */ void handleDamage::FinalizeDefinitions() -{ - // We are finding all possible injuries for a specific damage type here, so we don't have to figure that out at a later stage. - for each (std::shared_ptr damageType in damageTypes) - { - for each (std::shared_ptr injuryType in injuryTypes) - { - if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end()) - { - damageType->possibleInjuries.push_back(injuryType); - } - } - } -} - -/* static */ int SelectionToNumber(const std::string& selectionName) -{ - // TODO use dynamic selections instead - std::vector selections = {"head", "body", "hand_l", "hand_r", "leg_l", "leg_r"}; - std::vector::iterator it = find(selections.begin(), selections.end(), selectionName); - if (it != selections.end()) - { - return it - selections.begin(); - } - else - { - return -1; // TODO throw exception - } + handleDamage::handleDamage() + { + } + + + handleDamage::~handleDamage() + { + } + + /* static */ std::vector handleDamage::HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage) + { + std::vector wounds; + int selectionN = SelectionToNumber(selectionName); + if (selectionN >= 0) + { + // std::vector> injuryTypeInfo = GetInjuryInfoFor(typeOfDamage); + } + + return wounds; + } + + /* static */ void handleDamage::AddDamageType(const std::vector& input) + { + if (input.size() == 4) + { + std::string typeName = input[0]; + double minimalLethalDamage = std::stod(input[1]); + double minDamageThreshold = std::stod(input[2]); + double maxDamageThreshold = std::stod(input[3]); + + std::shared_ptr type(new ace::medical::injuries::DamageType(typeName, minimalLethalDamage, minDamageThreshold, maxDamageThreshold)); + damageTypes.push_back(type); + } + } + + void handleDamage::AddInjuryType(const std::vector& input) + { + if (input.size() == 9) + { + // TODO parse arrays from string input + + int ID = std::stod(input[0]); + std::string className = input[1]; + std::vector allowedSelections; // input[2]; + double bloodLoss = std::stod(input[3]); + double pain = std::stod(input[4]); + + double minDamage = std::stod(input[5]); + double maxDamage = std::stod(input[6]); + std::vector possibleCauses; // input[7]; + std::string displayName = input[8]; + + std::shared_ptr type(new ace::medical::injuries::InjuryType(ID, className, allowedSelections, bloodLoss, pain, minDamage, maxDamage, possibleCauses, displayName)); + injuryTypes.push_back(type); + } + } + + void handleDamage::FinalizeDefinitions() + { + // We are finding all possible injuries for a specific damage type here, so we don't have to figure that out at a later stage. + for each (std::shared_ptr damageType in damageTypes) + { + for each (std::shared_ptr injuryType in injuryTypes) + { + if (find(injuryType->causes.begin(), injuryType->causes.end(), damageType->typeName) != injuryType->causes.end()) + { + damageType->possibleInjuries.push_back(injuryType); + } + } + } + } + + int handleDamage::SelectionToNumber(const std::string& selectionName) + { + // TODO use dynamic selections instead + std::vector selections = { "head", "body", "hand_l", "hand_r", "leg_l", "leg_r" }; + std::vector::iterator it = find(selections.begin(), selections.end(), selectionName); + if (it != selections.end()) + { + return it - selections.begin(); + } + else + { + return -1; // TODO throw exception + } + } + } } diff --git a/extensions/medical/handleDamage.h b/extensions/medical/handleDamage.h index 7e030f2b84..a74941c605 100644 --- a/extensions/medical/handleDamage.h +++ b/extensions/medical/handleDamage.h @@ -21,46 +21,46 @@ namespace ace { /** * */ - static std::vector HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage); + std::vector HandleDamageWounds(const std::string& selectionName, double amountOfDamage, const std::string& typeOfDamage); /** * */ - static void AddDamageType(const std::vector& sqfDamageTypeDefinition); + void AddDamageType(const std::vector& sqfDamageTypeDefinition); /** * */ - static void AddInjuryType(const std::vector& sqfInjuryDefinition); + void AddInjuryType(const std::vector& sqfInjuryDefinition); /** * */ - static std::string SetInjuryTypeData(const std::string& data); + //static std::string SetInjuryTypeData(const std::string& data); /** * */ - static int SelectionToNumber(const std::string& selectionName); + int SelectionToNumber(const std::string& selectionName); /** * */ - static std::vector> GetInjuryInfoFor(const std::string& damageType); + //static std::vector> GetInjuryInfoFor(const std::string& damageType); /** * */ - static void FinalizeDefinitions(); + void FinalizeDefinitions(); private: handleDamage(); - static std::vector> damageTypes; - static std::vector> injuryTypes; - static std::vector selections; - static std::vector hitPoints; + std::vector> damageTypes; + std::vector> injuryTypes; + std::vector selections; + std::vector hitPoints; }; } }