You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@@ -28,50 +28,52 @@
|
||||
/*************************************************************************/
|
||||
#include "cp_loader_it.h"
|
||||
|
||||
bool CPLoader_IT::can_load_song() { return true; }
|
||||
bool CPLoader_IT::can_load_sample() { return true; }
|
||||
bool CPLoader_IT::can_load_instrument() { return true; }
|
||||
bool CPLoader_IT::can_load_song() {
|
||||
return true;
|
||||
}
|
||||
bool CPLoader_IT::can_load_sample() {
|
||||
return true;
|
||||
}
|
||||
bool CPLoader_IT::can_load_instrument() {
|
||||
return true;
|
||||
}
|
||||
|
||||
CPLoader::Error CPLoader_IT::load_song(const char *p_file,CPSong *p_song, bool p_sampleset) {
|
||||
|
||||
|
||||
song=p_song;
|
||||
CPLoader::Error CPLoader_IT::load_song(const char *p_file, CPSong *p_song, bool p_sampleset) {
|
||||
|
||||
if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
|
||||
song = p_song;
|
||||
|
||||
if (file->open(p_file, CPFileAccessWrapper::READ) != CPFileAccessWrapper::OK)
|
||||
return CPLoader::FILE_CANNOT_OPEN;
|
||||
|
||||
|
||||
|
||||
Error err;
|
||||
|
||||
|
||||
char aux_identifier[4];
|
||||
file->get_byte_array((uint8_t*)aux_identifier,4);
|
||||
file->get_byte_array((uint8_t *)aux_identifier, 4);
|
||||
|
||||
if ( aux_identifier[0]!='I' ||
|
||||
aux_identifier[1]!='M' ||
|
||||
aux_identifier[2]!='P' ||
|
||||
aux_identifier[3]!='M') {
|
||||
if (aux_identifier[0] != 'I' ||
|
||||
aux_identifier[1] != 'M' ||
|
||||
aux_identifier[2] != 'P' ||
|
||||
aux_identifier[3] != 'M') {
|
||||
|
||||
|
||||
CP_PRINTERR("IT CPLoader CPSong: Failed Identifier");
|
||||
return FILE_UNRECOGNIZED;
|
||||
CP_PRINTERR("IT CPLoader CPSong: Failed Identifier");
|
||||
return FILE_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
|
||||
if (p_sampleset) {
|
||||
|
||||
song->reset(false,true,true,false);
|
||||
song->reset(false, true, true, false);
|
||||
|
||||
if ((err=load_header(true))) {
|
||||
if ((err = load_header(true))) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_samples())) {
|
||||
if ((err = load_samples())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_instruments())) {
|
||||
if ((err = load_instruments())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
@@ -81,136 +83,126 @@ CPLoader::Error CPLoader_IT::load_song(const char *p_file,CPSong *p_song, bool p
|
||||
|
||||
song->reset();
|
||||
|
||||
if ((err=load_header(false))) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_orders())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_patterns())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_samples())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_effects())) {
|
||||
if ((err = load_header(false))) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_instruments())) {
|
||||
if ((err = load_orders())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err=load_message())) {
|
||||
|
||||
if ((err = load_patterns())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err = load_samples())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err = load_effects())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err = load_instruments())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((err = load_message())) {
|
||||
file->close();
|
||||
return err;
|
||||
}
|
||||
|
||||
file->close();
|
||||
return FILE_OK;
|
||||
|
||||
}
|
||||
|
||||
CPLoader::Error CPLoader_IT::load_sample(const char *p_file, CPSample *p_sample) {
|
||||
|
||||
|
||||
|
||||
CPLoader::Error CPLoader_IT::load_sample(const char *p_file,CPSample *p_sample) {
|
||||
|
||||
if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
|
||||
if (file->open(p_file, CPFileAccessWrapper::READ) != CPFileAccessWrapper::OK)
|
||||
return CPLoader::FILE_CANNOT_OPEN;
|
||||
|
||||
|
||||
p_sample->reset();
|
||||
CPLoader::Error res=load_sample(p_sample);
|
||||
|
||||
CPLoader::Error res = load_sample(p_sample);
|
||||
|
||||
file->close();
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
CPLoader::Error CPLoader_IT::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) {
|
||||
|
||||
CP_FAIL_INDEX_V(p_instr_idx,CPSong::MAX_INSTRUMENTS,CPLoader::FILE_CANNOT_OPEN);
|
||||
|
||||
if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
|
||||
CPLoader::Error CPLoader_IT::load_instrument(const char *p_file, CPSong *p_song, int p_instr_idx) {
|
||||
|
||||
CP_FAIL_INDEX_V(p_instr_idx, CPSong::MAX_INSTRUMENTS, CPLoader::FILE_CANNOT_OPEN);
|
||||
|
||||
if (file->open(p_file, CPFileAccessWrapper::READ) != CPFileAccessWrapper::OK)
|
||||
return CPLoader::FILE_CANNOT_OPEN;
|
||||
|
||||
|
||||
p_song->get_instrument( p_instr_idx )->reset();
|
||||
|
||||
|
||||
int samples=0;
|
||||
CPLoader::Error res=load_instrument( p_song->get_instrument( p_instr_idx ), &samples );
|
||||
|
||||
|
||||
p_song->get_instrument(p_instr_idx)->reset();
|
||||
|
||||
int samples = 0;
|
||||
CPLoader::Error res = load_instrument(p_song->get_instrument(p_instr_idx), &samples);
|
||||
|
||||
if (res) {
|
||||
file->close();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char exchange[CPSong::MAX_SAMPLES];
|
||||
for (int i=0;i<CPSong::MAX_SAMPLES;i++)
|
||||
exchange[i]=0;
|
||||
|
||||
for (int i=0;i<samples;i++) {
|
||||
|
||||
file->seek( 554+i*80 ); //i think this should work?! seems to.. but i'm not sure
|
||||
|
||||
for (int i = 0; i < CPSong::MAX_SAMPLES; i++)
|
||||
exchange[i] = 0;
|
||||
|
||||
for (int i = 0; i < samples; i++) {
|
||||
|
||||
file->seek(554 + i * 80); //i think this should work?! seems to.. but i'm not sure
|
||||
|
||||
/* find free sample */
|
||||
|
||||
int free_idx=-1;
|
||||
for (int s=0;s<CPSong::MAX_SAMPLES;s++) {
|
||||
|
||||
if (p_song->get_sample( s )->get_sample_data().is_null()) {
|
||||
free_idx=s;
|
||||
|
||||
int free_idx = -1;
|
||||
for (int s = 0; s < CPSong::MAX_SAMPLES; s++) {
|
||||
|
||||
if (p_song->get_sample(s)->get_sample_data().is_null()) {
|
||||
free_idx = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (free_idx==-1)
|
||||
if (free_idx == -1)
|
||||
break; //can't seem to be able to load more samples
|
||||
|
||||
exchange[i]=free_idx;
|
||||
res=load_sample( p_song->get_sample( free_idx ) );
|
||||
|
||||
|
||||
exchange[i] = free_idx;
|
||||
res = load_sample(p_song->get_sample(free_idx));
|
||||
|
||||
if (res) {
|
||||
|
||||
|
||||
file->close();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<CPNote::NOTES;i++) {
|
||||
|
||||
int smp=song->get_instrument(p_instr_idx)->get_sample_number(i);
|
||||
|
||||
if (smp>=CPSong::MAX_SAMPLES)
|
||||
|
||||
for (int i = 0; i < CPNote::NOTES; i++) {
|
||||
|
||||
int smp = song->get_instrument(p_instr_idx)->get_sample_number(i);
|
||||
|
||||
if (smp >= CPSong::MAX_SAMPLES)
|
||||
continue;
|
||||
|
||||
if (smp<0)
|
||||
|
||||
if (smp < 0)
|
||||
continue;
|
||||
|
||||
smp=exchange[smp];
|
||||
|
||||
song->get_instrument(p_instr_idx)->set_sample_number(i,smp);
|
||||
|
||||
|
||||
smp = exchange[smp];
|
||||
|
||||
song->get_instrument(p_instr_idx)->set_sample_number(i, smp);
|
||||
}
|
||||
|
||||
|
||||
file->close();
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
CPLoader_IT::CPLoader_IT(CPFileAccessWrapper *p_file) {
|
||||
|
||||
file=p_file;
|
||||
|
||||
file = p_file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user