- Fixed more major bugs, both in game and scenario editor.

- Removed all remnants of the password code (I think).
- The game is now almost ready for beta.

git-svn-id: http://openexile.googlecode.com/svn/trunk@49 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
2009-05-02 20:25:13 +00:00
parent d60b8a7fb1
commit 1cbb12e1b8
25 changed files with 858 additions and 1433 deletions

View File

@@ -65,14 +65,11 @@ FSSpec file_to_load;
void load_base_item_defs();
bool load_scen_item_defs(char scen_name[256]);
//void load_file()
//{
// //SFReply reply;
// //StandardFileReply s_reply;
// Point where = {40,40};
// Str255 message = "Select saved game:";
// long file_size;
//bool select_save_location(FSSpec* to_save_ptr){
// if(to_save_ptr==NULL)
// return(false);
// OSErr error;
// Str255 message = "\pSelect saved game: ";
// NavTypeListHandle type_list;
// NavDialogCreationOptions dialogOptions;
// NavDialogRef theDialog;
@@ -81,576 +78,79 @@ bool load_scen_item_defs(char scen_name[256]);
// AEKeyword dummyKeyword;
// long descCount;
// long descNum;
// FSRef fileRef;
// short file_id,i,j,k;
// bool town_restore = false;
// bool maps_there = false;
// bool map_doh = false;
// bool in_scen = false;
//
// flag_type fred;
// flag_type *store;
// char flag_data[8];
//
// town_item_list *item_ptr;
// long len,store_len,count;
// out_info_type *explored_ptr;
// char *party_ptr;
// char *pc_ptr;
// flag_type flag;
// flag_type *flag_ptr;
// stored_items_list_type *items_ptr;
//
// short flags[3][2] = {{5790,1342}, // slot 0 ... 5790 - out 1342 - town
// {100,200}, // slot 1 100 in scenario, 200 not in
// {3422,5567}}; // slot 2 ... 3422 - no maps 5567 - maps
//
// OSType typeList[2] = {'beSV','TEXT'};
// type_list = (NavTypeListHandle)NewHandle(sizeof(NavTypeList) + 2 * sizeof(OSType));
//
// if (type_list != NULL){
// (*type_list)->componentSignature = 'blx!';
// (*type_list)->osTypeCount = 2;
// BlockMoveData(&typeList, (*type_list)->osType, 2 * sizeof(OSType));
// }
//
// if (ae_loading == false) {
// //StandardGetFile(NULL,1,type_list,&s_reply);
// // StandardGetFile is not available in Carbon -jmr
// /* XXX FIXME general lack of error checking in these nav services calls */
// NavGetDefaultDialogCreationOptions(&dialogOptions);
// NavCreateChooseFileDialog(&dialogOptions, type_list, NULL,
// NULL, NULL, NULL, &theDialog);
// NavDialogRun(theDialog);
// theAction = NavDialogGetUserAction(theDialog);
// if (theAction == kNavUserActionCancel || theAction == kNavUserActionNone) {
// NavDialogDispose(theDialog);
// return;
// }
// NavDialogGetReply(theDialog, &dialogReply);
//
// AECountItems(&(dialogReply.selection), &descCount);
// for (descNum = 1 ; descNum <= descCount ; descNum++) {
// DescType returnedType;
// Size actualSize;
// AEGetNthPtr(&(dialogReply.selection), descNum, typeWildCard,
// &dummyKeyword, &returnedType, (Ptr)(&fileRef),
// sizeof(fileRef), &actualSize);
// /* we'd get typeFSS on classic Mac OS, but I have omitted that check due to laziness -jmr */
// if (returnedType == typeFSRef)
// break;
// }
// if (descNum > descCount) {
// /* no valid file reference came back from the dialog - shouldn't happen... */
// NavDisposeReply(&dialogReply);
// NavDialogDispose(theDialog);
// return;
// }
//
// FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL,
// NULL, &file_to_load, NULL);
//
// NavDisposeReply(&dialogReply);
// /* XXX FIXME general lack of error checking in these nav services calls */
// NavGetDefaultDialogCreationOptions(&dialogOptions);
// NavCreatePutFileDialog(&dialogOptions, 'beSV', 'blx!',NULL, NULL, &theDialog);
// NavDialogRun(theDialog);
// theAction = NavDialogGetUserAction(theDialog);
// if (theAction == kNavUserActionCancel || theAction == kNavUserActionNone) {
// NavDialogDispose(theDialog);
// return(false);
// }
//
// if ((error = FSpOpenDF(&file_to_load,1,&file_id)) != 0) {
// FCD(1064,0);
// SysBeep(2);
// return;
// }
//
// file_size = sizeof(party_record_type);
//
// len = sizeof(flag_type);
//
// // sprintf((char *) debug, " Len %d ", (short) len);
// // add_string_to_buf((char *) debug);
//
// for (i = 0; i < 3; i++) {
// if ((error = FSRead(file_id, &len, (char *) flag_data)) != 0) {
// FSClose(file_id);
// FCD(1064,0);
// return;
// }
// flag_ptr = (flag_type *) flag_data;
// flag = *flag_ptr;
// store_flags[i] = (short) flag.i;
// if ((flag.i != flags[i][0]) && (flag.i != flags[i][1])) { // OK BoE save file?
// FSClose(file_id);
// FCD(1063,0);
// return;
// }
//
// if ((i == 0) && (flag.i == flags[i][1]))
// town_restore = true;
// if ((i == 1) && (flag.i == flags[i][0])) {
// in_scen = true;
// }
// if ((i == 2) && (flag.i == flags[i][1]))
// maps_there = true;
// }
//
// // LOAD PARTY
// len = (long) sizeof(party_record_type);
// store_len = len;
// party_ptr = (char *) &party;
// if ((error = FSRead(file_id, &len, (char *) party_ptr)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
// for (count = 0; count < store_len; count++)
// party_ptr[count] ^= 0x5C;
//
// // LOAD SETUP
// len = (long) sizeof(setup_save_type);
// if ((error = FSRead(file_id, &len, (char *) &setup_save)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// // LOAD PCS
// store_len = (long) sizeof(pc_record_type);
// for (i = 0; i < 6; i++) {
// len = store_len;
// pc_ptr = (char *) &ADVEN[i];
// if ((error = FSRead(file_id, &len, (char *) pc_ptr)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
// for (count = 0; count < store_len; count++)
// pc_ptr[count] ^= 0x6B;
// }
//
// if (in_scen == true) {
// // LOAD OUTDOOR MAP
// len = (long) sizeof(out_info_type);
// if ((error = FSRead(file_id, &len, (char *) out_e)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// // LOAD TOWN
// if (town_restore == true) {
// len = (long) sizeof(current_town_type);
// if ((error = FSRead(file_id, &len, (char *) &c_town)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// len = (long) sizeof(big_tr_type);
// if ((error = FSRead(file_id, &len, (char *) &t_d)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// len = (long) sizeof(town_item_list);
// if ((error = FSRead(file_id, &len, (char *) &t_i)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// }
//
// // LOAD STORED ITEMS
// for (i = 0; i < 3; i++) {
// len = (long) sizeof(stored_items_list_type);
// if ((error = FSRead(file_id, &len, (char *) &stored_items[i])) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
// }
//
// // LOAD SAVED MAPS
// if (maps_there == true) {
// len = (long) sizeof(stored_town_maps_type);
// if ((error = FSRead(file_id, &len, (char *) &(town_maps))) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// len = (long) sizeof(stored_outdoor_maps_type);
// if ((error = FSRead(file_id, &len, (char *) &o_maps)) != 0) {
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
// }
//
// // LOAD SFX & MISC_I
// len = (long) (64 * 64);
// if ((error = FSRead(file_id, &len, (char *) sfx)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
// if ((error = FSRead(file_id, &len, (char *) misc_i)) != 0){
// FSClose(file_id);
// SysBeep(2);
// FCD(1064,0);
// return;
// }
//
// } // end if_scen
//
// if ((error = FSClose(file_id)) != 0){
// add_string_to_buf("Load: Can't close file. ");
// SysBeep(2);
// return;
// }
//
// for (i = 0; i < 6; i++){
// if (ADVEN[i].main_status > 0) {
// current_active_pc = i;
// i = 6;
// }
// }
// file_in_mem = true;
// save_blocked = false;
// party_in_scen = in_scen;
//
// if (ae_loading == false) {
// /* not reached with Carbon */
// /*strcpy ((char *) last_load_file, (char *) reply.fName);*/
// } else {
// strcpy ((char *) last_load_file, (char *) file_to_load.name);
// store_file_reply = file_to_load;
// }
//
// //load item definitions
// if(party_in_scen){
// if(!load_scen_item_defs(party.scen_name)){
// load_base_item_defs();
// scen_items_loaded = false;
// }
// else
// scen_items_loaded = true;
// }
// else{
// load_base_item_defs();
// scen_items_loaded = false;
// }
// update_item_menu();
//
// redraw_screen();
//}
bool select_save_location(FSSpec* to_save_ptr){
if(to_save_ptr==NULL)
return(false);
OSErr error;
Str255 message = "\pSelect saved game: ";
NavTypeListHandle type_list;
NavDialogCreationOptions dialogOptions;
NavDialogRef theDialog;
NavUserAction theAction;
NavReplyRecord dialogReply;
AEKeyword dummyKeyword;
long descCount;
long descNum;
/* XXX FIXME general lack of error checking in these nav services calls */
NavGetDefaultDialogCreationOptions(&dialogOptions);
NavCreatePutFileDialog(&dialogOptions, 'beSV', 'blx!',NULL, NULL, &theDialog);
NavDialogRun(theDialog);
theAction = NavDialogGetUserAction(theDialog);
if (theAction == kNavUserActionCancel || theAction == kNavUserActionNone) {
NavDialogDispose(theDialog);
return(false);
}
NavDialogGetReply(theDialog, &dialogReply);
if(dialogReply.validRecord){
// Deal with multiple file selection
long count;
error = AECountItems(&(dialogReply.selection), &descCount);
// Set up index for file list
if (error == noErr){
long index;
for (index = 1; index <= 1; index++){
AEKeyword theKeyword;
DescType actualType;
Size actualSize;
FSSpec documentFSSpec;
// Get a pointer to selected file
error = AEGetNthPtr(&(dialogReply.selection), index,
typeFSS, &theKeyword,
&actualType,&documentFSSpec,
sizeof(documentFSSpec),
&actualSize);
if (error == noErr){
FSRef tempRef;
FSpMakeFSRef(&documentFSSpec,&tempRef);
UniChar uniname[256];
CFRange range = {0,255};
CFStringGetCharacters (dialogReply.saveFileName,range,uniname);
uniname[(UniCharCount)CFStringGetLength (dialogReply.saveFileName)]=0;
error=FSCreateFileUnicode(&tempRef, (UniCharCount)CFStringGetLength (dialogReply.saveFileName), (UniChar *) uniname, kFSCatInfoNone, NULL, NULL, to_save_ptr);
if(error==noErr){//file didn't exist and so we just created it
printf("created file\n");
//kludge to correctly set creator and file types so that we'll recognize the file when we go to open it later
FInfo fileInfo;
FSpGetFInfo(to_save_ptr, &fileInfo);
fileInfo.fdCreator='blx!';
fileInfo.fdType='beSV';
FSpSetFInfo(to_save_ptr, &fileInfo);
}
else{
if(error==dupFNErr){ //file already exists
UInt8 tempPath[512];
FSpMakeFSRef(to_save_ptr, &tempRef);
FSRefMakePath (&tempRef,tempPath,512);
CFStringRef path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/%S"),tempPath,uniname);
CFStringGetCString(path, (char*)tempPath, 512, kCFStringEncodingUTF8);
FSPathMakeRef(tempPath, &tempRef, NULL);
error=FSGetCatalogInfo(&tempRef, kFSCatInfoNone, NULL,NULL, to_save_ptr, NULL);
}
else{ //something bad happened
printf("creation error was: %i\n",error);
return(false);
}
}
}
else
return(false);
}
}
// Dispose of NavReplyRecord
error = NavDisposeReply(&dialogReply);
}
store_file_reply = *to_save_ptr;
NavDialogDispose(theDialog);
return(true);
}
//void save_file(FSSpec to_save)
//{
// long file_size;
// OSErr error;
//
// short file_id;
// bool got_error = false,in_scen = false,town_save = false,save_maps = false;
// FSRef fileRef;
//
// if ((error = FSpOpenDF(&to_save,3,&file_id)) != 0) {
// printf("Save: Couldn't open file, error %i.\n",error);
// add_string_to_buf("Save: Couldn't open file. ");
// SysBeep(2);
// return;
// }
// strcpy ((char *) last_load_file, (char *) to_save.name);
//
// short i,j;
//
// long len,store_len,count;
// flag_type flag;
// flag_type *store;
//
// char* party_encryptor;
// char debug[60];
//
// if (file_in_mem == false)
// return;
//
// if (save_blocked == true) {
// FCD(903,0);
// return;
// }
//
// if (store_flags[0] == 1342)
// town_save = true;
// else
// town_save = false;
// if (store_flags[1] == 100)
// in_scen = true;
// else
// in_scen = false;
// if (store_flags[2] == 5567)
// save_maps = true;
// else
// save_maps = false;
//
// store = &flag;
//
// len = sizeof(flag_type);
//
// flag.i = store_flags[0];
// if ((error = FSWrite(file_id, &len, (char *) store)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// }
// flag.i = store_flags[1];
// if ((error = FSWrite(file_id, &len, (char *) store)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// flag.i = store_flags[2];
// if ((error = FSWrite(file_id, &len, (char *) store)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
//
// // SAVE PARTY
// party_record_type* party_ptr = &party;
// len = sizeof(party_record_type);
//
// store_len = len;
// party_encryptor = (char *) party_ptr;
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x5C;
// if ((error = FSWrite(file_id, &len, (char *) party_ptr)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x5C;
// SysBeep(2);
// return;
// }
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x5C;
//
// // SAVE SETUP
// setup_save_type* setup_ptr = &setup_save;
// len = sizeof(setup_save_type);
// if ((error = FSWrite(file_id, &len, (char *) setup_ptr)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
//
// // SAVE PCS
// store_len = sizeof(pc_record_type);
// for (i = 0; i < 6; i++) {
// pc_record_type* pc_ptr = &ADVEN[i];
//
// len = store_len;
// party_encryptor = (char *) pc_ptr;
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x6B;
// if ((error = FSWrite(file_id, &len, (char *) pc_ptr)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x6B;
// SysBeep(2);
// return;
// }
// for (count = 0; count < store_len; count++)
// party_encryptor[count] ^= 0x6B;
// }
//
// if (party_in_scen == true) {
// // SAVE OUT DATA
// len = sizeof(out_info_type);
// if ((error = FSWrite(file_id, &len, (char *) out_e)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// if (town_save == true) {
// current_town_type* town_ptr = &c_town;
// len = sizeof(current_town_type);
// if ((error = FSWrite(file_id, &len, (char *) town_ptr)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// big_tr_type* town_data_ptr = &t_d;
// len = sizeof(big_tr_type);
// if ((error = FSWrite(file_id, &len, (char *) town_data_ptr)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// town_item_list* item_ptr = &t_i;
// len = sizeof(town_item_list);
// if ((error = FSWrite(file_id, &len, (char *) item_ptr)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// }
// // Save stored items
// for (i = 0; i < 3; i++) {
// stored_items_list_type* items_ptr = &stored_items[i];
// len = (long) sizeof(stored_items_list_type);
// if ((error = FSWrite(file_id, &len, (char *) items_ptr)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// NavDialogGetReply(theDialog, &dialogReply);
// if(dialogReply.validRecord){
// // Deal with multiple file selection
// long count;
// error = AECountItems(&(dialogReply.selection), &descCount);
// // Set up index for file list
// if (error == noErr){
// long index;
// for (index = 1; index <= 1; index++){
// AEKeyword theKeyword;
// DescType actualType;
// Size actualSize;
// FSSpec documentFSSpec;
// // Get a pointer to selected file
// error = AEGetNthPtr(&(dialogReply.selection), index,
// typeFSS, &theKeyword,
// &actualType,&documentFSSpec,
// sizeof(documentFSSpec),
// &actualSize);
// if (error == noErr){
// FSRef tempRef;
// FSpMakeFSRef(&documentFSSpec,&tempRef);
// UniChar uniname[256];
// CFRange range = {0,255};
// CFStringGetCharacters (dialogReply.saveFileName,range,uniname);
// uniname[(UniCharCount)CFStringGetLength (dialogReply.saveFileName)]=0;
// error=FSCreateFileUnicode(&tempRef, (UniCharCount)CFStringGetLength (dialogReply.saveFileName), (UniChar *) uniname, kFSCatInfoNone, NULL, NULL, to_save_ptr);
// if(error==noErr){//file didn't exist and so we just created it
// printf("created file\n");
// //kludge to correctly set creator and file types so that we'll recognize the file when we go to open it later
// FInfo fileInfo;
// FSpGetFInfo(to_save_ptr, &fileInfo);
// fileInfo.fdCreator='blx!';
// fileInfo.fdType='beSV';
// FSpSetFInfo(to_save_ptr, &fileInfo);
// }
// else{
// if(error==dupFNErr){ //file already exists
// UInt8 tempPath[512];
// FSpMakeFSRef(to_save_ptr, &tempRef);
// FSRefMakePath (&tempRef,tempPath,512);
// CFStringRef path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/%S"),tempPath,uniname);
// CFStringGetCString(path, (char*)tempPath, 512, kCFStringEncodingUTF8);
// FSPathMakeRef(tempPath, &tempRef, NULL);
// error=FSGetCatalogInfo(&tempRef, kFSCatInfoNone, NULL,NULL, to_save_ptr, NULL);
// }
// else{ //something bad happened
// printf("creation error was: %i\n",error);
// return(false);
// }
// }
// }
// else
// return(false);
// }
// }
// // If saving maps, save maps
// if (save_maps == true) {
// stored_town_maps_type* maps_ptr = &(town_maps);
// len = (long) sizeof(stored_town_maps_type);
// if ((error = FSWrite(file_id, &len, (char *) maps_ptr)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// stored_outdoor_maps_type* o_maps_ptr = &o_maps;
// len = (long) sizeof(stored_outdoor_maps_type);
// if ((error = FSWrite(file_id, &len, (char *) o_maps_ptr)) != 0) {
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// }
// // SAVE SFX and MISC_I
// len = (long) (64 * 64);
// if ((error = FSWrite(file_id, &len, (char *) sfx)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// if ((error = FSWrite(file_id, &len, (char *) misc_i)) != 0){
// add_string_to_buf("Save: Couldn't write to file. ");
// FSClose(file_id);
// SysBeep(2);
// return;
// }
// // Dispose of NavReplyRecord
// error = NavDisposeReply(&dialogReply);
// }
// if ((error = FSClose(file_id)) != 0) {
// add_string_to_buf("Save: Couldn't close file. ");
// SysBeep(2);
// return;
// }
// file_to_load = to_save;
//
// store_file_reply = *to_save_ptr;
//
// NavDialogDispose(theDialog);
// return(true);
//}
void leave_town()
@@ -665,188 +165,6 @@ void remove_party_from_scen()
load_base_item_defs();
}
//long open_pref_file()
//{
// Str255 pref_name;
// short vol_ref = 0;
// long dir_ID = 0,stored_key;
// FSSpec pref;
// short file_ref_num;
// PrefHandle data_handle;
//
// GetIndString(pref_name,5,19);
// if (sys_7_avail == true)
// FindFolder(kOnSystemDisk,kPreferencesFolderType,kDontCreateFolder,&vol_ref,&dir_ID);
// FSMakeFSSpec(vol_ref,dir_ID,pref_name,&pref);
// file_ref_num = FSpOpenResFile(&pref,fsCurPerm);
// if (file_ref_num == -1) {
// save_prefs();
// //make_pref_file(pref);
// return -1;
// }
//
// UseResFile(file_ref_num);
// data_handle = (PrefHandle) Get1Resource('PRFN',128);
//
// if ((**data_handle).l[2] != 0)
// give_intro_hint = true;
// else
// give_intro_hint = false;
// display_mode = (short) ((**data_handle).l[3]);
// play_sounds = (short) ((**data_handle).l[4]);
// register_flag = (long) (800000) - (**data_handle).l[5];
// stored_key = (long) (700000) - (**data_handle).l[7];
// ed_flag = (long) (800000) - (**data_handle).l[6];
// ed_key = (long) (700000) - (**data_handle).l[8];
//
// if ((registered == true) && (stored_key != init_data(register_flag))) {
// display_mode = 0;
// CloseResFile(file_ref_num);
// save_prefs();
// return -100;
// }
// if ((stored_key != init_data(register_flag)) && ((register_flag < 10000) || (register_flag > 30000)
// || (display_mode < 0) || (display_mode > 5) || (ed_flag < 0) || (ed_flag > 10000)) ) {
// registered = false;
// if ((register_flag < 10000) || (register_flag > 30000))
// register_flag = get_ran(1,10000,30000);
// if ((ed_flag < 0) || (ed_flag > 10000))
// ed_flag = 10000;
//
// stored_key = 0;
// display_mode = 0;
// CloseResFile(file_ref_num);
// save_prefs();
// return -100;
// }
//
// CloseResFile(file_ref_num);
//
// return stored_key;
//}
void make_pref_file(FSSpec pref)
{
short file_ref_num;
Handle app_handle;
short res_ID;
ResType res_type;
Str255 res_name = "xxx";
short res_attributes;
short i,rf;
// rf = CurResFile();
// UseResFile(rf);
// app_handle = Get1Resource('PRFN',128);
// for (i = 0; i < 10; i++)
// (**(PrefHandle)app_handle).l[i] = (long) (get_ran(1,-20000,20000)) * (i + 2);
// (**(PrefHandle)app_handle).l[2] = (long) (give_intro_hint);
// (**(PrefHandle)app_handle).l[3] = (long) (display_mode);
// (**(PrefHandle)app_handle).l[4] = (long) (play_sounds);
// if (register_flag == 0) {
// register_flag = (long) get_ran(1,10000,20000);
// ed_flag = get_ran(1,5000,9999);
// }
// Amputating this code, cause it's broken, while save prefs code works OK
// (**(PrefHandle)app_handle).l[5] = (long) (800000) - register_flag;
// if (registered == true)
// (**(PrefHandle)app_handle).l[7] = (long) (700000) - init_data(register_flag);
// (**(PrefHandle)app_handle).l[6] = (long) (800000) - ed_flag;
// if (ed_reg == true)
// (**(PrefHandle)app_handle).l[8] = (long) (700000) - init_data(ed_flag);
// GetResInfo((Handle) app_handle,&res_ID,&res_type,res_name);
// res_attributes = GetResAttrs(app_handle);
// DetachResource(app_handle);
FSpCreateResFile(&pref,'EX3!','E3PR',smSystemScript);
// save_prefs();
return;
// FSpCreateResFile(&pref,'RSED','rsrc',smSystemScript);
file_ref_num = FSpOpenResFile(&pref,fsCurPerm);
UseResFile(file_ref_num);
AddResource(app_handle,res_type,res_ID,res_name);
SetResAttrs(app_handle,res_attributes);
ChangedResource(app_handle);
WriteResource(app_handle);
ReleaseResource(app_handle);
CloseResFile(file_ref_num);
}
//void save_prefs()
//{
// short file_ref_num;
// Handle old_handle,data_handle;
// short vol_ref,i;
// short res_ID;
// long dir_ID;
// ResType res_type = 'PRFN';
// Str255 res_name;
// short res_attributes;
// StringPtr source_str;
// Size byte_count;
// FSSpec pref;
// short app_res_num;
// Str255 pref_name;
//
// app_res_num = CurResFile();
//
// GetIndString(pref_name,5,19);
// if (sys_7_avail == true)
// FindFolder(kOnSystemDisk,kPreferencesFolderType,
// kDontCreateFolder,&vol_ref,&dir_ID);
// FSMakeFSSpec(vol_ref,dir_ID,pref_name,&pref);
// file_ref_num = FSpOpenResFile(&pref,fsCurPerm);
// if (file_ref_num == -1) {
// make_pref_file(pref);
// file_ref_num = FSpOpenResFile(&pref,fsCurPerm);
//// return;
// }
//
// UseResFile(file_ref_num);
//
// data_handle = NewHandleClear(sizeof(PrefRecord));
// HLock(data_handle);
//
// for (i = 0; i < 10; i++)
// (**(PrefHandle)data_handle).l[i] = (long) (get_ran(1,-20000,20000)) * (i + 2);
// (**(PrefHandle)data_handle).l[2] = (long) (give_intro_hint);
// (**(PrefHandle)data_handle).l[3] = (long) (display_mode);
// (**(PrefHandle)data_handle).l[4] = (long) (play_sounds);
//
//
// if (register_flag == 0) {
// register_flag = (long) get_ran(1,10000,20000);
// ed_flag = get_ran(1,5000,9999);
// }
// (**(PrefHandle)data_handle).l[5] = (long) (800000) - register_flag;
// (**(PrefHandle)data_handle).l[6] = (long) (800000) - ed_flag;
// if (registered == true)
// (**(PrefHandle)data_handle).l[7] = (long) (700000) - init_data(register_flag);
// if (ed_reg == true)
// (**(PrefHandle)data_handle).l[8] = (long) (700000) - init_data(ed_flag);
//
// old_handle = Get1Resource('PRFN',128);
// GetResInfo(old_handle,&res_ID,&res_type,res_name);
// res_attributes = GetResAttrs(old_handle);
// RemoveResource(old_handle);
//
// AddResource(data_handle,'PRFN',128,res_name);
// WriteResource(data_handle);
// HUnlock(data_handle);
// ReleaseResource(data_handle);
//
// CloseResFile(file_ref_num);
// UseResFile(app_res_num);
//}
/*
* XXX This was referenced but not defined, so I copied the implementation
* from blxfileio.c. Need to check that it's OK.

View File

@@ -1,8 +1,8 @@
bool select_save_location(FSSpec* to_save_ptr);
//bool select_save_location(FSSpec* to_save_ptr);
//void save_file(FSSpec to_save);
//void load_file();
void leave_town();
long do_waterfall(long flag);
//long do_waterfall(long flag);
short init_data(short flag);
//long open_pref_file();
//void make_pref_file(FSSpec pref);

View File

@@ -189,6 +189,7 @@ int main(void)
//
//MW specified argument and return type.
void check_for_intel();
void Initialize(void)
{
@@ -197,7 +198,7 @@ void Initialize(void)
// unsigned long randSeed;
BitMap screenBits;
check_for_intel();
//Open the resource files we'll be needing
char cPath[768];
CFBundleRef mainBundle=CFBundleGetMainBundle();
@@ -536,14 +537,17 @@ void handle_file_menu(int item_hit)
save_party(file_to_load);
break;
case 2://save as
if(select_save_location(&file))
try{
file = nav_put_party();
save_party(file);
} catch(no_file_chosen){}
break;
case 3://open
if (verify_restore_quit(1) == true){
FSSpec* file = nav_get_party();
file_to_load = *file;
load_party(file_to_load);
try{
file_to_load = nav_get_party();
load_party(file_to_load);
} catch(no_file_chosen){}
}
break;
case 5://how to order
@@ -555,6 +559,18 @@ void handle_file_menu(int item_hit)
}
}
void check_for_intel(){
SInt32 response;
OSErr err;
err = Gestalt(gestaltSysArchitecture,&response);
if(err != noErr){
printf("Gestalt error %i\n",err);
exit(1);
}
if(response == gestaltIntel) mac_is_intel = true;
else mac_is_intel = false;
}
void handle_extra_menu(int item_hit)
{
short i,j,choice;