Revision: 1483
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1483&view=rev
Author:   rorthomas
Date:     2010-07-22 01:32:04 +0000 (Thu, 22 Jul 2010)

Log Message:
-----------
improved icons for no trucks loaded
fixed MP GUI loading (broken in last rev)
improved stream checking logic
added grey up/down arrows to icons
fixed chatsystem/character registration result queue overflow

Modified Paths:
--------------
    trunk/bin/resources/icons.zip
    trunk/source/main/BeamFactory.cpp
    trunk/source/main/BeamFactory.h
    trunk/source/main/ChatSystem.cpp
    trunk/source/main/ChatSystem.h
    trunk/source/main/RoRFrameListener.cpp
    trunk/source/main/RoRFrameListener.h
    trunk/source/main/Streamable.cpp
    trunk/source/main/Streamable.h
    trunk/source/main/StreamableFactory.h
    trunk/source/main/gui_mp.cpp
    trunk/source/main/network.cpp

Modified: trunk/bin/resources/icons.zip
===================================================================
(Binary files differ)

Modified: trunk/source/main/BeamFactory.cpp
===================================================================
--- trunk/source/main/BeamFactory.cpp   2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/BeamFactory.cpp   2010-07-22 01:32:04 UTC (rev 1483)
@@ -30,6 +30,10 @@
 #include "RoRFrameListener.h"
 #include "mirrors.h"
 
+#ifdef USE_MYGUI
+#include "gui_mp.h"
+#endif  // USE_MYGUI
+
 using namespace Ogre;
 
 
@@ -269,3 +273,23 @@
        UNLOCKSTREAMS();
        return 0;
 }
+
+bool BeamFactory::syncRemoteStreams()
+{
+       // we override this here, so we know if something changed and could 
update the player list
+       bool changes = StreamableFactory <BeamFactory, 
Beam>::syncRemoteStreams();
+       
+       if(changes)
+               updateGUI();
+
+       return changes;
+}
+
+void BeamFactory::updateGUI()
+{
+#ifdef USE_MYGUI
+#ifdef USE_SOCKETW
+       GUI_Multiplayer::getSingleton().update();
+#endif // USE_SOCKETW
+#endif // USE_MYGUI    
+}
\ No newline at end of file

Modified: trunk/source/main/BeamFactory.h
===================================================================
--- trunk/source/main/BeamFactory.h     2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/BeamFactory.h     2010-07-22 01:32:04 UTC (rev 1483)
@@ -71,6 +71,9 @@
        void netUserAttributesChanged(int source, int streamid);
        void localUserAttributesChanged(int newid);
 
+
+       bool syncRemoteStreams();
+       void updateGUI();
 };
 
 

Modified: trunk/source/main/ChatSystem.cpp
===================================================================
--- trunk/source/main/ChatSystem.cpp    2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/ChatSystem.cpp    2010-07-22 01:32:04 UTC (rev 1483)
@@ -78,23 +78,13 @@
        // 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
-       if(changes)
-               updatePlayerList();
-       
-       return changes;
-}
-
-void ChatSystemFactory::updatePlayerList()
-{
-       if(!net) return;
-
 #ifdef USE_MYGUI
 #ifdef USE_SOCKETW
-       // TODO: we need to do this upon changes only, not all the time
-       GUI_Multiplayer::getSingleton().update();
+       if(changes)
+               GUI_Multiplayer::getSingleton().update();
 #endif // USE_SOCKETW
-#endif // USE_MYGUI
+#endif // USE_MYGUI    
+       return changes;
 }
 
 ChatSystem *ChatSystemFactory::getFirstChatSystem()

Modified: trunk/source/main/ChatSystem.h
===================================================================
--- trunk/source/main/ChatSystem.h      2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/ChatSystem.h      2010-07-22 01:32:04 UTC (rev 1483)
@@ -76,8 +76,6 @@
        void localUserAttributesChanged(int newid) {};
 
        bool syncRemoteStreams();
-
-       void updatePlayerList();
 };
 
 #endif

Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp      2010-07-21 23:07:57 UTC (rev 
1482)
+++ trunk/source/main/RoRFrameListener.cpp      2010-07-22 01:32:04 UTC (rev 
1483)
@@ -775,6 +775,7 @@
        objectCounter=0;
        hdrListener=0;
        netPointToUID=-1;
+       netcheckGUITimer=0;
        mDOF=0;
        mDOFDebug=false;
        mouseGrabForce=100000.0f;
@@ -1181,6 +1182,7 @@
 
 #ifdef USE_SOCKETW
                new GUI_Multiplayer(net);
+               GUI_Multiplayer::getSingleton().update();
 #endif //USE_SOCKETW
 
 #endif //USE_MYGUI
@@ -7111,6 +7113,17 @@
        // update animated objects
        updateAnimatedObjects(dt);
 
+       // update network gui if required, at most every 2 seconds
+       if(net)
+       {
+               netcheckGUITimer += dt;
+               if(netcheckGUITimer > 2)
+               {
+                       checkRemoteStreamResultsChanged();
+                       netcheckGUITimer=0;
+               }
+       }
+
        // updating mirrors fixes its shaking!
        if (cameramode==CAMERA_INT)
                updateTruckMirrors(dt);
@@ -7932,3 +7945,14 @@
        // TODO: setup arrow
        netPointToUID = uid;
 }
+
+
+void RoRFrameListener::checkRemoteStreamResultsChanged()
+{
+#ifdef USE_MYGUI
+#ifdef USE_SOCKETW
+       if(BeamFactory::getSingleton().checkStreamsResultsChanged())
+               GUI_Multiplayer::getSingleton().update();
+#endif // USE_SOCKETW
+#endif // USE_MYGUI    
+}
\ No newline at end of file

Modified: trunk/source/main/RoRFrameListener.h
===================================================================
--- trunk/source/main/RoRFrameListener.h        2010-07-21 23:07:57 UTC (rev 
1482)
+++ trunk/source/main/RoRFrameListener.h        2010-07-22 01:32:04 UTC (rev 
1483)
@@ -339,6 +339,8 @@
        void showspray(bool s);
        int getNetPointToUID() { return netPointToUID; };
        void setNetPointToUID(int uid);
+       void checkRemoteStreamResultsChanged();
+       float netcheckGUITimer;
 
        Character *person;
        ChatSystem *netChat;

Modified: trunk/source/main/Streamable.cpp
===================================================================
--- trunk/source/main/Streamable.cpp    2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/Streamable.cpp    2010-07-22 01:32:04 UTC (rev 1483)
@@ -32,7 +32,7 @@
 
 using namespace Ogre;
 
-Streamable::Streamable() : isOrigin(false)
+Streamable::Streamable() : isOrigin(false), streamResultsChanged(false)
 {
        //NetworkStreamManager::getSingleton().addStream(this);
        pthread_mutex_init(&recv_work_mutex, NULL);
@@ -149,6 +149,7 @@
 void Streamable::addStreamRegistrationResult(int sourceid, stream_register_t 
reg)
 {
        mStreamableResults[sourceid] = reg;
+       streamResultsChanged=true;
 }
 
 int Streamable::getStreamRegisterResultForSource(int sourceid, 
stream_register_t *reg)
@@ -158,3 +159,13 @@
        *reg = mStreamableResults[sourceid];
        return 0;
 }
+
+bool Streamable::getStreamResultsChanged()
+{
+       if(streamResultsChanged)
+       {
+               streamResultsChanged = false;
+               return true;
+       }
+       return false;
+}
\ No newline at end of file

Modified: trunk/source/main/Streamable.h
===================================================================
--- trunk/source/main/Streamable.h      2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/Streamable.h      2010-07-22 01:32:04 UTC (rev 1483)
@@ -55,6 +55,7 @@
 
        void addStreamRegistrationResult(int source, stream_register_t reg);
        int getStreamRegisterResultForSource(int sourceid, stream_register_t 
*reg);
+       bool getStreamResultsChanged();
 
 protected:
        // constructor/destructor are protected, so you cannot create instances 
without using the factory
@@ -97,7 +98,7 @@
 
 private:
        std::map < int, stream_register_t > mStreamableResults;
-       bool isOrigin;
+       bool isOrigin, streamResultsChanged;
 
 };
 

Modified: trunk/source/main/StreamableFactory.h
===================================================================
--- trunk/source/main/StreamableFactory.h       2010-07-21 23:07:57 UTC (rev 
1482)
+++ trunk/source/main/StreamableFactory.h       2010-07-22 01:32:04 UTC (rev 
1483)
@@ -145,7 +145,14 @@
                        reg.reg.origin_sourceid = reg.sourceid;
                        reg.reg.origin_streamid = reg.streamid;
 
-                       stream_creation_results.push_back(reg);
+                       // only save registration results for beam streams
+                       // TODO: maybe enforce general design to allow all 
stream types to
+                       // have a feedback channel
+                       if(reg.reg.type == 0)
+                       {
+                               stream_creation_results.push_back(reg);
+                       }
+                       // remove registration from list
                        stream_registrations.pop_front();
                        changes++;
                }
@@ -189,38 +196,63 @@
                }
        }
 
-       bool checkStreamsOK(int sourceid)
+       int checkStreamsOK(int sourceid)
        {
                // walk client and the streams and checks for errors
                typename std::map < int, std::map < unsigned int, X *> > 
&streamables = getStreams();
                typename std::map < int, std::map < unsigned int, X *> 
>::iterator it1;
                typename std::map < unsigned int, X *>::iterator it2;
 
-               bool ok = true;
+               int ok = 0;
+               int num = 0;
                for(it1=streamables.begin(); it1!=streamables.end();it1++)
                {
                        if(it1->first != sourceid) continue;
                        for(it2=it1->second.begin(); 
it2!=it1->second.end();it2++)
                        {
-                               if(it2->second == 0)
+                               num++;
+                               if(it2->second != 0)
                                {
-                                       ok = false;
+                                       ok = 1;
                                        break;
                                }
                        }
                        break;
                }
+               if(!num)
+                       ok = 2;
                return ok;
        }
 
-       bool checkStreamsRemoteOK(int sourceid)
+       int checkStreamsResultsChanged()
        {
+               typename std::map < int, std::map < unsigned int, X *> > 
&streamables = getStreams();
+               typename std::map < int, std::map < unsigned int, X *> 
>::iterator it1;
+               typename std::map < unsigned int, X *>::iterator it2;
+
+               for(it1=streamables.begin(); it1!=streamables.end();it1++)
+               {
+                       for(it2=it1->second.begin(); 
it2!=it1->second.end();it2++)
+                       {
+                               if(!it2->second) continue;
+                               if(it2->second->getStreamResultsChanged())
+                               {
+                                       return 1;
+                               }
+                       }
+               }
+               return 0;
+       }
+
+       int checkStreamsRemoteOK(int sourceid)
+       {
                // walk client and the streams and checks for errors
                typename std::map < int, std::map < unsigned int, X *> > 
&streamables = getStreams();
                typename std::map < int, std::map < unsigned int, X *> 
>::iterator it1;
                typename std::map < unsigned int, X *>::iterator it2;
 
-               bool ok = false;
+               int ok = 0;
+               int originstreams = 0;
                for(it1=streamables.begin(); it1!=streamables.end();it1++)
                {
                        for(it2=it1->second.begin(); 
it2!=it1->second.end();it2++)
@@ -229,21 +261,32 @@
                                        continue;
                                if(!it2->second->getIsOrigin())
                                        continue;
+                               originstreams++;
                                stream_register_t reg;
                                reg.status = -2;
                                int res = 
it2->second->getStreamRegisterResultForSource(sourceid, &reg);
                                if(!res)
                                {
                                        if(reg.status == 1)
-                                               ok = true;
+                                               ok = 1;
                                }
                                break;
                        }
                        break;
                }
+               if(!originstreams)
+                       ok = 2;
                return ok;
        }
 
+       int clearStreamRegistrationResults()
+       {
+               LOCKSTREAMS();
+               stream_creation_results.clear();
+               UNLOCKSTREAMS();
+               return 0;
+       }
+
        int getStreamRegistrationResults(std::deque < stream_reg_t > 
*net_results)
        {
                LOCKSTREAMS();

Modified: trunk/source/main/gui_mp.cpp
===================================================================
--- trunk/source/main/gui_mp.cpp        2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/gui_mp.cpp        2010-07-22 01:32:04 UTC (rev 1483)
@@ -207,26 +207,34 @@
                row->userTruckOKRemoteImg->setPosition(x, y);
                x -= 10;
 
-               bool ok = 
BeamFactory::getSingleton().checkStreamsOK(c->uniqueid);
-               if(ok)
+               int ok = 
BeamFactory::getSingleton().checkStreamsOK(c->uniqueid);
+               if(ok == 0)
                {
+                       
row->userTruckOKImg->setImageTexture("arrow_down_red.png");
+                       row->userTruckOKImg->setUserString("tooltip", "Truck 
loading errors");
+               } else if(ok == 1)
+               {
                        row->userTruckOKImg->setImageTexture("arrow_down.png");
                        row->userTruckOKImg->setUserString("tooltip", "Truck 
loaded correctly, no errors");
-               } else
+               } else if(ok == 2)
                {
-                       
row->userTruckOKImg->setImageTexture("arrow_down_red.png");
-                       row->userTruckOKImg->setUserString("tooltip", "Truck 
loading errors");
+                       
row->userTruckOKImg->setImageTexture("arrow_down_grey.png");
+                       row->userTruckOKImg->setUserString("tooltip", "no truck 
loaded");
                }
 
-               bool rok = 
BeamFactory::getSingleton().checkStreamsRemoteOK(c->uniqueid);
-               if(rok)
+               int rok = 
BeamFactory::getSingleton().checkStreamsRemoteOK(c->uniqueid);
+               if(rok == 0)
                {
+                       
row->userTruckOKRemoteImg->setImageTexture("arrow_up_red.png");
+                       row->userTruckOKRemoteImg->setUserString("tooltip", 
"Remote Truck loading errors");
+               } else if(rok == 1)
+               {
                        
row->userTruckOKRemoteImg->setImageTexture("arrow_up.png");
                        row->userTruckOKRemoteImg->setUserString("tooltip", 
"Remote Truck loaded correctly, no errors");
-               } else
+               } else if(rok == 2)
                {
-                       
row->userTruckOKRemoteImg->setImageTexture("arrow_up_red.png");
-                       row->userTruckOKRemoteImg->setUserString("tooltip", 
"Remote Truck loading errors");
+                       
row->userTruckOKRemoteImg->setImageTexture("arrow_up_grey.png");
+                       row->userTruckOKRemoteImg->setUserString("tooltip", "No 
Trucks loaded");
                }
        } else
        {

Modified: trunk/source/main/network.cpp
===================================================================
--- trunk/source/main/network.cpp       2010-07-21 23:07:57 UTC (rev 1482)
+++ trunk/source/main/network.cpp       2010-07-22 01:32:04 UTC (rev 1483)
@@ -130,13 +130,6 @@
 
        // direct start, no vehicle required
        initiated = true;
-
-#ifdef USE_MYGUI
-#ifdef USE_SOCKETW
-       // you can just run this here in the main thread, not in others!
-       GUI_Multiplayer::getSingleton().update();
-#endif // USE_SOCKETW
-#endif // USE_MYGUI
 }
 
 Network::~Network()


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