Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//Cube Runes needing 3 to get next
inline void combo1(int& first, int& second)
{
while (first>=3)
{
first-=3;
second++;
}
}
//Cube Runes needing 2 to get next
inline void combo2(int& first, int& second)
{
while (first>=2)
{
first-=2;
second++;
}
}
//Cubing
inline void cube(int& el, int& eld, int& tir, int& nef, int& eth, int& ith, int& tal,
int& ral, int& ort, int& thul, int& amn, int& sol, int& shael,
int& dol, int& hel, int& io, int& lum, int& ko, int& fal, int& lem,
int& pul, int& um, int& mal, int& ist, int& gul, int& vex, int& ohm,
int& lo, int& sur, int& ber, int& jah, int& cham, int& zod)
{
combo1(el,eld);
combo1(eld,tir);
combo1(tir,nef);
combo1(nef,eth);
combo1(eth,ith);
combo1(ith,tal);
combo1(tal,ral);
combo1(ral,ort);
combo1(ort,thul);
combo1(thul,amn);
combo1(amn,sol);
combo1(sol,shael);
combo1(shael,dol);
combo1(dol,hel);
combo1(hel,io);
combo1(io,lum);
combo1(lum,ko);
combo1(ko,fal);
combo1(fal,lem);
combo1(lem,pul);
combo2(pul,um);
combo2(um,mal);
combo2(mal,ist);
combo2(ist,gul);
combo2(gul,vex);
combo2(vex,ohm);
combo2(ohm,lo);
combo2(lo,sur);
combo2(sur,ber);
combo2(ber,jah);
combo2(jah,cham);
combo2(cham,zod);
}
//Output to the console
inline int output(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
int& jah, int& cham, int& zod)
{
cout<<"El:" << el << " " << "Eld:" << eld << endl << "Tir:" << tir << " "
<< "Nef:" << nef << endl << "Eth:" << eth << " " << "Ith:" << ith
<< endl << "Tal:" << tal << " " << "Ral:" << ral << endl << "Ort:" << ort
<< " " << "Thul:" << thul << endl << "Amn:" << amn << " " << "Sol:"
<< sol << endl << "Shael:" << shael << " " << "Dol:" << dol << endl << "Hel:"
<< hel << " " << "Io:" << io << endl << "Lum:" << lum << " " << "Ko:"
<< ko << endl << "Fal:" << fal << " " << "Lem:" << lem << endl << "Pul:"
<< pul << " " "Um:" << um << endl << "Mal:" << mal << " " << "Ist:"
<< ist << endl << "Gul:" << gul << " " << "Vex:" << vex << endl << "Ohm:"
<< ohm << " " << "Lo:" << lo << endl << "Sur:" << sur << " " << "Ber:"
<< ber << endl << "Jah:" << jah << " " << "Cham:" << cham << endl << "Zod:"
<< zod <<endl;
return 0;
}
//Loads the atma dump
inline void loadfile(ifstream& file)
{
while(!file.is_open())
{
file.open("Runes.txt");
if (!file.is_open())
file.open( "runes.txt");
if (!file.is_open())
file.open( "rune.txt");
if (!file.is_open())
file.open( "Rune.txt");
if (!file.is_open())
{
string filename;
cout<<"TodesRunes could not find your ATMA dump,"<<endl
<<"please specify the path to the txt file."<<endl;
getline(cin,filename);
file.open(filename.c_str());
}
}
}
//Tallies up all the runes from the dump
inline void counter(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
int& jah, int& cham, int& zod, ifstream& file)
{
string line;
while (getline( file , line ))
{
if (line.empty() || (line == "\r")) continue;
int colon_pos = line.find(':');
string rune = line.substr(colon_pos+2,line.size()-colon_pos-7);
if (rune == "El")
el++;
else if (rune == "Eld")
eld++;
else if (rune == "Tir")
tir++;
else if (rune == "Nef")
nef++;
else if (rune == "Eth")
eth++;
else if (rune == "Ith")
ith++;
else if (rune == "Tal")
tal++;
else if (rune == "Ral")
ral++;
else if (rune == "Ort")
ort++;
else if (rune == "Thul")
thul++;
else if (rune == "Amn")
amn++;
else if (rune == "Sol")
sol++;
else if (rune == "Shael")
shael++;
else if (rune == "Dol")
dol++;
else if (rune == "Hel")
hel++;
else if (rune == "Io")
io++;
else if (rune == "Lum")
lum++;
else if (rune == "Ko")
ko++;
else if (rune == "Fal")
fal++;
else if (rune == "Lem")
lem++;
else if (rune == "Pul")
pul++;
else if (rune == "Um")
um++;
else if (rune == "Mal")
mal++;
else if (rune == "Ist")
ist++;
else if (rune == "Gul")
gul++;
else if (rune == "Vex")
vex++;
else if (rune == "Ohm")
ohm++;
else if (rune == "Lo")
lo++;
else if (rune == "Sur")
sur++;
else if (rune == "Ber")
ber++;
else if (rune == "Jah")
jah++;
else if (rune == "Cham")
cham++;
else if (rune == "Zod")
zod++;
}
}
//Dump info to txt file, if no cubing has been done.
inline void SaveNoCube(ofstream& save,int& el, int& eld, int& tir, int& nef,
int& eth, int& ith, int& tal, int& ral, int& ort, int& thul,
int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
int& sur, int& ber, int& jah, int& cham, int& zod)
{
string filename;
cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
getline(cin,filename);
save.open(filename.c_str());
if (!save.is_open())
cout<<"The file did not open!";
else
save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
+ thul + amn + sol + shael + dol + hel + io + lum +
ko + fal + lem + pul + um + mal + ist + gul + vex +
ohm + lo + sur + ber + jah + cham + zod <<endl;
save<<"El:" << el << " " << "Eld:" << eld << endl << "Tir:" << tir
<< " " << "Nef:" << nef << endl << "Eth:" << eth << " "
<<"Ith:" << ith << endl << "Tal:" << tal << " " << "Ral:" << ral
<< endl << "Ort:" << ort << " " << "Thul:" << thul << endl << "Amn:"
<< amn << " " << "Sol:" << sol << endl << "Shael:" << shael << " "
<< "Dol:" << dol << endl << "Hel:" << hel << " " << "Io:" << io
<< endl << "Lum:" << lum << " " << "Ko:" << ko << endl << "Fal:"
<< fal << " " << "Lem:" << lem << endl << "Pul:" << pul << " "
<<"Um:" << um << endl << "Mal:" << mal << " " << "Ist:" << ist
<< endl << "Gul:" << gul << " " << "Vex:" << vex << endl << "Ohm:"
<< ohm << " " << "Lo:" << lo << endl << "Sur:" << sur << " "
<< "Ber:" << ber << endl << "Jah:" << jah << " " << "Cham:" << cham
<< endl << "Zod:" << zod <<endl;
inline void SaveCube(ofstream& save, int& el, int& eld, int& tir, int& nef,
int& eth, int& ith, int& tal, int& ral, int& ort, int& thul,
int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
int& sur, int& ber, int& jah, int& cham, int& zod, int& el2,
int& eld2, int& tir2, int& nef2, int& eth2, int& ith2, int& tal2,
int& ral2, int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
int& cham2, int& zod2)
{
string filename;
cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
getline(cin,filename);
save.open(filename.c_str());
if (!save.is_open())
cout<<"The file did not open!";
else
save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
+ thul + amn + sol + shael + dol + hel + io + lum
+ ko + fal + lem + pul + um + mal + ist + gul + vex
+ ohm + lo + sur + ber + jah + cham + zod <<endl;
save<<"\nEl:" << el << " " << "Eld:" << eld << endl << "Tir:" << tir << " "
<< "Nef:" << nef << endl << "Eth:" << eth << " " << "Ith:" << ith
<< endl << "Tal:" << tal << " " << "Ral:" << ral << endl << "Ort:" << ort
<< " " << "Thul:" << thul << endl << "Amn:" << amn << " " << "Sol:"
<< sol << endl << "Shael:" << shael << " " << "Dol:" << dol << endl << "Hel:"
<< hel << " " << "Io:" << io << endl << "Lum:" << lum << " " << "Ko:"
<< ko << endl << "Fal:" << fal << " " << "Lem:" << lem << endl << "Pul:"
<< pul << " " "Um:" << um << endl << "Mal:" << mal << " " << "Ist:"
<< ist << endl << "Gul:" << gul << " " << "Vex:" << vex << endl << "Ohm:"
<< ohm << " " << "Lo:" << lo << endl << "Sur:" << sur << " " << "Ber:"
<< ber << endl << "Jah:" << jah << " " << "Cham:" << cham << endl << "Zod:"
<< zod <<endl
<< "\nAfter cubing"<< endl
<<"\nEl:" << el2 << " " << "Eld:" << eld2 << endl << "Tir:" << tir2 << " "
<< "Nef:" << nef2 << endl << "Eth:" << eth2 << " " << "Ith:" << ith2
<< endl << "Tal:" << tal2 << " " << "Ral:" << ral2 << endl << "Ort:" << ort2
<< " " << "Thul:" << thul2 << endl << "Amn:" << amn2 << " " << "Sol:"
<< sol2 << endl << "Shael:" << shael2 << " " << "Dol:" << dol2 << endl << "Hel:"
<< hel2 << " " << "Io:" << io2 << endl << "Lum:" << lum2 << " " << "Ko:"
<< ko2 << endl << "Fal:" << fal2 << " " << "Lem:" << lem2 << endl << "Pul:"
<< pul2 << " " "Um:" << um2 << endl << "Mal:" << mal2 << " " << "Ist:"
<< ist2 << endl << "Gul:" << gul2 << " " << "Vex:" << vex2 << endl << "Ohm:"
<< ohm2 << " " << "Lo:" << lo2 << endl << "Sur:" << sur2 << " " << "Ber:"
<< ber2 << endl << "Jah:" << jah2 << " " << "Cham:" << cham2 << endl << "Zod:"
<< zod2 <<endl;
}
//copies all the tallied up runes into another variable, used to cube so outputting both is possible
inline void swap(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
int& jah, int& cham, int& zod, int& el2, int& eld2,
int& tir2, int& nef2, int& eth2, int& ith2, int& tal2, int& ral2,
int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
int& cham2, int& zod2)
{
el2 = el;
eld2 = eld;
tir2 = tir;
nef2 = nef;
eth2 = eth;
ith2 = ith;
tal2 = tal;
ral2 = ral;
ort2 = ort;
thul2 = thul;
amn2 = amn;
sol2 = sol;
shael2 = shael;
dol2 = dol;
hel2 = hel;
io2 = io;
lum2 = lum;
ko2 = ko;
fal2 = fal;
lem2 = lem;
pul2 = pul;
um2 = um;
mal2 = mal;
ist2 = ist;
gul2 = gul;
vex2 = vex;
ohm2 = ohm;
lo2 = lo;
sur2 = lo;
ber2 = ber;
jah2 = jah;
cham2 = cham;
zod2 = zod;
}
int main ()
{
cout<<"Welcome to TodesRunes 1.1!"<<endl;
int run = 1; //menu choice
int cubed = 0; //if the cubing function has been called
int el = 0, eld = 0, tir = 0, nef = 0, eth = 0, ith = 0, tal = 0, ral = 0,
ort = 0, thul = 0,amn = 0, sol = 0, shael = 0, dol = 0, hel = 0, io = 0,
lum = 0, ko = 0, fal = 0, lem = 0,pul = 0, um = 0, mal = 0, ist = 0,
gul = 0, vex = 0, ohm = 0, lo = 0, sur = 0, ber = 0, jah = 0, cham = 0,
zod = 0,
int el2 = 0, eld2 = 0, tir2 = 0, nef2 = 0, eth2 = 0, ith2 = 0, tal2 = 0,
ral2 = 0, ort2 = 0, thul2 = 0,amn2 = 0, sol2 = 0, shael2 = 0, dol2 = 0,
hel2 = 0, io2 = 0, lum2 = 0, ko2 = 0, fal2 = 0, lem2 = 0,pul2 = 0, um2 = 0,
mal2 = 0, ist2 = 0, gul2 = 0, vex2 = 0, ohm2 = 0, lo2 = 0, sur2 = 0, ber2 = 0,
jah2 = 0, cham2 = 0, zod2 = 0;
// ^^^ all the rune variables
ifstream file; //ATMA dump
ofstream save; //TodesRune dump
loadfile(file); //loads the ATMA dump
counter(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn, //counts the runes in the dump
sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod, file);
//outputs the total runes the console
cout<< "There are "<<el + eld + tir + nef + eth + ith + tal + ral + ort + thul
+ amn + sol + shael + dol + hel + io + lum + ko + fal + lem + pul + um +
mal + ist + gul + vex + ohm + lo + sur + ber + jah + cham + zod
<<" runes that have been sorted" << endl;
//menu
while(run!=4)
{
cout<<"1. Cube all runes to the max."<<endl<<"2. Display current runes."<<
endl<<"3. Save data to a file."<<endl<<"4. Blame Durf!!!! (quit)"<<endl<<"Choice: ";
cin>>run;
cin.ignore();
switch(run)
{
case 1:
swap(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
cube(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
cubed = 1;
output(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
break;
case 2:
output(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
break;
case 3:
if(cubed=0)
{
SaveNoCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
}
else
{
SaveCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
}
break;
default:
cout<<"You entered an invalid response, please try agian"<<endl;
break;
}
}
return 0;
}
If anyone could lead me to my errors, that would be great. Also any tips on making the program faster would be good also. I converted to 5 because it is easier to get GTK and wxWidgets installed on them, but now I don't know if it was worth it.