2015-05-03 22:02:39 +00:00
|
|
|
/*
|
|
|
|
* ace_medical.cpp
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Glowbal
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ace_common.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include "handleDamage.h"
|
2015-05-16 21:20:17 +00:00
|
|
|
#include "OpenWound.h"
|
2015-05-03 22:02:39 +00:00
|
|
|
|
|
|
|
extern "C" {
|
2015-05-03 22:32:44 +00:00
|
|
|
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
|
2015-05-03 22:02:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<std::string> parseExtensionInput(const std::string& input)
|
|
|
|
{
|
2015-05-03 22:32:44 +00:00
|
|
|
std::istringstream ss(input);
|
|
|
|
std::string token;
|
|
|
|
|
|
|
|
std::vector<std::string> output;
|
|
|
|
while (std::getline(ss, token, ',')) {
|
|
|
|
output.push_back(token);
|
|
|
|
}
|
|
|
|
return output;
|
2015-05-03 22:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
2015-05-03 22:32:44 +00:00
|
|
|
if (!strcmp(function, "version")) {
|
|
|
|
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-16 21:20:17 +00:00
|
|
|
std::string returnValue = "";
|
2015-05-03 22:32:44 +00:00
|
|
|
std::vector<std::string> arguments = parseExtensionInput(function);
|
2015-05-14 14:23:01 +00:00
|
|
|
if (arguments.size() > 0)
|
2015-05-03 22:32:44 +00:00
|
|
|
{
|
|
|
|
std::string command = arguments.at(0);
|
2015-05-16 21:20:17 +00:00
|
|
|
arguments.erase(arguments.begin());
|
|
|
|
|
2015-05-03 22:32:44 +00:00
|
|
|
if (command == "addInjuryType") {
|
2015-05-16 21:20:17 +00:00
|
|
|
returnValue = ace::medical::handleDamage::GetInstance().AddInjuryType(arguments);
|
2015-05-03 22:32:44 +00:00
|
|
|
}
|
|
|
|
else if (command == "addDamageType") {
|
2015-05-16 21:20:17 +00:00
|
|
|
returnValue = ace::medical::handleDamage::GetInstance().AddDamageType(arguments);
|
|
|
|
}
|
|
|
|
else if (command == "HandleDamageWounds") {
|
|
|
|
if (arguments.size() >= 4) {
|
|
|
|
std::string selectionName = arguments.at(0);
|
|
|
|
double amountOfDamage = std::stod(arguments.at(1));
|
|
|
|
std::string typeOfDamage = arguments.at(2);
|
|
|
|
int woundID = std::stoi(arguments.at(3));
|
|
|
|
returnValue = ace::medical::handleDamage::GetInstance().HandleDamageWounds(selectionName, amountOfDamage, typeOfDamage, woundID);
|
|
|
|
}
|
2015-05-03 22:32:44 +00:00
|
|
|
}
|
2015-05-16 21:20:17 +00:00
|
|
|
else if (command == "ConfigComplete") {
|
2015-05-17 07:48:59 +00:00
|
|
|
ace::medical::handleDamage::GetInstance().FinalizeDefinitions();
|
2015-05-03 22:32:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
strncpy(output, returnValue.c_str(), outputSize);
|
|
|
|
output[outputSize - 1] = '\0';
|
|
|
|
}
|
2015-05-03 22:02:39 +00:00
|
|
|
}
|
|
|
|
|