CMS50 Code review and cleanup

This commit is contained in:
Mark Watkins 2011-06-07 12:07:28 +10:00
parent b302f528bc
commit 7c46b36b53
4 changed files with 30 additions and 20 deletions

View File

@ -8295,7 +8295,7 @@
<sleeplib/machine.h>
<list>
1307409339 /home/mark/projects/git/sleepyhead/src/version.h
1307412369 /home/mark/projects/git/sleepyhead/src/version.h
1307358939 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h
"machine.h"
@ -8312,7 +8312,7 @@
"preferences.h"
"tinyxml/tinyxml.h"
1307376956 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
1307409337 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
"wx_pch.h"
"version.h"
<wx/app.h>
@ -8368,7 +8368,7 @@
<wx/stdpaths.h>
"preferences.h"
1307372029 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/profiles.cpp
1307411755 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/profiles.cpp
<wx/filefn.h>
<wx/filename.h>
<wx/utils.h>
@ -8413,7 +8413,7 @@
1307358939 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.h
"sleeplib/machine_loader.h"
1307372542 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp
1307412363 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp
<wx/log.h>
<wx/progdlg.h>
"cms50_loader.h"

View File

@ -57,7 +57,7 @@ bool CMS50Loader::OpenCMS50(wxString & path, Profile *profile)
bool cont=dir.GetFirst(&filename);
while (cont) {
if (filename.EndsWith(wxT(".spoR"))) {
if (filename.Lower().EndsWith(wxT(".spor"))) {
pathname=path+wxFileName::GetPathSeparator()+filename;
files.push_back(pathname);
}
@ -100,19 +100,27 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile)
f.Read(tmp,2);
br=f.Read(tmp,2);
if (br!=2) return false;
data_starts=tmp[0] | (tmp[1] << 8);
f.Read(tmp,2);
br=f.Read(tmp,2);
if (br!=2) return false;
some_code=tmp[0] | (tmp[1] << 8); // == 512
f.Read(tmp,2);
br=f.Read(tmp,2);
if (br!=2) return false;
num_records=tmp[0] | (tmp[1] << 8);
num_records <<= 1;
f.Read(tmp,2);
some_more_code=tmp[0] | (tmp[1] << 8); // == 512
br=f.Read(tmp,2);
if (br!=2) return false;
some_more_code=tmp[0] | (tmp[1] << 8); // == 0
f.Read(tmp,34);
br=f.Read(tmp,34);
if (br!=34) return false;
// Widechar date string in format 'DD/MM/YY HH:MM:SS'
for (int i=0;i<17;i++) {
tmp[i]=tmp[i << 1];
}
@ -124,10 +132,12 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile)
//wxLogMessage(datestr);
f.Seek(data_starts,wxFromStart);
buffer=new char [num_records*2];
buffer=new char [num_records];
br=f.Read(buffer,num_records);
if (br!=num_records) {
wxLogDebug(wxT("Short .spoR File: ")+path);
wxLogError(wxT("Short .spoR File: ")+path);
return false;
}
wxDateTime last_pulse_time=date;

View File

@ -171,7 +171,7 @@ void Profile::Import(wxString path)
wxLogMessage(wxT("Importing ")+path);
list<MachineLoader *>loaders=GetLoaders();
for (list<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
c+=(*i)->Open(path,this);
if (c+=(*i)->Open(path,this)) break;
}
}

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 7;
static const long BUILD = 3335;
static const long REVISION = 1351;
static const long BUILD = 3342;
static const long REVISION = 1381;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 506;
#define RC_FILEVERSION 0,7,3335,1351
#define RC_FILEVERSION_STRING "0, 7, 3335, 1351\0"
static const char FULLVERSION_STRING[] = "0.7.3335.1351";
static const long BUILDS_COUNT = 520;
#define RC_FILEVERSION 0,7,3342,1381
#define RC_FILEVERSION_STRING "0, 7, 3342, 1381\0"
static const char FULLVERSION_STRING[] = "0.7.3342.1381";
//These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 0;