From f198b4899d278ea7e9a2f0d5fbc3c329562033b7 Mon Sep 17 00:00:00 2001 From: Niemand Date: Fri, 22 May 2009 03:01:05 +0000 Subject: [PATCH] Added include guards to all class headers. Removed unnecessary or potentially harmful compiler flags. Added alignment attribute to all old struct members. Removed some unused variables. Made some switch statements handle all or more cases. Removed using declarations in favor of fully qualified names. Fixed a couple of assignments in conditionals that should have been comparisons. Eliminated linker warnings by restoring default linking of standard libraries. Fixed some comparisons between signed and unsigned integers. Note: No testing has been done, in particular of old file I/O. This should be checked for regression caused by alteration of old struct definitions. git-svn-id: http://openexile.googlecode.com/svn/trunk@63 4ebdad44-0ea0-11de-aab3-ff745001d230 --- osx/BoE.xcodeproj/project.pbxproj | 18 +- osx/boe.actions.cpp | 3 +- osx/boe.combat.cpp | 3 +- osx/boe.dlgutil.cpp | 10 +- osx/boe.fields.cpp | 2 +- osx/boe.fileio.cpp | 39 +-- osx/boe.graphics.cpp | 17 +- osx/boe.graphutil.cpp | 5 +- osx/boe.infodlg.cpp | 23 +- osx/boe.itemdata.cpp | 2 +- osx/boe.items.cpp | 4 +- osx/boe.locutils.cpp | 2 +- osx/boe.main.cpp | 1 - osx/boe.monster.cpp | 2 +- osx/boe.newgraph.cpp | 2 +- osx/boe.party.cpp | 2 +- osx/boe.specials.cpp | 12 +- osx/boe.startup.cpp | 2 +- osx/boe.text.cpp | 42 +-- osx/boe.text.h | 8 +- osx/boe.town.cpp | 5 +- osx/boe.townspec.cpp | 2 +- osx/classes/creatlist.cpp | 2 +- osx/classes/creatlist.h | 5 + osx/classes/item.cpp | 74 ++--- osx/classes/item.h | 27 +- osx/classes/location.h | 5 +- osx/classes/monster.cpp | 4 +- osx/classes/monster.h | 12 +- osx/classes/outdoors.cpp | 28 +- osx/classes/outdoors.h | 13 +- osx/classes/party.cpp | 102 +++---- osx/classes/party.h | 38 +-- osx/classes/pc.cpp | 54 ++-- osx/classes/pc.h | 17 +- osx/classes/regtown.cpp | 2 +- osx/classes/regtown.h | 13 +- osx/classes/scenario.cpp | 2 +- osx/classes/scenario.h | 9 +- osx/classes/special.cpp | 2 +- osx/classes/special.h | 9 +- osx/classes/talking.cpp | 2 +- osx/classes/talking.h | 9 +- osx/classes/terrain.cpp | 2 +- osx/classes/terrain.h | 12 +- osx/classes/tmpltown.cpp | 2 +- osx/classes/tmpltown.h | 13 +- osx/classes/town.cpp | 2 +- osx/classes/town.h | 12 +- osx/classes/universe.cpp | 48 +-- osx/classes/universe.h | 15 +- osx/classes/vehicle.cpp | 2 +- osx/classes/vehicle.h | 8 +- osx/oldstructs.h | 473 +++++++++++++++--------------- osx/tools/dlgutil.cpp | 1 - osx/tools/fileio.cpp | 42 ++- osx/tools/graphtool.cpp | 4 +- 57 files changed, 691 insertions(+), 580 deletions(-) diff --git a/osx/BoE.xcodeproj/project.pbxproj b/osx/BoE.xcodeproj/project.pbxproj index 16278be5..25a704d5 100644 --- a/osx/BoE.xcodeproj/project.pbxproj +++ b/osx/BoE.xcodeproj/project.pbxproj @@ -1192,15 +1192,17 @@ ppc, ); COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_INPUT_FILETYPE = sourcecode.cpp.cpp; GCC_MODEL_TUNING = G4; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PROTOTYPE_CONVERSION = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; @@ -1209,8 +1211,6 @@ GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "/usr/include/c++/4.0.0/"; - LIBRARY_SEARCH_PATHS = ""; LINK_WITH_STANDARD_LIBRARIES = YES; MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; MACOSX_DEPLOYMENT_TARGET_ppc = 10.3; @@ -1218,7 +1218,6 @@ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_ppc = /Developer/SDKs/MacOSX10.4u.sdk; - STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; STRIP_INSTALLED_PRODUCT = NO; WARNING_CFLAGS = ( "-Wfloat-equal", @@ -1235,16 +1234,16 @@ ppc, ); COPY_PHASE_STRIP = YES; - GCC_CHAR_IS_UNSIGNED_CHAR = YES; + DEAD_CODE_STRIPPING = YES; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_INPUT_FILETYPE = sourcecode.cpp.cpp; - GCC_ONE_BYTE_BOOL = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PROTOTYPE_CONVERSION = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; @@ -1253,8 +1252,6 @@ GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "/usr/include/c++/4.0.0/"; - LIBRARY_SEARCH_PATHS = ""; LINK_WITH_STANDARD_LIBRARIES = YES; MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; MACOSX_DEPLOYMENT_TARGET_ppc = 10.3; @@ -1262,7 +1259,6 @@ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_ppc = /Developer/SDKs/MacOSX10.4u.sdk; - STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; WARNING_CFLAGS = ( "-Wfloat-equal", "-Wno-long-long", @@ -1288,7 +1284,6 @@ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; INFOPLIST_FILE = "Blades of Exile-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - OTHER_CFLAGS = "-fpack-struct=2"; OTHER_LDFLAGS = ( "-framework", Carbon, @@ -1318,7 +1313,6 @@ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; INFOPLIST_FILE = "Blades of Exile-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - OTHER_CFLAGS = "-fpack-struct=2"; OTHER_LDFLAGS = ( "-framework", Carbon, diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 8e5acb38..222dde8b 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -4,7 +4,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.actions.h" #include "boe.graphutil.h" @@ -2045,7 +2045,6 @@ void do_save(short mode) print_buf(); return; } - FSSpec file; try{ if(mode == 1) univ.file = nav_put_party(); save_party(univ.file); diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 48614cb4..96887e9f 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -3,7 +3,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.monster.h" #include "boe.graphics.h" @@ -4787,4 +4787,5 @@ short get_monst_sound(cCreature *attacker,short which_att) { return 0; break; } + return 0; } diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 9fb21a1e..fb2b16e6 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -4,7 +4,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.dlgutil.h" @@ -62,8 +62,8 @@ extern cUniverse univ; short terrain_pic[256]; -vector scen_headers; -vector scen_header_strs; +std::vector scen_headers; +std::vector scen_header_strs; GWorldPtr pcs_gworld = NULL; @@ -1777,8 +1777,8 @@ void tip_of_day() void put_scen_info() { - short i; - ostringstream sout; + unsigned int i; + std::ostringstream sout; char *ratings[] = {"G","PG","R","NC-17"}; char *difficulty[] = {"Low","Medium","High","Very High"}; diff --git a/osx/boe.fields.cpp b/osx/boe.fields.cpp index 558c4dca..8474e0d6 100644 --- a/osx/boe.fields.cpp +++ b/osx/boe.fields.cpp @@ -2,7 +2,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.locutils.h" #include "boe.fields.h" diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index 5a04e5ad..b7ffaf73 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -1,11 +1,9 @@ - -#include #include +#include //#include "item.h" #include "boe.global.h" -using namespace std; #include "classes.h" #include "boe.fileio.h" #include "boe.text.h" @@ -25,11 +23,6 @@ using namespace std; #include "fileio.h" #include "porting.h" // only needed for one little flip_short call, though... -#include -#include -using std::vector; -using std::string; - #define DONE_BUTTON_ITEM 1 #define IN_FRONT (WindowPtr)-1L @@ -67,12 +60,12 @@ extern short terrain_pic[256],cur_town_talk_loaded; extern cScenario scenario; extern cUniverse univ; //extern piles_of_stuff_dumping_type *data_store; -extern vector scen_header_strs; +extern std::vector scen_header_strs; //std::vector scen_names; //stored_town_maps_type town_maps; //extern talking_record_type talking; //extern outdoor_strs_type outdoor_text[2][2]; -extern vector scen_headers; +extern std::vector scen_headers; extern unsigned short combat_terrain[64][64]; extern bool belt_present; extern bool mac_is_intel; @@ -93,7 +86,7 @@ short specials_res_id,data_dump_file_id; Str255 start_name; short start_volume,data_volume; long start_dir,data_dir/*,scen_dir*/; -string progDir; +std::string progDir; //outdoor_record_type dummy_out;//// //town_record_type dummy_town; @@ -106,8 +99,8 @@ string progDir; CInfoPBRec myCPB; GWorldPtr spec_scen_g = NULL; ResFileRefNum mainRef, graphicsRef, soundRef; -#include -ofstream flog("bladeslog.txt"); + +std::ofstream flog("bladeslog.txt"); void init_directories() { short error; @@ -144,8 +137,8 @@ void init_directories() progDir.erase(last_slash); std::cout<m_d.a[i] > 0) { - ostringstream sout(store_text); + std::ostringstream sout(store_text); sout << store_m->m_d.a[i] / 100 + 1 << 'd' << store_m->m_d.a[i] % 100; store_text = sout.str(); @@ -953,7 +954,7 @@ void give_pc_info(short pc_num) void adventure_notes_event_filter (short item_hit) { - short i; + unsigned short i; Str255 place_str; switch (item_hit) { @@ -1028,7 +1029,8 @@ void adventure_notes_event_filter (short item_hit) void adventure_notes() { - short i,item_hit; + unsigned short i; + short item_hit; Str255 place_str; store_num_i = 0; @@ -1206,21 +1208,24 @@ void journal_event_filter (short item_hit) } for (i = 0; i < 3; i++) { - if (univ.party.journal.size() > i + (store_page_on * 3)) { + if ((long)univ.party.journal.size() > i + (store_page_on * 3)) { ////get_str(place_str,17,univ.party.journal_str[i + (store_page_on * 3)]); csit(962,3 + i,scenario.scen_strs(univ.party.journal[i].str_num + 10)); sprintf((char *)place_str,"Day: %d",univ.party.journal[i + (store_page_on * 3)].day); csit(962,9 + i,(char *)place_str); - } - else {csit(962,3 + i,"");csit(962,9 + i,"");} } + else{ + csit(962,3 + i,"");csit(962,9 + i,""); + } + } } void journal() { - short i,item_hit; + unsigned short i; + short item_hit; Str255 place_str; store_num_i = 0; @@ -1304,7 +1309,7 @@ void put_spec_item_info (short which_i) void record_display_strings(){ bool had1 = false, had2 = false; - int i; + unsigned int i; play_sound(0); for (i = 0; i < univ.party.special_notes.size(); i++) if ((store_str_label_1 == univ.party.special_notes[i].str_num) && diff --git a/osx/boe.itemdata.cpp b/osx/boe.itemdata.cpp index bd834f51..e2c05e67 100644 --- a/osx/boe.itemdata.cpp +++ b/osx/boe.itemdata.cpp @@ -5,7 +5,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.itemdata.h" #include "mathutil.h" diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 0c304aa0..2e5bc3e5 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -5,7 +5,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.graphics.h" @@ -618,6 +618,8 @@ void drop_item(short pc_num,short item_num,location where_drop) take_item(pc_num,item_num); } break; + default: //should never be reached + break; } } diff --git a/osx/boe.locutils.cpp b/osx/boe.locutils.cpp index e6272441..cae06efc 100644 --- a/osx/boe.locutils.cpp +++ b/osx/boe.locutils.cpp @@ -3,7 +3,7 @@ #include "mathutil.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.locutils.h" #include "boe.text.h" diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index 9a431ea9..c3e33694 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -2,7 +2,6 @@ //#include "item.h" #include "boe.global.h" -using namespace std; #include "classes.h" #include "gamma.h" diff --git a/osx/boe.monster.cpp b/osx/boe.monster.cpp index 405d3546..1fb23b6c 100644 --- a/osx/boe.monster.cpp +++ b/osx/boe.monster.cpp @@ -3,7 +3,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.locutils.h" #include "boe.fields.h" diff --git a/osx/boe.newgraph.cpp b/osx/boe.newgraph.cpp index 106912b2..2320990d 100644 --- a/osx/boe.newgraph.cpp +++ b/osx/boe.newgraph.cpp @@ -5,7 +5,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.graphics.h" #include "boe.graphutil.h" diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index f900424e..73cb088e 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -3,7 +3,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.fileio.h" diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index a41900a7..b7f9f45d 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -4,7 +4,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.party.h" #include "boe.town.h" @@ -305,7 +305,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short pic_type = 0; if (PSD[SDF_PARTY_FIREWALK] > 0) { add_string_to_buf(" It doesn't affect you."); - goto LBL_NO_DAMAGE; + goto LBL_NO_DAMAGE; //TODO: nix the goto } break; case DAMAGE_COLD: @@ -329,7 +329,12 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short case DAMAGE_DEMON: add_string_to_buf(" A dark wind blows through you!"); pic_type = 1; // TODO: Verify that this is correct +<<<<<<< .mine + default: break; +======= + break; +>>>>>>> .r62 } r1 = get_ran(ter_flag2,dam_type,ter_flag1); if (mode < 2) @@ -1621,7 +1626,8 @@ void push_things()//// void special_increase_age() { - short i,s1,s2,s3; + unsigned short i; + short s1,s2,s3; bool redraw = false,stat_area = false; location null_loc; diff --git a/osx/boe.startup.cpp b/osx/boe.startup.cpp index dbcf9254..e37eca84 100644 --- a/osx/boe.startup.cpp +++ b/osx/boe.startup.cpp @@ -2,7 +2,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.newgraph.h" #include "boe.graphics.h" diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index da3151c8..f751cfa1 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -7,7 +7,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.text.h" #include "boe.locutils.h" @@ -831,7 +831,7 @@ short do_look(location space) short i,j,num_items = 0; bool gold_here = false, food_here = false, is_lit = true; location from_where; - string msg; + std::string msg; from_where = get_cur_loc(); is_lit = pt_in_light(from_where,space); @@ -1022,7 +1022,7 @@ short out_horse_there(location where) void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) { short i; - string msg; + std::string msg; add_string_to_buf((char *) "COMBAT! "); @@ -1033,7 +1033,7 @@ void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) default: msg = get_m_name(encounter.monst[i]); - ostringstream sout; + std::ostringstream sout; sout << " " << nums[i] << " x " << msg << " "; msg = sout.str(); break; @@ -1046,16 +1046,16 @@ void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) } } -string get_m_name(unsigned short num) +std::string get_m_name(unsigned short num) { //// //strcpy((char *) str,(char *) scenario.scen_monsters[num].m_name); return scenario.scen_monsters[num].m_name; } -string get_ter_name(unsigned short num) +std::string get_ter_name(unsigned short num) { - string store_name = "Pit"; + std::string store_name = "Pit"; //// if ((num == 90) && ((is_out()) || (is_town()) || ((is_combat()) && (which_combat_type == 1)))); @@ -1068,7 +1068,7 @@ string get_ter_name(unsigned short num) void print_monst_name(unsigned short m_type) { - string msg = get_m_name(m_type) + ':'; + std::string msg = get_m_name(m_type) + ':'; add_string_to_buf((char *) msg.c_str()); } @@ -1077,7 +1077,7 @@ void print_monst_attacks(unsigned short m_type,short target) { //char store_string3[60]; - string msg = get_m_name(m_type); + std::string msg = get_m_name(m_type); msg += " attacks "; if (target < 100) msg += ADVEN[target].name; @@ -1089,27 +1089,27 @@ void print_monst_attacks(unsigned short m_type,short target) //// void damaged_message(short damage,short type) { - string msg = " "; + std::string msg = " "; Str255 str; get_str(str,20,130 + type); msg += (char*)str; - ostringstream sout(msg); + std::ostringstream sout(msg); sout << " for " << damage; msg = sout.str(); add_string_to_buf((char *) msg.c_str()); } // This prepares the monster's string for the text bar -string print_monster_going(unsigned short m_num,short ap) +std::string print_monster_going(unsigned short m_num,short ap) { - ostringstream sout(get_m_name(m_num)); + std::ostringstream sout(get_m_name(m_num)); sout << " (ap: " << ap << ')'; return sout.str(); } void monst_spell_note(unsigned short number,short which_mess) { - string msg = get_m_name(number); + std::string msg = get_m_name(number); switch (which_mess) { case 1: msg = " " + msg + " scared. "; @@ -1226,7 +1226,7 @@ void monst_spell_note(unsigned short number,short which_mess) void monst_cast_spell_note(unsigned short number,short spell,short type) //short type; // 0 - mage 1- priest { - string msg = get_m_name(number); + std::string msg = get_m_name(number); msg += " casts:"; add_string_to_buf((char *) msg.c_str()); msg = (type == 1) ? m_priest_sp[spell - 1] : m_mage_sp[spell - 1]; @@ -1236,7 +1236,7 @@ void monst_cast_spell_note(unsigned short number,short spell,short type) void monst_breathe_note(unsigned short number) { - string msg = get_m_name(number); + std::string msg = get_m_name(number); msg += " breathes."; add_string_to_buf((char *) msg.c_str()); @@ -1244,9 +1244,9 @@ void monst_breathe_note(unsigned short number) void monst_damaged_mes(short which_m,short how_much,short how_much_spec) { - string msg = get_m_name(univ.town.monst.dudes[which_m].number); + std::string msg = get_m_name(univ.town.monst.dudes[which_m].number); msg = " " + msg + " takes "; - ostringstream sout(msg); + std::ostringstream sout(msg); sout << how_much; if (how_much_spec > 0) sout << '+' << how_much_spec; @@ -1256,14 +1256,14 @@ void monst_damaged_mes(short which_m,short how_much,short how_much_spec) void monst_killed_mes(short which_m) { - string msg = get_m_name(univ.town.monst.dudes[which_m].number); + std::string msg = get_m_name(univ.town.monst.dudes[which_m].number); msg = " " + msg + " dies."; add_string_to_buf((char *) msg.c_str()); } void print_nums(short a,short b,short c) { - ostringstream sout; + std::ostringstream sout; sout << "debug: " << a << ' ' << b << ' ' << c; add_string_to_buf((char *) sout.str().c_str()); @@ -1282,7 +1282,7 @@ short print_terrain(location space) if (overall_mode == MODE_LOOK_COMBAT) { which_terrain = combat_terrain[space.x][space.y]; } - string msg = get_ter_name(which_terrain); + std::string msg = get_ter_name(which_terrain); msg = " " + msg; add_string_to_buf((char *) msg.c_str()); diff --git a/osx/boe.text.h b/osx/boe.text.h index 15d292d5..abbc6877 100644 --- a/osx/boe.text.h +++ b/osx/boe.text.h @@ -1,3 +1,5 @@ +#include + short text_pc_has_abil_equip(short pc_num,short abil); void put_pc_screen(); void place_buy_button(short position,short pc_num,short item_num); @@ -18,12 +20,12 @@ short out_boat_there(location where); short town_horse_there(location where); short out_horse_there(location where); void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) ; -string get_m_name(unsigned short num); -string get_ter_name(unsigned short num); +std::string get_m_name(unsigned short num); +std::string get_ter_name(unsigned short num); void print_monst_name(unsigned short m_type); void print_monst_attacks(unsigned short m_type,short target); void damaged_message(short damage,short type); -string print_monster_going(unsigned short m_num,short ap); +std::string print_monster_going(unsigned short m_num,short ap); void monst_spell_note(unsigned short number,short which_mess); void monst_cast_spell_note(unsigned short number,short spell,short type); void monst_breathe_note(unsigned short number); diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index e4c16f55..25885064 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -3,7 +3,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.graphutil.h" @@ -488,7 +488,8 @@ void start_town_mode(short which_town, short entry_dir) if (univ.town->preset_items[i].ability > 0) univ.town.items[j].item_level = univ.town->preset_items[i].ability; break; - + default: //leave other type alone + break; } } diff --git a/osx/boe.townspec.cpp b/osx/boe.townspec.cpp index ca6d4490..53f07174 100644 --- a/osx/boe.townspec.cpp +++ b/osx/boe.townspec.cpp @@ -3,7 +3,7 @@ //#include "item.h" #include "boe.global.h" -using namespace std; + #include "classes.h" #include "boe.party.h" #include "boe.town.h" diff --git a/osx/classes/creatlist.cpp b/osx/classes/creatlist.cpp index 39503bbe..6e72dbe7 100644 --- a/osx/classes/creatlist.cpp +++ b/osx/classes/creatlist.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/creatlist.h b/osx/classes/creatlist.h index 5ccc0906..9b255946 100644 --- a/osx/classes/creatlist.h +++ b/osx/classes/creatlist.h @@ -6,6 +6,9 @@ * */ +#ifndef CREATLIST_H +#define CREATLIST_H + namespace legacy { struct creature_list_type; struct creature_data_type; @@ -31,3 +34,5 @@ public: cPopulation& operator = (legacy::creature_list_type old); }; + +#endif \ No newline at end of file diff --git a/osx/classes/item.cpp b/osx/classes/item.cpp index c3316d26..c044b355 100644 --- a/osx/classes/item.cpp +++ b/osx/classes/item.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "boe.consts.h" @@ -316,7 +316,7 @@ cItemRec& cItemRec::operator = (legacy::item_record_type& old){ special_class = old.special_class; item_loc.x = old.item_loc.x; item_loc.y = old.item_loc.y; - full_name = string(old.full_name); + full_name = std::string(old.full_name); name = old.name; treas_class = old.treas_class; item_properties = old.item_properties; @@ -325,37 +325,37 @@ cItemRec& cItemRec::operator = (legacy::item_record_type& old){ return *this; } -void cItemRec::writeTo(ostream& file, string prefix){ - file << prefix << "VARIETY " << variety << endl; - file << prefix << "LEVEL " << item_level << endl; - file << prefix << "AWKWARD " << awkward << endl; - file << prefix << "BONUS " << bonus << endl; - file << prefix << "PROT " << protection << endl; - file << prefix << "CHARGES " << charges << endl; - file << prefix << "WEAPON " << type << endl; - file << prefix << "USE " << magic_use_type << endl; - file << prefix << "ICON " << graphic_num << endl; - file << prefix << "ABILITY " << ability << endl; - file << prefix << "ABILSTR " << ability_strength << endl; - file << prefix << "TYPE " << type_flag << endl; - file << prefix << "ISSPEC " << is_special << endl; - file << prefix << "VALUE " << value << endl; - file << prefix << "WEIGHT " << weight << endl; - file << prefix << "SPEC " << special_class << endl; - file << prefix << "AT " << item_loc.x << ' ' << item_loc.y << endl; - file << prefix << "FULLNAME " << full_name << endl; - file << prefix << "NAME " << name << endl; - file << prefix << "TREASURE " << treas_class << endl; - if(is_ident()) file << prefix << "IDENTIFIED" << endl; - if(is_property()) file << prefix << "PROPERTY" << endl; - if(is_magic()) file << prefix << "MAGIC" << endl; - if(is_contained()) file << prefix << "CONTAINED" << endl; - if(is_cursed()) file << prefix << "CURSED" << endl; - if(is_concealed()) file << prefix << "CONCEALED" << endl; - if(is_enchanted()) file << prefix << "ENCHANTED" << endl; +void cItemRec::writeTo(std::ostream& file, std::string prefix){ + file << prefix << "VARIETY " << variety << std::endl; + file << prefix << "LEVEL " << item_level << std::endl; + file << prefix << "AWKWARD " << awkward << std::endl; + file << prefix << "BONUS " << bonus << std::endl; + file << prefix << "PROT " << protection << std::endl; + file << prefix << "CHARGES " << charges << std::endl; + file << prefix << "WEAPON " << type << std::endl; + file << prefix << "USE " << magic_use_type << std::endl; + file << prefix << "ICON " << graphic_num << std::endl; + file << prefix << "ABILITY " << ability << std::endl; + file << prefix << "ABILSTR " << ability_strength << std::endl; + file << prefix << "TYPE " << type_flag << std::endl; + file << prefix << "ISSPEC " << is_special << std::endl; + file << prefix << "VALUE " << value << std::endl; + file << prefix << "WEIGHT " << weight << std::endl; + file << prefix << "SPEC " << special_class << std::endl; + file << prefix << "AT " << item_loc.x << ' ' << item_loc.y << std::endl; + file << prefix << "FULLNAME " << full_name << std::endl; + file << prefix << "NAME " << name << std::endl; + file << prefix << "TREASURE " << treas_class << std::endl; + if(is_ident()) file << prefix << "IDENTIFIED" << std::endl; + if(is_property()) file << prefix << "PROPERTY" << std::endl; + if(is_magic()) file << prefix << "MAGIC" << std::endl; + if(is_contained()) file << prefix << "CONTAINED" << std::endl; + if(is_cursed()) file << prefix << "CURSED" << std::endl; + if(is_concealed()) file << prefix << "CONCEALED" << std::endl; + if(is_enchanted()) file << prefix << "ENCHANTED" << std::endl; } -void cItemRec::readAttrFrom(string cur, istream& sin){ +void cItemRec::readAttrFrom(std::string cur, std::istream& sin){ if(cur == "VARIETY") sin >> variety; else if(cur == "LEVEL") sin >> item_level; else if(cur == "AWKWARD") sin >> awkward; @@ -390,19 +390,19 @@ void cItemRec::readAttrFrom(string cur, istream& sin){ else if(cur == "ENCHANTED") set_enchanted(true); } -ostream& operator << (ostream& out, eWeapType& e){ +std::ostream& operator << (std::ostream& out, eWeapType& e){ return out << (int) e; } -ostream& operator << (ostream& out, eItemType& e){ +std::ostream& operator << (std::ostream& out, eItemType& e){ return out << (int) e; } -ostream& operator << (ostream& out, eItemAbil& e){ +std::ostream& operator << (std::ostream& out, eItemAbil& e){ return out << (int) e; } -istream& operator >> (istream& in, eWeapType& e){ +std::istream& operator >> (std::istream& in, eWeapType& e){ int i; in >> i; if(i > 0 && i < 4) @@ -411,7 +411,7 @@ istream& operator >> (istream& in, eWeapType& e){ return in; } -istream& operator >> (istream& in, eItemType& e){ +std::istream& operator >> (std::istream& in, eItemType& e){ int i; in >> i; if(i > 0 && i < 28) @@ -420,7 +420,7 @@ istream& operator >> (istream& in, eItemType& e){ return in; } -istream& operator >> (istream& in, eItemAbil& e){ +std::istream& operator >> (std::istream& in, eItemAbil& e){ int i; in >> i; if((i > 0 && i < 15) || (i > 29 && i < 63) || diff --git a/osx/classes/item.h b/osx/classes/item.h index d7fdded4..b8ebc1e0 100644 --- a/osx/classes/item.h +++ b/osx/classes/item.h @@ -6,7 +6,12 @@ * */ +#ifndef ITEM_H +#define ITEM_H + #include "location.h" +#include +#include namespace legacy { struct item_record_type; }; @@ -201,8 +206,8 @@ public: unsigned char weight; unsigned char special_class; location item_loc; - string full_name; - string name; + std::string full_name; + std::string name; unsigned char treas_class; unsigned char item_properties; private: @@ -230,16 +235,16 @@ public: cItemRec(); cItemRec(long preset); cItemRec& operator = (legacy::item_record_type& old); - void writeTo(ostream& file, string prefix = ""); - void readAttrFrom(string cur, istream& sin); + void writeTo(std::ostream& file, std::string prefix = ""); + void readAttrFrom(std::string cur, std::istream& sin); }; -ostream& operator << (ostream& out, eWeapType& e); -ostream& operator << (ostream& out, eItemType& e); -ostream& operator << (ostream& out, eItemAbil& e); -istream& operator >> (istream& in, eWeapType& e); -istream& operator >> (istream& in, eItemType& e); -istream& operator >> (istream& in, eItemAbil& e); +std::ostream& operator << (std::ostream& out, eWeapType& e); +std::ostream& operator << (std::ostream& out, eItemType& e); +std::ostream& operator << (std::ostream& out, eItemAbil& e); +std::istream& operator >> (std::istream& in, eWeapType& e); +std::istream& operator >> (std::istream& in, eItemType& e); +std::istream& operator >> (std::istream& in, eItemAbil& e); /* typedef struct { @@ -254,3 +259,5 @@ istream& operator >> (istream& in, eItemAbil& e); unsigned char magic_use_type, ability_strength, treas_class, real_abil; } short_item_record_type; */ + +#endif \ No newline at end of file diff --git a/osx/classes/location.h b/osx/classes/location.h index 22493efa..c97ae327 100644 --- a/osx/classes/location.h +++ b/osx/classes/location.h @@ -6,7 +6,8 @@ * */ -#pragma once +#ifndef LOCATION_H +#define LOCATION_H struct rectangle; @@ -43,3 +44,5 @@ location loc(); rectangle rect(); rectangle rect(location tl, location br); rectangle rect(char top, char left, char bottom, char right); + +#endif \ No newline at end of file diff --git a/osx/classes/monster.cpp b/osx/classes/monster.cpp index 54516d10..2752c0ae 100644 --- a/osx/classes/monster.cpp +++ b/osx/classes/monster.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" @@ -58,7 +58,7 @@ cMonster& cMonster::operator = (legacy::monster_record_type& old){ res2 = old.res2; res3 = old.res3; picture_num = old.picture_num; - if(picture_num = 122) picture_num = 119; + if(picture_num == 122) picture_num = 119; return *this; } diff --git a/osx/classes/monster.h b/osx/classes/monster.h index c6bd9c2d..9826b75c 100644 --- a/osx/classes/monster.h +++ b/osx/classes/monster.h @@ -6,6 +6,12 @@ * */ +#ifndef MONSTER_H +#define MONSTER_H + +#include +#include + namespace legacy { struct monster_record_type; struct creature_data_type; @@ -109,7 +115,7 @@ class cMonster { public: unsigned short m_num; unsigned char level; - string m_name; + std::string m_name; short health,m_health,mp,max_mp; unsigned char armor,skill; short a[3]; @@ -125,7 +131,7 @@ public: short picture_num; cMonster& operator = (legacy::monster_record_type& old); - void writeTo(ostream& file, string prefix); + void writeTo(std::ostream& file, std::string prefix); }; class cCreature { @@ -152,3 +158,5 @@ public: cCreature& operator = (legacy::creature_data_type old); cCreature& operator = (legacy::creature_start_type old); }; + +#endif \ No newline at end of file diff --git a/osx/classes/outdoors.cpp b/osx/classes/outdoors.cpp index 1357023a..e90deb05 100644 --- a/osx/classes/outdoors.cpp +++ b/osx/classes/outdoors.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" @@ -49,8 +49,8 @@ cOutdoors& cOutdoors::operator = (legacy::outdoor_record_type& old){ // special_enc[i].monst[j] = old.special_enc[i].monst[j]; // } // for(j = 0; j < 3; j++){ -// wandering[i].friendly[j] = old.wandering[i].friendly[j]; -// special_enc[i].friendly[j] = old.special_enc[i].friendly[j]; +// wandering[i].fristd::endly[j] = old.wandering[i].fristd::endly[j]; +// special_enc[i].fristd::endly[j] = old.special_enc[i].fristd::endly[j]; // } // wandering[i].spec_on_meet = old.wandering[i].spec_on_meet; // special_enc[i].spec_on_meet = old.special_enc[i].spec_on_meet; @@ -145,29 +145,29 @@ cOutdoors::cCreature& cOutdoors::cCreature::operator = (legacy::outdoor_creature return *this; } -void cOutdoors::writeTo(ostream& file){ +void cOutdoors::writeTo(std::ostream& file){ // for(int i = 0; i < 48; i++){ // file << expl[i][0]; // for(int j = 1; j < 48; j++){ // file << '\t' << expl[i][j]; // } -// file << endl; +// file << std::endl; // } } -void cOutdoors::cWandering::writeTo(ostream& file, string prefix){ +void cOutdoors::cWandering::writeTo(std::ostream& file, std::string prefix){ for(int i = 0; i < 7; i++) - file << prefix << "HOSTILE " << i << ' ' << monst[i] << endl; + file << prefix << "HOSTILE " << i << ' ' << monst[i] << std::endl; for(int i = 0; i < 3; i++) - file << prefix << "FRIEND " << i << ' ' << friendly[i] << endl; - file << prefix << "MEET " << spec_on_meet << endl; - file << prefix << "WIN " << spec_on_win << endl; - file << prefix << "FLEE " << spec_on_flee << endl; - file << prefix << "FLAGS " << cant_flee << endl; - file << prefix << "SDF " << end_spec1 << ' ' << end_spec2 << endl; + file << prefix << "FRIEND " << i << ' ' << friendly[i] << std::endl; + file << prefix << "MEET " << spec_on_meet << std::endl; + file << prefix << "WIN " << spec_on_win << std::endl; + file << prefix << "FLEE " << spec_on_flee << std::endl; + file << prefix << "FLAGS " << cant_flee << std::endl; + file << prefix << "SDF " << end_spec1 << ' ' << end_spec2 << std::endl; } -void cOutdoors::cWandering::readAttrFrom(string cur, istream& sin){ +void cOutdoors::cWandering::readAttrFrom(std::string cur, std::istream& sin){ if(cur == "HOSTILE"){ int i; sin >> i; diff --git a/osx/classes/outdoors.h b/osx/classes/outdoors.h index c8afafdb..e412cb0d 100644 --- a/osx/classes/outdoors.h +++ b/osx/classes/outdoors.h @@ -6,7 +6,12 @@ * */ +#ifndef OUTDOORS_H +#define OUTDOORS_H + #include "location.h" +#include +#include namespace legacy { struct out_wandering_type; @@ -24,8 +29,8 @@ public: short end_spec1,end_spec2; cWandering& operator = (legacy::out_wandering_type old); - void writeTo(ostream& file, string prefix = ""); - void readAttrFrom(string cur, istream& sin); + void writeTo(std::ostream& file, std::string prefix = ""); + void readAttrFrom(std::string cur, std::istream& sin); }; class cCreature { // formerly outdoor_creature_type public: @@ -58,5 +63,7 @@ public: cOutdoors(); cOutdoors& operator = (legacy::outdoor_record_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/party.cpp b/osx/classes/party.cpp index 3a9e4d95..1200992d 100644 --- a/osx/classes/party.cpp +++ b/osx/classes/party.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" @@ -153,7 +153,7 @@ void cParty::add_pc(cPlayer new_pc){ } bool cParty::has_talk_save(short who, short str1, short str2){ - for (int j = 0; j < talk_save.size(); j++) + for (unsigned int j = 0; j < talk_save.size(); j++) if ((talk_save[j].personality == who) && (talk_save[j].str_num1 == str1) && (talk_save[j].str_num2 == str2)) return true; return false; @@ -198,27 +198,28 @@ bool cParty::start_timer(short time, short node, short type){ t.global_or_town = type; t.node_to_call = node; party_event_timers.push_back(t); + return(true); } -void cParty::writeTo(ostream& file){ - file << "AGE " << age << endl; - file << "GOLD " << gold << endl; - file << "FOOD " << food << endl; +void cParty::writeTo(std::ostream& file){ + file << "AGE " << age << std::endl; + file << "GOLD " << gold << std::endl; + file << "FOOD " << food << std::endl; for(int i = 0; i < 310; i++) for(int j = 0; j < 50; j++) if(stuff_done[i][j] > 0) - file << "SDF " << i << ' ' << j << ' ' << stuff_done[i][j] << endl; + file << "SDF " << i << ' ' << j << ' ' << stuff_done[i][j] << std::endl; for(int i = 0; i < 200; i++) if(item_taken[i][0] > 0 || item_taken[i][1] > 0 || item_taken[i][2] > 0 || item_taken[i][3] > 0 || item_taken[i][4] > 0 || item_taken[i][5] > 0 || item_taken[i][6] > 0 || item_taken[i][7] > 0) file << "ITEMTAKEN " << i << ' ' << item_taken[i][0] << ' ' << item_taken[i][1] << ' ' << item_taken[i][2] << ' ' << item_taken[i][3] << ' ' << item_taken[i][4] << ' ' << item_taken[i][5] - << ' ' << item_taken[i][6] << ' ' << item_taken[i][7] << endl; - file << "LIGHT " << light_level << endl; - file << "OUTCORNER " << outdoor_corner.x << ' ' << outdoor_corner.y << endl; - file << "INWHICHCORNER " << i_w_c.x << ' ' << i_w_c.y << endl; - file << "SECTOR " << p_loc.x << ' ' << p_loc.y << endl; - file << "LOCINSECTOR " << loc_in_sec.x << ' ' << loc_in_sec.y << endl; + << ' ' << item_taken[i][6] << ' ' << item_taken[i][7] << std::endl; + file << "LIGHT " << light_level << std::endl; + file << "OUTCORNER " << outdoor_corner.x << ' ' << outdoor_corner.y << std::endl; + file << "INWHICHCORNER " << i_w_c.x << ' ' << i_w_c.y << std::endl; + file << "SECTOR " << p_loc.x << ' ' << p_loc.y << std::endl; + file << "LOCINSECTOR " << loc_in_sec.x << ' ' << loc_in_sec.y << std::endl; // TODO: Delegate this to the cVehicle class for(int i = 0; i < 30; i++){ if(!boats[i].exists) continue; @@ -226,7 +227,7 @@ void cParty::writeTo(ostream& file){ file << boats[i].loc.x << ' ' << boats[i].loc.y << ' '; file << boats[i].loc_in_sec.x << ' ' << boats[i].loc_in_sec.y << ' '; file << boats[i].sector.x << ' ' << boats[i].sector.y << ' '; - file << boats[i].which_town << ' ' << (short)boats[i].property << endl; + file << boats[i].which_town << ' ' << (short)boats[i].property << std::endl; } for(int i = 0; i < 30; i++){ if(!horses[i].exists) continue; @@ -234,77 +235,77 @@ void cParty::writeTo(ostream& file){ file << horses[i].loc.x << ' ' << horses[i].loc.y << ' '; file << horses[i].loc_in_sec.x << ' ' << horses[i].loc_in_sec.y << ' '; file << horses[i].sector.x << ' ' << horses[i].sector.y << ' '; - file << horses[i].which_town << ' ' << (short)horses[i].property << endl; + file << horses[i].which_town << ' ' << (short)horses[i].property << std::endl; } - file << "IN " << in_boat << ' ' << in_horse << endl; + file << "IN " << in_boat << ' ' << in_horse << std::endl; for(int i = 0; i < 5; i++) for(int j = 0; j < 50; j++) if(magic_store_items[i][j].variety > ITEM_TYPE_NO_ITEM){ - ostringstream sout; + std::ostringstream sout; sout << "MAGICSTORE " << i << ' ' << j << ' '; magic_store_items[i][j].writeTo(file, sout.str()); } for(int i = 0; i < 256; i++) if(m_seen[i]) - file << "ROSTER " << i << endl; + file << "ROSTER " << i << std::endl; for(int i = 0; i < 10; i++) if(out_c[i].exists){ - file << "ENCOUNTER " << i << " DIRECTION " << out_c[i].direction << endl; - file << "ENCOUNTER " << i << " SECTOR " << out_c[i].which_sector.x << ' ' << out_c[i].which_sector.y << endl; - file << "ENCOUNTER " << i << " LOCINSECTOR " << out_c[i].m_loc.x << ' ' << out_c[i].m_loc.y << endl; - file << "ENCOUNTER " << i << " HOME " << out_c[i].home_sector.x << ' ' << out_c[i].home_sector.y << endl; - ostringstream sout; + file << "ENCOUNTER " << i << " DIRECTION " << out_c[i].direction << std::endl; + file << "ENCOUNTER " << i << " SECTOR " << out_c[i].which_sector.x << ' ' << out_c[i].which_sector.y << std::endl; + file << "ENCOUNTER " << i << " LOCINSECTOR " << out_c[i].m_loc.x << ' ' << out_c[i].m_loc.y << std::endl; + file << "ENCOUNTER " << i << " HOME " << out_c[i].home_sector.x << ' ' << out_c[i].home_sector.y << std::endl; + std::ostringstream sout; sout << "ENCOUNTER " << i << ' '; out_c[i].what_monst.writeTo(file,sout.str()); } for(int i = 0; i < 4; i++) if(imprisoned_monst[i] > 0) - file << "SOULCRYSTAL " << i << ' ' << imprisoned_monst[i] << endl; - file << "DIRECTION " << direction << endl; - file << "WHICHSLOT " << at_which_save_slot << endl; + file << "SOULCRYSTAL " << i << ' ' << imprisoned_monst[i] << std::endl; + file << "DIRECTION " << direction << std::endl; + file << "WHICHSLOT " << at_which_save_slot << std::endl; for(int i = 0; i < 20; i++) if(alchemy[i]) - file << "ALCHEMY " << i << endl; + file << "ALCHEMY " << i << std::endl; for(int i = 0; i < 200; i++) if(can_find_town[i]) - file << "TOWN " << i << endl; + file << "TOWN " << i << std::endl; for(int i = 0; i < 100; i++) if(key_times[i]) - file << "EVENT " << i << ' ' << key_times[i] << endl; + file << "EVENT " << i << ' ' << key_times[i] << std::endl; for(int i = 0; i < 50; i++) if(spec_items[i]) - file << "ITEM " << i << endl; + file << "ITEM " << i << std::endl; for(int i = 0; i < 120; i++) if(help_received[i]) - file << "HELP " << i << endl; + file << "HELP " << i << std::endl; for(int i = 0; i < 200; i++) if(m_killed[i] > 0) - file << "TOWNSLAUGHTER " << i << ' ' << m_killed[i] << endl; - file << "KILLS " << total_m_killed << endl; - file << "DAMAGE " << total_dam_done << endl; - file << "WOUNDS " << total_dam_taken << endl; - file << "EXPERIENCE " << total_xp_gained << endl; - file << "SCENARIO " << scen_name << endl; - file << "WON " << scen_won << endl; - file << "PLAYED " << scen_played << endl; + file << "TOWNSLAUGHTER " << i << ' ' << m_killed[i] << std::endl; + file << "KILLS " << total_m_killed << std::endl; + file << "DAMAGE " << total_dam_done << std::endl; + file << "WOUNDS " << total_dam_taken << std::endl; + file << "EXPERIENCE " << total_xp_gained << std::endl; + file << "SCENARIO " << scen_name << std::endl; + file << "WON " << scen_won << std::endl; + file << "PLAYED " << scen_played << std::endl; for(campIter iter = campaign_flags.begin(); iter != campaign_flags.end(); iter++){ - for(int i = 0; i < iter->second.size(); i++) + for(unsigned int i = 0; i < iter->second.size(); i++) if(iter->second[i] > 0) - file << "CAMPAIGN \"" << iter->first << "\" " << i << ' ' << iter->second[i] << endl; + file << "CAMPAIGN \"" << iter->first << "\" " << i << ' ' << iter->second[i] << std::endl; } - for(int i = 0; i < 250; i++) + for(unsigned int i = 0; i < 250; i++) if(graphicUsed[i]) - file << "GRAPHIC " << i << endl; - for(int i = 0; i < party_event_timers.size(); i++) + file << "GRAPHIC " << i << std::endl; + for(unsigned int i = 0; i < party_event_timers.size(); i++) file << "TIMER " << i << ' ' << party_event_timers[i].time << ' ' << party_event_timers[i].global_or_town - << ' ' << party_event_timers[i].node_to_call << endl; + << ' ' << party_event_timers[i].node_to_call << std::endl; file << '\f'; for(int i = 0; i < 4; i++){ for(int j = 0; j < 64; j++){ file << setup[i][j][0]; for(int k = 1; k < 64; k++) file << '\t' << setup[i][j][k]; - file << endl; + file << std::endl; } file << '\f'; } @@ -314,10 +315,10 @@ void cParty::writeTo(ostream& file){ // TODO: summons } -void cParty::readFrom(istream& file){ +void cParty::readFrom(std::istream& file){ // TODO: Error-check input - istringstream bin, sin; - string cur; + std::istringstream bin, sin; + std::string cur; getline(file, cur, '\f'); bin.str(cur); while(bin) { // continue as long as no error, such as eof, occurs @@ -430,7 +431,8 @@ void cParty::readFrom(istream& file){ else if(cur == "PLAYED") sin >> scen_played; else if(cur == "CAMPAIGN"){ - int i,j; + unsigned int i; + int j; if(sin.peek() == '"'){ sin.get(); getline(sin, cur, '"'); diff --git a/osx/classes/party.h b/osx/classes/party.h index a7c48d55..1c6663ea 100644 --- a/osx/classes/party.h +++ b/osx/classes/party.h @@ -6,10 +6,12 @@ * */ +#ifndef PARTY_H +#define PARTY_H + #include #include #include -using namespace std; namespace legacy { struct party_record_type; @@ -28,7 +30,7 @@ public: short personality; short town_num; short str_num1, str_num2; - string who_said, in_town, the_str1, the_str2, in_scen; // the actual strings; not always saved, like maps + std::string who_said, in_town, the_str1, the_str2, in_scen; // the actual strings; not always saved, like maps cConvers& operator = (legacy::talk_save_type old); }; @@ -36,12 +38,12 @@ public: public: unsigned short str_num; unsigned short day; - string the_str, in_scen; // the actual strings; not always saved, like maps + std::string the_str, in_scen; // the actual strings; not always saved, like maps }; class cEncNote { public: unsigned short str_num, where; - string the_str1, the_str2, in_scen; // the actual strings; not always saved, like maps + std::string the_str1, the_str2, in_scen; // the actual strings; not always saved, like maps }; class cTimer { public: @@ -69,22 +71,22 @@ public: cItemRec magic_store_items[5][10]; short imprisoned_monst[4]; // Soul Crystal? char m_seen[256]; - vector journal; - vector special_notes; - vector talk_save; + std::vector journal; + std::vector special_notes; + std::vector talk_save; short direction; short at_which_save_slot; char alchemy[20]; bool can_find_town[200]; short key_times[100]; - vector party_event_timers; + std::vector party_event_timers; //short global_or_town[30]; //short node_to_call[30]; char spec_items[50]; char help_received[120]; short m_killed[200]; // monsters killed per town, I think long long total_m_killed, total_dam_done, total_xp_gained, total_dam_taken; - string scen_name; + std::string scen_name; cPlayer adven[6]; @@ -95,7 +97,7 @@ public: cMonster summons; // an array of monsters which can be summoned by the parties items yet don't originate from this scenario bool graphicUsed[250]; // whether each custom graphics slot on the party's sheet is actually used; needed to place new custom graphics on the sheet. unsigned short scen_won, scen_played; // numbers of scenarios won and played respectively by this party - map > campaign_flags; + std::map > campaign_flags; cParty& operator = (legacy::party_record_type& old); void append(legacy::big_tr_type& old); @@ -111,11 +113,13 @@ public: bool record(short what, short where); bool start_timer(short time, short node, short type); - typedef vector::iterator encIter; - typedef vector::iterator journalIter; - typedef vector::iterator talkIter; - typedef vector::iterator timerIter; - typedef map >::iterator campIter; - void writeTo(ostream& file); - void readFrom(istream& file); + typedef std::vector::iterator encIter; + typedef std::vector::iterator journalIter; + typedef std::vector::iterator talkIter; + typedef std::vector::iterator timerIter; + typedef std::map >::iterator campIter; + void writeTo(std::ostream& file); + void readFrom(std::istream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/pc.cpp b/osx/classes/pc.cpp index 1b81e8ac..e982132e 100644 --- a/osx/classes/pc.cpp +++ b/osx/classes/pc.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" @@ -246,49 +246,49 @@ void operator -= (eMainStatus& stat, eMainStatus othr){ stat = (eMainStatus) (-10 + stat); } -void cPlayer::writeTo(ostream& file){ - file << "STATUS -1 " << main_status << endl; - file << "NAME " << name << endl; - file << "SKILL -2 " << max_health << endl; - file << "SKILL -1 " << max_sp << endl; +void cPlayer::writeTo(std::ostream& file){ + file << "STATUS -1 " << main_status << std::endl; + file << "NAME " << name << std::endl; + file << "SKILL -2 " << max_health << std::endl; + file << "SKILL -1 " << max_sp << std::endl; for(int i = 0; i < 30; i++) if(skills[i] > 0) - file << "SKILL " << i << ' ' << skills[i] << endl; - file << "HEALTH " << cur_health << endl; - file << "MANA " << cur_sp << endl; - file << "EXPERIENCE " << experience << endl; - file << "SKILLPTS " << skill_pts << endl; - file << "LEVEL " << level << endl; + file << "SKILL " << i << ' ' << skills[i] << std::endl; + file << "HEALTH " << cur_health << std::endl; + file << "MANA " << cur_sp << std::endl; + file << "EXPERIENCE " << experience << std::endl; + file << "SKILLPTS " << skill_pts << std::endl; + file << "LEVEL " << level << std::endl; for(int i = 0; i < 15; i++) if(status[i] != 0) - file << "STATUS " << i << ' ' << status[i] << endl; + file << "STATUS " << i << ' ' << status[i] << std::endl; for(int i; i < 24; i++) if(items[i].variety > ITEM_TYPE_NO_ITEM){ - ostringstream sout; + std::ostringstream sout; sout << "ITEM " << i << ' '; items[i].writeTo(file, sout.str()); } for(int i = 0; i < 24; i++) if(equip[i]) - file << "EQUIP " << i << endl; + file << "EQUIP " << i << std::endl; for(int i = 0; i < 62; i++) if(mage_spells[i]) - file << "MAGE " << i << endl; + file << "MAGE " << i << std::endl; for(int i = 0; i < 62; i++) if(priest_spells[i]) - file << "PRIEST " << i << endl; + file << "PRIEST " << i << std::endl; for(int i = 0; i < 62; i++) if(traits[i]) - file << "TRAIT " << i << endl; - file << "ICON " << which_graphic << endl; - file << "RACE " << race << endl; - file << "DIRECTION " << direction << endl; - file << "POISON " << weap_poisoned << endl; + file << "TRAIT " << i << std::endl; + file << "ICON " << which_graphic << std::endl; + file << "RACE " << race << std::endl; + file << "DIRECTION " << direction << std::endl; + file << "POISON " << weap_poisoned << std::endl; } -void cPlayer::readFrom(istream& file){ - istringstream bin, sin; - string cur; +void cPlayer::readFrom(std::istream& file){ + std::istringstream bin, sin; + std::string cur; getline(file, cur, '\f'); bin.str(cur); while(bin) { // continue as long as no error, such as eof, occurs @@ -360,11 +360,11 @@ void cPlayer::readFrom(istream& file){ } } -ostream& operator << (ostream& out, eMainStatus& e){ +std::ostream& operator << (std::ostream& out, eMainStatus& e){ return out << (int) e; } -istream& operator >> (istream& in, eMainStatus& e){ +std::istream& operator >> (std::istream& in, eMainStatus& e){ int i; in >> i; if(i > 0 && i < 18 && i !=8 && i != 9) diff --git a/osx/classes/pc.h b/osx/classes/pc.h index 80a691fc..a77f416e 100644 --- a/osx/classes/pc.h +++ b/osx/classes/pc.h @@ -6,6 +6,11 @@ * */ +#ifndef PC_H +#define PC_H + +#include +#include namespace legacy { struct pc_record_type; }; @@ -33,7 +38,7 @@ enum eMainStatus { class cPlayer { public: eMainStatus main_status; - string name; + std::string name; short skills[30]; unsigned short max_health; short cur_health; @@ -60,11 +65,13 @@ public: cPlayer(); cPlayer(long key,short slot); short get_tnl(); - void writeTo(ostream& file); - void readFrom(istream& file); + void writeTo(std::ostream& file); + void readFrom(std::istream& file); }; void operator += (eMainStatus& stat, eMainStatus othr); void operator -= (eMainStatus& stat, eMainStatus othr); -ostream& operator << (ostream& out, eMainStatus& e); -istream& operator >> (istream& in, eMainStatus& e); +std::ostream& operator << (std::ostream& out, eMainStatus& e); +std::istream& operator >> (std::istream& in, eMainStatus& e); + +#endif \ No newline at end of file diff --git a/osx/classes/regtown.cpp b/osx/classes/regtown.cpp index e074383a..8713a9a8 100644 --- a/osx/classes/regtown.cpp +++ b/osx/classes/regtown.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/regtown.h b/osx/classes/regtown.h index 6de09a91..20b731fb 100644 --- a/osx/classes/regtown.h +++ b/osx/classes/regtown.h @@ -6,6 +6,11 @@ * */ +#ifndef REGTOWN_H +#define REGTOWN_H + +#include + namespace legacy { struct big_tr_type; struct ave_tr_type; @@ -28,7 +33,7 @@ public: short max_monst(); cBigTown(); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; class cMedTown : public cTown { // formerly ave_tr_type @@ -47,7 +52,7 @@ public: short max_monst(); cMedTown(); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; class cTinyTown : public cTown { // formerly tiny_tr_type @@ -66,5 +71,7 @@ public: short max_monst(); cTinyTown(); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/scenario.cpp b/osx/classes/scenario.cpp index 217fa566..f89c9210 100644 --- a/osx/classes/scenario.cpp +++ b/osx/classes/scenario.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/scenario.h b/osx/classes/scenario.h index d5894aa5..369dd2ee 100644 --- a/osx/classes/scenario.h +++ b/osx/classes/scenario.h @@ -6,6 +6,11 @@ * */ +#ifndef SCENARIO_H +#define SCENARIO_H + +#include + namespace legacy{ struct scenario_data_type; struct item_storage_shortcut_type; @@ -87,5 +92,7 @@ public: char(& scen_strs(short i))[256]; cScenario& operator = (legacy::scenario_data_type& old); void append(legacy::scen_item_data_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/special.cpp b/osx/classes/special.cpp index b058be63..d63d0cf0 100644 --- a/osx/classes/special.cpp +++ b/osx/classes/special.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/special.h b/osx/classes/special.h index e2e2ac0f..ebacefce 100644 --- a/osx/classes/special.h +++ b/osx/classes/special.h @@ -6,6 +6,11 @@ * */ +#ifndef SPECIAL_H +#define SPECIAL_H + +#include + namespace legacy { struct special_node_type; }; class cSpecial { @@ -24,5 +29,7 @@ public: cSpecial(); cSpecial& operator = (legacy::special_node_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/talking.cpp b/osx/classes/talking.cpp index 9753ed4b..4d4c53ef 100644 --- a/osx/classes/talking.cpp +++ b/osx/classes/talking.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/talking.h b/osx/classes/talking.h index d3e0747b..cfdaa7ea 100644 --- a/osx/classes/talking.h +++ b/osx/classes/talking.h @@ -6,6 +6,11 @@ * */ +#ifndef TALKING_H +#define TALKING_H + +#include + namespace legacy { struct talking_record_type; struct talking_node_type; @@ -24,5 +29,7 @@ public: cNode talk_nodes[60]; cSpeech& operator = (legacy::talking_record_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/terrain.cpp b/osx/classes/terrain.cpp index 47a9de95..f6798598 100644 --- a/osx/classes/terrain.cpp +++ b/osx/classes/terrain.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/terrain.h b/osx/classes/terrain.h index 292b4d59..2d776af4 100644 --- a/osx/classes/terrain.h +++ b/osx/classes/terrain.h @@ -6,6 +6,12 @@ * */ +#ifndef TERRAIN_H +#define TERRAIN_H + +#include +#include + namespace legacy { struct terrain_type_type; }; /* Terrains Specials Properties : scenario.ter_types[i].special */ //complete @@ -99,7 +105,7 @@ enum eTrimType { class cTerrain { public: - string name; + std::string name; short picture; unsigned char blockage; unsigned short flag1; @@ -123,5 +129,7 @@ public: unsigned short i; // for temporary use in porting cTerrain& operator = (legacy::terrain_type_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/tmpltown.cpp b/osx/classes/tmpltown.cpp index c3b536e8..ff59f8bd 100644 --- a/osx/classes/tmpltown.cpp +++ b/osx/classes/tmpltown.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" diff --git a/osx/classes/tmpltown.h b/osx/classes/tmpltown.h index 76c89e8d..b513bb10 100644 --- a/osx/classes/tmpltown.h +++ b/osx/classes/tmpltown.h @@ -6,6 +6,11 @@ * */ +#ifndef TMPLTOWN_H +#define TMPLTOWN_H + +#include + class cTemplTown { public: class cCityBlock { // formerly city_block_type @@ -24,7 +29,7 @@ public: }; cCityBlock blocks[15]; cTerRect ter_rects[10]; - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; class cBigTemplTown : public cBigTown, cTemplTown { @@ -40,7 +45,7 @@ public: unsigned char& lighting(size_t i, size_t r); short max_dim(); short max_monst(); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; class cMedTemplTown : public cMedTown, cTemplTown { @@ -56,7 +61,7 @@ public: unsigned char& lighting(size_t i, size_t r); short max_dim(); short max_monst(); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; class cTinyTemplTown : public cTinyTown, cTemplTown { @@ -95,3 +100,5 @@ public: // city_block_type city_block[15]; // city_ter_rect_type city_ter_rect[10]; //}; + +#endif \ No newline at end of file diff --git a/osx/classes/town.cpp b/osx/classes/town.cpp index 9a1e70a3..fab79bf9 100644 --- a/osx/classes/town.cpp +++ b/osx/classes/town.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/town.h b/osx/classes/town.h index cb59c8af..7053dbed 100644 --- a/osx/classes/town.h +++ b/osx/classes/town.h @@ -6,6 +6,12 @@ * */ +#ifndef TOWN_H +#define TOWN_H + +#include +#include + namespace legacy { struct town_record_type; struct big_tr_type; @@ -68,7 +74,7 @@ public: rectangle in_town_rect; cItem preset_items[64]; short max_num_monst; - vector preset_fields; + std::vector preset_fields; short spec_on_entry,spec_on_entry_if_dead; short timer_spec_times[8]; short timer_specs[8]; @@ -99,5 +105,7 @@ public: cTown(); cTown(short size); cTown& operator = (legacy::town_record_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; + +#endif \ No newline at end of file diff --git a/osx/classes/universe.cpp b/osx/classes/universe.cpp index 0cbc8fb9..5425b97c 100644 --- a/osx/classes/universe.cpp +++ b/osx/classes/universe.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" @@ -667,13 +667,13 @@ unsigned short(& cCurOut::operator [] (size_t i))[96]{ return out[i]; } -void cCurOut::writeTo(ostream& file){ +void cCurOut::writeTo(std::ostream& file){ // for(int i = 0; i < 96; i++){ // file << expl[i][0]; // for(int j = 1; j < 96; j++){ // file << '\t' << expl[i][j]; // } -// file << endl; +// file << std::endl; // } // file << '\f'; // for(int i = 9; i < 96; i++){ @@ -681,7 +681,7 @@ void cCurOut::writeTo(ostream& file){ // for(int j = 1; j < 96; j++){ // file << '\t' << out[i][j]; // } -// file << endl; +// file << std::endl; // } // file << '\f'; for(int i = 0; i < 96; i++){ @@ -689,28 +689,28 @@ void cCurOut::writeTo(ostream& file){ for(int j = 1; j < 96; j++){ file << '\t' << out_e[i][j]; } - file << endl; + file << std::endl; } -// file << "OUTDOORS 0 0" << endl; +// file << "OUTDOORS 0 0" << std::endl; // outdoors[0][0].writeTo(file); -// file << "OUTDOORS 0 1" << endl; +// file << "OUTDOORS 0 1" << std::endl; // outdoors[0][1].writeTo(file); -// file << "OUTDOORS 1 0" << endl; +// file << "OUTDOORS 1 0" << std::endl; // outdoors[1][0].writeTo(file); -// file << "OUTDOORS 1 1" << endl; +// file << "OUTDOORS 1 1" << std::endl; // outdoors[1][1].writeTo(file); -// file << endl; +// file << std::endl; } -void cCurTown::writeTo(ostream& file){ - file << "TOWN " << num << endl; - file << "DIFFICULTY " << difficulty << endl; - if(hostile) file << "HOSTILE" << endl; - file << "INBOAT " << in_boat << endl; - file << "AT " << p_loc.x << ' ' << p_loc.y << endl; +void cCurTown::writeTo(std::ostream& file){ + file << "TOWN " << num << std::endl; + file << "DIFFICULTY " << difficulty << std::endl; + if(hostile) file << "HOSTILE" << std::endl; + file << "INBOAT " << in_boat << std::endl; + file << "AT " << p_loc.x << ' ' << p_loc.y << std::endl; for(int i; i < 115; i++) if(items[i].variety > ITEM_TYPE_NO_ITEM){ - ostringstream sout; + std::ostringstream sout; sout << "ITEM " << i << ' '; items[i].writeTo(file, sout.str()); } @@ -719,22 +719,22 @@ void cCurTown::writeTo(ostream& file){ file << fields[i][0]; for(int j = 1; j < 64; j++) file << '\t' << fields[i][j]; - file << endl; + file << std::endl; } - file << '\f' << record->max_dim() << endl; + file << '\f' << record->max_dim() << std::endl; for(int i = 0; i < record->max_dim(); i++){ file << record->terrain(i,0); for(int j = 1; j < record->max_dim(); j++) file << '\t' << record->terrain(i,j); - file << endl; + file << std::endl; } file << '\f'; // TODO: Write population } -void cCurTown::readFrom(istream& file){ - istringstream bin, sin; - string cur; +void cCurTown::readFrom(std::istream& file){ + std::istringstream bin, sin; + std::string cur; getline(file, cur, '\f'); bin.str(cur); while(bin){ @@ -785,7 +785,7 @@ void cCurTown::readFrom(istream& file){ } -void cCurOut::readFrom(istream& file){ +void cCurOut::readFrom(std::istream& file){ for(int i = 0; i < 96; i++) for(int j = 1; j < 96; j++) file >> out_e[i][j]; diff --git a/osx/classes/universe.h b/osx/classes/universe.h index 6e15be04..46bbe4d9 100644 --- a/osx/classes/universe.h +++ b/osx/classes/universe.h @@ -6,6 +6,11 @@ * */ +#ifndef UNIVERSE_H +#define UNIVERSE_H + +#include + namespace legacy { struct out_info_type; struct current_town_type; @@ -102,8 +107,8 @@ public: bool set_bones(char x, char y, bool b); bool set_rubble(char x, char y, bool b); // bool set_trim(char x, char y, char t, bool b); - void writeTo(ostream& file); - void readFrom(istream& file); + void writeTo(std::ostream& file); + void readFrom(std::istream& file); }; class cCurOut { @@ -119,8 +124,8 @@ public: void append(legacy::out_info_type& old); unsigned short(& operator [] (size_t i))[96]; - void writeTo(ostream& file); - void readFrom(istream& file); + void writeTo(std::ostream& file); + void readFrom(std::istream& file); }; class cUniverse{ @@ -135,3 +140,5 @@ public: void append(legacy::stored_town_maps_type& old); void append(legacy::stored_outdoor_maps_type& old); }; + +#endif \ No newline at end of file diff --git a/osx/classes/vehicle.cpp b/osx/classes/vehicle.cpp index 7f865874..2075a146 100644 --- a/osx/classes/vehicle.cpp +++ b/osx/classes/vehicle.cpp @@ -10,7 +10,7 @@ #include #include #include -using namespace std; + #include "classes.h" #include "oldstructs.h" diff --git a/osx/classes/vehicle.h b/osx/classes/vehicle.h index ef2b5698..d465e7f8 100644 --- a/osx/classes/vehicle.h +++ b/osx/classes/vehicle.h @@ -6,6 +6,10 @@ * */ +#ifndef VEHICLE_H +#define VEHICLE_H + +#include #include "location.h" namespace legacy { @@ -27,7 +31,7 @@ public: cVehicle(); cVehicle& operator = (legacy::horse_record_type& old); cVehicle& operator = (legacy::boat_record_type& old); - void writeTo(ostream& file); + void writeTo(std::ostream& file); }; /* @@ -42,3 +46,5 @@ typedef struct { bool exists,property; } boat_record_type; */ + +#endif \ No newline at end of file diff --git a/osx/oldstructs.h b/osx/oldstructs.h index d652083b..ed8a7165 100644 --- a/osx/oldstructs.h +++ b/osx/oldstructs.h @@ -6,6 +6,9 @@ * */ +#ifndef OLDSTRUCTS_H +#define OLDSTRUCTS_H + namespace legacy { //#define NLS 25 // // number of left slots for buttons @@ -15,357 +18,359 @@ namespace legacy { // // number of right slots for scrolling list on page at 1 time struct location { - char x,y; + char x,y __attribute__((aligned(2))); }; struct special_node_type { - short type,sd1,sd2,pic,m1,m2,ex1a,ex1b,ex2a,ex2b,jumpto; + short type,sd1,sd2,pic,m1,m2,ex1a,ex1b,ex2a,ex2b,jumpto __attribute__((aligned(2))); }; struct talking_node_type { - short personality,type; - char link1[4],link2[4]; - short extras[4]; + short personality,type __attribute__((aligned(2))); + char link1[4],link2[4] __attribute__((aligned(2))); + short extras[4] __attribute__((aligned(2))); }; struct talking_record_type { - unsigned char strlens[200]; - talking_node_type talk_nodes[60]; + unsigned char strlens[200] __attribute__((aligned(2))); + talking_node_type talk_nodes[60] __attribute__((aligned(2))); }; struct terrain_type_type { - short picture; - unsigned char blockage,flag1,flag2,special,trans_to_what,fly_over,boat_over; - unsigned char block_horse,light_radius,step_sound,shortcut_key,res1,res2,res3; + short picture __attribute__((aligned(2))); + unsigned char blockage,flag1,flag2,special,trans_to_what,fly_over,boat_over __attribute__((aligned(2))); + unsigned char block_horse,light_radius,step_sound,shortcut_key,res1,res2,res3 __attribute__((aligned(2))); }; struct wandering_type { - unsigned char monst[4]; + unsigned char monst[4] __attribute__((aligned(2))); }; struct out_wandering_type { - unsigned char monst[7]; - unsigned char friendly[3]; - short spec_on_meet,spec_on_win,spec_on_flee,cant_flee; - short end_spec1,end_spec2; + unsigned char monst[7] __attribute__((aligned(2))); + unsigned char friendly[3] __attribute__((aligned(2))); + short spec_on_meet,spec_on_win,spec_on_flee,cant_flee __attribute__((aligned(2))); + short end_spec1,end_spec2 __attribute__((aligned(2))); }; struct outdoor_record_type { - unsigned char terrain[48][48]; - location special_locs[18]; - unsigned char special_id[18]; - location exit_locs[8]; - char exit_dests[8]; - location sign_locs[8]; - out_wandering_type wandering[4],special_enc[4]; - location wandering_locs[4]; - Rect info_rect[8]; - unsigned char strlens[180]; - special_node_type specials[60]; + unsigned char terrain[48][48] __attribute__((aligned(2))); + location special_locs[18] __attribute__((aligned(2))); + unsigned char special_id[18] __attribute__((aligned(2))); + location exit_locs[8] __attribute__((aligned(2))); + char exit_dests[8] __attribute__((aligned(2))); + location sign_locs[8] __attribute__((aligned(2))); + out_wandering_type wandering[4],special_enc[4] __attribute__((aligned(2))); + location wandering_locs[4] __attribute__((aligned(2))); + Rect info_rect[8] __attribute__((aligned(2))); + unsigned char strlens[180] __attribute__((aligned(2))); + special_node_type specials[60] __attribute__((aligned(2))); }; struct creature_start_type { - unsigned char number; - unsigned char start_attitude; - location start_loc; - unsigned char mobile; - unsigned char time_flag; - unsigned char extra1,extra2; - short spec1, spec2; - char spec_enc_code,time_code; - short monster_time,personality; - short special_on_kill,facial_pic; + unsigned char number __attribute__((aligned(2))); + unsigned char start_attitude __attribute__((aligned(2))); + location start_loc __attribute__((aligned(2))); + unsigned char mobile __attribute__((aligned(2))); + unsigned char time_flag __attribute__((aligned(2))); + unsigned char extra1,extra2 __attribute__((aligned(2))); + short spec1, spec2 __attribute__((aligned(2))); + char spec_enc_code,time_code __attribute__((aligned(2))); + short monster_time,personality __attribute__((aligned(2))); + short special_on_kill,facial_pic __attribute__((aligned(2))); }; struct short_item_record_type { - short variety, item_level; - char awkward, bonus, protection, charges, type; - unsigned char graphic_num,ability, type_flag, is_special; - short value; - bool identified, magic; - unsigned char weight, description_flag; - char full_name[25], name[15]; - unsigned char reserved1,reserved2; - unsigned char magic_use_type, ability_strength, treas_class, real_abil; + short variety, item_level __attribute__((aligned(2))); + char awkward, bonus, protection, charges, type __attribute__((aligned(2))); + unsigned char graphic_num,ability, type_flag, is_special __attribute__((aligned(2))); + short value __attribute__((aligned(2))); + bool identified, magic __attribute__((aligned(2))); + unsigned char weight, description_flag __attribute__((aligned(2))); + char full_name[25], name[15] __attribute__((aligned(2))); + unsigned char reserved1,reserved2 __attribute__((aligned(2))); + unsigned char magic_use_type, ability_strength, treas_class, real_abil __attribute__((aligned(2))); }; struct item_record_type { - short variety, item_level; - char awkward, bonus, protection, charges, type, magic_use_type; - unsigned char graphic_num,ability, ability_strength,type_flag, is_special; - short value; - unsigned char weight, special_class; - location item_loc; - char full_name[25], name[15]; - unsigned char treas_class,item_properties,reserved1,reserved2; + short variety, item_level __attribute__((aligned(2))); + char awkward, bonus, protection, charges, type, magic_use_type __attribute__((aligned(2))); + unsigned char graphic_num,ability, ability_strength,type_flag, is_special __attribute__((aligned(2))); + short value __attribute__((aligned(2))); + unsigned char weight, special_class __attribute__((aligned(2))); + location item_loc __attribute__((aligned(2))); + char full_name[25], name[15] __attribute__((aligned(2))); + unsigned char treas_class,item_properties,reserved1,reserved2 __attribute__((aligned(2))); }; struct preset_item_type { - location item_loc; - short item_code,ability; - unsigned char charges,always_there,property,contained; + location item_loc __attribute__((aligned(2))); + short item_code,ability __attribute__((aligned(2))); + unsigned char charges,always_there,property,contained __attribute__((aligned(2))); }; struct preset_field_type { - location field_loc; - short field_type; + location field_loc __attribute__((aligned(2))); + short field_type __attribute__((aligned(2))); }; struct town_record_type { - short town_chop_time,town_chop_key; - wandering_type wandering[4]; - location wandering_locs[4]; - location special_locs[50]; - unsigned char spec_id[50]; - location sign_locs[15]; - short lighting; - location start_locs[4]; - location exit_locs[4]; - short exit_specs[4]; - Rect in_town_rect; - preset_item_type preset_items[64]; - short max_num_monst; - preset_field_type preset_fields[50]; - short spec_on_entry,spec_on_entry_if_dead; - short timer_spec_times[8]; - short timer_specs[8]; - unsigned char strlens[180]; - special_node_type specials[100]; - unsigned char specials1,specials2,res1,res2; - short difficulty; + short town_chop_time,town_chop_key __attribute__((aligned(2))); + wandering_type wandering[4] __attribute__((aligned(2))); + location wandering_locs[4] __attribute__((aligned(2))); + location special_locs[50] __attribute__((aligned(2))); + unsigned char spec_id[50] __attribute__((aligned(2))); + location sign_locs[15] __attribute__((aligned(2))); + short lighting __attribute__((aligned(2))); + location start_locs[4] __attribute__((aligned(2))); + location exit_locs[4] __attribute__((aligned(2))); + short exit_specs[4] __attribute__((aligned(2))); + Rect in_town_rect __attribute__((aligned(2))); + preset_item_type preset_items[64] __attribute__((aligned(2))); + short max_num_monst __attribute__((aligned(2))); + preset_field_type preset_fields[50] __attribute__((aligned(2))); + short spec_on_entry,spec_on_entry_if_dead __attribute__((aligned(2))); + short timer_spec_times[8] __attribute__((aligned(2))); + short timer_specs[8] __attribute__((aligned(2))); + unsigned char strlens[180] __attribute__((aligned(2))); + special_node_type specials[100] __attribute__((aligned(2))); + unsigned char specials1,specials2,res1,res2 __attribute__((aligned(2))); + short difficulty __attribute__((aligned(2))); }; struct big_tr_type { - unsigned char terrain[64][64]; - Rect room_rect[16]; - creature_start_type creatures[60]; - unsigned char lighting[8][64]; + unsigned char terrain[64][64] __attribute__((aligned(2))); + Rect room_rect[16] __attribute__((aligned(2))); + creature_start_type creatures[60] __attribute__((aligned(2))); + unsigned char lighting[8][64] __attribute__((aligned(2))); }; struct ave_tr_type { - unsigned char terrain[48][48]; - Rect room_rect[16]; - creature_start_type creatures[40]; - unsigned char lighting[6][48]; + unsigned char terrain[48][48] __attribute__((aligned(2))); + Rect room_rect[16] __attribute__((aligned(2))); + creature_start_type creatures[40] __attribute__((aligned(2))); + unsigned char lighting[6][48] __attribute__((aligned(2))); }; struct tiny_tr_type { - unsigned char terrain[32][32]; - Rect room_rect[16]; - creature_start_type creatures[30]; - unsigned char lighting[4][32]; + unsigned char terrain[32][32] __attribute__((aligned(2))); + Rect room_rect[16] __attribute__((aligned(2))); + creature_start_type creatures[30] __attribute__((aligned(2))); + unsigned char lighting[4][32] __attribute__((aligned(2))); }; struct city_block_type { - short block_type; - short block_destroy_time; - char block_alignment; - char block_key_time; - location block_loc; + short block_type __attribute__((aligned(2))); + short block_destroy_time __attribute__((aligned(2))); + char block_alignment __attribute__((aligned(2))); + char block_key_time __attribute__((aligned(2))); + location block_loc __attribute__((aligned(2))); }; struct city_ter_rect_type { - Rect what_rect; - unsigned char ter_type; - unsigned char hollow; + Rect what_rect __attribute__((aligned(2))); + unsigned char ter_type __attribute__((aligned(2))); + unsigned char hollow __attribute__((aligned(2))); }; struct template_town_type { - creature_start_type creatures[30]; - city_block_type city_block[15]; - city_ter_rect_type city_ter_rect[10]; + creature_start_type creatures[30] __attribute__((aligned(2))); + city_block_type city_block[15] __attribute__((aligned(2))); + city_ter_rect_type city_ter_rect[10] __attribute__((aligned(2))); }; struct scen_item_data_type { - item_record_type scen_items[400]; - char monst_names[256][20]; - char ter_names[256][30]; + item_record_type scen_items[400] __attribute__((aligned(2))); + char monst_names[256][20] __attribute__((aligned(2))); + char ter_names[256][30] __attribute__((aligned(2))); }; struct item_storage_shortcut_type { - short ter_type,item_num[10],item_odds[10],property; + short ter_type,item_num[10],item_odds[10],property __attribute__((aligned(2))); }; struct monster_record_type { - unsigned char m_num,level,m_name[26]; - short health,m_health,mp,max_mp; - unsigned char armor,skill; - short a[3]; - unsigned char a1_type,a23_type,m_type,speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison; - short morale,m_morale; - short corpse_item,corpse_item_chance; - short status[15]; - unsigned char direction,immunities,x_width,y_width,radiate_1,radiate_2; - unsigned char default_attitude,summon_type,default_facial_pic,res1,res2,res3; - short picture_num; + unsigned char m_num,level,m_name[26] __attribute__((aligned(2))); + short health,m_health,mp,max_mp __attribute__((aligned(2))); + unsigned char armor,skill __attribute__((aligned(2))); + short a[3] __attribute__((aligned(2))); + unsigned char a1_type,a23_type,m_type,speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison __attribute__((aligned(2))); + short morale,m_morale __attribute__((aligned(2))); + short corpse_item,corpse_item_chance __attribute__((aligned(2))); + short status[15] __attribute__((aligned(2))); + unsigned char direction,immunities,x_width,y_width,radiate_1,radiate_2 __attribute__((aligned(2))); + unsigned char default_attitude,summon_type,default_facial_pic,res1,res2,res3 __attribute__((aligned(2))); + short picture_num __attribute__((aligned(2))); }; struct horse_record_type { - location horse_loc,horse_loc_in_sec,horse_sector; - short which_town; - bool exists,property; + location horse_loc,horse_loc_in_sec,horse_sector __attribute__((aligned(2))); + short which_town __attribute__((aligned(2))); + bool exists,property __attribute__((aligned(2))); }; struct boat_record_type { - location boat_loc,boat_loc_in_sec,boat_sector; - short which_town; - bool exists,property; + location boat_loc,boat_loc_in_sec,boat_sector __attribute__((aligned(2))); + short which_town __attribute__((aligned(2))); + bool exists,property __attribute__((aligned(2))); }; struct talk_save_type { - short personality; - short town_num; - short str1,str2; + short personality __attribute__((aligned(2))); + short town_num __attribute__((aligned(2))); + short str1,str2 __attribute__((aligned(2))); }; struct creature_data_type { - short active,attitude; - unsigned char number; - location m_loc; - monster_record_type m_d; - short mobile; - short summoned; - creature_start_type monst_start; + short active,attitude __attribute__((aligned(2))); + unsigned char number __attribute__((aligned(2))); + location m_loc __attribute__((aligned(2))); + monster_record_type m_d __attribute__((aligned(2))); + short mobile __attribute__((aligned(2))); + short summoned __attribute__((aligned(2))); + creature_start_type monst_start __attribute__((aligned(2))); }; struct creature_list_type { - creature_data_type dudes[60]; - short which_town; - short friendly; + creature_data_type dudes[60] __attribute__((aligned(2))); + short which_town __attribute__((aligned(2))); + short friendly __attribute__((aligned(2))); }; struct outdoor_creature_type { - bool exists; - short direction; - out_wandering_type what_monst; - location which_sector,m_loc; + bool exists __attribute__((aligned(2))); + short direction __attribute__((aligned(2))); + out_wandering_type what_monst __attribute__((aligned(2))); + location which_sector,m_loc __attribute__((aligned(2))); }; struct party_record_type { - long age; - short gold,food; - unsigned char stuff_done[310][10],item_taken[200][8]; - short light_level; - location outdoor_corner,i_w_c,p_loc,loc_in_sec; - boat_record_type boats[30]; - horse_record_type horses[30]; - creature_list_type creature_save[4]; - short in_boat,in_horse; - outdoor_creature_type out_c[10]; - item_record_type magic_store_items[5][10]; - short imprisoned_monst[4]; - char m_seen[256]; - char journal_str[50]; - short journal_day[50]; - short special_notes_str[140][2]; - talk_save_type talk_save[120]; - short direction,at_which_save_slot; - char alchemy[20]; - bool can_find_town[200]; - short key_times[100]; - short party_event_timers[30]; - short global_or_town[30]; - short node_to_call[30]; - char spec_items[50],help_received[120]; - short m_killed[200]; - long total_m_killed,total_dam_done,total_xp_gained,total_dam_taken; - char scen_name[256]; + long age __attribute__((aligned(2))); + short gold,food __attribute__((aligned(2))); + unsigned char stuff_done[310][10],item_taken[200][8] __attribute__((aligned(2))); + short light_level __attribute__((aligned(2))); + location outdoor_corner,i_w_c,p_loc,loc_in_sec __attribute__((aligned(2))); + boat_record_type boats[30] __attribute__((aligned(2))); + horse_record_type horses[30] __attribute__((aligned(2))); + creature_list_type creature_save[4] __attribute__((aligned(2))); + short in_boat,in_horse __attribute__((aligned(2))); + outdoor_creature_type out_c[10] __attribute__((aligned(2))); + item_record_type magic_store_items[5][10] __attribute__((aligned(2))); + short imprisoned_monst[4] __attribute__((aligned(2))); + char m_seen[256] __attribute__((aligned(2))); + char journal_str[50] __attribute__((aligned(2))); + short journal_day[50] __attribute__((aligned(2))); + short special_notes_str[140][2] __attribute__((aligned(2))); + talk_save_type talk_save[120] __attribute__((aligned(2))); + short direction,at_which_save_slot __attribute__((aligned(2))); + char alchemy[20] __attribute__((aligned(2))); + bool can_find_town[200] __attribute__((aligned(2))); + short key_times[100] __attribute__((aligned(2))); + short party_event_timers[30] __attribute__((aligned(2))); + short global_or_town[30] __attribute__((aligned(2))); + short node_to_call[30] __attribute__((aligned(2))); + char spec_items[50],help_received[120] __attribute__((aligned(2))); + short m_killed[200] __attribute__((aligned(2))); + long total_m_killed,total_dam_done,total_xp_gained,total_dam_taken __attribute__((aligned(2))); + char scen_name[256] __attribute__((aligned(2))); }; struct scenario_data_type { - unsigned char out_width,out_height,difficulty,intro_pic,default_ground; - unsigned char town_size[200]; - unsigned char town_hidden[200]; - short flag_a; - short intro_mess_pic,intro_mess_len; - location where_start,out_sec_start,out_start; - short which_town_start; - short flag_b; - short town_data_size[200][5]; - short town_to_add_to[10]; - short flag_to_add_to_town[10][2]; - short flag_c; - short out_data_size[100][2]; - Rect store_item_rects[3]; - short store_item_towns[3]; - short flag_e; - short special_items[50]; - short special_item_special[50]; - short rating,uses_custom_graphics; - short flag_f; - monster_record_type scen_monsters[256]; - boat_record_type scen_boats[30]; - horse_record_type scen_horses[30]; - short flag_g; - terrain_type_type ter_types[256]; - short scenario_timer_times[20]; - short scenario_timer_specs[20]; - short flag_h; - special_node_type scen_specials[256]; - item_storage_shortcut_type storage_shortcuts[10]; - short flag_d; - unsigned char scen_str_len[300]; - short flag_i; - location last_out_edited; - short last_town_edited; + unsigned char out_width,out_height,difficulty,intro_pic,default_ground __attribute__((aligned(2))); + unsigned char town_size[200] __attribute__((aligned(2))); + unsigned char town_hidden[200] __attribute__((aligned(2))); + short flag_a __attribute__((aligned(2))); + short intro_mess_pic,intro_mess_len __attribute__((aligned(2))); + location where_start,out_sec_start,out_start __attribute__((aligned(2))); + short which_town_start __attribute__((aligned(2))); + short flag_b __attribute__((aligned(2))); + short town_data_size[200][5] __attribute__((aligned(2))); + short town_to_add_to[10] __attribute__((aligned(2))); + short flag_to_add_to_town[10][2] __attribute__((aligned(2))); + short flag_c __attribute__((aligned(2))); + short out_data_size[100][2] __attribute__((aligned(2))); + Rect store_item_rects[3] __attribute__((aligned(2))); + short store_item_towns[3] __attribute__((aligned(2))); + short flag_e __attribute__((aligned(2))); + short special_items[50] __attribute__((aligned(2))); + short special_item_special[50] __attribute__((aligned(2))); + short rating,uses_custom_graphics __attribute__((aligned(2))); + short flag_f __attribute__((aligned(2))); + monster_record_type scen_monsters[256] __attribute__((aligned(2))); + boat_record_type scen_boats[30] __attribute__((aligned(2))); + horse_record_type scen_horses[30] __attribute__((aligned(2))); + short flag_g __attribute__((aligned(2))); + terrain_type_type ter_types[256] __attribute__((aligned(2))); + short scenario_timer_times[20] __attribute__((aligned(2))); + short scenario_timer_specs[20] __attribute__((aligned(2))); + short flag_h __attribute__((aligned(2))); + special_node_type scen_specials[256] __attribute__((aligned(2))); + item_storage_shortcut_type storage_shortcuts[10] __attribute__((aligned(2))); + short flag_d __attribute__((aligned(2))); + unsigned char scen_str_len[300] __attribute__((aligned(2))); + short flag_i __attribute__((aligned(2))); + location last_out_edited __attribute__((aligned(2))); + short last_town_edited __attribute__((aligned(2))); }; struct setup_save_type { - unsigned char setup[4][64][64]; + unsigned char setup[4][64][64] __attribute__((aligned(2))); }; struct pc_record_type { - short main_status; - char name[20]; - short skills[30]; - short max_health,cur_health,max_sp,cur_sp,experience,skill_pts,level; - short status[15]; - item_record_type items[24]; - bool equip[24]; - bool priest_spells[62],mage_spells[62]; - short which_graphic,weap_poisoned; - bool advan[15],traits[15]; - short race,exp_adj,direction; + short main_status __attribute__((aligned(2))); + char name[20] __attribute__((aligned(2))); + short skills[30] __attribute__((aligned(2))); + short max_health,cur_health,max_sp,cur_sp,experience,skill_pts,level __attribute__((aligned(2))); + short status[15] __attribute__((aligned(2))); + item_record_type items[24] __attribute__((aligned(2))); + bool equip[24] __attribute__((aligned(2))); + bool priest_spells[62],mage_spells[62] __attribute__((aligned(2))); + short which_graphic,weap_poisoned __attribute__((aligned(2))); + bool advan[15],traits[15] __attribute__((aligned(2))); + short race,exp_adj,direction __attribute__((aligned(2))); }; struct town_item_list { - item_record_type items[115]; + item_record_type items[115] __attribute__((aligned(2))); }; struct stored_town_maps_type { - char town_maps[200][8][64]; + char town_maps[200][8][64] __attribute__((aligned(2))); }; typedef struct stored_outdoor_maps_type { - char outdoor_maps[100][6][48]; + char outdoor_maps[100][6][48] __attribute__((aligned(2))); }; struct stored_items_list_type { - item_record_type items[115]; + item_record_type items[115] __attribute__((aligned(2))); }; struct current_town_type { - short town_num, difficulty; - town_record_type town; - char explored[64][64]; - bool hostile; - creature_list_type monst; - bool in_boat; - location p_loc; + short town_num, difficulty __attribute__((aligned(2))); + town_record_type town __attribute__((aligned(2))); + char explored[64][64] __attribute__((aligned(2))); + bool hostile __attribute__((aligned(2))); + creature_list_type monst __attribute__((aligned(2))); + bool in_boat __attribute__((aligned(2))); + location p_loc __attribute__((aligned(2))); }; struct out_info_type { - char expl[96][96]; + char expl[96][96] __attribute__((aligned(2))); }; // struct piles_of_stuff_dumping_type { -// char strings_ls[NLS][40]; -// char strings_rs[NRS][40]; -// char town_strs[180][256]; -// char out_strs[120][256]; -// char scen_strs[270][256]; -// char talk_strs[170][256]; -// scen_item_data_type scen_item_list; +// char strings_ls[NLS][40] __attribute__((aligned(2))); +// char strings_rs[NRS][40] __attribute__((aligned(2))); +// char town_strs[180][256] __attribute__((aligned(2))); +// char out_strs[120][256] __attribute__((aligned(2))); +// char scen_strs[270][256] __attribute__((aligned(2))); +// char talk_strs[170][256] __attribute__((aligned(2))); +// scen_item_data_type scen_item_list __attribute__((aligned(2))); // }; }; + +#endif diff --git a/osx/tools/dlgutil.cpp b/osx/tools/dlgutil.cpp index 26d88fbf..410d8fdc 100644 --- a/osx/tools/dlgutil.cpp +++ b/osx/tools/dlgutil.cpp @@ -320,7 +320,6 @@ void display_strings(char *text1, char *text2, short item_hit; location view_loc; - bool sound_done = false; //make_cursor_sword(); diff --git a/osx/tools/fileio.cpp b/osx/tools/fileio.cpp index 4e7100ec..6a240038 100644 --- a/osx/tools/fileio.cpp +++ b/osx/tools/fileio.cpp @@ -10,11 +10,8 @@ #include #include #include -using namespace std; -#include #include -#include //#include "scen.global.h" #include #include "classes.h" @@ -127,10 +124,10 @@ FSSpec nav_get_scenario() throw(no_file_chosen) { } FSSpec nav_put_scenario() throw(no_file_chosen) { - NavReplyRecord s_reply; + /*NavReplyRecord s_reply; AEKeyword keyword; DescType descType; - Size actualSize; + Size actualSize;*/ FSSpec file_to_load; return file_to_load; @@ -182,7 +179,6 @@ FSSpec nav_put_party() throw(no_file_chosen) { throw no_file_chosen(); // Deal with multiple file selection - long count; error = AECountItems(&(s_reply.selection), &descCount); // Set up index for file list if (error == noErr){ @@ -222,7 +218,7 @@ FSSpec nav_put_party() throw(no_file_chosen) { error=FSGetCatalogInfo(&tempRef, kFSCatInfoNone, NULL,NULL, &file_to_save, NULL); } else{ //something bad happened - printf("creation error was: %i\n",error); + printf("creation error was: %i\n",(int32_t)error); throw no_file_chosen(); // TODO: This should probably be some other exception. } } @@ -258,12 +254,12 @@ struct header_posix_ustar { header_posix_ustar generateTarHeader(const std::string& fileName, unsigned long long fileSize,bool directory=false){ if(fileSize>077777777777LL) - throw length_error("Specified file size >= 8 GB"); + throw std::length_error("Specified file size >= 8 GB"); if(fileName.length()>=100) - throw length_error("Specified file name longer than 99 characters."); + throw std::length_error("Specified file name longer than 99 characters."); header_posix_ustar header; char* init = (char*) &header; - for(int i = 0; i < sizeof(header); i++) init[i] = 0; + for(unsigned int i = 0; i < sizeof(header); i++) init[i] = 0; sprintf(header.name,"%s",fileName.c_str()); sprintf(header.mode,"%07o",0600); @@ -288,7 +284,7 @@ header_posix_ustar generateTarHeader(const std::string& fileName, unsigned long sum+=ptr[i]; } if(sum>0777777) - throw runtime_error("Checksum overflow"); + throw std::runtime_error("Checksum overflow"); sprintf(header.checksum,"%o",sum); return(header); } @@ -1139,8 +1135,8 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma char* path = new char[200]; FSpMakeFSRef(&file_to_load, &dest_ref); FSRefMakePath(&dest_ref, (UInt8*) path, 200); - ifstream fin(path); - fin.seekg(3*sizeof(short),ios_base::beg); // skip the header, which is 6 bytes in the old format + std::ifstream fin(path); + fin.seekg(3*sizeof(short),std::ios_base::beg); // skip the header, which is 6 bytes in the old format //short flags[3]; //fin.read((char*)flags,3*sizeof(short)); // OSErr error = FSpOpenDF(&file_to_load,1,&file_id); @@ -1386,12 +1382,11 @@ bool load_party_v2(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma /* Initialize various variables */ header_posix_ustar header; - istringstream sin; - string tar_name; - string tar_entry; + std::istringstream sin; + std::string tar_name; + std::string tar_entry; size_t tar_size; - int x; - map party_archive; + std::map party_archive; /* Split the tar archive into its component files */ while(!gzeof(party_file)){ @@ -1417,7 +1412,7 @@ bool load_party_v2(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma for(int i = 0; i < 6; i++){ buf = new char[20]; sprintf(buf,"save/pc%i.txt",i); - string f_name = buf; + std::string f_name = buf; delete buf; if(party_archive.find(f_name) == party_archive.end()){ FCD(1064,0); @@ -1483,7 +1478,7 @@ bool save_party(FSSpec dest_file) FSRefMakePath(&dest_ref, (UInt8*)path, 200); //buf = new char[10000]; //FILE* f = fopen(path,"wb"); - ofstream fout(path); + std::ofstream fout(path); short flags[] = { 0x0B0E, // to indicate new format in_town ? 1342 : 5790, // is the party in town? @@ -1506,12 +1501,11 @@ bool save_party(FSSpec dest_file) /* Initialize buffer and other variables */ header_posix_ustar header; static char footer[2*sizeof(header_posix_ustar)] = {0}; - ostringstream sout(""); - ostringstream bout("",ios_base::binary); - string tar_entry; + std::ostringstream sout(""); + std::ostringstream bout("",std::ios_base::binary); + std::string tar_entry; size_t tar_size, y; int x; - streambuf* tmp = sout.rdbuf(); sout << x; /* Write main party data to a buffer, and then to the file */ univ.party.writeTo(sout); diff --git a/osx/tools/graphtool.cpp b/osx/tools/graphtool.cpp index 604dfbe2..2dd37013 100644 --- a/osx/tools/graphtool.cpp +++ b/osx/tools/graphtool.cpp @@ -138,7 +138,7 @@ GWorldPtr load_bmp(unsigned char *data, unsigned long length){ cur+=24; int indexed; unsigned int colourTable[256]; - int i; + unsigned int i; if (bitCount == 8) { if (length < 54 + 256 * 4) { return NULL; @@ -182,7 +182,7 @@ GWorldPtr load_bmp(unsigned char *data, unsigned long length){ unsigned int * picBuf = (unsigned int*) GetPixBaseAddr(pixMap); int pixrow = ((*pixMap)->rowBytes & 0x3FFF) / 4; - int j; + unsigned int j; for (i = height - 1; i>= 0 ; --i) { for (j=0; j