Make check_for_intel() call automatically
This will avoid future repeats of the situation where it took way too long to figure out why a unit test wasn't working
This commit is contained in:
@@ -21,7 +21,13 @@
|
|||||||
#include "fileio/resmgr/res_strings.hpp"
|
#include "fileio/resmgr/res_strings.hpp"
|
||||||
#include "fileio/resmgr/res_sound.hpp"
|
#include "fileio/resmgr/res_sound.hpp"
|
||||||
|
|
||||||
bool mac_is_intel;
|
bool _mac_is_intel;
|
||||||
|
bool _checked_for_intel = false;
|
||||||
|
bool mac_is_intel(){
|
||||||
|
if(!_checked_for_intel)
|
||||||
|
check_for_intel();
|
||||||
|
return _mac_is_intel;
|
||||||
|
}
|
||||||
fs::path progDir, tempDir, scenDir;
|
fs::path progDir, tempDir, scenDir;
|
||||||
|
|
||||||
// This is here to avoid unnecessarily duplicating it in platform-specific files.
|
// This is here to avoid unnecessarily duplicating it in platform-specific files.
|
||||||
@@ -120,7 +126,8 @@ fs::path get_posix_tempdir() {
|
|||||||
void check_for_intel() {
|
void check_for_intel() {
|
||||||
union {uint16_t x; uint8_t c;} endian;
|
union {uint16_t x; uint8_t c;} endian;
|
||||||
endian.x = 1;
|
endian.x = 1;
|
||||||
mac_is_intel = endian.c;
|
_mac_is_intel = endian.c;
|
||||||
|
_checked_for_intel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string read_maybe_quoted_string(std::istream& from) {
|
std::string read_maybe_quoted_string(std::istream& from) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "fileio/tarball.hpp"
|
#include "fileio/tarball.hpp"
|
||||||
#include "replay.hpp"
|
#include "replay.hpp"
|
||||||
|
|
||||||
extern bool mac_is_intel;
|
extern bool mac_is_intel();
|
||||||
extern fs::path progDir, tempDir;
|
extern fs::path progDir, tempDir;
|
||||||
extern cCustomGraphics spec_scen_g;
|
extern cCustomGraphics spec_scen_g;
|
||||||
|
|
||||||
@@ -90,12 +90,12 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mac_is_intel && flags.a == 0x8B1F){ // Gzip header (new format)
|
if(mac_is_intel() && flags.a == 0x8B1F){ // Gzip header (new format)
|
||||||
format = new_oboe;
|
format = new_oboe;
|
||||||
}else if(!mac_is_intel && flags.a == 0x1F8B){ // Gzip header (new format)
|
}else if(!mac_is_intel() && flags.a == 0x1F8B){ // Gzip header (new format)
|
||||||
format = new_oboe;
|
format = new_oboe;
|
||||||
}else if(flags.a == mac_flags[0][0] || flags.a == mac_flags[0][1]){ // old format
|
}else if(flags.a == mac_flags[0][0] || flags.a == mac_flags[0][1]){ // old format
|
||||||
if(mac_is_intel){ // it's actually a windows save
|
if(mac_is_intel()){ // it's actually a windows save
|
||||||
flip_short((short*)&flags.a);
|
flip_short((short*)&flags.a);
|
||||||
flip_short((short*)&flags.b);
|
flip_short((short*)&flags.b);
|
||||||
flip_short((short*)&flags.c);
|
flip_short((short*)&flags.c);
|
||||||
@@ -116,7 +116,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
|
|||||||
else if(flags.c != mac_flags[2][0]) format = unknown;
|
else if(flags.c != mac_flags[2][0]) format = unknown;
|
||||||
}
|
}
|
||||||
}else if(flags.a == win_flags[0][0] || flags.a == win_flags[0][1]){ // old format
|
}else if(flags.a == win_flags[0][0] || flags.a == win_flags[0][1]){ // old format
|
||||||
if(mac_is_intel){ // it's actually a macintosh save
|
if(mac_is_intel()){ // it's actually a macintosh save
|
||||||
flip_short((short*)&flags.a);
|
flip_short((short*)&flags.a);
|
||||||
flip_short((short*)&flags.b);
|
flip_short((short*)&flags.b);
|
||||||
flip_short((short*)&flags.c);
|
flip_short((short*)&flags.c);
|
||||||
@@ -143,10 +143,10 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
switch(format){
|
switch(format){
|
||||||
case old_mac:
|
case old_mac:
|
||||||
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, mac_is_intel);
|
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, mac_is_intel());
|
||||||
break;
|
break;
|
||||||
case old_win:
|
case old_win:
|
||||||
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, !mac_is_intel);
|
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, !mac_is_intel());
|
||||||
break;
|
break;
|
||||||
case new_oboe:
|
case new_oboe:
|
||||||
result = load_party_v2(file_to_load, univ);
|
result = load_party_v2(file_to_load, univ);
|
||||||
|
|||||||
@@ -548,7 +548,6 @@ static void replay_next_action() {
|
|||||||
void init_boe(int argc, char* argv[]) {
|
void init_boe(int argc, char* argv[]) {
|
||||||
set_up_apple_events();
|
set_up_apple_events();
|
||||||
init_directories(argv[0]);
|
init_directories(argv[0]);
|
||||||
check_for_intel();
|
|
||||||
process_args(argc, argv);
|
process_args(argc, argv);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
init_menubar(); // Do this first of all because otherwise a default File and Window menu will be seen
|
init_menubar(); // Do this first of all because otherwise a default File and Window menu will be seen
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ int main(int argc, char* argv[]) {
|
|||||||
init_menubar(); // This is called twice because Windows and Mac have different ordering requirements
|
init_menubar(); // This is called twice because Windows and Mac have different ordering requirements
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
check_for_intel();
|
|
||||||
game_rand.seed(time(nullptr));
|
game_rand.seed(time(nullptr));
|
||||||
|
|
||||||
set_up_apple_events();
|
set_up_apple_events();
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
#include "porting.hpp"
|
#include "porting.hpp"
|
||||||
|
|
||||||
extern bool cur_scen_is_mac, mac_is_intel;
|
extern bool cur_scen_is_mac, mac_is_intel();
|
||||||
|
|
||||||
void port_town(legacy::town_record_type* dummy_town_ptr){
|
void port_town(legacy::town_record_type* dummy_town_ptr){
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
flip_short(&dummy_town_ptr->town_chop_time);
|
flip_short(&dummy_town_ptr->town_chop_time);
|
||||||
flip_short(&dummy_town_ptr->town_chop_key);
|
flip_short(&dummy_town_ptr->town_chop_key);
|
||||||
@@ -40,7 +40,7 @@ void port_town(legacy::town_record_type* dummy_town_ptr){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_talk_nodes(legacy::talking_record_type* dummy_talk_ptr) {
|
void port_talk_nodes(legacy::talking_record_type* dummy_talk_ptr) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
for(short i = 0; i < 60; i++) {
|
for(short i = 0; i < 60; i++) {
|
||||||
flip_short(&dummy_talk_ptr->talk_nodes[i].personality);
|
flip_short(&dummy_talk_ptr->talk_nodes[i].personality);
|
||||||
@@ -53,7 +53,7 @@ void port_talk_nodes(legacy::talking_record_type* dummy_talk_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_t_d(legacy::big_tr_type* old) {
|
void port_t_d(legacy::big_tr_type* old) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(short i = 0; i < 16; i++)
|
for(short i = 0; i < 16; i++)
|
||||||
@@ -69,7 +69,7 @@ void port_t_d(legacy::big_tr_type* old) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_ave_t(legacy::ave_tr_type* old) {
|
void port_ave_t(legacy::ave_tr_type* old) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(short i = 0; i < 16; i++)
|
for(short i = 0; i < 16; i++)
|
||||||
@@ -85,7 +85,7 @@ void port_ave_t(legacy::ave_tr_type* old) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_tiny_t(legacy::tiny_tr_type* old) {
|
void port_tiny_t(legacy::tiny_tr_type* old) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(short i = 0; i < 16; i++)
|
for(short i = 0; i < 16; i++)
|
||||||
@@ -101,7 +101,7 @@ void port_tiny_t(legacy::tiny_tr_type* old) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
flip_short(&temp_scenario->flag_a);
|
flip_short(&temp_scenario->flag_a);
|
||||||
flip_short(&temp_scenario->flag_b);
|
flip_short(&temp_scenario->flag_b);
|
||||||
@@ -180,7 +180,7 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
|||||||
|
|
||||||
|
|
||||||
void port_item_list(legacy::scen_item_data_type* old){
|
void port_item_list(legacy::scen_item_data_type* old){
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(short i = 0; i < 400; i++) {
|
for(short i = 0; i < 400; i++) {
|
||||||
@@ -191,7 +191,7 @@ void port_item_list(legacy::scen_item_data_type* old){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_out(legacy::outdoor_record_type *out) {
|
void port_out(legacy::outdoor_record_type *out) {
|
||||||
if(cur_scen_is_mac != mac_is_intel)
|
if(cur_scen_is_mac != mac_is_intel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(short i = 0; i < 4; i++) {
|
for(short i = 0; i < 4; i++) {
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ void init_scened(int argc, char* argv[]) {
|
|||||||
mainPtr.display();
|
mainPtr.display();
|
||||||
|
|
||||||
set_cursor(watch_curs);
|
set_cursor(watch_curs);
|
||||||
check_for_intel();
|
|
||||||
game_rand.seed(time(nullptr));
|
game_rand.seed(time(nullptr));
|
||||||
|
|
||||||
cen_x = 18;
|
cen_x = 18;
|
||||||
|
|||||||
Reference in New Issue
Block a user