Revision: 1480
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1480&view=rev
Author:   rorthomas
Date:     2010-07-21 17:58:03 +0000 (Wed, 21 Jul 2010)

Log Message:
-----------
added installer platform, fixed serveral netowkring issues, improved playerlist 
updating rate

Modified Paths:
--------------
    trunk/source/installer/ConfigManager.cpp
    trunk/source/installer/wthread.h
    trunk/source/main/Beam.cpp
    trunk/source/main/BeamFactory.cpp
    trunk/source/main/ChatSystem.cpp
    trunk/source/main/ChatSystem.h
    trunk/source/main/StreamableFactory.h
    trunk/source/main/StreamableFactoryInterface.h
    trunk/source/main/network.cpp

Modified: trunk/source/installer/ConfigManager.cpp
===================================================================
--- trunk/source/installer/ConfigManager.cpp    2010-07-21 17:54:31 UTC (rev 
1479)
+++ trunk/source/installer/ConfigManager.cpp    2010-07-21 17:58:03 UTC (rev 
1480)
@@ -336,7 +336,7 @@
        wxRegKey *pRegKey = new 
wxRegKey(wxT("HKEY_LOCAL_MACHINE\\Software\\RigsOfRods"));
        if(pRegKey->Exists())
                pRegKey->DeleteSelf();
-       
+
        pRegKey = new 
wxRegKey(wxT("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Rigs
 of Rods"));
        if(pRegKey->Exists())
                pRegKey->DeleteSelf();
@@ -738,7 +738,7 @@
 {
        // now hash ourself and validate our installer version, to be sure we 
are using the latest installer
        std::string myPath = conv(MyApp::getExecutablePath());
-       
+
        CSHA1 sha1;
        bool res = sha1.HashFile(const_cast<char*>(myPath.c_str()));
        if(!res) return std::string("");
@@ -752,15 +752,24 @@
 {
        std::string ourHash = getOwnHash();
 
-       char url_tmp[256]="";
-       sprintf(url_tmp, API_CHINSTALLER, ourHash.c_str());
+    char platform_str[256]="";
+#ifdef WIN32
+   sprintf(platform_str, "windows");
+#else
+   sprintf(platform_str, "linux");
+#endif
 
+    char url_tmp[256]="";
+       sprintf(url_tmp, API_CHINSTALLER, ourHash.c_str(), platform_str);
+
        WsyncDownload *wsdl = new WsyncDownload();
+       LOG("checking for installer updates...\n");
        wsdl->setDownloadMessage(_T("checking for installer updates"));
        std::vector< std::vector< std::string > > list;
        int res = wsdl->downloadConfigFile(API_SERVER, std::string(url_tmp), 
list, true);
        if(!res && list.size()>0 && list[0].size()>0)
        {
+               LOG("installer check update result: %s\n", list[0][0].c_str());
                if(list[0][0] == std::string("ok"))
                {
                        // no updates
@@ -768,11 +777,11 @@
                {
                        // yay, an update
                        wsdl->setDownloadMessage(_T("downloading installer 
update"));
-                       
+
                        // rename ourself, so we can replace ourself
                        std::string myPath = conv(MyApp::getExecutablePath());
                        boost::filesystem::rename(myPath, 
myPath+std::string(".old"));
-                       
+
                        int res = wsdl->downloadFile(0, myPath, list[0][1], 
list[0][2], 0, 0, true);
                        if(!res)
                        {

Modified: trunk/source/installer/wthread.h
===================================================================
--- trunk/source/installer/wthread.h    2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/installer/wthread.h    2010-07-21 17:58:03 UTC (rev 1480)
@@ -28,7 +28,7 @@
 #define API_MIRROR_NOGEO    "/getwsyncmirror/?ignoregeo"
 #define API_RECORDTRAFFIC   "/reporttraffic/?mirror=%s&bytes=%d"
 #define API_REPOSEARCH      "/reposearch/"
-#define API_CHINSTALLER     "/checkinstallerupdate/?h=%s"
+#define API_CHINSTALLER     "/checkinstallerupdate/?h=%s&platform=%s"
 
 #define REPO_DOWNLOAD       "/files/mirror/geoselect/"
 

Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp  2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/main/Beam.cpp  2010-07-21 17:58:03 UTC (rev 1480)
@@ -399,7 +399,7 @@
        free_pressure_beam=0;
        default_beam_diameter=DEFAULT_BEAM_DIAMETER;
        skeleton_beam_diameter=BEAM_SKELETON_DIAMETER;
-       
+
        default_spring=DEFAULT_SPRING;
        default_spring_scale=1;
        default_damp=DEFAULT_DAMP;
@@ -408,7 +408,7 @@
        default_deform_scale=1;
        default_break=BEAM_BREAK;
        default_break_scale=1;
-       
+
        default_node_friction=NODE_FRICTION_COEF_DEFAULT;
        default_node_volume=NODE_VOLUME_COEF_DEFAULT;
        default_node_surface=NODE_SURFACE_COEF_DEFAULT;
@@ -1575,7 +1575,7 @@
                         * this command has several layers for splitting up the 
line:
                         * 1. ',' the top level will be split up with a comma 
to separate the main options
                         * 2. ':' the second level will be split up with colon, 
it separates the entry name and its value
-                        * 3. '|' the third level is used to specify multiple 
values for the entry value 
+                        * 3. '|' the third level is used to specify multiple 
values for the entry value
                         */
                        int animnum = 0;
                        float ratio = 0.0f, opt1 = -1.0f, opt2 = -1.0f;
@@ -1602,7 +1602,7 @@
                        prop_t *prop = &props[free_prop-1];
 
                        // look for a free anim slot, important: do not over 
the borders!
-                       while (prop->animFlags[animnum] && animnum < 10) 
+                       while (prop->animFlags[animnum] && animnum < 10)
                                animnum++;
 
                        // all slots used?
@@ -1641,7 +1641,7 @@
                                        Ogre::vector<Ogre::String>::type args2 
= Ogre::StringUtil::split(options[i], ":");
                                        if(args2.size() == 0)
                                                continue;
-                                       
+
                                        // trim spaces from the entry
                                        Ogre::StringUtil::trim(args2[0]);
                                        if(args2.size() >= 2) 
Ogre::StringUtil::trim(args2[1]);
@@ -1758,7 +1758,7 @@
                                        {
                                                // TODO: re-add check for 
invalid cases
                                                prop->animMode[animnum] |= 
(ANIM_MODE_AUTOANIMATE);
-                                               
+
                                                if     (prop->animMode[animnum] 
& ANIM_MODE_ROTA_X)   { prop->animOpt1[animnum] = opt1 + prop->rotaX; 
prop->animOpt2[animnum] = opt2 + prop->rotaX; prop->animOpt4[animnum] = 
prop->rotaX; }
                                                else if(prop->animMode[animnum] 
& ANIM_MODE_ROTA_Y)   { prop->animOpt1[animnum] = opt1 + prop->rotaY; 
prop->animOpt2[animnum] = opt2 + prop->rotaY; prop->animOpt4[animnum] = 
prop->rotaY; }
                                                else if(prop->animMode[animnum] 
& ANIM_MODE_ROTA_Z)   { prop->animOpt1[animnum] = opt1 + prop->rotaZ; 
prop->animOpt2[animnum] = opt2 + prop->rotaZ; prop->animOpt4[animnum] = 
prop->rotaZ; }
@@ -1785,7 +1785,7 @@
                                        {
                                                // we are using keys as source
                                                prop->animFlags[animnum] |= 
ANIM_FLAG_EVENT;
-                                               
+
                                                // now parse the keys
                                                prop->animFlags[animnum] |= 
ANIM_FLAG_EVENT;
                                                
Ogre::vector<Ogre::String>::type args3 = Ogre::StringUtil::split(args2[1], "|");
@@ -1807,7 +1807,7 @@
                        continue;
                }
 
-               
+
                if (!strncmp("set_managedmaterials_options", line, 28))
                {
                        int result = sscanf(line,"set_managedmaterials_options 
%d", &managedmaterials_doublesided);
@@ -4306,7 +4306,7 @@
                                
LogManager::getSingleton().logMessage("airbrakes limit reached 
("+StringConverter::toString(MAX_AIRBRAKES)+"): " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". trying to continue ...");
                                continue;
                        }
-                       if (liftcoef != 1.0f) 
+                       if (liftcoef != 1.0f)
                                
LogManager::getSingleton().logMessage("Airbrakes force coefficent: " + 
StringConverter::toString(liftcoef));
 
                        airbrakes[free_airbrake]=new Airbrake(manager, 
truckname, free_airbrake, &nodes[ref], &nodes[nx], &nodes[ny], &nodes[na], 
Vector3(ox,oy,oz), wd, len, maxang, texname, tx1,tx2,tx3,tx4,liftcoef);
@@ -6092,7 +6092,7 @@
 
                // no materialmapping for beams!
                //              ec->setCastShadows(false);
-               
+
                if (beams[pos].mEntity && (type==BEAM_HYDRO || 
type==BEAM_MARKED))
                        beams[pos].mEntity->setMaterialName("tracks/Chrome");
                else if(beams[pos].mEntity)
@@ -6619,10 +6619,17 @@
 
        // register the local stream
        stream_register_trucks_t reg;
+       memset(&reg, 0, sizeof(stream_register_trucks_t));
        reg.status = 0;
-       reg.type = 0; // 0 = truck
+       reg.type   = 0; // 0 = truck
        reg.bufferSize = netbuffersize;
-       strcpy(reg.name, realtruckfilename.c_str());
+       strncpy(reg.name, realtruckfilename.c_str(), 128);
+       if(!truckconfig.empty())
+       {
+               // insert section config
+               for(int i = 0; i < std::min<int>(truckconfig.size(), 10); i++)
+                       strncpy(reg.truckconfig[i], truckconfig[i].c_str(), 60);
+       }
 
        NetworkStreamManager::getSingleton().addLocalStream(this, 
(stream_register_t *)&reg, sizeof(reg));
 }
@@ -6778,7 +6785,7 @@
                        if (getAxleLockName() == "Split") cstate = 0.5f;
                        if (getAxleLockName() == "Locked") cstate = 1.0f;
                } else  // no axles/diffs avail, mode is split by default
-                       cstate=0.5f;  
+                       cstate=0.5f;
 
                div++;
        }
@@ -7001,9 +7008,9 @@
 
                if (flag_state & ANIM_FLAG_AESTATUS)
                {
-                       if (!aeroengines[aenum]->getIgnition()) 
+                       if (!aeroengines[aenum]->getIgnition())
                                cstate = 0.0f;
-                       else 
+                       else
                                cstate = 0.5f;
                        if (aeroengines[aenum]->isFailed()) cstate = 1.0f;
                        div++;
@@ -7100,7 +7107,7 @@
                //flip to other side when upside down
                if (upv.y<0) rollangle= 180.0f - rollangle;
                cstate = rollangle / 180.0f;
-               // dataoutpu is -0.5 to 1.5, normalize to -1 to +1 without 
changing the zero position. 
+               // dataoutpu is -0.5 to 1.5, normalize to -1 to +1 without 
changing the zero position.
                // this is vital for the animateor beams and does not effect 
the animated props
                if (cstate >= 1.0f) cstate = cstate - 2.0f;
                div++;
@@ -7390,7 +7397,7 @@
                                                        d=d*0.1f;
                                                }
                                        }
-                                       else // We assume bounded=SUPPORTBEAM 
+                                       else // We assume bounded=SUPPORTBEAM
                                        {
                                                if (difftoBeamL>0.0f)
                                                {
@@ -7576,7 +7583,7 @@
                                                                // use animkey 
as bool to determine keypress / release state of inputengine
                                                                
props[propi].animKeyState[animnum] = 1.0f;
                                                        }
-                                                       else 
+                                                       else
                                                        {
                                                                
props[propi].lastanimKS[animnum] = 0.0f;
                                                                // use animkey 
as bool to determine keypress / release state of inputengine
@@ -7589,7 +7596,7 @@
                                                }
                                        } else
                                        {
-                                               // keyevent exists and keylock 
is enabled but the key isnt pressed right now = get lastanimkeystatus for 
cstate and reset keypressed bool animkey 
+                                               // keyevent exists and keylock 
is enabled but the key isnt pressed right now = get lastanimkeystatus for 
cstate and reset keypressed bool animkey
                                                if 
(props[propi].animKeyState[animnum] != -1.0f)
                                                {
                                                        cstate 
+=props[propi].lastanimKS[animnum];
@@ -7673,14 +7680,14 @@
                                                                limiter = 
180.0f;                                                                         
      // stop at limit
                                                                
props[propi].animOpt5[animnum] *= -1.0f;                                // 
change cstate multiplier if bounce is set
                                                                limiterchanged 
= true;
-                                                       } else 
+                                                       } else
                                                        {
                                                                limiter -= 
360.0f;                                                                         
     // flip to other side at limit
                                                                limiterchanged 
= true;
                                                        }
                                                }
                                        }
-       
+
                                        // check if a negative custom limit is 
set to evaluate/calc flip back
                                        if (props[propi].animOpt1[animnum] - 
props[propi].animOpt4[animnum])
                                        {
@@ -7713,7 +7720,7 @@
                                                        }
                                                }
                                        }
-                                       
+
                                        if (limiterchanged)
                                        {
                                                if 
(props[propi].animMode[animnum] & ANIM_MODE_ROTA_X) props[propi].rotaX = 
limiter;
@@ -7765,7 +7772,7 @@
                                                                {
                                                                        
autooffset = 10.0f;                                                             
                // stop at limit
                                                                        
props[propi].animOpt5[animnum] *= -1.0f;                                // 
change cstate multiplier if bounce is set
-                                                               } else 
+                                                               } else
                                                                        
autooffset -= 20.0f;                                                            
        // flip to other side at limit including overflow
                                                        }
 
@@ -7788,7 +7795,7 @@
                                                                {
                                                                        
autooffset = -10.0f;                                                            
        // stop at limit
                                                                        
props[propi].animOpt5[animnum] *= -1.0f;                                // 
change cstate multiplier if bounce is set
-                                                               } else 
+                                                               } else
                                                                        
autooffset += 20.0f;                                                            
        // flip to other side at limit including overflow
                                                        }
                                        }
@@ -7812,7 +7819,7 @@
                                                        props[propi].orgoffsetZ 
= autooffset;
                                        }
                                }
-                               
+
                        }
                animnum++;
                }
@@ -8028,7 +8035,7 @@
                                float ns=0;
                                ground_model_t *gm = 0; // this is used as 
result storage, so we can use it later on
                                int contacted = 
collisions->groundCollision(&nodes[i], nodes[i].colltesttimer, &gm, &ns);
-                               
+
                                //TODO is this supposed to be a binary 
operator, or a logical operator?
                                if ( contacted |
                                        collisions->nodeCollision(&nodes[i], 
i==cinecameranodepos[currentcamera], contacted, nodes[i].colltesttimer, &ns, 
&gm))
@@ -8627,7 +8634,7 @@
                        else
                                hydrorudderstate+=dt*4.0;
                }
-               
+
                float delta=dt;
                if (hydrorudderstate>delta) hydrorudderstate-=delta;
                else if (hydrorudderstate<-delta) hydrorudderstate+=delta;

Modified: trunk/source/main/BeamFactory.cpp
===================================================================
--- trunk/source/main/BeamFactory.cpp   2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/main/BeamFactory.cpp   2010-07-21 17:58:03 UTC (rev 1480)
@@ -127,13 +127,15 @@
 {
        // NO LOCKS IN HERE, already locked
 
+       stream_register_trucks_t *treg = (stream_register_trucks_t *)&reg->reg;
+
        LogManager::getSingleton().logMessage(" new beam truck for " + 
StringConverter::toString(reg->sourceid) + ":" + 
StringConverter::toString(reg->streamid));
 
        bool networked=true, networking=false;
        if(net) networking = true;
 
        // check if we got this truck installed
-       String filename = String(reg->reg.name);
+       String filename = String(treg->name);
        String group = "";
        if(!CACHE.checkResourceLoaded(filename, group))
        {
@@ -146,8 +148,18 @@
                return 0;
        }
 
+       // fill truckconfig
+       std::vector<Ogre::String> truckconfig;
+       for(int i = 0; i < 10; i++)
+       {
+               if(!strnlen(treg->truckconfig[i], 60))
+                       break;
+               truckconfig.push_back(String(treg->truckconfig[i]));
+       }
+
+
        // spawn the truck far off anywhere
-       Vector3 pos = Vector3(0,0,0);
+       Vector3 pos = Vector3(1000000,1000000,1000000);
 
        int truck_num = efl->getFreeTruckSlot();
        if(truck_num == -1)
@@ -178,7 +190,7 @@
                0,
                false,
                0,
-               0,
+               &truckconfig,
                0);
 
        efl->trucks[truck_num] = b;

Modified: trunk/source/main/ChatSystem.cpp
===================================================================
--- trunk/source/main/ChatSystem.cpp    2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/main/ChatSystem.cpp    2010-07-21 17:58:03 UTC (rev 1480)
@@ -73,18 +73,21 @@
        return ch;
 }
 
-void ChatSystemFactory::syncRemoteStreams()
+bool ChatSystemFactory::syncRemoteStreams()
 {
-       StreamableFactory <ChatSystemFactory, ChatSystem>::syncRemoteStreams();
+       // we override this here, so we know if something changed and could 
update the player list
+       bool changes = StreamableFactory <ChatSystemFactory, 
ChatSystem>::syncRemoteStreams();
 
        // now add the update for the player list here
-       updatePlayerList();
+       if(changes)
+               updatePlayerList();
 }
 
 void ChatSystemFactory::updatePlayerList()
 {
        if(!net) return;
 
+       LogManager::getSingleton().logMessage(" updatePlayerList()");
 #ifdef USE_MYGUI
 #ifdef USE_SOCKETW
        // TODO: we need to do this upon changes only, not all the time

Modified: trunk/source/main/ChatSystem.h
===================================================================
--- trunk/source/main/ChatSystem.h      2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/main/ChatSystem.h      2010-07-21 17:58:03 UTC (rev 1480)
@@ -6,7 +6,7 @@
 For more information, see http://www.rigsofrods.com/
 
 Rigs of Rods is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 3, as 
+it under the terms of the GNU General Public License version 3, as
 published by the Free Software Foundation.
 
 Rigs of Rods is distributed in the hope that it will be useful,
@@ -75,7 +75,7 @@
        void netUserAttributesChanged(int source, int streamid) {};
        void localUserAttributesChanged(int newid) {};
 
-       void syncRemoteStreams();
+       bool syncRemoteStreams();
 
        void updatePlayerList();
 };

Modified: trunk/source/main/StreamableFactory.h
===================================================================
--- trunk/source/main/StreamableFactory.h       2010-07-21 17:54:31 UTC (rev 
1479)
+++ trunk/source/main/StreamableFactory.h       2010-07-21 17:58:03 UTC (rev 
1480)
@@ -122,10 +122,11 @@
                UNLOCKSTREAMS();
        }
 
-       virtual void syncRemoteStreams()
+       virtual bool syncRemoteStreams()
        {
                LOCKSTREAMS();
                // first registrations
+               int changes = 0;
                while (!stream_registrations.empty())
                {
                        stream_reg_t reg = stream_registrations.front();
@@ -146,6 +147,7 @@
 
                        stream_creation_results.push_back(reg);
                        stream_registrations.pop_front();
+                       changes++;
                }
                // then deletions:
                // first registrations
@@ -154,8 +156,10 @@
                        stream_del_t del = stream_deletions.front();
                        removeInstance(&del);
                        stream_deletions.pop_front();
+                       changes++;
                }
                UNLOCKSTREAMS();
+               return (changes > 0);
        }
 
        void removeInstance(stream_del_t *del)

Modified: trunk/source/main/StreamableFactoryInterface.h
===================================================================
--- trunk/source/main/StreamableFactoryInterface.h      2010-07-21 17:54:31 UTC 
(rev 1479)
+++ trunk/source/main/StreamableFactoryInterface.h      2010-07-21 17:58:03 UTC 
(rev 1480)
@@ -52,7 +52,7 @@
        virtual Streamable *createRemoteInstance(stream_reg_t *reg) = 0;
        virtual void createRemote(int sourceid, int streamid, stream_register_t 
*reg, int colour) = 0;
        virtual void deleteRemote(int sourceid, int streamid) = 0;
-       virtual void syncRemoteStreams() = 0;
+       virtual bool syncRemoteStreams() = 0;
        virtual void removeInstance(stream_del_t *del) = 0;
 };
 

Modified: trunk/source/main/network.cpp
===================================================================
--- trunk/source/main/network.cpp       2010-07-21 17:54:31 UTC (rev 1479)
+++ trunk/source/main/network.cpp       2010-07-21 17:58:03 UTC (rev 1480)
@@ -177,7 +177,7 @@
        }
 
        header_t header;
-       char buffer[256];
+       char buffer[MAX_MESSAGE_LENGTH];
        //get server version
        if (receivemessage(&socket, &header, buffer, 255))
        {
@@ -190,6 +190,7 @@
                netFatalError("Establishing network session: error getting 
server hello");
                return false;
        }
+
        // save server settings
        memcpy(&server_settings, buffer, sizeof(server_info_t));
 


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

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to