diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index e054c263..71718220 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -2509,7 +2509,6 @@ void entityclass::updateentities( int i ) //wait for collision if (entities[i].state == 1) { - game.trinkets++; if (game.intimetrial) { collect[entities[i].para] = 1; @@ -2521,9 +2520,9 @@ void entityclass::updateentities( int i ) if(music.currentsong!=-1) music.silencedasmusik(); music.playef(3); collect[entities[i].para] = 1; - if (game.trinkets > game.stat_trinkets && !map.custommode) + if (game.trinkets() > game.stat_trinkets && !map.custommode) { - game.stat_trinkets = game.trinkets; + game.stat_trinkets = game.trinkets(); } } diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 13b37bf4..ea90da2a 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -1357,16 +1357,16 @@ void Game::updatestate() timetrialresulttime = seconds + (minutes * 60); timetrialrank = 0; if (timetrialresulttime <= timetrialpar) timetrialrank++; - if (trinkets >= timetrialshinytarget) timetrialrank++; + if (trinkets() >= timetrialshinytarget) timetrialrank++; if (deathcounts == 0) timetrialrank++; if (timetrialresulttime < besttimes[timetriallevel] || besttimes[timetriallevel]==-1) { besttimes[timetriallevel] = timetrialresulttime; } - if (trinkets > besttrinkets[timetriallevel] || besttrinkets[timetriallevel]==-1) + if (trinkets() > besttrinkets[timetriallevel] || besttrinkets[timetriallevel]==-1) { - besttrinkets[timetriallevel] = trinkets; + besttrinkets[timetriallevel] = trinkets(); } if (deathcounts < bestlives[timetriallevel] || bestlives[timetriallevel]==-1) { @@ -1949,12 +1949,12 @@ void Game::updatestate() if(map.custommode) { - graphics.createtextbox(" " + help.number(trinkets) + " out of " + help.number(map.customtrinkets)+ " ", 50, 65, 174, 174, 174); + graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(map.customtrinkets)+ " ", 50, 65, 174, 174, 174); graphics.textboxcenterx(); } else { - graphics.createtextbox(" " + help.number(trinkets) + " out of Twenty ", 50, 65, 174, 174, 174); + graphics.createtextbox(" " + help.number(trinkets()) + " out of Twenty ", 50, 65, 174, 174, 174); graphics.textboxcenterx(); } } @@ -1967,12 +1967,12 @@ void Game::updatestate() if(map.custommode) { - graphics.createtextbox(" " + help.number(trinkets) + " out of " + help.number(map.customtrinkets)+ " ", 50, 135, 174, 174, 174); + graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(map.customtrinkets)+ " ", 50, 135, 174, 174, 174); graphics.textboxcenterx(); } else { - graphics.createtextbox(" " + help.number(trinkets) + " out of Twenty ", 50, 135, 174, 174, 174); + graphics.createtextbox(" " + help.number(trinkets()) + " out of Twenty ", 50, 135, 174, 174, 174); graphics.textboxcenterx(); } } @@ -2090,7 +2090,7 @@ void Game::updatestate() if(map.customcrewmates-crewmates==0) { //Finished level - if(map.customtrinkets-trinkets==0) + if(map.customtrinkets-trinkets()==0) { //and got all the trinkets! updatecustomlevelstats(customlevelfilename, 3); @@ -3121,7 +3121,7 @@ void Game::updatestate() state++; statedelay = 45; - std::string tempstring = help.number(trinkets); + std::string tempstring = help.number(trinkets()); if (graphics.flipmode) { graphics.createtextbox("Trinkets Found:", 48, 155-24, 0,0,0); @@ -4731,7 +4731,6 @@ void Game::customstart() gravitycontrol = savegc; coins = 0; - trinkets = 0; //state = 2; deathseq = -1; lifeseq = 10; //Not dead, in game initilisation state state = 0; @@ -4758,7 +4757,6 @@ void Game::start() gravitycontrol = savegc; coins = 0; - trinkets = 0; //state = 2; deathseq = -1; lifeseq = 10; //Not dead, in game initilisation state state = 0; @@ -4856,7 +4854,6 @@ void Game::startspecial( int t ) savepoint = 0; gravitycontrol = savegc; coins = 0; - trinkets = 0; state = 0; deathseq = -1; lifeseq = 0; @@ -4929,7 +4926,6 @@ void Game::starttrial( int t ) gravitycontrol = savegc; coins = 0; - trinkets = 0; crewmates = 0; //state = 2; deathseq = -1; lifeseq = 10; //Not dead, in game initilisation state @@ -5070,10 +5066,6 @@ void Game::loadquick() { savepoint = atoi(pText); } - else if (pKey == "trinkets") - { - trinkets = atoi(pText); - } else if (pKey == "companion") { companion = atoi(pText); @@ -5343,10 +5335,6 @@ void Game::customloadquick(std::string savfile) { savepoint = atoi(pText); } - else if (pKey == "trinkets") - { - trinkets = atoi(pText); - } else if (pKey == "crewmates") { crewmates = atoi(pText); @@ -5727,7 +5715,7 @@ void Game::savetele() msgs->LinkEndChild( msg ); msg = new TiXmlElement( "trinkets" ); - msg->LinkEndChild( new TiXmlText( help.String(trinkets).c_str() )); + msg->LinkEndChild( new TiXmlText( help.String(trinkets()).c_str() )); msgs->LinkEndChild( msg ); @@ -5924,7 +5912,7 @@ void Game::savequick() msgs->LinkEndChild( msg ); msg = new TiXmlElement( "trinkets" ); - msg->LinkEndChild( new TiXmlText( help.String(trinkets).c_str() )); + msg->LinkEndChild( new TiXmlText( help.String(trinkets()).c_str() )); msgs->LinkEndChild( msg ); @@ -6132,7 +6120,7 @@ void Game::customsavequick(std::string savfile) msgs->LinkEndChild( msg ); msg = new TiXmlElement( "trinkets" ); - msg->LinkEndChild( new TiXmlText( help.String(trinkets).c_str() )); + msg->LinkEndChild( new TiXmlText( help.String(trinkets()).c_str() )); msgs->LinkEndChild( msg ); msg = new TiXmlElement( "crewmates" ); @@ -6377,10 +6365,6 @@ void Game::loadtele() { savepoint = atoi(pText); } - else if (pKey == "trinkets") - { - trinkets = atoi(pText); - } else if (pKey == "companion") { companion = atoi(pText); @@ -7670,3 +7654,8 @@ void Game::resetgameclock() hours = 0; timerStartTime = SDL_GetTicks(); } + +int Game::trinkets() +{ + return std::count(obj.collect.begin(), obj.collect.end(), 1); +} diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index ccac8ab9..37c13ad2 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -247,7 +247,7 @@ public: int deathseq, lifeseq; - int coins, trinkets, crewmates, trinkencollect; + int coins, trinkets(), crewmates, trinkencollect; int savepoint, teleport, teleportxpos; int edteleportent; bool completestop; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index ea961439..06938086 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2117,7 +2117,7 @@ void mapinput() game.savetime = game.timestring(); game.savearea = map.currentarea(map.area(game.roomx, game.roomy)); - game.savetrinkets = game.trinkets; + game.savetrinkets = game.trinkets(); if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) game.savearea = "The Ship"; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 9201a90d..d390203a 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -649,7 +649,7 @@ void titlerender() tempstring = "You rescued " + help.number(game.crewrescued()) + " crewmates"; graphics.Print(0, 100, tempstring, tr, tg, tb, true); - tempstring = "and found " + help.number(game.trinkets) + " trinkets."; + tempstring = "and found " + help.number(game.trinkets()) + " trinkets."; graphics.Print(0, 110, tempstring, tr, tg, tb, true); tempstring = "You managed to reach:"; @@ -700,7 +700,7 @@ void titlerender() std::string tempstring = "You rescued all the crewmates!"; graphics.Print(0, 100, tempstring, tr, tg, tb, true); - tempstring = "And you found " + help.number(game.trinkets) + " trinkets."; + tempstring = "And you found " + help.number(game.trinkets()) + " trinkets."; graphics.Print(0, 110, tempstring, tr, tg, tb, true); graphics.Print(0, 160, "A new trophy has been awarded and", tr, tg, tb, true); @@ -731,11 +731,11 @@ void titlerender() graphics.Print(220, 85+20, "+1 Rank!", 255, 255, 255); } - tempstring = help.String(game.trinkets) + " of " + help.String(game.timetrialshinytarget); + tempstring = help.String(game.trinkets()) + " of " + help.String(game.timetrialshinytarget); graphics.drawspritesetcol(30, 80+55, 22, 22); graphics.Print(65, 80+55, "SHINY TRINKETS:", 255, 255, 255); graphics.Print(65, 90+55, tempstring, tr, tg, tb); - if (game.trinkets >= game.timetrialshinytarget) + if (game.trinkets() >= game.timetrialshinytarget) { graphics.Print(220, 85+55, "+1 Rank!", 255, 255, 255); } @@ -1675,13 +1675,13 @@ void gamerender() { graphics.bprint(56, 30,help.String(game.deathcounts), 196, 196, 196); } - if(game.trinkets= ss_toi(words[1])) + if (game.trinkets() >= ss_toi(words[1])) { load("custom_"+words[2]); position--; @@ -163,7 +163,7 @@ void scriptclass::run() } if (words[0] == "customiftrinketsless") { - if (game.trinkets < ss_toi(words[1])) + if (game.trinkets() < ss_toi(words[1])) { load("custom_"+words[2]); position--; @@ -1321,7 +1321,7 @@ void scriptclass::run() } else if (words[0] == "iftrinkets") { - if (game.trinkets >= ss_toi(words[1])) + if (game.trinkets() >= ss_toi(words[1])) { load(words[2]); position--; @@ -1466,7 +1466,6 @@ void scriptclass::run() i = obj.getplayer(); obj.entities[i].tile = 0; - game.trinkets = 0; game.crewmates=0; for (i = 0; i < 100; i++) { @@ -1879,7 +1878,6 @@ void scriptclass::run() music.haltdasmusik(); music.playef(3); - game.trinkets++; obj.collect[ss_toi(words[1])] = 1; graphics.textboxremovefast(); @@ -1898,7 +1896,7 @@ void scriptclass::run() { usethisnum = "Twenty"; } - graphics.createtextbox(" " + help.number(game.trinkets) + " out of " + usethisnum + " ", 50, 135, 174, 174, 174); + graphics.createtextbox(" " + help.number(game.trinkets()) + " out of " + usethisnum + " ", 50, 135, 174, 174, 174); graphics.textboxcenterx(); if (!game.backgroundtext) @@ -2040,12 +2038,12 @@ void scriptclass::run() } else if (words[0] == "trinketbluecontrol") { - if (game.trinkets == 20 && obj.flags[67] == 1) + if (game.trinkets() == 20 && obj.flags[67] == 1) { load("talkblue_trinket6"); position--; } - else if (game.trinkets >= 19 && obj.flags[67] == 0) + else if (game.trinkets() >= 19 && obj.flags[67] == 0) { load("talkblue_trinket5"); position--; @@ -2058,7 +2056,7 @@ void scriptclass::run() } else if (words[0] == "trinketyellowcontrol") { - if (game.trinkets >= 19) + if (game.trinkets() >= 19) { load("talkyellow_trinket3"); position--; @@ -2257,7 +2255,7 @@ void scriptclass::run() else { //Ok, we've already dealt with the trinket thing; so either you have them all, or you don't. If you do: - if (game.trinkets >= 20) + if (game.trinkets() >= 20) { load("startepilogue"); position--; @@ -2862,7 +2860,6 @@ void scriptclass::startgamemode( int t ) map.explored[i + (j * 20)] = 1; } } - game.trinkets = 20; game.insecretlab = true; map.showteleporters = true;