Commit f4486f87 authored by sirjorj's avatar sirjorj

updates for libxwing2 refactoring

parent 1d7df8f7
Subproject commit ccaf06b362435ef167e62c29a8571a6701878c4b
Subproject commit 14613616d6c800afc52a31f635984b23f9d0877e
......@@ -7,9 +7,9 @@ void condition2(struct kreq *req) {
std::string namestr;
for(int i=0; i<req->fieldsz; i++) {
if (strcmp(req->fields[i].key, "name") == 0) { namestr = req->fields[i].val; }
if (strcmp(req->fields[i].key, "name") == 0) { namestr = req->fields[i].val; }
}
Condition condition = Condition::GetCondition(xws::condition::GetCondition(namestr));
Condition condition = Condition::GetCondition(namestr);
// page
resp_open(req, KHTTP_200);
......@@ -45,7 +45,7 @@ void condition2(struct kreq *req) {
bool first=true;
for(Release rel : Release::GetAllReleases()) {
for(Cnd c : rel.GetConditions()) {
if(c == condition.GetType()) {
if(c == condition.GetCnd()) {
if(first) { first = false; }
else { khtml_elem(&r, KELEM_BR); }
std::string url = std::string(req->pname)+"/release2?sku=" + rel.GetSku();
......
......@@ -31,7 +31,7 @@ void damagedeck2(struct kreq *req) {
khtml_elem(&r, KELEM_TABLE);
for(DamageCard dc : DamageCard::GetAllDamageCards(dd.GetType())) {
for(const DamageCard& dc : DamageCard::GetAllDamageCards(dd.GetDck())) {
khtml_elem(&r, KELEM_TR);
{ // number
......
......@@ -21,7 +21,7 @@ void damagedecks2(struct kreq *req) {
PrintBreadcrumbs(r, {{req->pname, StripLeadingSlash(req->pname)}}, req->pagename);
khtml_elem(&r, KELEM_TABLE);
for(Deck d : Deck::GetAllDecks()) {
for(Deck deck : Deck::GetAllDecks()) {
khtml_elem(&r, KELEM_TR);
{ // Name
//bool isHugeShip = (d.GetXws() != "core" && d.GetXws() != "core2");
......@@ -29,9 +29,9 @@ void damagedecks2(struct kreq *req) {
//if(isHugeShip) { css = "text"; }
//else { css = "bold"; }
khtml_attr(&r, KELEM_TD, /*KATTR_CLASS, css.c_str(),*/ KATTR__MAX);
std::string url = std::string(req->pname)+"/damagedeck2?dd=" + d.GetXws();
std::string url = std::string(req->pname)+"/damagedeck2?dd=" + deck.GetDckStr();
khtml_attr(&r, KELEM_A, KATTR_HREF, url.c_str(), KATTR__MAX);
khtml_puts(&r, d.GetName().c_str());
khtml_puts(&r, deck.GetName().c_str());
khtml_closeelem(&r, 2); // a, td
}
khtml_closeelem(&r, 1); // tr
......
......@@ -112,7 +112,7 @@ void dialcomp(struct kreq *req) {
}
// Ship Icon
std::string glyph = "";
if(s2) { glyph = libxwing2::ShipGlyph::GetGlyph(s2->GetType()); }
if(s2) { glyph = libxwing2::ShipGlyph::GetGlyph(s2->GetShp()); }
if(s1 && (glyph == "")) { glyph = libxwing::ShipGlyph::GetGlyph(s1->GetType()); }
if(glyph == "") {
std::string s = "";
......
......@@ -10,7 +10,7 @@ void pilot2(struct kreq *req) {
if (strcmp(req->fields[i].key, "pilot") == 0) { pltstr = req->fields[i].val; }
else if(strcmp(req->fields[i].key, "format") == 0) { format = req->fields[i].val; }
}
Pilot pilot = Pilot::GetPilot(xws::pilot::GetPilot(pltstr));
Pilot pilot = Pilot::GetPilot(pltstr);
// page
resp_open(req, KHTTP_200);
......@@ -42,7 +42,7 @@ void pilot2(struct kreq *req) {
{ // xws
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "xws"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, xws::pilot::GetPilot(pilot.GetType()).c_str()); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, xws::pilot::GetPilot(pilot.GetPlt()).c_str()); khtml_closeelem(&r, 1);
khtml_closeelem(&r, 1);
}
{ // subtitle
......@@ -67,7 +67,7 @@ void pilot2(struct kreq *req) {
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Ship"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX);
std::string sUrl= std::string(req->pname) + "/ship2?ship=" + xws::ship::GetShip(pilot.GetShip().GetType());
std::string sUrl= std::string(req->pname) + "/ship2?ship=" + pilot.GetShip().GetShpStr();
khtml_attr(&r, KELEM_A, KATTR_HREF, sUrl.c_str(), KATTR__MAX);
khtml_puts(&r, pilot.GetShip().GetName().c_str());
khtml_closeelem(&r, 3);
......@@ -187,7 +187,7 @@ void pilot2(struct kreq *req) {
khtml_closeelem(&r, 1);
}
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::Action(sa.difficulty).c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetAct()).c_str());
khtml_closeelem(&r, 1);
next = true;
}
......@@ -211,7 +211,7 @@ void pilot2(struct kreq *req) {
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Availability"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX);
int first=true;
for(Release rel : Release::GetByPilot(pilot.GetType())) {
for(Release rel : Release::GetByPilot(pilot.GetPlt())) {
if(first) { first = false; }
else { khtml_elem(&r, KELEM_BR); }
std::string url = std::string(req->pname)+"/release2?sku=" + rel.GetSku();
......@@ -270,7 +270,7 @@ void pilot2(struct kreq *req) {
}
{ // Faction
khtml_attr(&r, KELEM_DIV, KATTR_CLASS, "pc_Faction", KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(pilot.GetFaction().GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(pilot.GetFac()).c_str());
khtml_closeelem(&r, 1);
}
{ // Text
......@@ -292,7 +292,7 @@ void pilot2(struct kreq *req) {
{ // Ship (Icon)
khtml_attr(&r, KELEM_DIV, KATTR_CLASS, "pc_ShipIcon", KATTR__MAX);
khtml_puts(&r, ShipGlyph::GetGlyph(pilot.GetShip().GetType()).c_str());
khtml_puts(&r, ShipGlyph::GetGlyph(pilot.GetShp()).c_str());
khtml_closeelem(&r, 1);
}
......
......@@ -29,7 +29,7 @@ void pilots2(struct kreq *req) {
// gather data
std::map<Fac, std::map<Shp,std::vector<Pilot>>> data;
for(const Pilot &p : Pilot::GetAllPilots()) {
data[p.GetFaction().GetType()][p.GetShip().GetType()].push_back(p);
data[p.GetFac()][p.GetShp()].push_back(p);
}
// list of pilots
......@@ -100,7 +100,7 @@ void pilots2(struct kreq *req) {
for(const Pilot& p : plts) {
pilots[pc]["name"] = p.GetName();
pilots[pc]["xws"] = xws::pilot::GetPilot(p.GetType());
pilots[pc]["xws"] = xws::pilot::GetPilot(p.GetPlt());
if(p.GetSubtitle() != "") { pilots[pc]["subtitle"] = p.GetSubtitle(); }
pilots[pc]["limited"] = p.GetLimited();
pilots[pc]["faction"] = p.GetFaction().GetName();
......@@ -161,7 +161,7 @@ void pilots2(struct kreq *req) {
}
{
int ac = 0;
for(Release rel : Release::GetByPilot(p.GetType())) {
for(Release rel : Release::GetByPilot(p.GetPlt())) {
pilots[pc]["availability"][ac]["name"] = rel.GetName();
pilots[pc]["availability"][ac]["sku"] = rel.GetSku();
ac++;
......
......@@ -28,9 +28,9 @@ void quickbuilds2(struct kreq *req) {
khtml_attr(&r, KELEM_TABLE, KATTR__MAX);
{ // faction
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::IconHeader(f.GetType()).c_str(), KATTR_COLSPAN, "4", KATTR__MAX);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::IconHeader(f.GetFac()).c_str(), KATTR_COLSPAN, "4", KATTR__MAX);
khtml_attr(&r, KELEM_SPAN, KATTR_TITLE, f.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(f.GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(f.GetFac()).c_str());
khtml_closeelem(&r, 3); // span td tr
}
......@@ -39,9 +39,9 @@ void quickbuilds2(struct kreq *req) {
for(const Ship& s : Ship::GetAllShips()) {
std::vector<QuickBuild> quickBuilds;
for(const Pilot &p : Pilot::GetAllPilots()) {
if(p.GetFaction().GetType() == f.GetType() && p.GetShip().GetType() == s.GetType()) {
if(p.GetFac() == f.GetFac() && p.GetShp() == s.GetShp()) {
try {
quickBuilds.push_back(QuickBuild::GetQuickBuild(p.GetType()));
quickBuilds.push_back(QuickBuild::GetQuickBuild(p.GetPlt()));
}
catch(QuickBuildNotFound &qbnf) {
}
......@@ -58,7 +58,7 @@ void quickbuilds2(struct kreq *req) {
if(drawShip) { // ship icon
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::ShipHeader().c_str(), KATTR_ROWSPAN, std::to_string(rows).c_str(), KATTR__MAX);
khtml_attr(&r, KELEM_SPAN, KATTR_TITLE, s.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, ShipGlyph::GetGlyph(s.GetType()).c_str());
khtml_puts(&r, ShipGlyph::GetGlyph(s.GetShp()).c_str());
khtml_closeelem(&r, 2); // span td
drawShip=false;
}
......@@ -85,7 +85,7 @@ void quickbuilds2(struct kreq *req) {
xp = xws::pilot::GetPilot(qbp.plt);
}
catch(PilotNotFound &pnf) {
khtml_puts(&r, std::string("CANNOT FIND PILOT" + std::to_string((int)p.GetType())).c_str());
khtml_puts(&r, std::string("CANNOT FIND PILOT" + std::to_string((int)p.GetPlt())).c_str());
continue;
}
catch(std::runtime_error &re) {
......@@ -103,22 +103,7 @@ void quickbuilds2(struct kreq *req) {
bool isFirst = true;
for(Upg up : qbp.upgs) {
Upgrade u = Upgrade::GetUpgrade(up);
std::string xu;
try{
xu = xws::upgrade::GetUpgrade(up);
}
catch(UpgradeNotFound &unf) {
khtml_puts(&r, std::string("CANNOT FIND UPGRADE" + std::to_string((int)u.GetType())).c_str());
continue;
}
catch(std::runtime_error &re) {
khtml_puts(&r, (std::string("error: ") + re.what()).c_str());
}
catch(...) {
khtml_puts(&r, "WTF?");
continue;
}
std::string uUrl = std::string(req->pname)+"/upgrade2?upgrade=" + xu;
std::string uUrl = std::string(req->pname)+"/upgrade2?upgrade=" + u.GetUpgStr();
if(isFirst) { isFirst=false;}
else { khtml_puts(&r, " . "); }
khtml_attr(&r, KELEM_A, KATTR_HREF, uUrl.c_str(), KATTR__MAX);
......
......@@ -100,7 +100,7 @@ void release2(struct kreq *req) {
printedLabel = true;
}
khtml_attr(&r, KELEM_TD, KATTR__MAX);
std::string url = std::string(req->pname)+"/ship2?ship=" + xws::ship::GetShip(ship.GetType());
std::string url = std::string(req->pname)+"/ship2?ship=" + ship.GetShpStr();
khtml_attr(&r, KELEM_A, KATTR_HREF, url.c_str(), KATTR__MAX);
khtml_puts(&r, ship.GetName().c_str());
khtml_closeelem(&r, 3);
......@@ -118,19 +118,10 @@ void release2(struct kreq *req) {
}
khtml_attr(&r, KELEM_TD, KATTR__MAX);
try {
Pilot pilot = Pilot::GetPilot(rp);
std::string xs= xws::pilot::GetPilot(pilot.GetType());
std::string url = std::string(req->pname)+"/pilot2?pilot=" + xs;
khtml_attr(&r, KELEM_A, KATTR_HREF, url.c_str(), KATTR__MAX);
if(pilot.GetLimited()) {
khtml_attr(&r, KELEM_SPAN, KATTR_CLASS, "fnt_icon", KATTR__MAX);
for(int i=0; i<pilot.GetLimited(); i++) {
khtml_puts(&r, IconGlyph::GetGlyph(Ico::unique).c_str());
}
khtml_closeelem(&r, 1);
}
khtml_puts(&r, pilot.GetName().c_str());
khtml_closeelem(&r, 2);
const Pilot pilot = Pilot::GetPilot(rp);
PrintPilotName(req, r, pilot);
khtml_closeelem(&r, 1);
}
catch(PilotNotFound pnf) {
PrintError(r, pnf.what());
......@@ -151,19 +142,9 @@ void release2(struct kreq *req) {
}
khtml_attr(&r, KELEM_TD, KATTR__MAX);
try {
Upgrade upgrade = Upgrade::GetUpgrade(u);
std::string xu = xws::upgrade::GetUpgrade(upgrade.GetType());
std::string url = std::string(req->pname)+"/upgrade2?upgrade=" + xu;
khtml_attr(&r, KELEM_A, KATTR_HREF, url.c_str(), KATTR__MAX);
if(upgrade.GetLimited()) {
khtml_attr(&r, KELEM_SPAN, KATTR_CLASS, "fnt_icon", KATTR__MAX);
for(int i=0; i<upgrade.GetLimited(); i++) {
khtml_puts(&r, IconGlyph::GetGlyph(Ico::unique).c_str());
}
khtml_closeelem(&r, 1);
}
khtml_puts(&r, upgrade.GetName().c_str());
khtml_closeelem(&r, 2);
const Upgrade upgrade = Upgrade::GetUpgrade(u);
PrintUpgradeName(req, r, upgrade);
khtml_closeelem(&r, 1);
}
catch (UpgradeNotFound unf) {
PrintError(r, unf.what());
......@@ -184,10 +165,8 @@ void release2(struct kreq *req) {
}
khtml_attr(&r, KELEM_TD, KATTR__MAX);
try {
Condition condition = Condition::GetCondition(c);
std::string url = std::string(req->pname)+"/condition?name=" + xws::condition::GetCondition(condition.GetType());
khtml_attr(&r, KELEM_A, KATTR_HREF, url.c_str(), KATTR__MAX);
khtml_puts(&r, condition.GetName().c_str());
const Condition condition = Condition::GetCondition(c);
PrintConditionName(req, r, condition);
khtml_closeelem(&r, 1);
}
catch(ConditionNotFound cnf) {
......
......@@ -24,7 +24,7 @@ void ship2(struct kreq *req) {
shipstr = req->fields[i].val;
}
}
Ship ship = Ship::GetShip(xws::ship::GetShip(shipstr));
Ship ship = Ship::GetShip(shipstr);
// page
resp_open(req, KHTTP_200);
......@@ -43,7 +43,7 @@ void ship2(struct kreq *req) {
khtml_elem(&r, KELEM_DIV);
{ // ship icon
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, cssHeaderIcon().c_str(), KATTR__MAX);
khtml_puts(&r, ShipGlyph::GetGlyph(ship.GetType()).c_str());
khtml_puts(&r, ShipGlyph::GetGlyph(ship.GetShp()).c_str());
khtml_closeelem(&r, 1);
}
{ // ship name
......@@ -61,7 +61,7 @@ void ship2(struct kreq *req) {
std::vector<Pilot> pilots;
std::map<std::string,std::string> shipAbilities;
for(Pilot p : Pilot::GetAllPilots()) {
if(p.GetShip().GetType() == ship.GetType()) {
if(p.GetShp() == ship.GetShp()) {
pilots.push_back(p);
auto sa = p.GetShipAbility();
if(sa) {
......@@ -71,8 +71,8 @@ void ship2(struct kreq *req) {
}
}
std::sort(pilots.begin(), pilots.end(), [] (Pilot a, Pilot b) {
return (a.GetFaction().GetType() < b.GetFaction().GetType())
|| ((a.GetFaction().GetType() == b.GetFaction().GetType()) && (a.GetNatInitiative() > b.GetNatInitiative()));
return (a.GetFac() < b.GetFac())
|| ((a.GetFac() == b.GetFac()) && (a.GetNatInitiative() > b.GetNatInitiative()));
});
// print ship abilities
if(shipAbilities.size()) {
......@@ -97,8 +97,8 @@ void ship2(struct kreq *req) {
{ // faction
khtml_elem(&r, KELEM_TD);
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::FactionIcon(p.GetFaction().GetType()).c_str(), KATTR_TITLE, p.GetFaction().GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(p.GetFaction().GetType()).c_str());
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::FactionIcon(p.GetFac()).c_str(), KATTR_TITLE, p.GetFaction().GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(p.GetFac()).c_str());
khtml_closeelem(&r, 2); // span, td
}
{ // initiative
......@@ -203,7 +203,7 @@ void ship2(struct kreq *req) {
khtml_closeelem(&r, 1);
}
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::Action(sa.difficulty).c_str(), KATTR_TITLE, Action::GetAction(sa.action).GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetAct()).c_str());
khtml_closeelem(&r, 1);
next = true;
}
......
......@@ -37,15 +37,15 @@ void ships2(struct kreq *req) {
Fac f = Fac::None;
for(auto p : Pilot::GetAllPilots()) {
if(p.GetShip().GetType() == s.GetType()) {
f = f | p.GetFaction().GetType();
if(p.GetShp() == s.GetShp()) {
f = f | p.GetFac();
}
}
{ // factions
khtml_attr(&r, KELEM_TD, KATTR_STYLE, cssCenter().c_str(), KATTR__MAX);
for(const Faction& fac : Faction::GetAllFactions()) {
Fac it = fac.GetType();
for(const Faction& faction : Faction::GetAllFactions()) {
Fac it = faction.GetFac();
if((f & it) == it) {
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::FactionIcon(it).c_str(), KATTR_TITLE, Faction::GetFaction(it).GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(it).c_str());
......@@ -58,7 +58,7 @@ void ships2(struct kreq *req) {
{ // ship icon
khtml_attr(&r, KELEM_TD, KATTR_STYLE, cssCenter().c_str(), KATTR__MAX);
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::ShipIcon().c_str(), KATTR_TITLE, s.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, ShipGlyph::GetGlyph(s.GetType()).c_str());
khtml_puts(&r, ShipGlyph::GetGlyph(s.GetShp()).c_str());
khtml_closeelem(&r, 2);
}
......@@ -70,7 +70,8 @@ void ships2(struct kreq *req) {
}
{ // ship name
//std::string sUrl= std::string(req->pname) + "/ship2?id=" + std::to_string((int)s.GetType());
std::string sUrl= std::string(req->pname) + "/ship2?ship=" + xws::ship::GetShip(s.GetType());
//std::string sUrl= std::string(req->pname) + "/ship2?ship=" + xws::ship::GetShip(s.GetShp());
std::string sUrl= std::string(req->pname) + "/ship2?ship=" + s.GetShpStr();
khtml_attr(&r, KELEM_TD, KATTR__MAX);
khtml_attr(&r, KELEM_A, KATTR_HREF, sUrl.c_str(), KATTR__MAX);
khtml_puts(&r, s.GetName().c_str());
......@@ -108,8 +109,8 @@ void ships2(struct kreq *req) {
// faction
Fac f = Fac::None;
for(auto p : Pilot::GetAllPilots()) {
if(p.GetShip().GetType() == s.GetType()) {
f = f | p.GetFaction().GetType();
if(p.GetShp() == s.GetShp()) {
f = f | p.GetFac();
}
}
......@@ -122,7 +123,7 @@ void ships2(struct kreq *req) {
// name
ships[pc]["name"] = s.GetName();
// glyph
ShipGlyph sg = ShipGlyph::GetShipGlyph(s.GetType());
ShipGlyph sg = ShipGlyph::GetShipGlyph(s.GetShp());
ships[pc]["glyph"]["scss"] = sg.GetScssName();
ships[pc]["glyph"]["char"] = sg.GetGlyph();
// dial id
......
......@@ -10,7 +10,7 @@ void upgrade2(struct kreq *req) {
if (strcmp(req->fields[i].key, "upgrade") == 0) { namestr = req->fields[i].val; }
else if(strcmp(req->fields[i].key, "format" ) == 0) { format = req->fields[i].val; }
}
Upgrade upgrade = Upgrade::GetUpgrade(xws::upgrade::GetUpgrade( namestr));
Upgrade upgrade = Upgrade::GetUpgrade(namestr);
// page
resp_open(req, KHTTP_200);
......@@ -46,7 +46,7 @@ void upgrade2(struct kreq *req) {
{ // xws
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "xws"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, xws::upgrade::GetUpgrade(upgrade.GetType()).c_str()); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX); khtml_puts(&r, xws::upgrade::GetUpgrade(upgrade.GetUpg()).c_str()); khtml_closeelem(&r, 1);
khtml_closeelem(&r, 1);
}
{ // upgrade type
......@@ -140,7 +140,7 @@ void upgrade2(struct kreq *req) {
for(SAct sa : a) {
if(next) { khtml_puts(&r, ">"); }
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::Action(sa.difficulty).c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(Action::GetAction(sa.action).GetAct()).c_str());
khtml_closeelem(&r, 1);
next = true;
}
......@@ -244,7 +244,7 @@ void upgrade2(struct kreq *req) {
khtml_attr(&r, KELEM_TD, KATTR_STYLE, CSS::Key().c_str(), KATTR__MAX); khtml_puts(&r, "Availability"); khtml_closeelem(&r, 1);
khtml_attr(&r, KELEM_TD, KATTR__MAX);
int first=true;
for(Release rel : Release::GetByUpgrade(upgrade.GetType())) {
for(Release rel : Release::GetByUpgrade(upgrade.GetUpg())) {
if(first) { first = false; }
else { khtml_elem(&r, KELEM_BR); }
std::string url = std::string(req->pname)+"/release2?sku=" + rel.GetSku();
......
......@@ -34,7 +34,7 @@ void upgrades2(struct kreq *req) {
std::vector<UpgradeType> upTypes;
std::map<UpT, uint16_t> uptc;
for(const Upgrade &h : Upgrade::GetAllUpgrades()) {
uptc[h.GetUpgradeType().GetType()]++;
uptc[h.GetUpT()]++;
}
std::vector<std::pair<UpT,uint16_t>> uptcv;
for(const std::pair<UpT,uint16_t> &p : uptc) {
......@@ -61,19 +61,19 @@ void upgrades2(struct kreq *req) {
khtml_elem(&r, KELEM_TR);
khtml_attr(&r, KELEM_TD, KATTR_STYLE, cssUpgHeader().c_str(), KATTR_COLSPAN, "2", KATTR__MAX);
khtml_attr(&r, KELEM_SPAN, KATTR_TITLE, ut.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(ut.GetType()).c_str());
khtml_puts(&r, IconGlyph::GetGlyph(ut.GetUpT()).c_str());
khtml_closeelem(&r, 3); // span td tr
}
for(const Upgrade& u : Upgrade::GetAllUpgrades()) {
if(u.GetUpgradeType().GetType() == ut.GetType()) {
if(u.GetUpT() == ut.GetUpT()) {
// upgrade name
std::string xu;
try{
xu = xws::upgrade::GetUpgrade(u.GetType());
xu = xws::upgrade::GetUpgrade(u.GetUpg());
}
catch(UpgradeNotFound &unf) {
khtml_puts(&r, std::string("CANNOT FIND UPGRADE" + std::to_string((int)u.GetType())).c_str());
khtml_puts(&r, std::string("CANNOT FIND UPGRADE" + std::to_string((int)u.GetUpg())).c_str());
continue;
}
catch(std::runtime_error &re) {
......@@ -94,10 +94,10 @@ void upgrades2(struct kreq *req) {
if(factions == Fac::All) {
}
else {
for(const Faction &f : Faction::GetAllFactions()) {
if((int)(factions & f.GetType()) > 0) {
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::FactionIcon(f.GetType()).c_str(), KATTR_TITLE, f.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(f.GetType()).c_str());
for(const Faction &faction : Faction::GetAllFactions()) {
if((int)(factions & faction.GetFac()) > 0) {
khtml_attr(&r, KELEM_SPAN, KATTR_STYLE, CSS::FactionIcon(faction.GetFac()).c_str(), KATTR_TITLE, faction.GetName().c_str(), KATTR__MAX);
khtml_puts(&r, IconGlyph::GetGlyph(faction.GetFac()).c_str());
khtml_closeelem(&r, 1); // span
}
}
......@@ -310,7 +310,7 @@ void upgrades2(struct kreq *req) {
for(Upgrade u : upgds) {
upgrades[uc]["name"] = u.GetName();
upgrades[uc]["xws"] = xws::upgrade::GetUpgrade(u.GetType());
upgrades[uc]["xws"] = xws::upgrade::GetUpgrade(u.GetUpg());
upgrades[uc]["limited"] = u.GetLimited();
UCost c = u.GetUCost();
switch(c.GetVPC()) {
......@@ -384,7 +384,7 @@ void upgrades2(struct kreq *req) {
upgrades[uc]["unreleased"] = true;
}
int rc = 0;
for(Release rel : Release::GetByUpgrade(u.GetType())) {
for(Release rel : Release::GetByUpgrade(u.GetUpg())) {
upgrades[uc]["availability"][rc]["name"] = rel.GetName();
upgrades[uc]["availability"][rc]["sku"] = rel.GetSku();
rc++;
......
......@@ -103,51 +103,21 @@ void PrintNameAndUnreleased(khtmlreq &r, std::string name, std::string url, uint
void PrintPilotName(struct kreq *req, khtmlreq &r, const Pilot &p) {
std::string xp;
try{
xp = xws::pilot::GetPilot(p.GetType());
}
catch(PilotNotFound &pnf) {
khtml_puts(&r, std::string("CANNOT FIND PILOT" + std::to_string((int)p.GetType())).c_str());
return;
}
catch(std::runtime_error &re) {
khtml_puts(&r, (std::string("error: ") + re.what()).c_str());
}
catch(...) {
khtml_puts(&r, "???");
return;
}
std::string url = std::string(req->pname)+"/pilot2?pilot=" + xp;
std::string url = std::string(req->pname)+"/pilot2?pilot=" + p.GetPltStr();
PrintNameAndUnreleased(r, p.GetName(), url, p.GetLimited(), p.IsUnreleased());
}
void PrintUpgradeName(struct kreq *req, khtmlreq &r, const Upgrade &u) {
std::string xu;
try{
xu = xws::upgrade::GetUpgrade(u.GetType());
}
catch(UpgradeNotFound &unf) {
khtml_puts(&r, std::string("CANNOT FIND UPGRADE" + std::to_string((int)u.GetType())).c_str());
return;
}
catch(std::runtime_error &re) {
khtml_puts(&r, (std::string("error: ") + re.what()).c_str());
}
catch(...) {
khtml_puts(&r, "WTF?");
return;
}
std::string url = std::string(req->pname)+"/upgrade2?upgrade=" + xu;
std::string url = std::string(req->pname)+"/upgrade2?upgrade=" + u.GetUpgStr();
PrintNameAndUnreleased(r, u.GetName(), url, u.GetLimited(), u.IsUnreleased());
}
void PrintConditionName(struct kreq *req, khtmlreq &r, const Condition &c) {
std::string url = std::string(req->pname)+"/condition2?name=" + xws::condition::GetCondition(c.GetType());
std::string url = std::string(req->pname)+"/condition2?name=" + c.GetCndStr();
PrintNameAndUnreleased(r, c.GetName(), url, c.GetLimited(), c.IsUnreleased());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment