Revision: 1622
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1622&view=rev
Author:   rorthomas
Date:     2011-01-31 10:51:12 +0000 (Mon, 31 Jan 2011)

Log Message:
-----------
improved installer bits a bit
improved online script api
fixed sha under 64 bit

Modified Paths:
--------------
    trunk/source/main/Beam.h
    trunk/source/main/BeamLoadTruck.cpp
    trunk/source/main/RoRFrameListener.cpp
    trunk/source/main/ScriptEngine.cpp
    trunk/source/main/ScriptEngine.h
    trunk/source/main/Settings.cpp
    trunk/source/main/Settings.h
    trunk/source/main/sha1.h
    trunk/tools/windows/installer/setup.nsi

Modified: trunk/source/main/Beam.h
===================================================================
--- trunk/source/main/Beam.h    2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/Beam.h    2011-01-31 10:51:12 UTC (rev 1622)
@@ -34,6 +34,7 @@
 #include "BeamData.h" // for rig_t
 #include "rormemory.h"
 #include "approxmath.h"
+#include "CacheSystem.h"
 
 // system includes
 #include <vector>
@@ -340,6 +341,7 @@
        float *mapsizex, *mapsizez;
        float refpressure;
        PointColDetector *pointCD;
+       Cache_Entry cacheEntryInfo;
 
        pthread_mutex_t work_mutex;
        pthread_cond_t work_cv;

Modified: trunk/source/main/BeamLoadTruck.cpp
===================================================================
--- trunk/source/main/BeamLoadTruck.cpp 2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/BeamLoadTruck.cpp 2011-01-31 10:51:12 UTC (rev 1622)
@@ -60,6 +60,8 @@
                }
        }
 
+       this->cacheEntryInfo = CACHE.getResourceInfo(filename);
+
        DataStreamPtr ds = 
ResourceGroupManager::getSingleton().openResource(filename, group);
        linecounter = 0;
 

Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp      2011-01-31 09:11:25 UTC (rev 
1621)
+++ trunk/source/main/RoRFrameListener.cpp      2011-01-31 10:51:12 UTC (rev 
1622)
@@ -4722,6 +4722,22 @@
 
        }
 
+       // set the terrain hash
+       {
+               Cache_Entry ce = CACHE.getResourceInfo(terrainfile);
+               char hash_result[250];
+               RoR::CSHA1 sha1;
+               String fn;
+               if(ce.type == "Zip")
+                       fn = ce.dirname;
+               else if(ce.type == "FileSystem")
+                       fn = ce.dirname + SETTINGS.getSetting("dirsep") + 
ce.fname;
+               sha1.HashFile(const_cast<char*>(fn.c_str()));
+               sha1.Final();
+               sha1.ReportHash(hash_result, RoR::CSHA1::REPORT_HEX_SHORT);
+               SETTINGS.setSetting("TerrainHash", String(hash_result));
+       }
+
        loadedTerrain = terrainfile;
 
        initializeCompontents();

Modified: trunk/source/main/ScriptEngine.cpp
===================================================================
--- trunk/source/main/ScriptEngine.cpp  2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/ScriptEngine.cpp  2011-01-31 10:51:12 UTC (rev 1622)
@@ -62,7 +62,7 @@
 
 template<> ScriptEngine *Ogre::Singleton<ScriptEngine>::ms_Singleton=0;
 
-ScriptEngine::ScriptEngine(RoRFrameListener *efl, Collisions *_coll) : 
mefl(efl), coll(_coll), engine(0), context(0), frameStepFunctionPtr(-1), 
wheelEventFunctionPtr(-1), eventMask(0)
+ScriptEngine::ScriptEngine(RoRFrameListener *efl, Collisions *_coll) : 
mefl(efl), coll(_coll), engine(0), context(0), frameStepFunctionPtr(-1), 
wheelEventFunctionPtr(-1), eventMask(0), terrainScriptName(), 
terrainScriptHash()
 {
        init();
 
@@ -78,10 +78,12 @@
 
 int ScriptEngine::loadTerrainScript(Ogre::String scriptname)
 {
+       terrainScriptName = scriptname;
+
        // Load the entire script file into the buffer
        int result=0;
-       string script, hash;
-       result = loadScriptFile(scriptname.c_str(), script, hash);
+       string script;
+       result = loadScriptFile(scriptname.c_str(), script, terrainScriptHash);
        if( result )
        {
                LogManager::getSingleton().logMessage("SE| Unkown error while 
loading script file: "+scriptname);
@@ -1220,8 +1222,37 @@
                }
        }
 
+       // add some hardcoded values
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "terrain_Name", 
CURLFORM_COPYCONTENTS, mse->getTerrainName().c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "terrain_Hash", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("TerrainHash").c_str(), 
CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"terrain_ScriptHash", CURLFORM_COPYCONTENTS, 
mse->getTerrainScriptHash().c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "User_NickName", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("Nickname").c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "User_Language", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("Language").c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "User_Token", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("User Token").c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"RoR_VersionString", CURLFORM_COPYCONTENTS, ROR_VERSION_STRING, CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "RoR_VersionSVN", 
CURLFORM_COPYCONTENTS, SVN_REVISION, CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"RoR_VersionSVNID", CURLFORM_COPYCONTENTS, SVN_ID, CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"RoR_ProtocolVersion", CURLFORM_COPYCONTENTS, RORNET_VERSION, CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "RoR_BinaryHash", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("BinaryHash").c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "RoR_GUID", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("GUID").c_str(), CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "MP_ServerName", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("Server name").c_str(), 
CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "MP_ServerPort", 
CURLFORM_COPYCONTENTS, SETTINGS.getSetting("Server port").c_str(), 
CURLFORM_END);
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"MP_NetworkEnabled", CURLFORM_COPYCONTENTS, SETTINGS.getSetting("Network 
enable").c_str(), CURLFORM_END);
+       
+       if(mefl->getCurrentTruckNumber() >= 0 && mefl->getCurrentTruck())
+       {
+               Beam *truck = mefl->getCurrentTruck();
+
+               curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"Truck_Name", CURLFORM_COPYCONTENTS, truck->getTruckName().c_str(), 
CURLFORM_END);
+               curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"Truck_ModHash", CURLFORM_COPYCONTENTS, truck->cacheEntryInfo.hash.c_str(), 
CURLFORM_END);
+               curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, 
"Truck_ModFileName", CURLFORM_COPYCONTENTS, 
truck->cacheEntryInfo.fname.c_str(), CURLFORM_END);
+       }
+
+       const RenderTarget::FrameStats& stats = 
mefl->getRenderWindow()->getStatistics();
+       curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "AVG_FPS", 
CURLFORM_COPYCONTENTS, StringConverter::toString(stats.avgFPS).c_str(), 
CURLFORM_END);
+
  
-
+       
        CURLcode res;
        CURL *curl = curl_easy_init();
        if(!curl)

Modified: trunk/source/main/ScriptEngine.h
===================================================================
--- trunk/source/main/ScriptEngine.h    2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/ScriptEngine.h    2011-01-31 10:51:12 UTC (rev 1622)
@@ -137,6 +137,9 @@
 
        AngelScript::asIScriptEngine *getEngine() { return engine; };
 
+       Ogre::String getTerrainName() { return terrainScriptName; };
+       Ogre::String getTerrainScriptHash() { return terrainScriptHash; };
+
 protected:
     RoRFrameListener *mefl;             //!< local RoRFrameListener instance, 
used as proxy for many functions
        Collisions *coll;
@@ -145,6 +148,7 @@
        int frameStepFunctionPtr;               //!< script function pointer to 
the frameStep function
        int wheelEventFunctionPtr;               //!< script function pointer
        int eventCallbackFunctionPtr;           //!< script function pointer to 
the event callback function
+       Ogre::String terrainScriptName, terrainScriptHash;
        std::map <std::string , std::vector<int> > callbacks;
 
        /**

Modified: trunk/source/main/Settings.cpp
===================================================================
--- trunk/source/main/Settings.cpp      2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/Settings.cpp      2011-01-31 10:51:12 UTC (rev 1622)
@@ -29,6 +29,7 @@
 #define _L
 
 #include "errorutils.h"
+#include "sha1.h"
 
 using namespace std;
 using namespace Ogre;
@@ -60,7 +61,7 @@
 {
        // hide certain settings for scripts
        if(key == "User Token" || key == "Config Root" || key == "Cache Path" 
|| key == "Log Path" || key == "Resources Path" || key == "Streams Path" || key 
== "Program Path")
-               return "";
+               return "permission denied";
 
        return settings[key];
 }
@@ -111,6 +112,7 @@
        std::map<std::string, std::string>::iterator it;
        for(it = settings.begin(); it != settings.end(); it++)
        {
+               if(it->first == "BinaryHash") continue;
                fprintf(fd, "%s=%s\n", it->first.c_str(), it->second.c_str());
        }
 
@@ -136,11 +138,51 @@
        }
        // add a GUID if not there
        checkGUID();
+       generateBinaryHash();
 }
 
+int Settings::generateBinaryHash()
+{
+#ifndef NOOGRE
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+       // note: we enforce usage of the non-UNICODE interfaces (since its 
easier to integrate here)
+       char program_path[1024]="";
+       if (!GetModuleFileNameA(NULL, program_path, 512))
+       {
+               showError(_L("Startup error"), _L("Error while retrieving 
program space path"));
+               return 1;
+       }
+       GetShortPathNameA(program_path, program_path, 512); //this is legal
+
+#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
+       //true program path is impossible to get from POSIX functions
+       //lets hack!
+       pid_t pid = getpid();
+       char procpath[256];
+       sprintf(procpath, "/proc/%d/exe", pid);
+       int ch = readlink(procpath,program_path,240);
+       if (ch != -1)
+       {
+               program_path[ch] = 0;
+       } else return 1;
+#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+       // TO BE DONE
+#endif //OGRE_PLATFORM
+       // now hash ourself
+       {
+               char hash_result[250];
+               RoR::CSHA1 sha1;
+               sha1.HashFile(program_path);
+               sha1.Final();
+               sha1.ReportHash(hash_result, RoR::CSHA1::REPORT_HEX_SHORT);
+               setSetting("BinaryHash", String(hash_result));
+       }
+#endif //NOOGRE
+       return 0;
+}
+
 bool Settings::get_system_paths(char *program_path, char *user_path)
 {
-
 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        // note: we enforce usage of the non-UNICODE interfaces (since its 
easier to integrate here)
        if (!GetModuleFileNameA(NULL, program_path, 512))

Modified: trunk/source/main/Settings.h
===================================================================
--- trunk/source/main/Settings.h        2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/Settings.h        2011-01-31 10:51:12 UTC (rev 1622)
@@ -62,6 +62,7 @@
        void path_add(char* path, const char* dirname);
 
        bool get_system_paths(char *program_path, char *user_path);
+       int generateBinaryHash();
 
 };
 #endif

Modified: trunk/source/main/sha1.h
===================================================================
--- trunk/source/main/sha1.h    2011-01-31 09:11:25 UTC (rev 1621)
+++ trunk/source/main/sha1.h    2011-01-31 10:51:12 UTC (rev 1622)
@@ -36,7 +36,6 @@
 #define ___SHA1_HDR___
 
 #include <stdint.h> //"pstdint.h" // Needed for uint32_t, uint8_t
-#define uint8_t char
 
 #if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)
 #define SHA1_UTILITY_FUNCTIONS

Modified: trunk/tools/windows/installer/setup.nsi
===================================================================
--- trunk/tools/windows/installer/setup.nsi     2011-01-31 09:11:25 UTC (rev 
1621)
+++ trunk/tools/windows/installer/setup.nsi     2011-01-31 10:51:12 UTC (rev 
1622)
@@ -1,5 +1,12 @@
-; Script generated by the HM NIS Edit Script Wizard.
+; HM NIS Edit Wizard helper defines
+!define PRODUCT_NAME "Rigs of Rods"
+!define PRODUCT_VERSION "0.38.6"
+!define PRODUCT_PUBLISHER "Rigs of Rods Team"
+!define PRODUCT_WEB_SITE "http://www.rigsofrods.com";
+!define PRODUCT_UNINST_KEY 
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+!define PRODUCT_UNINST_ROOT_KEY "HKLM"
 
+
 ; ################################################################
 ; appends \ to the path if missing
 ; example: !insertmacro GetCleanDir "c:\blabla"
@@ -80,13 +87,6 @@
 !macroend
 !define WriteToFile "!insertmacro WriteToFile"
 
-; HM NIS Edit Wizard helper defines
-!define PRODUCT_NAME "Rigs of Rods"
-!define PRODUCT_VERSION "0.38.2"
-!define PRODUCT_PUBLISHER "Rigs of Rods Team"
-!define PRODUCT_WEB_SITE "http://www.rigsofrods.com";
-!define PRODUCT_UNINST_KEY 
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
-!define PRODUCT_UNINST_ROOT_KEY "HKLM"
 
 SetCompressor /FINAL /SOLID lzma
 
@@ -203,7 +203,7 @@
 ; MUI end ------
 
 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
-OutFile "RoR-${PRODUCT_VERSION}-Setup.exe"
+OutFile "RoR-Setup-${PRODUCT_VERSION}.exe"
 InstallDir "$PROGRAMFILES\Rigs of Rods ${PRODUCT_VERSION}"
 
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to