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

@@ -50,17 +50,15 @@ extern RECT pc_race_rect;
extern RECT edit_rect[5][2];
short store_trait_mode;
//extern RECT pc_area_buttons[6][6] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later
//extern RECT item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 -
bool handle_action(sf::Event event,short mode)
bool handle_action(sf::Event event)
//short mode; // ignore,
{
short i;
location the_point;
short choice = 4;
bool to_return = false;
@@ -88,7 +86,7 @@ bool handle_action(sf::Event event,short mode)
display_pc(current_active_pc,1,NULL);
break;
case 2:
pick_race_abil(&univ.party[current_active_pc],0,NULL);
pick_race_abil(&univ.party[current_active_pc],0);
break;
case 3:
spend_xp(current_active_pc,1,NULL);
@@ -115,9 +113,8 @@ bool handle_action(sf::Event event,short mode)
return to_return;
}
void flash_rect(RECT to_flash)
void flash_rect(RECT /*to_flash*/)
{
unsigned long dummy;
// TODO: Think of a good way to do this
//InvertRect (&to_flash);
@@ -125,7 +122,7 @@ void flash_rect(RECT to_flash)
sf::sleep(time_in_ticks(5));
}
static bool get_num_event_filter(cDialog& me, std::string item_hit, eKeyMod mods)
static bool get_num_event_filter(cDialog& me, std::string, eKeyMod)
{
me.toast();
me.setResult<long long>(me["number"].getTextAsNum());
@@ -136,8 +133,6 @@ void edit_gold_or_food(short which_to_edit)
//0 - gold 1 - food
{
short item_hit;
char sign_text[256];
location view_loc;
store_which_to_edit = which_to_edit;
@@ -161,8 +156,6 @@ void edit_gold_or_food(short which_to_edit)
void edit_day()
{
short item_hit;
char sign_text[256];
location view_loc;
@@ -210,7 +203,7 @@ void combine_things(short pc_num)
}
}
bool give_to_pc(short pc_num,cItemRec item, short print_result)
bool give_to_pc(short pc_num,cItemRec item, short /*print_result*/)
{
short free_space;
@@ -238,12 +231,12 @@ bool give_to_party(cItemRec item,short print_result)
return false;
}
void give_gold(short amount,bool print_result)
void give_gold(short amount,bool /*print_result*/)
{
univ.party.gold = univ.party.gold + amount;
}
bool take_gold(short amount,bool print_result)
bool take_gold(short amount,bool /*print_result*/)
{
if (univ.party.gold < amount)
return false;

View File

@@ -2,7 +2,7 @@
#include <SFML/Window/Event.hpp>
#include "dialog.h"
bool handle_action(sf::Event event,short mode);
bool handle_action(sf::Event event);
void flash_rect(RECT to_flash);
void edit_gold_or_food(short which_to_edit);
void display_pc(short pc_num,short mode,cDialog* parent);

View File

@@ -18,6 +18,7 @@ typedef NSAppleEventDescriptor AEDescr;
-(void)handleQuit:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply;
@end
void set_up_apple_events(); // Suppress "no prototype" warning
void set_up_apple_events() {
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
NSAppleEventManager* AEmgr = [NSAppleEventManager sharedAppleEventManager];
@@ -29,9 +30,13 @@ void set_up_apple_events() {
@implementation AppleEventHandler
-(void)handleOpenDoc:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply {
(void) theAppleEvent; // Suppress "unused parameter" warning
(void) reply;
// TODO: Handle this
}
-(void)handleQuit:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply {
(void) theAppleEvent; // Suppress "unused parameter" warning
(void) reply;
All_Done = verify_restore_quit(0);
}
@end

View File

@@ -10,7 +10,20 @@
#include "dlogutil.h"
#include <boost/lexical_cast.hpp>
extern std::string get_str(std::string, short);
/*
* These three are not declared in any included header.
* Instead they are declared in pc.actions.h, which is not
* included here because it contains additional functions that
* should not be available to the game (which also includes
* this file).
*
* For the game's purposes, these are declared in
* boe.infodlg.h and boe.party.h.
*/
void display_pc(short pc_num,short mode,cDialog* parent);
void display_alchemy(bool allowEdit);
bool spend_xp(short pc_num, short mode, cDialog* parent);
// TODO: There's probably a more logical way of arranging this
/* Adventure globals */
//extern party_record_type party;
@@ -34,7 +47,6 @@ extern short d_rect_index[80];
extern bool diff_depth_ok,current_file_has_maps;
bool choice_active[6];
extern short store_trait_mode;
extern short which_pc_displayed;
cPlayer *store_pc;
sf::Texture button_num_gworld;
@@ -68,8 +80,7 @@ short store_skills[20],store_h,store_sp,i,store_skp,which_skill;
long store_g;
short store_train_mode,store_train_pc;
static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod mods)
{
static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod) {
me.toast();
if(item_hit != "cancel") {
short which_pc = item_hit[item_hit.length() - 1] - '1';
@@ -128,8 +139,7 @@ static short party_total_level()
return j;
}
static void put_pc_spells(cDialog& me)
{
static void put_pc_spells(cDialog& me, const short store_trait_mode) {
short i;
for (i = 0; i < 62; i++) {
@@ -144,8 +154,7 @@ static void put_pc_spells(cDialog& me)
me["who"].setText(univ.party[which_pc_displayed].name.c_str());
}
static bool display_pc_event_filter(cDialog& me, std::string item_hit, eKeyMod mods)
{
static bool display_pc_event_filter(cDialog& me, std::string item_hit, const short trait_mode) {
short pc_num;
pc_num = which_pc_displayed;
@@ -156,19 +165,19 @@ static bool display_pc_event_filter(cDialog& me, std::string item_hit, eKeyMod m
pc_num = (pc_num == 0) ? 5 : pc_num - 1;
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
which_pc_displayed = pc_num;
put_pc_spells(me);
put_pc_spells(me, trait_mode);
} else if(item_hit == "right") {
do {
pc_num = (pc_num == 5) ? 0 : pc_num + 1;
} while(univ.party[pc_num].main_status == eMainStatus::ABSENT);
which_pc_displayed = pc_num;
put_pc_spells(me);
put_pc_spells(me, trait_mode);
}
return true;
}
void display_pc(short pc_num,short mode,cDialog* parent)
{
void display_pc(short pc_num,short mode, cDialog* parent) {
using namespace std::placeholders;
short i;
std::string label_str;
@@ -178,19 +187,18 @@ void display_pc(short pc_num,short mode,cDialog* parent)
break;
}
which_pc_displayed = pc_num;
store_trait_mode = mode;
make_cursor_sword();
cDialog pcInfo("pc-spell-info.xml", parent);
pcInfo.attachClickHandlers(display_pc_event_filter,{"done","left","right"});
pcInfo.attachClickHandlers(std::bind(display_pc_event_filter, _1, _2, mode),{"done","left","right"});
for (i = 0; i < 62; i++) {
std::string id = "spell" + boost::lexical_cast<std::string>(i + 1);
label_str = get_str((mode == 0) ? "mage-spells" : "priest-spells",i * 2 + 1);
pcInfo[id].setText(label_str);
}
put_pc_spells(pcInfo);
put_pc_spells(pcInfo, mode);
dynamic_cast<cPict&>(pcInfo["pic"]).setPict(14 + mode,PIC_DLOG);
@@ -216,13 +224,13 @@ static void display_traits_graphics(cDialog& me)
me["xp"].setTextToNum(store);
}
static bool pick_race_abil_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) {
static bool pick_race_abil_event_filter(cDialog& me, std::string, eKeyMod) {
me.toast();
return true;
}
static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing)
{
static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing, const short store_trait_mode) {
if(losing) return true;
std::string abil_str;
cPlayer *pc;
@@ -258,21 +266,22 @@ static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing)
return store_trait_mode == 0;
}
void pick_race_abil(cPlayer *pc,short mode,cDialog* parent)
void pick_race_abil(cPlayer *pc,short mode)
//mode; // 0 - edit 1 - just display 2 - can't change race
{
using namespace std::placeholders;
static const char*const start_str1 = "Click on button by name for description.";
static const char*const start_str2 = "Click on advantage button to add/remove.";
store_trait_mode = mode;
store_pc = pc;
make_cursor_sword();
cDialog pickAbil("pick-race-abil.xml");
pickAbil["done"].attachClickHandler(pick_race_abil_event_filter);
pickAbil.attachFocusHandlers(pick_race_select_led, {"race", "bad1", "bad2", "bad3", "bad4", "bad5"});
pickAbil.attachFocusHandlers(pick_race_select_led, {"good1", "good2", "good3", "good4", "good5"});
pickAbil.attachFocusHandlers(pick_race_select_led, {"good6", "good7", "good8", "good9", "good10"});
auto led_selector = std::bind(pick_race_select_led, _1, _2, _3, mode);
pickAbil.attachFocusHandlers(led_selector, {"race", "bad1", "bad2", "bad3", "bad4", "bad5"});
pickAbil.attachFocusHandlers(led_selector, {"good1", "good2", "good3", "good4", "good5"});
pickAbil.attachFocusHandlers(led_selector, {"good6", "good7", "good8", "good9", "good10"});
display_traits_graphics(pickAbil);
if (mode == 1)
@@ -399,8 +408,7 @@ static void do_xp_draw(cDialog& me)
update_gold_skills(me);
}
static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod mods)
{
static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod) {
short mode,pc_num;
bool talk_done = false;
@@ -513,7 +521,7 @@ static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mod
draw_xp_skills(me);
} else {
for(int i = 0; i < 19; i++) {
int n = strlen(skill_ids[i]);
size_t n = strlen(skill_ids[i]);
if(item_hit.length() < n + 2) continue;
if(item_hit.substr(0, item_hit.length() - 2) == skill_ids[i]) {
which_skill = i;

View File

@@ -6,9 +6,9 @@ void give_gold(short amount,bool print_result);
bool take_gold(short amount,bool print_result);
short pc_has_space(short pc_num);
void take_item(short pc_num,short which_item);
short char_select_pc(short active_only,short free_inv_only,char *title);
short char_select_pc(short active_only,short free_inv_only,const char *title);
short select_pc(short active_only,short free_inv_only);
void give_spec_items();
void pick_race_abil(cPlayer *pc,short mode,class cDialog* parent_num);
void pick_race_abil(cPlayer *pc,short mode);
void reset_boats();
void combine_things(short pc_num);

View File

@@ -13,8 +13,6 @@
#include "message.h"
#include "mathutil.h"
extern std::string get_str(std::string, short);
extern cUniverse univ;
extern sf::RenderWindow mainPtr;
@@ -229,7 +227,6 @@ void init_main_buttons()
void Set_up_win ()
{
short i;
title_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("pcedtitle"));
invenbtn_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("invenbtns"));
status_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("staticons"));
@@ -326,9 +323,9 @@ void draw_main_screen()
}
void do_button_action(short which_pc,short which_button)
// TODO: Not quite sure what the first parameter is for
void do_button_action(short /*which_pc*/,short which_button)
{
unsigned long dummy;
current_pressed_button = which_button;
redraw_screen();

View File

@@ -17,8 +17,6 @@
#include "winutil.h"
#include "cursors.h"
extern std::string get_str(std::string, short);
cUniverse univ;
RECT pc_area_buttons[6][4] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later
@@ -102,7 +100,7 @@ cScenario scenario;
//
//MW specified return type was 'void', changed to ISO C style for Carbonisation -jmr
int main(int argc, char* argv[]) {
int main(int /*argc*/, char* argv[]) {
init_menubar();
init_directories(argv[0]);
Initialize();
@@ -175,6 +173,9 @@ void Handle_One_Event()
case sf::Event::Closed:
All_Done = verify_restore_quit(false);
break;
default:
break;
}
}
@@ -182,7 +183,7 @@ void Mouse_Pressed()
{
bool try_to_end;
try_to_end = handle_action(event,0);
try_to_end = handle_action(event);
if (try_to_end == true)
All_Done = verify_restore_quit(false);
}
@@ -334,7 +335,7 @@ void handle_extra_menu(int item_hit)
void handle_edit_menu(int item_hit)
{
short choice,i,j,k;
short i,j,k;
if(file_in_mem.empty()) {
display_strings(5,7);
@@ -383,7 +384,7 @@ void handle_edit_menu(int item_hit)
display_pc(current_active_pc,1,0);
break;
case 11:
pick_race_abil(&univ.party[current_active_pc],0,0);
pick_race_abil(&univ.party[current_active_pc],0);
break;
case 12:
spend_xp(current_active_pc,1,0);
@@ -449,7 +450,6 @@ void handle_edit_menu(int item_hit)
// TODO: Let this take the item directly instead of the index
void handle_item_menu(int item_hit)
{
short choice;
cItemRec store_i;
if(file_in_mem.empty()) {

View File

@@ -123,6 +123,7 @@ void update_item_menu() {
-(void) itemMenu:(id) sender {
ItemWrapper* item = [sender representedObject];
cItemRec& theItem = [item item];
(void) theItem; // Suppress "unused parameter" warning
for(int i = 0; i < 4; i++) {
int whichItem = [items_menu[i] indexOfItem: sender];
if(whichItem >= 0)