3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
21 static truth
DebugDraw (festring Filename
) {
23 inputfile
HighScore(Filename
, 0, false);
24 if (!HighScore
.IsOpen()) return false;
26 if (HighScore
.Eof()) return false;
28 inputfile
HighScore(Filename
, 0, false);
30 HighScore
>> HVersion
;
31 std::cout
<< "\nFile is version " << HVersion
<< std::endl
;
36 static int OutputHTML (festring InputFilename
) {
38 Input
.Load(InputFilename
);
39 std::cout
<< "<TABLE BORDER=3> \n <TR> <TH>Rank</TH> <TH>Who</TH> <TH>Score</TH>\n";
40 for (int c
= 0; c
< Input
.GetSize();++c
) {
42 Score
<< Input
.GetScore(c
);
43 Rank
<< c
+1 << festring(".");
45 << std::string("<TR> <TD>")
47 << std::string("</TD> <TD>")
48 << Input
.GetEntry(c
).CStr()
49 << std::string("</TD> <TD>")
51 << std::string("</TD> </TR>\n");
53 std::cout
<< "</TABLE>";
58 int Main (int argc
, char **argv
) {
60 festring Arg
= festring(argv
[1]);
62 highscore
Input(argv
[2]);
63 if (!Input
.GetSize()) std::cout
<< "No games. No winners.\n";
64 std::cout
<< std::endl
;
65 for (festring::sizetype c
= 0; c
< (festring::sizetype
)Input
.GetSize(); ++c
)
66 std::cout
<< c
+1 << " " << Input
.GetEntry(c
).CStr() << " " << Input
.GetScore(c
) << "\n";
69 if (Arg
== "-h") return OutputHTML(argv
[2]);
71 if (!DebugDraw(argv
[2])) {
72 std::cout
<< "\nProblem showing version number\n";
83 if (!Input
.CheckVersion()) {
84 std::cout
<< "Version check not ok with " << argv
[1] << std::endl
;
89 if (!Output
.CheckVersion()) {
90 std::cout
<< "Version check not ok with " << argv
[2] << std::endl
;
93 if(!Input
.MergeToFile(&Output
))
94 std::cout
<< "\n All entries also found in " << argv
[2] << ". Oh well.\n";
98 std::cout
<< "\nTo list scores in highscore file:\n mihail -l [filename] \n\nTo merge 2 files\n mihail [1st input filename] [2nd input filename] [output filename] \n\nTo give version number of highscore file\n mihail -d [filename]\nNotice that first filename in merges gives also version number\n";