Skip to content

Commit

Permalink
Fix Visual C errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpas committed May 22, 2019
1 parent a42636b commit fbcad40
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions dmc/src/DmsInterpretationModel/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "../DmsObjects/DmsScenario.h"

#include "lib/rang.hpp"
#undef max

class RuntimeException: public std::exception {
public:
Expand Down
2 changes: 1 addition & 1 deletion dmc/src/DmsInterpretationModel/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Resolver::resolve() {
if (enemy == nullptr) {
throw ResolveException(enemy_field.get_name(), ResolveException::VariableUndefined);
}
encounter->addSpawner(static_cast<DmsEnemy*>(enemy->get_value()), enemy_field.get_value());
encounter->add_spawner(static_cast<DmsEnemy*>(enemy->get_value()), static_cast<int>(enemy_field.get_value()));
}
}

Expand Down
8 changes: 4 additions & 4 deletions dmc/src/DmsObjects/DmsCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ DmsCharacter::DmsCharacter(DmsFieldScope *enclosing_scope)

bool DmsCharacter::verify() {
if (field_scope.get_field<float>("hit_chance") != nullptr) {
if (field_scope.get_field<float>("hit_chance")->get_value() > 1.0) {
field_scope.set_field_value("hit_chance", 1.0, true);
} else if (field_scope.get_field<float>("hit_chance")->get_value() < 0.0) {
field_scope.set_field_value("hit_chance", 0.01, true);
if (field_scope.get_field<float>("hit_chance")->get_value() > 1.0f) {
field_scope.set_field_value("hit_chance", 1.0f, true);
} else if (field_scope.get_field<float>("hit_chance")->get_value() < 0.0f) {
field_scope.set_field_value("hit_chance", 0.01f, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dmc/src/DmsObjects/DmsEncounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool DmsEncounter::verify() {
return true && field_scope.get_field<std::string>("name") != nullptr;
}

void DmsEncounter::addSpawner(DmsEnemy *enemy, int amount) {
void DmsEncounter::add_spawner(DmsEnemy *enemy, int amount) {
enemies.push_back(new DmsDuplicator<DmsEnemy>(enemy, amount));
}

Expand Down
2 changes: 1 addition & 1 deletion dmc/src/DmsObjects/DmsEncounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DmsEncounter: public DmsObject {
~DmsEncounter();

bool verify();
void addSpawner(DmsEnemy *enemy, int amount);
void add_spawner(DmsEnemy *enemy, int amount);
std::vector<DmsDuplicator<DmsEnemy>*> getSpawners() { return enemies; }
std::string serialize();

Expand Down
2 changes: 1 addition & 1 deletion dmc/src/DmsObjects/DmsScenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool DmsScenario::verify() {
return true && field_scope.get_field<std::string>("name") != nullptr;
}

void DmsScenario::addEncounter(DmsEncounter *encounter, int amount) {
void DmsScenario::add_encounter(DmsEncounter *encounter, int amount) {
encounters.push_back(new DmsDuplicator<DmsEncounter>(encounter, amount));
}

Expand Down
2 changes: 1 addition & 1 deletion dmc/src/DmsObjects/DmsScenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DmsScenario: public DmsObject {
~DmsScenario();

bool verify();
void addEncounter(DmsEncounter *encounter, int amount);
void add_encounter(DmsEncounter *encounter, int amount);
std::vector<DmsDuplicator<DmsEncounter>*> getEncounters() { return encounters; }
std::string serialize();

Expand Down
36 changes: 18 additions & 18 deletions dmc/src/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Parser {
field = game->constants->field_scope.get_field<std::string>(token.lexem());
}

float new_value;
float new_value = 0.0f;
if (field) {
//value = field->get_value();
token = scanner.next_token();
Expand Down Expand Up @@ -277,10 +277,10 @@ class Parser {

scope = current;
current = nullptr;
bool isEncounter = false;
bool is_encounter = false;
if (scope == game->encounters) {
set_current(new DmsEncounter());
isEncounter = true;
is_encounter = true;
} else if (scope == game->scenarios) {
set_current(new DmsScenario());
} else {
Expand All @@ -294,7 +294,7 @@ class Parser {
if (token.lexem() == "has") {
token = scanner.next_token();

if (!THING(isEncounter)) return Error;
if (!THING(is_encounter)) return Error;

scope->field_scope.set_field_value(lexem, current, true);
current = scope;
Expand All @@ -309,16 +309,16 @@ class Parser {
return Error;
}

bool THING(bool isEncounter) {
bool THING(bool is_encounter) {
if (token.type() == Token::Identifier) {
std::string occurrence_name = token.lexem();

token = scanner.next_token();
if (!OCCURRENCES(occurrence_name, isEncounter)) return Error;
if (!OCCURRENCES(occurrence_name, is_encounter)) return Error;

if (token.lexem() == "+") {
token = scanner.next_token();
return THING(isEncounter);
return THING(is_encounter);
} else {
return Ok;
}
Expand All @@ -327,12 +327,12 @@ class Parser {
return Error;
}

bool OCCURRENCES(std::string occurrence_name, bool isEncounter) {
bool OCCURRENCES(std::string occurrence_name, bool is_encounter) {
if (token.lexem() == "*") {

token = scanner.next_token();
if (token.type() == Token::Float) {
if (isEncounter) {
if (is_encounter) {
// Encounter
float temp = 0;
DmsField<float> *previous = current->field_scope.get_field<float>(occurrence_name);
Expand All @@ -348,7 +348,7 @@ class Parser {
}
DmsEncounter *encounter = static_cast<DmsEncounter*>(field->get_value());

static_cast<DmsScenario*>(current)->addEncounter(encounter, std::stof(token.lexem()));
static_cast<DmsScenario*>(current)->add_encounter(encounter, std::stoi(token.lexem()));
}


Expand All @@ -359,7 +359,7 @@ class Parser {
}
}

if (isEncounter) {
if (is_encounter) {
// Encounter
current->field_scope.set_field_value(occurrence_name, 1, true);
} else {
Expand All @@ -370,7 +370,7 @@ class Parser {
}
DmsEncounter *encounter = static_cast<DmsEncounter*>(field->get_value());

static_cast<DmsScenario*>(current)->addEncounter(encounter, 1);
static_cast<DmsScenario*>(current)->add_encounter(encounter, 1);
}

return Ok;
Expand Down Expand Up @@ -405,8 +405,8 @@ class Parser {
std::string sign = token.lexem();
token = scanner.next_token();

float new_in_value;
float new_out_value;
float new_in_value = 0.0f;
float new_out_value = 0.0f;
bool ret = T(new_in_value);
ret = ret && EE(new_in_value, new_out_value);
if (sign == "-") {
Expand All @@ -432,8 +432,8 @@ class Parser {
std::string sign = token.lexem();
token = scanner.next_token();

float new_in_value;
float new_out_value;
float new_in_value = 0.0f;
float new_out_value = 0.0f;
bool ret = F(new_in_value);
ret = ret && TT(new_in_value, new_out_value);

Expand All @@ -442,9 +442,9 @@ class Parser {
} else if (sign == "/") {
out_value = in_value / new_out_value;
} else if (sign == "^") {
out_value = pow(in_value, new_out_value);
out_value = std::pow(in_value, new_out_value);
} else if (sign == "%") {
out_value = int(in_value) % int(new_out_value);
out_value = std::fmod(in_value, new_out_value);;
}

return ret;
Expand Down

0 comments on commit fbcad40

Please sign in to comment.