From 74ec4c67b5e08045d6ee9a7609f1b76200fe69dc Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 27 Apr 2009 13:14:24 +0000 Subject: [PATCH] Fixed several bugs, including one where dialogs were not redrawn properly and one where random numbers were not in the expected range. git-svn-id: http://openexile.googlecode.com/svn/trunk@36 4ebdad44-0ea0-11de-aab3-ff745001d230 --- osx/Blades of Exile Char Editor/pc.main.cpp | 7 +++--- osx/Scenario Editor/scen.main.cpp | 7 +++--- osx/boe.actions.cpp | 4 +++- osx/boe.combat.cpp | 4 ++-- osx/boe.consts.h | 2 +- osx/boe.dlgutil.cpp | 6 ++--- osx/boe.fileio.cpp | 2 +- osx/boe.main.cpp | 9 ++++---- osx/boe.party.cpp | 25 ++++++++++++--------- osx/boe.specials.cpp | 6 ++--- osx/boe.town.cpp | 3 ++- osx/misc/dlgtool.cpp | 2 +- osx/misc/mathutil.cpp | 2 +- osx/pc.h | 4 ++-- 14 files changed, 47 insertions(+), 36 deletions(-) diff --git a/osx/Blades of Exile Char Editor/pc.main.cpp b/osx/Blades of Exile Char Editor/pc.main.cpp index a327f5fa..500c33a0 100644 --- a/osx/Blades of Exile Char Editor/pc.main.cpp +++ b/osx/Blades of Exile Char Editor/pc.main.cpp @@ -194,7 +194,7 @@ void Initialize(void) OSErr error; //SysEnvRec theWorld; - unsigned long randSeed; + // unsigned long randSeed; BitMap screenBits; @@ -273,8 +273,9 @@ void Initialize(void) // will always be different. Don’t for each call of Random, or the sequence // will no longer be random. Only needed once, here in the init. // - GetDateTime(&randSeed); - SetQDGlobalsRandomSeed((long)randSeed); + //GetDateTime(&randSeed); + // SetQDGlobalsRandomSeed((long)randSeed); + srand(time(NULL)); // // Make a new window for drawing in, and it must be a color window. diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index 6e3a719f..c34be1e2 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -186,9 +186,10 @@ void Initialize(void) // will always be different. Don’t for each call of Random, or the sequence // will no longer be random. Only needed once, here in the init. // - unsigned long time; - GetDateTime(&time); - SetQDGlobalsRandomSeed(time); + //unsigned long time; + //GetDateTime(&time); + //SetQDGlobalsRandomSeed(time); + srand(time(NULL)); // // Make a new window for drawing in, and it must be a color window. diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 33839762..eb68f56f 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -2423,7 +2423,9 @@ void start_new_game() //which = choice - 1; // display_intro(); - init_party(0); + long keys = GetCurrentKeyModifiers(); + if(keys & 256) init_party(2); // if command key held down, create debug party + else init_party(0); //while (creation_done == FALSE) { edit_party(1,0); diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 4fc61983..f9edcdb2 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -1469,7 +1469,7 @@ void fire_missile(location target) { if (dist(pc_pos[current_pc],target) > range) add_string_to_buf(" Out of range."); - else if (can_see(pc_pos[current_pc],target,0) == 5) + else if (can_see(pc_pos[current_pc],target,0) >= 5) add_string_to_buf(" Can't see target. "); else { // First, some missiles do special things @@ -1556,7 +1556,7 @@ void fire_missile(location target) { } combat_posing_monster = current_working_monster = -1; - ADVEN[current_pc].status[0] = move_to_zero(ADVEN[current_pc].status[0]); + if(!exploding) ADVEN[current_pc].status[0] = move_to_zero(ADVEN[current_pc].status[0]); print_buf(); } diff --git a/osx/boe.consts.h b/osx/boe.consts.h index 86cbef99..ebed2b3b 100644 --- a/osx/boe.consts.h +++ b/osx/boe.consts.h @@ -46,7 +46,7 @@ #define SDF_LESS_SOUND 305][5 #define SDF_NO_TARGET_LINE 305][6 #define SDF_HOSTILES_PRESENT 305][9 -#define SFD_NO_MAPS 306][0 +#define SDF_NO_MAPS 306][0 #define SDF_NO_SOUNDS 306][1 #define SDF_NO_FRILLS 306][2 #define SDF_ROOM_DESCS_AGAIN 306][3 diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 4f0992da..981cea92 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -1529,7 +1529,7 @@ void prefs_event_filter (short item_hit) if (done_yet== TRUE) { if (did_cancel == FALSE) { display_mode = cur_display_mode; - PSD[SFD_NO_MAPS] = cd_get_led(1099,18); + PSD[SDF_NO_MAPS] = cd_get_led(1099,18); PSD[SDF_NO_SOUNDS] = cd_get_led(1099,20); play_sounds = 1 - PSD[SDF_NO_SOUNDS]; PSD[SDF_NO_FRILLS] = cd_get_led(1099,22); @@ -1561,7 +1561,7 @@ void prefs_event_filter (short item_hit) }*/ } //play_sounds = 1 - PSD[SDF_NO_SOUNDS]; - save_maps = 1 - PSD[SFD_NO_MAPS]; + save_maps = 1 - PSD[SDF_NO_MAPS]; give_delays = PSD[SDF_NO_FRILLS]; save_prefs(); } @@ -1579,7 +1579,7 @@ void pick_preferences() cd_set_led(1099,4 + cur_display_mode,1); - cd_set_led(1099,18,(PSD[SFD_NO_MAPS] != 0) ? 1 : 0); + cd_set_led(1099,18,(PSD[SDF_NO_MAPS] != 0) ? 1 : 0); cd_set_led(1099,20,(play_sounds == FALSE) ? 1 : 0); cd_set_led(1099,22,(PSD[SDF_NO_FRILLS] != 0) ? 1 : 0); cd_set_led(1099,24,(PSD[SDF_ROOM_DESCS_AGAIN] != 0) ? 1 : 0); diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index 1f1622e1..83d0e617 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -281,7 +281,7 @@ void finish_load_party(){ flip_sound(); } give_delays = PSD[SDF_NO_FRILLS]; - if (PSD[SFD_NO_MAPS] == 0) + if (PSD[SDF_NO_MAPS] == 0) save_maps = TRUE; else save_maps = FALSE; diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index c28e815c..de799312 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -280,12 +280,13 @@ void Initialize(void) // To make the Random sequences truly random, we need to make the seed start // at a different number. An easy way to do this is to put the current time // and date into the seed. Since it is always incrementing the starting seed - // will always be different. Don‚Äö√Ñ√¥t for each call of Random, or the sequence + // will always be different. Don't for each call of Random, or the sequence // will no longer be random. Only needed once, here in the init. // - unsigned long time; - GetDateTime(&time); - SetQDGlobalsRandomSeed(time); + //unsigned long time; + //GetDateTime(&time); + //SetQDGlobalsRandomSeed(time); + srand(time(NULL)); // // Make a new window for drawing in, and it must be a color window. diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 708235b3..1e791247 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -192,7 +192,7 @@ void put_spell_list(); void put_pick_spell_graphics(); -//mode; // 0 - prefab 1 - regular +//mode; // 0 - prefab 1 - regular 2 - debug void init_party(short mode) { short i,j,k,l; @@ -270,14 +270,19 @@ void init_party(short mode) refresh_store_items(); - for (i = 0; i < 6; i++) { - if (mode != 1) - //ADVEN[i] = cPlayer('dbug',i); + for (i = 0; i < 6; i++) { + switch(mode){ + case 0: ADVEN[i] = cPlayer('dflt',i); - else - //ADVEN[i] = cPlayer('dbug',i); + break; + case 1: ADVEN[i] = cPlayer(); + break; + case 2: + ADVEN[i] = cPlayer('dbug',i); + break; } + } for (i = 0; i < 96; i++) for (j = 0; j < 96; j++) @@ -300,7 +305,7 @@ void init_party(short mode) univ.out.maps[i][k][l] = 0; // Default is save maps - PSD[SFD_NO_MAPS] = 0; + PSD[SDF_NO_MAPS] = 0; save_maps = TRUE; @@ -605,7 +610,7 @@ void heal_pc(short pc_num,short amt) { if (ADVEN[pc_num].cur_health > ADVEN[pc_num].max_health) return; - if (ADVEN[pc_num].main_status != 1) + if (ADVEN[pc_num].main_status != MAIN_STATUS_ALIVE) return; ADVEN[pc_num].cur_health += amt; if (ADVEN[pc_num].cur_health > ADVEN[pc_num].max_health) @@ -618,7 +623,7 @@ void heal_party(short amt) short i; for (i = 0; i < 6; i++) - if (ADVEN[i].main_status == 1) + if (ADVEN[i].main_status == MAIN_STATUS_ALIVE ) heal_pc(i,amt); } @@ -1512,7 +1517,7 @@ void do_mage_spell(short pc_num,short spell_num) case 38: // Stealth ADVEN[pc_num].cur_sp -= spell_cost[0][spell_num]; - PSD[SFD_NO_MAPS] += max(6,ADVEN[pc_num].level * 2); + PSD[SDF_PARTY_STEALTHY] += max(6,ADVEN[pc_num].level * 2); break; diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 6bb2eaf6..6c5fe76b 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -140,7 +140,7 @@ return TRUE; Boolean check_special_terrain(location where_check,short mode,short which_pc,short *spec_num, Boolean *forced) -//short mode; // 0 - univ.out.out 1 - town 2 - combat +//short mode; // 0 - out 1 - town 2 - combat // returns true if can enter this space // sets forced to TRUE if definitely can enter { @@ -314,7 +314,7 @@ Boolean check_special_terrain(location where_check,short mode,short which_pc,sho } r1 = get_ran(ter_flag2,dam_type,ter_flag1); if (mode < 2) - hit_party(r1,DAMAGE_FIRE); + hit_party(r1,dam_type); fast_bang = 1; if (mode == 2) damage_pc(which_pc,r1,dam_type,MONSTER_TYPE_UNKNOWN,0); @@ -1578,7 +1578,7 @@ void special_increase_age() // This is the big painful one, the main special engine // which_mode - says when it was called -// 0 - univ.out.out moving (a - 1 if blocked) +// 0 - out moving (a - 1 if blocked) // 1 - town moving (a - 1 if blocked) // 2 - combat moving (a - 1 if blocked) // 3 - univ.out.out looking (a - 1 if don't get items inside) NOT USED!!! diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index b86b01e2..d8f1cc8e 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -698,8 +698,9 @@ location end_town_mode(short switching_level,location destination) // returns n erase_out_specials(); load_area_graphics(); - + PSD[SDF_PARTY_STEALTHY] = 0; + //PSD[SDF_PARTY_DETECT_LIFE] = 0; //Yes? No? Maybe? for (i = 0; i < 6; i++) for (j = 0; j < 15; j++) if ((j != 2) && (j != 7) && (j != 9)) diff --git a/osx/misc/dlgtool.cpp b/osx/misc/dlgtool.cpp index 90ca482a..b7638206 100644 --- a/osx/misc/dlgtool.cpp +++ b/osx/misc/dlgtool.cpp @@ -180,7 +180,7 @@ short cd_kill_dialog(short dlog_num,short parent_message){ dlgs[which_dlg].key = -1; if (dlgs[which_dlg].parent != NULL) SetPortWindowPort( dlgs[which_dlg].parent); - if (redraw_screen != NULL && FrontWindow() != mainPtr) + if (redraw_screen != NULL && FrontWindow() == mainPtr) // Was formerly checkin != mainPtr for some reason... redraw_screen(); untoast_dialog(); return 0; diff --git a/osx/misc/mathutil.cpp b/osx/misc/mathutil.cpp index 451b7373..6ef985f0 100644 --- a/osx/misc/mathutil.cpp +++ b/osx/misc/mathutil.cpp @@ -15,7 +15,7 @@ short get_ran (short times,short min,short max){ for (i = 1; i < times + 1; i++) { store = rand(); - to_ret += min + (((store + 32767) * (max - min + 1)) / 65536); + to_ret += min + (store % (max - min + 1));//min + (((store + 32767) * (max - min + 1)) / 65536); } return to_ret; } diff --git a/osx/pc.h b/osx/pc.h index 59a9d2f7..1a700364 100644 --- a/osx/pc.h +++ b/osx/pc.h @@ -35,9 +35,9 @@ public: eMainStatus main_status; char name[20]; short skills[30]; - short max_health; + unsigned short max_health; short cur_health; - short max_sp; + unsigned short max_sp; short cur_sp; unsigned short experience; short skill_pts;