Don't use CoreFoundation to check machine's endianness

This commit is contained in:
2014-12-03 18:04:33 -05:00
parent 7a2a0f93d3
commit efa552a366
7 changed files with 11 additions and 48 deletions

View File

@@ -1,6 +1,4 @@
#include <CoreFoundation/CoreFoundation.h>
#include <iostream>
#include <fstream>
@@ -77,7 +75,7 @@ fs::path file_to_load;
fs::path store_file_reply;
short jl;
bool cur_scen_is_mac = true;
extern bool cur_scen_is_mac;
void print_write_position ();
void save_outdoor_maps();

View File

@@ -29,8 +29,6 @@
#include "boe.menus.h"
#include "cursors.h"
#include <CoreFoundation/CFByteOrder.h>
extern cursor_type arrow_curs[3][3];
extern cursor_type current_cursor;
@@ -144,8 +142,6 @@ bool sleep_field;
//
// Main body of program Exile
//
void check_for_intel();
bool mac_is_intel;
int main(int argc, char* argv[]) {
#if 0
@@ -217,16 +213,6 @@ int main(int argc, char* argv[]) {
}
}
void check_for_intel(){
int response = CFByteOrderGetCurrent();
if(response == CFByteOrderUnknown){
printf("Gestalt error\n");
exit(1);
}
if(response == CFByteOrderLittleEndian) mac_is_intel = true;
else mac_is_intel = false;
}
//
// Initialize everything for the program, make sure we can run
//

View File

@@ -16,9 +16,6 @@
#include "pc.menus.h"
#include "winutil.h"
#include "cursors.h"
#ifdef __APPLE__
#include <CoreFoundation/CFByteOrder.h>
#endif
extern std::string get_str(std::string, short);
@@ -92,7 +89,7 @@ bool verify_restore_quit(bool mode);
void set_up_apple_events();
void handle_item_menu(int item_hit);
//item_record_type convert_item (short_item_record_type s_item);
bool cur_scen_is_mac, mac_is_intel;
extern bool cur_scen_is_mac;
extern fs::path progDir;
// File io
short specials_res_id;
@@ -132,7 +129,6 @@ int main(int argc, char* argv[]) {
//
//MW specified argument and return type.
void check_for_intel();
void Initialize(void)
{
@@ -241,16 +237,6 @@ void handle_file_menu(int item_hit)
}
}
void check_for_intel(){
int response = CFByteOrderGetCurrent();
if(response == CFByteOrderUnknown){
printf("Gestalt error\n");
exit(1);
}
if(response == CFByteOrderLittleEndian) mac_is_intel = true;
else mac_is_intel = false;
}
static void display_strings(short nstr, pic_num_t pic) {
cStrDlog display_strings(get_str("pcedit", nstr), "", "Editing party", pic, PIC_DLOG);
display_strings.setSound(57);

View File

@@ -38,7 +38,7 @@ short start_volume,data_volume,jl = 0;
fs::path temp_file_to_load;
std::string last_load_file = "Blades of Exile Scenario";
extern fs::path progDir;
bool cur_scen_is_mac = true;
extern bool cur_scen_is_mac;
void print_write_position ();
void load_spec_graphics();

View File

@@ -21,8 +21,6 @@
#include "dlogutil.h"
#include "scen.menus.h"
#include <CoreFoundation/CFByteOrder.h>
cUniverse univ; // not needed; just to silence the compiler
/* Globals */
@@ -75,8 +73,6 @@ void ding();
cScenario scenario;
//piles_of_stuff_dumping_type *data_store;
RECT right_sbar_rect;
void check_for_intel();
bool mac_is_intel;
//
// Main body of program Exileedit
@@ -185,16 +181,6 @@ void Initialize(void) {
right_sbar->hide();
}
void check_for_intel(){
int response = CFByteOrderGetCurrent();
if(response == CFByteOrderUnknown){
printf("Gestalt error\n");
exit(1);
}
if(response == CFByteOrderLittleEndian) mac_is_intel = true;
else mac_is_intel = false;
}
void Handle_One_Event() {
short chr,chr2;
long menu_choice;

View File

@@ -22,7 +22,7 @@
#include "restypes.hpp"
#include "tarball.hpp"
extern bool cur_scen_is_mac, mac_is_intel;
bool cur_scen_is_mac = true, mac_is_intel;
extern cScenario scenario;
extern sf::Texture items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld;
extern sf::Texture dlogpics_gworld,monst_gworld[],terrain_gworld[],anim_gworld,talkfaces_gworld,pc_gworld;
@@ -70,6 +70,12 @@ void init_directories(const char* exec_path) {
tempDir /= "Temporary Files";
}
void check_for_intel() {
union {uint16_t x; uint8_t c;} endian;
endian.x = 1;
mac_is_intel = endian.c;
}
bool load_scenario(fs::path file_to_load, bool skip_strings){
short i,n;
bool file_ok = false;

View File

@@ -30,6 +30,7 @@ bool load_party(fs::path file_to_load);
bool save_party(fs::path dest_file);
void init_directories(const char* exec_path);
void check_for_intel();
std::string read_maybe_quoted_string(std::istream& from);
std::string maybe_quote_string(std::string which);