public
Created

Me and My Shadow Web Diff

  • Download Gist
meandmyshadow.web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
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
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.