Strictify skill enum

This commit is contained in:
2014-12-14 02:51:01 -05:00
parent 1200ff47d4
commit a198c232bb
23 changed files with 557 additions and 466 deletions

View File

@@ -9,6 +9,7 @@
#include "boe.menus.h"
#include <Cocoa/Cocoa.h>
#include <array>
#include "universe.h"
#include "scenario.h"
#include "boe.party.h"
@@ -17,7 +18,7 @@
extern short on_spell_menu[2][62];
extern short spell_level[62];
extern short spell_cost[2][62];
extern std::map<eSkill,std::array<short,62>> spell_cost;
extern short on_monst_menu[256];
extern const char* mage_s_name[62];
extern const char* priest_s_name[62];
@@ -56,8 +57,9 @@ MenuHandle actions_menu,music_menu,mage_spells_menu,priest_spells_menu;
@end
@interface SpellWrapper : NSObject
@property int type, num;
+(id) withSpell:(int) num ofType:(int) type;
@property int num;
@property eSkill type;
+(id) withSpell:(int) num ofType:(eSkill) type;
@end
void hideMenuBar() {
@@ -186,7 +188,7 @@ void adjust_spell_menus()
on_spell_menu[0][i] = -1;
}
for (i = 0; i < 62; i++)
if (pc_can_cast_spell(current_pc,0,i)) {
if (pc_can_cast_spell(current_pc,eSkill::MAGE_SPELLS,i)) {
on_spell_menu[0][spell_pos] = i;
spell_pos++;
}
@@ -199,9 +201,9 @@ void adjust_spell_menus()
}
for (i = 0; i < 62; i++)
if (on_spell_menu[0][i] >= 0) {
if (spell_cost[0][on_spell_menu[0][i]] > 0)
if (spell_cost[eSkill::MAGE_SPELLS][on_spell_menu[0][i]] > 0)
sprintf(spell_name," L%d - %s, C %d",spell_level[on_spell_menu[0][i]],
mage_s_name[on_spell_menu[0][i]],spell_cost[0][on_spell_menu[0][i]]);
mage_s_name[on_spell_menu[0][i]],spell_cost[eSkill::MAGE_SPELLS][on_spell_menu[0][i]]);
else sprintf(spell_name," L%d - %s, C ?",spell_level[on_spell_menu[0][i]],
mage_s_name[on_spell_menu[0][i]]);
spell_name[0] = strlen((char *) spell_name);
@@ -209,7 +211,7 @@ void adjust_spell_menus()
NSString* str = [NSString stringWithUTF8String: spell_name];
NSMenuItem* newItem = [spell_menu addItemWithTitle: str action: @selector(spellMenu:) keyEquivalent: @""];
[newItem setTarget: targ];
[newItem setRepresentedObject: [SpellWrapper withSpell: on_spell_menu[0][i] ofType: 0]];
[newItem setRepresentedObject: [SpellWrapper withSpell: on_spell_menu[0][i] ofType: eSkill::MAGE_SPELLS]];
}
}
@@ -222,7 +224,7 @@ void adjust_spell_menus()
on_spell_menu[1][i] = -1;
}
for (i = 0; i < 62; i++)
if (pc_can_cast_spell(current_pc,1,i)) {
if (pc_can_cast_spell(current_pc,eSkill::PRIEST_SPELLS,i)) {
on_spell_menu[1][spell_pos] = i;
spell_pos++;
}
@@ -237,16 +239,16 @@ void adjust_spell_menus()
if (on_spell_menu[1][i] >= 0) {
//spell_name[0] = strlen((char *) priest_s_name[on_spell_menu[1][i]]);
//strcpy((char *) (spell_name + 1),priest_s_name[on_spell_menu[1][i]]);
if (spell_cost[1][on_spell_menu[1][i]] > 0)
if (spell_cost[eSkill::PRIEST_SPELLS][on_spell_menu[1][i]] > 0)
sprintf(spell_name," L%d - %s, C %d",spell_level[on_spell_menu[1][i]],
priest_s_name[on_spell_menu[1][i]],spell_cost[1][on_spell_menu[1][i]]);
priest_s_name[on_spell_menu[1][i]],spell_cost[eSkill::PRIEST_SPELLS][on_spell_menu[1][i]]);
else sprintf(spell_name," L%d - %s, C ?",spell_level[i],
priest_s_name[on_spell_menu[1][i]]);
spell_name[0] = strlen((char *) spell_name);
NSString* str = [NSString stringWithUTF8String: spell_name];
NSMenuItem* newItem = [spell_menu addItemWithTitle: str action: @selector(spellMenu:) keyEquivalent: @""];
[newItem setTarget: targ];
[newItem setRepresentedObject: [SpellWrapper withSpell: on_spell_menu[1][i] ofType: 1]];
[newItem setRepresentedObject: [SpellWrapper withSpell: on_spell_menu[1][i] ofType: eSkill::PRIEST_SPELLS]];
}
}
@@ -288,7 +290,7 @@ void handle_help_menu(int item_hit);
void handle_library_menu(int item_hit);
void handle_actions_menu(int item_hit);
void handle_monster_info_menu(int item_hit);
void handle_menu_spell(short spell_picked,short spell_type);
void handle_menu_spell(short spell_picked,eSkill spell_type);
@implementation MenuHandler
-(void) appMenu:(id) sender {
@@ -350,7 +352,7 @@ void handle_menu_spell(short spell_picked,short spell_type);
@implementation SpellWrapper
@synthesize type, num;
+(id) withSpell:(int) num ofType:(int) type {
+(id) withSpell:(int) num ofType:(eSkill) type {
SpellWrapper* wrapper = [[SpellWrapper alloc] init];
[wrapper setType: type];
[wrapper setNum: num];