Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
Added screenshot-taking in the menu
If FPS get too low, instead of being ejected to the menu your score is
simply invalidated (will add a message)
Pack now has its own hash (I should send it for validation)
  • Loading branch information
vittorioromeo committed Mar 10, 2013
1 parent 03186fd commit a3ec595
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Data/PackData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ using namespace std;

namespace hg
{
PackData::PackData(string mId, const string& mName, float mPriority) : id{mId}, name{mName}, priority{mPriority} { }
PackData::PackData(const string& mId, const string& mName, float mPriority, const string& mHash) : id{mId}, name{mName}, priority{mPriority}, hash{mHash} { }

string PackData::getId() { return id; }
string PackData::getName() { return name; }
string PackData::getHash() { return hash; }
float PackData::getPriority() { return priority; }
}

4 changes: 3 additions & 1 deletion Data/PackData.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ namespace hg
private:
std::string id, name;
float priority;
std::string hash;

public:
PackData(std::string mId, const std::string& mName, float mPriority);
PackData(const std::string& mId, const std::string& mName, float mPriority, const std::string& mHash);
std::string getId();
std::string getName();
std::string getHash();
float getPriority();
};
}
Expand Down
8 changes: 7 additions & 1 deletion Global/Assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "Global/Config.h"
#include "Utils/Utils.h"
#include "Online/Online.h"
#include "Utils/MD5.h"
#include "Online/Definitions.h"

using namespace std;
using namespace sf;
Expand Down Expand Up @@ -52,8 +54,12 @@ namespace hg
{
string packName{packPath.substr(6, packPath.length() - 6)};

string packLua{""};
for(auto& path : getRecursiveFilesByExtension(packPath, ".lua")) packLua.append(getFileContents(path));
string packHash{Online::getMD5Hash(packLua + HG_SERVER_KEY)};

Json::Value packRoot{getJsonFileRoot(packPath + "/pack.json")};
PackData packData(packName, packRoot["name"].asString(), packRoot["priority"].asFloat());
PackData packData(packName, packRoot["name"].asString(), packRoot["priority"].asFloat(), packHash);
packDataMap.insert(make_pair(packName, packData));
}

Expand Down
1 change: 1 addition & 0 deletions HGStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace hg
bool randomSideChangesEnabled{true};
bool incrementEnabled{true};
bool drawing3D{false};
bool scoreInvalid{false};
sf::Color overrideColor{0, 0, 0, 0};
};
}
Expand Down
9 changes: 5 additions & 4 deletions HGUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ namespace hg

if(get3D()) update3D(mFrameTime);
if(!getNoRotation()) updateRotation(mFrameTime);
if(status.mustRestart) changeLevel(restartId, restartFirstTime);

inputMovement = 0; inputFocused = false;

if(status.currentTime > 5 && getOfficial() && window.getFPS() < 30)
if(status.mustRestart) changeLevel(restartId, restartFirstTime);

if(!status.scoreInvalid && status.currentTime > 5 && getOfficial() && window.getFPS() < 25)
{
log("Too low FPS, aborting official game", "Online");
goToMenu(false);
log("Too low FPS, invalidating official game", "Online");
status.scoreInvalid = true;
}
}
void HexagonGame::updateEvents(float mFrameTime)
Expand Down
2 changes: 1 addition & 1 deletion HexagonGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace hg
if(getScore(localValidator) < status.currentTime) setScore(localValidator, status.currentTime);
saveCurrentProfile();

if(!isEligibleForScore()) return;
if(status.scoreInvalid || !isEligibleForScore()) return;

string validator{Online::getValidator(levelData.getId(), levelData.getJsonRootPath(), levelData.getLuaScriptPath(), difficultyMult)};
Online::startSendScore(getCurrentProfile().getName(), validator, status.currentTime);
Expand Down
3 changes: 3 additions & 0 deletions MenuGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ namespace hg
}, t::SINGLE);
game.addInput({{k::Escape}}, [&](float) { playSound("beep.ogg"); if(state == s::OPTIONS) state = s::MAIN; }, t::SINGLE);
game.addInput({{k::Escape}}, [&](float mFrameTime) { if(state != s::OPTIONS) exitTimer += mFrameTime; });
game.addInput({{k::F12}}, [&](float){ mustTakeScreenshot = true; }, t::SINGLE);
}

void MenuGame::setIndex(int mIndex)
Expand Down Expand Up @@ -235,6 +236,8 @@ namespace hg
else if(state == States::OPTIONS) { window.clear(Color::Black); overlayCamera.apply(); drawOptions(); }

overlayCamera.apply(); render(titleBar); render(creditsBar1); render(creditsBar2); render(versionText);

if(mustTakeScreenshot) { window.getRenderWindow().capture().saveToFile("screenshot.png"); mustTakeScreenshot = false; }
}

void MenuGame::renderText(const string& mString, Text& mText, sf::Vector2f mPosition, unsigned int mSize)
Expand Down
1 change: 1 addition & 0 deletions MenuGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace hg
ssvms::Menu optionsMenu;
std::string scoresMessage;
float exitTimer{0};
bool mustTakeScreenshot{false};

sf::Sprite titleBar{getAssetManager().getTexture("titleBar.png")};
sf::Sprite creditsBar1{getAssetManager().getTexture("creditsBar1.png")};
Expand Down
78 changes: 78 additions & 0 deletions _RELEASE/log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[CONFIG] loading config
[Online] Checking updates...
[Online] Checking scores...
[loadImages] bottomBar.png image added
[loadImages] bottomBar.png texture added
[loadImagesToManager(Assets/)] bottomBar.png image added
[loadImages] creditsBar1.png image added
[loadImages] creditsBar1.png texture added
[loadImagesToManager(Assets/)] creditsBar1.png image added
[loadImages] creditsBar2.png image added
[loadImages] creditsBar2.png texture added
[loadImagesToManager(Assets/)] creditsBar2.png image added
[loadImages] titleBar.png image added
[loadImages] titleBar.png texture added
[loadImagesToManager(Assets/)] titleBar.png image added
[loadSound] beep.ogg soundBuffer added
[loadSound] beep.ogg sound added
[loadSoundsToManager(Assets/)] beep.ogg soundBuffer added
[loadSoundsToManager(Assets/)] beep.ogg sound added
[loadSound] death.ogg soundBuffer added
[loadSound] death.ogg sound added
[loadSoundsToManager(Assets/)] death.ogg soundBuffer added
[loadSoundsToManager(Assets/)] death.ogg sound added
[loadSound] gameOver.ogg soundBuffer added
[loadSound] gameOver.ogg sound added
[loadSoundsToManager(Assets/)] gameOver.ogg soundBuffer added
[loadSoundsToManager(Assets/)] gameOver.ogg sound added
[loadSound] go.ogg soundBuffer added
[loadSound] go.ogg sound added
[loadSoundsToManager(Assets/)] go.ogg soundBuffer added
[loadSoundsToManager(Assets/)] go.ogg sound added
[loadSound] levelUp.ogg soundBuffer added
[loadSound] levelUp.ogg sound added
[loadSoundsToManager(Assets/)] levelUp.ogg soundBuffer added
[loadSoundsToManager(Assets/)] levelUp.ogg sound added
[loadSound] openHexagon.ogg soundBuffer added
[loadSound] openHexagon.ogg sound added
[loadSoundsToManager(Assets/)] openHexagon.ogg soundBuffer added
[loadSoundsToManager(Assets/)] openHexagon.ogg sound added
[loadMusic] beep.ogg music added
[loadMusicsToManager(Assets/)] beep.ogg music added
[loadMusic] death.ogg music added
[loadMusicsToManager(Assets/)] death.ogg music added
[loadMusic] gameOver.ogg music added
[loadMusicsToManager(Assets/)] gameOver.ogg music added
[loadMusic] go.ogg music added
[loadMusicsToManager(Assets/)] go.ogg music added
[loadMusic] levelUp.ogg music added
[loadMusicsToManager(Assets/)] levelUp.ogg music added
[loadMusic] openHexagon.ogg music added
[loadMusicsToManager(Assets/)] openHexagon.ogg music added
[loadFonts] imagine.ttf font added
[loadFontsToManager(Assets/)] imagine.ttf font added
[ASSETS] loading profiles
[ASSETS] loading VeeDefault music
[ASSETS] loading VeeDefault music data
[ASSETS] loading VeeDefault style data
[ASSETS] loading VeeDefault level data
[ASSETS] loading VeeDefault events
[ASSETS] loading VeeDefault custom sounds
[FileSystem] Directory "Packs/VeeDefault/Sounds/" not found
[ASSETS] loading VeeEndurance music
[ASSETS] loading VeeEndurance music data
[ASSETS] loading VeeEndurance style data
[ASSETS] loading VeeEndurance level data
[ASSETS] loading VeeEndurance events
[ASSETS] loading VeeEndurance custom sounds
[loadSound] VeeEndurance_test.ogg soundBuffer added
[loadSound] VeeEndurance_test.ogg sound added
[Online] Scores retrieved successfully
[Online] Finished checking scores
[Online] Server message:
Welcome to Open Hexagon!
You're now connected to vittorioromeo.info.
Good luck and have fun!
[Online] Server latest version: 1.8
[Online] No updates available
[Online] Finished checking updates

0 comments on commit a3ec595

Please sign in to comment.