Fix indentation
This commit is contained in:
@@ -31,7 +31,7 @@ static NSImage* imageFromURL(CFURLRef url){
|
||||
imageRect.size.width = CGImageGetWidth(theImage);
|
||||
|
||||
// Create a new image to receive the Quartz image data.
|
||||
NSImage *newImage = [[NSImage alloc] initWithSize:imageRect.size];
|
||||
NSImage* newImage = [[NSImage alloc] initWithSize:imageRect.size];
|
||||
[newImage lockFocus];
|
||||
|
||||
// Get the Quartz context and draw.
|
||||
|
@@ -85,7 +85,7 @@ void init_directories(const char* exec_path) {
|
||||
#endif // __APPLE__
|
||||
#endif // _Win32||_Win64
|
||||
tempDir /= "Temporary Files";
|
||||
|
||||
|
||||
// Depending on the build environment, we may need to redirect stdout and stderr.
|
||||
#ifdef _MSC_VER
|
||||
#ifdef DEBUG
|
||||
@@ -175,26 +175,26 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario){
|
||||
scenario.append(*temp_scenario);
|
||||
scenario.append(*item_data);
|
||||
|
||||
// TODO: Consider skipping the fread and assignment when len is 0
|
||||
for(i = 0; i < 270; i++) {
|
||||
len = (long) (temp_scenario->scen_str_len[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i == 0) scenario.scen_name = temp_str;
|
||||
else if(i == 1 || i == 2)
|
||||
scenario.who_wrote[i-1] = temp_str;
|
||||
else if(i == 3)
|
||||
scenario.contact_info = temp_str;
|
||||
else if(i >= 4 && i < 10)
|
||||
scenario.intro_strs[i-4] = temp_str;
|
||||
else if(i >= 10 && i < 60)
|
||||
scenario.journal_strs[i-10] = temp_str;
|
||||
else if(i >= 60 && i < 160) {
|
||||
if(i % 2 == 0) scenario.special_items[(i-60)/2].name = temp_str;
|
||||
else scenario.special_items[(i-60)/2].descr = temp_str;
|
||||
} else if(i >= 260) continue; // These were never ever used, for some reason.
|
||||
else scenario.spec_strs[i-160] = temp_str;
|
||||
}
|
||||
// TODO: Consider skipping the fread and assignment when len is 0
|
||||
for(i = 0; i < 270; i++) {
|
||||
len = (long) (temp_scenario->scen_str_len[i]);
|
||||
n = fread(temp_str, len, 1, file_id);
|
||||
temp_str[len] = 0;
|
||||
if(i == 0) scenario.scen_name = temp_str;
|
||||
else if(i == 1 || i == 2)
|
||||
scenario.who_wrote[i-1] = temp_str;
|
||||
else if(i == 3)
|
||||
scenario.contact_info = temp_str;
|
||||
else if(i >= 4 && i < 10)
|
||||
scenario.intro_strs[i-4] = temp_str;
|
||||
else if(i >= 10 && i < 60)
|
||||
scenario.journal_strs[i-10] = temp_str;
|
||||
else if(i >= 60 && i < 160) {
|
||||
if(i % 2 == 0) scenario.special_items[(i-60)/2].name = temp_str;
|
||||
else scenario.special_items[(i-60)/2].descr = temp_str;
|
||||
} else if(i >= 260) continue; // These were never ever used, for some reason.
|
||||
else scenario.spec_strs[i-160] = temp_str;
|
||||
}
|
||||
|
||||
fclose(file_id);
|
||||
|
||||
@@ -687,14 +687,14 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
char *pc_ptr;
|
||||
long len,store_len,count;
|
||||
|
||||
// LOAD PARTY
|
||||
// LOAD PARTY
|
||||
len = (long) sizeof(legacy::party_record_type); // should be 46398
|
||||
store_len = len;
|
||||
fin.read((char*)&store_party, len);
|
||||
if(must_port) port_party(&store_party);
|
||||
party_ptr = (char*) &store_party;
|
||||
for(count = 0; count < store_len; count++)
|
||||
party_ptr[count] ^= 0x5C;
|
||||
party_ptr[count] ^= 0x5C;
|
||||
|
||||
// LOAD SETUP
|
||||
len = (long) sizeof(legacy::setup_save_type);
|
||||
@@ -708,7 +708,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
if(must_port) port_pc(&store_pc[i]);
|
||||
pc_ptr = (char*) &store_pc[i];
|
||||
for(count = 0; count < store_len; count++)
|
||||
pc_ptr[count] ^= 0x6B;
|
||||
pc_ptr[count] ^= 0x6B;
|
||||
}
|
||||
|
||||
if(in_scen) {
|
||||
@@ -717,7 +717,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
len = (long) sizeof(legacy::out_info_type);
|
||||
fin.read((char*)&store_out_info, len);
|
||||
|
||||
// LOAD TOWN
|
||||
// LOAD TOWN
|
||||
if(town_restore) {
|
||||
len = (long) sizeof(legacy::current_town_type);
|
||||
fin.read((char*)&store_c_town, len);
|
||||
@@ -728,7 +728,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
if(must_port) port_t_d(&t_d);
|
||||
|
||||
len = (long) sizeof(legacy::town_item_list);
|
||||
fin.read((char*)&t_i, len);
|
||||
fin.read((char*)&t_i, len);
|
||||
}else univ.town.num = 200;
|
||||
|
||||
// LOAD STORED ITEMS
|
||||
@@ -750,7 +750,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
len = (long) (64 * 64);
|
||||
fin.read((char*)sfx, len);
|
||||
|
||||
fin.read((char*)misc_i, len);
|
||||
fin.read((char*)misc_i, len);
|
||||
|
||||
} // end if_scen
|
||||
|
||||
|
@@ -70,4 +70,4 @@ sf::Time time_in_ticks(int ticks) {
|
||||
return sf::microseconds(micro);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -31,12 +31,12 @@ void port_town(legacy::town_record_type* dummy_town_ptr){
|
||||
flip_short(&dummy_town_ptr->max_num_monst);
|
||||
flip_short(&dummy_town_ptr->spec_on_entry);
|
||||
flip_short(&dummy_town_ptr->spec_on_entry_if_dead);
|
||||
for(i =0 ; i < 8; i++)
|
||||
for(i =0 ; i < 8; i++)
|
||||
flip_short(&dummy_town_ptr->timer_spec_times[i]);
|
||||
for(i =0 ; i < 8; i++)
|
||||
for(i =0 ; i < 8; i++)
|
||||
flip_short(&dummy_town_ptr->timer_specs[i]);
|
||||
flip_short(&dummy_town_ptr->difficulty);
|
||||
for(i =0 ; i < 100; i++)
|
||||
for(i =0 ; i < 100; i++)
|
||||
flip_spec_node(&dummy_town_ptr->specials[i]);
|
||||
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void port_t_d(legacy::big_tr_type* old) {
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(i =0 ; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 60; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
@@ -70,7 +70,7 @@ void port_t_d(legacy::big_tr_type* old) {
|
||||
flip_short(&old->creatures[i].personality);
|
||||
flip_short(&old->creatures[i].special_on_kill);
|
||||
flip_short(&old->creatures[i].facial_pic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void port_ave_t(legacy::ave_tr_type* old) {
|
||||
@@ -78,7 +78,7 @@ void port_ave_t(legacy::ave_tr_type* old) {
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(i =0 ; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 40; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
@@ -95,7 +95,7 @@ void port_tiny_t(legacy::tiny_tr_type* old) {
|
||||
if(cur_scen_is_mac != mac_is_intel)
|
||||
return;
|
||||
|
||||
for(i =0 ; i < 16; i++)
|
||||
for(i =0 ; i < 16; i++)
|
||||
flip_rect(&old->room_rect[i]);
|
||||
for(i =0 ; i < 30; i++) {
|
||||
flip_short(&old->creatures[i].spec1);
|
||||
@@ -104,7 +104,7 @@ void port_tiny_t(legacy::tiny_tr_type* old) {
|
||||
flip_short(&old->creatures[i].personality);
|
||||
flip_short(&old->creatures[i].special_on_kill);
|
||||
flip_short(&old->creatures[i].facial_pic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
@@ -169,9 +169,9 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) {
|
||||
for(i = 0; i < 30; i++) {
|
||||
flip_short(&temp_scenario->scen_horses[i].which_town);
|
||||
}
|
||||
for(i = 0; i < 20; i++)
|
||||
for(i = 0; i < 20; i++)
|
||||
flip_short(&temp_scenario->scenario_timer_times[i]);
|
||||
for(i = 0; i < 20; i++)
|
||||
for(i = 0; i < 20; i++)
|
||||
flip_short(&temp_scenario->scenario_timer_specs[i]);
|
||||
for(i = 0; i < 256; i++) {
|
||||
flip_spec_node(&temp_scenario->scen_specials[i]);
|
||||
@@ -219,11 +219,11 @@ void port_out(legacy::outdoor_record_type *out) {
|
||||
flip_short(&(out->special_enc[i].spec_on_flee));
|
||||
flip_short(&(out->special_enc[i].cant_flee));
|
||||
flip_short(&(out->special_enc[i].end_spec1));
|
||||
flip_short(&(out->special_enc[i].end_spec2));
|
||||
flip_short(&(out->special_enc[i].end_spec2));
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
for(i = 0; i < 8; i++)
|
||||
flip_rect(&(out->info_rect[i]));
|
||||
for(i = 0; i < 60; i++)
|
||||
for(i = 0; i < 60; i++)
|
||||
flip_spec_node(&(out->specials[i]));
|
||||
}
|
||||
|
||||
|
@@ -78,7 +78,7 @@ void play_sound(short which, short how_many_times) { // if < 0, play asynch
|
||||
inited = true;
|
||||
ResMgr::setIdMapFn<SoundRsrc>(sound_to_fname_map);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<sf::SoundBuffer> sndhandle;
|
||||
if(!play_sounds || how_many_times == 0) return;
|
||||
|
||||
@@ -112,131 +112,8 @@ void play_sound(short which, short how_many_times) { // if < 0, play asynch
|
||||
sf::sleep(time_in_ticks(sound_delay[-1 * which]));
|
||||
if(how_many_times > 1)
|
||||
play_sound(which, how_many_times - 1);
|
||||
// TODO: Since sounds are handled by SFML, all this Windows-specific code shouldn't be needed
|
||||
#if 0 //defined(WIN32)
|
||||
short i,num_fails = 0;
|
||||
char snd_name[30];
|
||||
bool asyn = false,a_sound_did_get_played = false;
|
||||
bool not_asyn = false,check_sound;
|
||||
HRSRC h;
|
||||
if((sounds_missing) || (!play_sounds) || (how_many_times == 0))
|
||||
return;
|
||||
|
||||
if(which < 0) {
|
||||
asyn = true;
|
||||
which = which * -1;
|
||||
}
|
||||
if(which >= 1000) {
|
||||
which -= 1000;
|
||||
not_asyn = true;
|
||||
}
|
||||
|
||||
if(which >= 100)
|
||||
return;
|
||||
|
||||
if((always_asynch[which]) &&
|
||||
((can_ignore[which] == 1) || (can_ignore[which] >= 3)))
|
||||
asyn = true;
|
||||
if((can_ignore[which] > 0) && (can_ignore[which] < 5) && (party.stuff_done[305][5] == 1))
|
||||
return;
|
||||
if((can_ignore[which] != 1) && (can_ignore[which] < 3))
|
||||
asyn = false;
|
||||
if((party.stuff_done[305][5] == 1) && (can_ignore[which] < 5))
|
||||
asyn = false;
|
||||
if(not_asyn)
|
||||
asyn = false;
|
||||
|
||||
if((load_when_play[which]) && (sound_handles[which] == NULL)) {
|
||||
asyn = false;
|
||||
sprintf((char *)snd_name,"#%d",which + 1);
|
||||
h = FindResource(hModule,snd_name,"#100");
|
||||
|
||||
sound_handles[which] = LoadResource(hModule,h);
|
||||
snds[which] = (char *) LockResource(sound_handles[which]);
|
||||
|
||||
}
|
||||
|
||||
if(store_last_sound_played == 6)
|
||||
sndPlaySound(NULL,0);
|
||||
|
||||
if(asyn) {
|
||||
if(can_ignore[which] >= 4)
|
||||
check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP);
|
||||
else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY);
|
||||
|
||||
while(!check_sound) {
|
||||
|
||||
if(can_ignore[store_last_sound_played] == 4) {// then sound goes away
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
num_fails++;
|
||||
if(num_fails < 40)
|
||||
sound_pause(25);
|
||||
else {
|
||||
MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error a. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
print_nums(111,which,num_fails);
|
||||
sounds_fucked = true;
|
||||
return;
|
||||
}
|
||||
sndPlaySound(NULL,0);
|
||||
|
||||
if(can_ignore[which] >= 4)
|
||||
check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP);
|
||||
else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY);
|
||||
}
|
||||
a_sound_did_get_played = true;
|
||||
}
|
||||
else {
|
||||
if(can_ignore[which] >= 4)
|
||||
check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP);
|
||||
else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY);
|
||||
while(!check_sound) {
|
||||
if(can_ignore[store_last_sound_played] == 4) {// then sound goes away
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
num_fails++;
|
||||
if(num_fails < 40)
|
||||
sound_pause(25);
|
||||
else {
|
||||
MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error b. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
print_nums(222,which,num_fails);
|
||||
sounds_fucked = true;
|
||||
return;
|
||||
}
|
||||
sndPlaySound(NULL,0);
|
||||
|
||||
if(can_ignore[which] >= 4)
|
||||
check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP);
|
||||
else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY);
|
||||
}
|
||||
a_sound_did_get_played = true;
|
||||
}
|
||||
|
||||
store_last_sound_played = which;
|
||||
|
||||
if((load_when_play[which]) && !asyn)
|
||||
sound_handles[which] = NULL;
|
||||
|
||||
for(i = 0; i < NUM_SOUNDS; i++)
|
||||
if((load_when_play[which]) && (sound_handles[which] != NULL)
|
||||
&& (a_sound_did_get_played) && (i != which)) {
|
||||
sound_handles[i] = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0 //def WIN32
|
||||
void kill_sound() {
|
||||
sndPlaySound(NULL,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void one_sound(short which) {
|
||||
if(which == last_played)
|
||||
return;
|
||||
@@ -252,73 +129,3 @@ void flip_sound() {
|
||||
play_sounds = (play_sounds) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
#if 0 //def WIN32
|
||||
void sound_pause(long len) {
|
||||
long t1,t2;
|
||||
|
||||
t1 = (long) GetCurrentTime();
|
||||
t2 = t1;
|
||||
while(t2 - t1 < len) {
|
||||
t2 = (long)GetCurrentTime();
|
||||
}
|
||||
}
|
||||
|
||||
void load_sounds(HMODULE handle) {
|
||||
short i,t,err;
|
||||
HRSRC h;
|
||||
char snd_name[20];
|
||||
WAVEOUTCAPS wavecaps;
|
||||
|
||||
hModule = handle;
|
||||
|
||||
t = waveOutGetNumDevs();
|
||||
if(t == 0) {
|
||||
sounds_missing = true;
|
||||
return;
|
||||
}
|
||||
err = waveOutGetDevCaps(0,&wavecaps,sizeof(WAVEOUTCAPS));
|
||||
if(err != 0) {
|
||||
sounds_missing = true;
|
||||
switch(err) {
|
||||
case MMSYSERR_BADDEVICEID:
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - No sound device detected. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
case MMSYSERR_NODRIVER:
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - No driver installed. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
case MMSYSERR_NOMEM :
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - can't find enough memory. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
case MMSYSERR_ALLOCATED:
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - sound card already allocated. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
case MMSYSERR_ERROR:
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - internal error. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
default:
|
||||
MessageBox(mainPtr,"Cannot initialize sounds - unidentified error. Game can still be played, but quietly.",
|
||||
"Sound Error",MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(i = 0; i < NUM_SOUNDS; i++) {
|
||||
sound_handles[i] = NULL;
|
||||
if(!load_when_play[i]) {
|
||||
sprintf((char *)snd_name,"#%d",i + 1);
|
||||
h = FindResource(handle,snd_name,"#100");
|
||||
|
||||
sound_handles[i] = LoadResource(handle,h);
|
||||
snds[i] = (char*) LockResource(sound_handles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -42,25 +42,25 @@ SpecialParser::SpecialParser() {
|
||||
symbol_ch = chset<>("A-Za-z$_-");
|
||||
symbol = symbol_ch >> *symbol_ch;
|
||||
eol = eol_p[_(next_line)];
|
||||
|
||||
|
||||
datcode = str_p("sdf")[_(for_sdf)] | str_p("pic")[_(for_pic)] | str_p("msg")[_(for_msg)] |
|
||||
str_p("ex1")[_(for_ex1)] | str_p("ex2")[_(for_ex2)] | str_p("goto")[_(for_goto)];
|
||||
|
||||
|
||||
command = datcode >> +ws >> (int_p[_(set_first)] | defn[_(set_first)]) >>
|
||||
!(*ws >> ch_p(',') >> *ws >> (int_p[_(set_second)] | defn[_(set_second)]) >>
|
||||
!(*ws >> ch_p(',') >> *ws >> (int_p[_(set_third)] | defn[_(set_third)])));
|
||||
|
||||
|
||||
null_line = !comment >> eol;
|
||||
init_line = null_line | def_line;
|
||||
def_line = str_p("def") >> +ws >> symbol[_(prep_add_symbol)] >> *ws >> ch_p('=') >> *ws >> int_p[_(add_symbol)] >> *ws >> !comment >> eol;
|
||||
cmd_line = command >> *ws >> !comment >> eol;
|
||||
op_line = ch_p('@') >> opcode[_(set_type)] >> *ws >> !(ch_p('=') >> *ws >> int_p[_(skip_to)]) >> *ws >> !comment >> eol;
|
||||
|
||||
|
||||
cmd_block = eps_p[_(init_block)] >> op_line >> *(*ws >> (cmd_line | def_line | null_line));
|
||||
|
||||
|
||||
// TODO: This fails if the file doesn't end in a newline.
|
||||
nodes_file = /*guard*/err(eps_p[_(init_file)] >> *(*ws >> init_line) >> *cmd_block[_(add_command)] >> end_p);//[_(on_error)];
|
||||
|
||||
|
||||
// Debugging. If BOOST_SPIRIT_DEBUG not defined, all these expand to nothing.
|
||||
BOOST_SPIRIT_DEBUG_NODE(ws);
|
||||
BOOST_SPIRIT_DEBUG_NODE(eol);
|
||||
@@ -79,7 +79,7 @@ SpecialParser::SpecialParser() {
|
||||
|
||||
grammar_built = true;
|
||||
}
|
||||
|
||||
|
||||
#undef _
|
||||
|
||||
auto SpecialParser::on_error(const Rule::scanner_t&, spirit::parser_error<eParseError, Iter>) -> ErrStatus {
|
||||
|
Reference in New Issue
Block a user