mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added error handling and debug printing to the medical extension
This commit is contained in:
parent
81f427ad82
commit
0c25f9d8fb
@ -39,26 +39,47 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
|||||||
std::vector<std::string> arguments = parseExtensionInput(function);
|
std::vector<std::string> arguments = parseExtensionInput(function);
|
||||||
if (arguments.size() > 0)
|
if (arguments.size() > 0)
|
||||||
{
|
{
|
||||||
std::string command = arguments.at(0);
|
try {
|
||||||
arguments.erase(arguments.begin());
|
std::string command = arguments.at(0);
|
||||||
|
arguments.erase(arguments.begin());
|
||||||
if (command == "addInjuryType") {
|
|
||||||
returnValue = ace::medical::handleDamage::GetInstance().AddInjuryType(arguments);
|
if (command == "addInjuryType") {
|
||||||
}
|
returnValue = ace::medical::handleDamage::GetInstance().AddInjuryType(arguments);
|
||||||
else if (command == "addDamageType") {
|
}
|
||||||
returnValue = ace::medical::handleDamage::GetInstance().AddDamageType(arguments);
|
else if (command == "addDamageType") {
|
||||||
}
|
returnValue = ace::medical::handleDamage::GetInstance().AddDamageType(arguments);
|
||||||
else if (command == "HandleDamageWounds") {
|
}
|
||||||
if (arguments.size() >= 4) {
|
else if (command == "HandleDamageWounds") {
|
||||||
std::string selectionName = arguments.at(0);
|
if (arguments.size() >= 4) {
|
||||||
double amountOfDamage = std::stod(arguments.at(1));
|
std::string selectionName = arguments.at(0);
|
||||||
std::string typeOfDamage = arguments.at(2);
|
double amountOfDamage = std::stod(arguments.at(1));
|
||||||
int woundID = std::stoi(arguments.at(3));
|
std::string typeOfDamage = arguments.at(2);
|
||||||
returnValue = ace::medical::handleDamage::GetInstance().HandleDamageWounds(selectionName, amountOfDamage, typeOfDamage, woundID);
|
int woundID = std::stoi(arguments.at(3));
|
||||||
|
returnValue = ace::medical::handleDamage::GetInstance().HandleDamageWounds(selectionName, amountOfDamage, typeOfDamage, woundID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (command == "ConfigComplete") {
|
||||||
|
ace::medical::handleDamage::GetInstance().FinalizeDefinitions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command == "ConfigComplete") {
|
catch (std::exception e) {
|
||||||
ace::medical::handleDamage::GetInstance().FinalizeDefinitions();
|
std::stringstream debugreturn;
|
||||||
|
debugreturn << "diag_log format['ACE3 ERROR - Medical Extension: Something went wrong. Input: '];";
|
||||||
|
int i = 0;
|
||||||
|
for (auto arg : arguments) {
|
||||||
|
debugreturn << "diag_log format[' arg " << i++ << ":" << arg << "'];";
|
||||||
|
}
|
||||||
|
debugreturn << "diag_log format['Exception: " << e.what() << "'];";
|
||||||
|
returnValue = debugreturn.str();
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
std::stringstream debugreturn;
|
||||||
|
debugreturn << "diag_log format['ACE3 ERROR - Medical Extension: Something went wrong. Input: '];";
|
||||||
|
int i = 0;
|
||||||
|
for (auto arg : arguments) {
|
||||||
|
debugreturn << "diag_log format[' arg " << i++ << ":" << arg << "'];";
|
||||||
|
}
|
||||||
|
returnValue = debugreturn.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strncpy(output, returnValue.c_str(), outputSize);
|
strncpy(output, returnValue.c_str(), outputSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user