Nuke as many warnings as possible, and several globals as well

- Warnings completely suppressed for the included TinyXML and gzstream libraries
- Parentheses warnings are now errors, since there were several that looked like bugs
- Ditto for dangling else warnings

Some of these warnings were actually bugs:
- Town wandering monsters would have never spawned, because the code to do so was accidentally nested within a check for overall_mode == MODE_OUTDOORS
---> boe.monster.cpp, lines 105-137
- Monster's behaviour with respect to elemental fields did not correctly depend on their immunities (this is the same precedence issue Sylae messed up fixing in the Windows code)
---> boe.monsters.cpp, lines 345-359
- Display of damage blocked by armour appeared to be incorrect (needs verification)
---> boe.newgraph.cpp, line 1079
- Three-choice dialogs probably weren't dealing with unusual button types correctly, though that's a minor point since they aren't expected to use such buttons
This commit is contained in:
2014-12-04 06:16:40 -05:00
parent e7d8a6d848
commit 94d8717a0b
74 changed files with 611 additions and 637 deletions

View File

@@ -175,7 +175,7 @@ rectangle rect(location tl, location br){
return rectangle(tl,br);
}
rectangle rect(char top, char left, char bottom, char right){
rectangle rect(int top, int left, int bottom, int right) {
return rectangle(top, left, bottom, right);
}

View File

@@ -130,7 +130,7 @@ cCreature& cCreature::operator = (legacy::creature_data_type old){
return *this;
}
cMonster::cAttack::operator int(){
cMonster::cAttack::operator int() const {
return dice * 100 + sides;
}
@@ -140,7 +140,7 @@ cMonster::cAttack& cMonster::cAttack::operator=(int n){
return *this;
}
std::ostream& operator<<(std::ostream& out, cMonster::cAttack& att) {
std::ostream& operator<<(std::ostream& out, const cMonster::cAttack& att) {
out << int(att.dice) << 'd' << int(att.sides);
return out;
}
@@ -174,6 +174,7 @@ std::istream& operator >> (std::istream& in, eRace& e){
extern cUniverse univ;
extern cScenario scenario;
// TODO: Any setup where "x = x" does something is probably a bad idea...
cCreature& cCreature::operator = (const cCreature& other){ // replaces return_monster_template() from boe.monsters.cpp
id = other.id;
number = other.number;
@@ -216,6 +217,8 @@ cMonster::cAbility::operator std::string(){
std::ostringstream sout;
short i = 0;
switch(abil){
case MONST_NO_ABIL:
break;
case MONST_THROWS_DARTS:
sout << "Throws darts (" << extra1 << 'd' << extra2 << ')';
break;
@@ -472,7 +475,7 @@ cMonster::cAbility::operator std::string(){
sout << "Unusual ability";
break;
}
return "*ERROR INVALID ABILITY*";
return sout.str();
}
std::string cMonster::getAbil1Name() {
@@ -496,11 +499,11 @@ bool cMonster::hasAbil(eMonstAbil what, unsigned char* x1, unsigned char* x2){
return false;
}
void cMonster::writeTo(std::ostream& file) {
void cMonster::writeTo(std::ostream& /*file*/) {
// TODO: Implement this (low priority since only used for exported summons)
}
void cMonster::readFrom(std::istream& file) {
void cMonster::readFrom(std::istream& /*file*/) {
// TODO: Implement this (low priority since only used for exported summons)
}

View File

@@ -97,7 +97,7 @@ public:
struct cAttack{
unsigned char dice, sides, type;
// TODO: Remove the need for these operators by changing the code that uses them
operator int();
operator int() const;
cAttack& operator=(int n);
};
struct cAbility{
@@ -189,5 +189,5 @@ std::ostream& operator << (std::ostream& out, eRace& e);
std::istream& operator >> (std::istream& in, eRace& e);
std::ostream& operator << (std::ostream& out, eMonstAbil& e);
std::istream& operator >> (std::istream& in, eMonstAbil& e);
std::ostream& operator<<(std::ostream& out, cMonster::cAttack& att);
std::ostream& operator<<(std::ostream& out, const cMonster::cAttack& att);
#endif

View File

@@ -13,15 +13,15 @@
#include "classes.h"
ter_num_t& cBigTemplTown::terrain(size_t x, size_t y){
ter_num_t& cBigTemplTown::terrain(size_t /*x*/, size_t /*y*/){
return _terrain[0][0]; // TODO: will need to calculate the terrain somehow
}
void cBigTemplTown::writeTerrainTo(std::ostream& file) {
void cBigTemplTown::writeTerrainTo(std::ostream& /*file*/) {
// TODO: Write out the terrain somehow;
}
void cBigTemplTown::readTerrainFrom(std::istream& file) {
void cBigTemplTown::readTerrainFrom(std::istream& /*file*/) {
// TODO: Read in the terrain somehow
}

View File

@@ -14,9 +14,9 @@
#include "classes.h"
#include "oldstructs.h"
void cTown::append(legacy::big_tr_type& old){}
void cTown::append(legacy::ave_tr_type& old){}
void cTown::append(legacy::tiny_tr_type& old){}
void cTown::append(legacy::big_tr_type&){}
void cTown::append(legacy::ave_tr_type&){}
void cTown::append(legacy::tiny_tr_type&){}
cTown& cTown::operator = (legacy::town_record_type& old){
int i;
@@ -82,7 +82,7 @@ cTown& cTown::operator = (legacy::town_record_type& old){
cTown::cTown(){}
short max_dim[3] = {64,48,32};
cTown::cTown(short size){
cTown::cTown(short){
short i,s;
location d_loc(100,0);
cTown::cWandering d_wan = {0,0,0,0};