Me and My Shadow Web Diff
| diff --git a/src/FileManager.cpp b/src/FileManager.cpp | |
| index 1df8e91..20200ba 100644 | |
| --- a/src/FileManager.cpp | |
| +++ b/src/FileManager.cpp | |
| @@ -24,8 +24,8 @@ | |
| #include "Globals.h" | |
| #include "FileManager.h" | |
| #include "Functions.h" | |
| -#include <archive.h> | |
| -#include <archive_entry.h> | |
| +//#include <archive.h> | |
| +//#include <archive_entry.h> | |
| using namespace std; | |
| #ifdef WIN32 | |
| @@ -445,6 +445,7 @@ bool downloadFile(const string &path, const string &destination) { | |
| return status; | |
| } | |
| +#ifndef EMSCRIPTEN | |
| bool downloadFile(const string &path, FILE* destination) { | |
| CURL* curl=curl_easy_init(); | |
| @@ -465,12 +466,13 @@ bool downloadFile(const string &path, FILE* destination) { | |
| return (res==0); | |
| } | |
| +#endif | |
| size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream){ | |
| return fwrite(ptr, size, nmemb, (FILE *)stream); | |
| } | |
| - | |
| +#ifndef EMSCRIPTEN | |
| bool extractFile(const string &fileName, const string &destination) { | |
| //Create the archive we're going to extract. | |
| archive* file=NULL; | |
| @@ -523,6 +525,7 @@ bool extractFile(const string &fileName, const string &destination) { | |
| archive_read_finish(file); | |
| return true; | |
| } | |
| +#endif | |
| bool createDirectory(const char* path){ | |
| #ifdef WIN32 | |
| @@ -656,6 +659,7 @@ bool renameDirectory(const char* oldPath,const char* newPath){ | |
| } | |
| +#ifndef EMSCRIPTEN | |
| void copyData(archive* file, archive* dest) { | |
| int status; | |
| const void* buff; | |
| @@ -683,6 +687,7 @@ void copyData(archive* file, archive* dest) { | |
| } | |
| } | |
| } | |
| +#endif | |
| bool copyFile(const char* source,const char* dest){ | |
| //Open the source file. | |
| @@ -717,3 +722,4 @@ bool createFile(const char* file){ | |
| return false; | |
| } | |
| } | |
| + | |
| diff --git a/src/FileManager.h b/src/FileManager.h | |
| index 9104508..e9c2540 100644 | |
| --- a/src/FileManager.h | |
| +++ b/src/FileManager.h | |
| @@ -20,9 +20,9 @@ | |
| #define FILE_MANAGER_H | |
| //Included for the extractFile method. | |
| -#include <archive.h> | |
| +// #include <archive.h> | |
| //Included for the downloadFile method. | |
| -#include <curl/curl.h> | |
| +// #include <curl/curl.h> | |
| //NOTE: All the methods work with processed pathnames. | |
| @@ -147,7 +147,7 @@ bool extractFile(const std::string &fileName, const std::string &destination); | |
| //Method used to read a data blcok from an archive and write it to an archive. | |
| //file: The archive to read from. | |
| //dest: The archive to write to. | |
| -void copyData(archive* file, archive* dest); | |
| +//void copyData(archive* file, archive* dest); | |
| //Method that will create a directory. | |
| //path: The directory to create. | |
| diff --git a/src/Functions.cpp b/src/Functions.cpp | |
| index be4a57f..5024869 100644 | |
| --- a/src/Functions.cpp | |
| +++ b/src/Functions.cpp | |
| @@ -312,7 +312,7 @@ void changeState(){ | |
| //NOTE: STATE_EXIT isn't mentioned, meaning that currentState is null. | |
| //This way the game loop will break and the program will exit. | |
| - //Fade out. | |
| + /*//Fade out. | |
| int fade=255; | |
| SDL_BlitSurface(screen,NULL,tempSurface,NULL); | |
| while(fade>0){ | |
| @@ -325,7 +325,7 @@ void changeState(){ | |
| SDL_BlitSurface(tempSurface,NULL,screen,NULL); | |
| SDL_Flip(screen); | |
| SDL_Delay(25); | |
| - } | |
| + }*/ | |
| } | |
| } | |
| diff --git a/src/InputManager.cpp b/src/InputManager.cpp | |
| index f8e0b93..4550e27 100644 | |
| --- a/src/InputManager.cpp | |
| +++ b/src/InputManager.cpp | |
| @@ -248,7 +248,7 @@ std::string InputManager::getKeyCodeName(int keyCode){ | |
| char c[64]; | |
| if(keyCode>0 && keyCode <0x1000){ | |
| //keyboard | |
| - char* s=SDL_GetKeyName((SDLKey)keyCode); | |
| + const char* s=SDL_GetKeyName((SDLKey)keyCode); | |
| if(s!=NULL){ | |
| return s; | |
| }else{ | |
| @@ -323,7 +323,8 @@ int InputManager::getKeyState(int keyCode,int oldState,bool hasEvent){ | |
| state|=0x4; | |
| } | |
| } | |
| - if(keyCode<SDLK_LAST && SDL_GetKeyState(NULL)[keyCode]){ | |
| + //if(keyCode<SDLK_LAST && SDL_GetKeyState(NULL)[keyCode]){ | |
| + if (SDL_GetKeyboardState(NULL)[keyCode]){ | |
| state|=0x1; | |
| } | |
| }else if(keyCode>0x1000){ | |
| diff --git a/src/Levels.cpp b/src/Levels.cpp | |
| index 921532f..a9f14e0 100644 | |
| --- a/src/Levels.cpp | |
| +++ b/src/Levels.cpp | |
| @@ -413,7 +413,11 @@ void Levels::getLevelAutoSaveRecordPath(int level,std::string &bestTimeFilePath, | |
| //calculate MD5 | |
| s+='-'; | |
| +#if EMSCRIPTEN | |
| + s+="nomd5"; | |
| +#else | |
| s+=Md5::toString(levels[level].md5Digest); | |
| +#endif | |
| //over | |
| bestTimeFilePath=s+"-best-time.mnmsrec"; | |
| diff --git a/src/MD5.cpp b/src/MD5.cpp | |
| index 655c5ba..7ff18f6 100644 | |
| --- a/src/MD5.cpp | |
| +++ b/src/MD5.cpp | |
| @@ -1,3 +1,4 @@ | |
| +#ifndef EMSCRIPTEN | |
| /**************************************************************************** | |
| ** Copyright (C) 2012 me and my shadow developers | |
| ** | |
| @@ -171,3 +172,5 @@ unsigned char *Md5::final(unsigned char *md){ | |
| return md; | |
| #endif | |
| } | |
| +#endif | |
| + | |
| diff --git a/src/Main.cpp b/src/Main.cpp | |
| index a68322c..e3a5e02 100644 | |
| --- a/src/Main.cpp | |
| +++ b/src/Main.cpp | |
| @@ -101,10 +101,20 @@ int main(int argc, char** argv) { | |
| tempSurface=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_SRCALPHA, | |
| screen->w,screen->h,screen->format->BitsPerPixel, | |
| screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0); | |
| - int fadeIn=0; | |
| + //int fadeIn=0; | |
| - //Start the game loop. | |
| - while(stateID!=STATE_EXIT){ | |
| + return 0; // The main loop will be called from postRun | |
| +} | |
| + | |
| +extern "C" { | |
| + | |
| +#include <emscripten.h> | |
| + | |
| +void __attribute__((used)) OneMainLoopIteration() { | |
| + if (stateID==STATE_EXIT) emscripten_run_script("Module.print('game finished'); throw 'game finished'"); | |
| + | |
| + ////Start the game loop. | |
| + //while(stateID!=STATE_EXIT){ | |
| //We start the timer. | |
| FPS.start(); | |
| @@ -132,13 +142,13 @@ int main(int argc, char** argv) { | |
| currentState->render(); | |
| //TODO: Shouldn't the gamestate take care of rendering the GUI? | |
| if(GUIObjectRoot) GUIObjectRoot->render(); | |
| - if(fadeIn>0&&fadeIn<255){ | |
| + /*if(fadeIn>0&&fadeIn<255){ | |
| SDL_BlitSurface(screen,NULL,tempSurface,NULL); | |
| SDL_FillRect(screen,NULL,0); | |
| SDL_SetAlpha(tempSurface, SDL_SRCALPHA, fadeIn); | |
| SDL_BlitSurface(tempSurface,NULL,screen,NULL); | |
| fadeIn+=17; | |
| - } | |
| + }*/ | |
| #ifdef RECORD_PICUTRE_SEQUENCE | |
| if(recordPictureSequence){ | |
| char s[64]; | |
| @@ -151,18 +161,20 @@ int main(int argc, char** argv) { | |
| SDL_Flip(screen); | |
| if(nextState!=STATE_NULL){ | |
| - fadeIn=17; | |
| + //fadeIn=17; | |
| changeState(); | |
| } | |
| - int t=FPS.getTicks(); | |
| + /*int t=FPS.getTicks(); | |
| t=(1000/g_FPS)-t; | |
| if(t>0){ | |
| SDL_Delay(t); | |
| - } | |
| + }*/ | |
| - } | |
| + //} | |
| +} | |
| +int __attribute__((used)) FinalCleanup() { // we don't really do this... | |
| //close all joysticks. | |
| inputMgr.closeAllJoysticks(); | |
| @@ -177,3 +189,6 @@ int main(int argc, char** argv) { | |
| //End of program. | |
| return 0; | |
| } | |
| + | |
| +} | |
| + | |
| diff --git a/src/TitleMenu.cpp b/src/TitleMenu.cpp | |
| index cca3713..ffc9b1c 100644 | |
| --- a/src/TitleMenu.cpp | |
| +++ b/src/TitleMenu.cpp | |
| @@ -400,7 +400,7 @@ void Options::handleEvents(){ | |
| } | |
| //Check if the escape button is pressed, if so go back to the main menu. | |
| - if(inputMgr.isKeyDownEvent(INPUTMGR_ESCAPE)){ | |
| + if(inputMgr.isKeyUpEvent(INPUTMGR_ESCAPE)){ | |
| setNextState(STATE_MENU); | |
| } | |
| } | |
| diff --git a/src/TreeStorageNode.cpp b/src/TreeStorageNode.cpp | |
| index 17aff2d..cf3f539 100644 | |
| --- a/src/TreeStorageNode.cpp | |
| +++ b/src/TreeStorageNode.cpp | |
| @@ -131,6 +131,9 @@ static void md5AppendMap(Md5& md5,const map<string,vector<string> >& m){ | |
| } | |
| unsigned char* TreeStorageNode::calcMD5(unsigned char* md){ | |
| +#if EMSCRIPTEN | |
| + memset(md, 0, 16); | |
| +#else | |
| unsigned char digest[16]; | |
| Md5 md5; | |
| @@ -149,4 +152,5 @@ unsigned char* TreeStorageNode::calcMD5(unsigned char* md){ | |
| } | |
| return md5.final(md); | |
| +#endif | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment