Revision: 1918 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1918&view=rev Author: rorthomas Date: 2011-05-12 07:39:51 +0000 (Thu, 12 May 2011)
Log Message: ----------- create InterThreadStoreVector to be used in more classes added lobbystate starts, WIP disabled some warnings, added VS prof. option added SSE2 arch Modified Paths: -------------- trunk/CMakeLists.txt trunk/source/main/framework/GameState.cpp trunk/source/main/framework/GameState.h trunk/source/main/gameplay/RigsOfRods.cpp trunk/source/main/gui/Console.cpp trunk/source/main/gui/Console.h Added Paths: ----------- trunk/source/main/framework/LobbyState.cpp trunk/source/main/framework/LobbyState.h trunk/source/main/gui/LobbyGUI.cpp trunk/source/main/gui/LobbyGUI.h trunk/source/main/utils/InterThreadStoreVector.h Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/CMakeLists.txt 2011-05-12 07:39:51 UTC (rev 1918) @@ -57,11 +57,16 @@ ) if(WIN32) - set(warnings /W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4251 /nologo) + set(ROR_USING_VISUAL_STUDIO_PROFESSIONAL "FALSE" CACHE BOOL "if you use VS professional, enable this. DO NOT enable this when using express versions") + + set(warnings /W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4251 /wd4275 /nologo) add_definitions(${warnings}) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /GL /Ox /Ob2 /Oi /Ot /Oy /fp:fast /GS- /MP /Zi") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /GL /Ox /Ob2 /Oi /Ot /Oy /fp:fast /GS- /MP /Zi /arch:SSE2") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Zi") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /Od /Zi") + if(ROR_USING_VISUAL_STUDIO_PROFESSIONAL) + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /analyze") # /analyze only available when using VS professional + endif(ROR_USING_VISUAL_STUDIO_PROFESSIONAL) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /Od /Zi") # some general flags add_definitions("-D_CRT_SECURE_NO_WARNINGS") Modified: trunk/source/main/framework/GameState.cpp =================================================================== --- trunk/source/main/framework/GameState.cpp 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/source/main/framework/GameState.cpp 2011-05-12 07:39:51 UTC (rev 1918) @@ -60,7 +60,6 @@ LOG("Resuming GameState..."); OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera); - m_bQuit = false; } void GameState::exit() Modified: trunk/source/main/framework/GameState.h =================================================================== --- trunk/source/main/framework/GameState.h 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/source/main/framework/GameState.h 2011-05-12 07:39:51 UTC (rev 1918) @@ -1,23 +1,33 @@ -//||||||||||||||||||||||||||||||||||||||||||||||| +/* +This source file is part of Rigs of Rods +Copyright 2005-2011 Pierre-Michel Ricordel +Copyright 2007-2011 Thomas Fischer +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 +published by the Free Software Foundation. + +Rigs of Rods is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef GAME_STATE_HPP #define GAME_STATE_HPP -//||||||||||||||||||||||||||||||||||||||||||||||| - #include "RoRPrerequisites.h" #include "AppState.h" -#include <OgreSubEntity.h> -#include <OgreMaterialManager.h> - -//||||||||||||||||||||||||||||||||||||||||||||||| - class GameState : public AppState { public: GameState(); - DECLARE_APPSTATE_CLASS(GameState) void enter(); @@ -26,36 +36,8 @@ bool pause(); void resume(); - void getInput(); - void buildGUI(); - void update(double timeSinceLastFrame); - void resized(Ogre::RenderWindow *r); - -private: - Ogre::SceneNode* m_pOgreHeadNode; - Ogre::Entity* m_pOgreHeadEntity; - Ogre::MaterialPtr m_pOgreHeadMat; - Ogre::MaterialPtr m_pOgreHeadMatHigh; - - bool m_bQuit; - - Ogre::Vector3 m_TranslateVector; - Ogre::Real m_MoveSpeed; - Ogre::Degree m_RotateSpeed; - float m_MoveScale; - Ogre::Degree m_RotScale; - - Ogre::RaySceneQuery* m_pRSQ; - Ogre::SceneNode* m_pCurrentObject; - Ogre::Entity* m_pCurrentEntity; - bool m_bLMouseDown, m_bRMouseDown; - bool m_bSettingsMode; }; -//||||||||||||||||||||||||||||||||||||||||||||||| - -#endif - -//||||||||||||||||||||||||||||||||||||||||||||||| \ No newline at end of file +#endif //GAME_STATE_HPP Added: trunk/source/main/framework/LobbyState.cpp =================================================================== --- trunk/source/main/framework/LobbyState.cpp (rev 0) +++ trunk/source/main/framework/LobbyState.cpp 2011-05-12 07:39:51 UTC (rev 1918) @@ -0,0 +1,41 @@ +#include "LobbyState.h" + +using namespace Ogre; + +LobbyState::LobbyState() +{ +} + +void LobbyState::enter() +{ + LOG("Entering LobbyState..."); +} + +bool LobbyState::pause() +{ + LOG("Pausing LobbyState..."); + + return true; +} + +void LobbyState::resume() +{ + LOG("Resuming LobbyState..."); +} + +void LobbyState::exit() +{ + LOG("Leaving LobbyState..."); +} + +void LobbyState::createScene() +{ +} + +void LobbyState::update(double timeSinceLastFrame) +{ +} + +void LobbyState::resized(Ogre::RenderWindow *r) +{ +} Added: trunk/source/main/framework/LobbyState.h =================================================================== --- trunk/source/main/framework/LobbyState.h (rev 0) +++ trunk/source/main/framework/LobbyState.h 2011-05-12 07:39:51 UTC (rev 1918) @@ -0,0 +1,43 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2011 Pierre-Michel Ricordel +Copyright 2007-2011 Thomas Fischer + +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 +published by the Free Software Foundation. + +Rigs of Rods is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef LOBBY_STATE_HPP +#define LOBBY_STATE_HPP + +#include "RoRPrerequisites.h" +#include "AppState.h" + +class LobbyState : public AppState +{ +public: + LobbyState(); + DECLARE_APPSTATE_CLASS(LobbyState) + + void enter(); + void createScene(); + void exit(); + bool pause(); + void resume(); + + void update(double timeSinceLastFrame); + void resized(Ogre::RenderWindow *r); +}; + +#endif //LOBBY_STATE_HPP Modified: trunk/source/main/gameplay/RigsOfRods.cpp =================================================================== --- trunk/source/main/gameplay/RigsOfRods.cpp 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/source/main/gameplay/RigsOfRods.cpp 2011-05-12 07:39:51 UTC (rev 1918) @@ -22,6 +22,7 @@ #include <Ogre.h> #include "GameState.h" +#include "LobbyState.h" #include "Settings.h" #include "ContentManager.h" @@ -57,17 +58,19 @@ // now add the game states stateManager = new AppStateManager(); - GameState::create(stateManager, "GameState"); + Ogre::String state = "GameState"; //"LobbyState" + GameState::create(stateManager, state); + // select the first one if(embedded) { LOG("Rigs of Rods embedded initialized!"); - stateManager->changeAppState(stateManager->findByName("GameState")); + stateManager->changeAppState(stateManager->findByName(state)); } else { LOG("Rigs of Rods main loop starting ..."); - stateManager->start(stateManager->findByName("GameState")); + stateManager->start(stateManager->findByName(state)); } } Modified: trunk/source/main/gui/Console.cpp =================================================================== --- trunk/source/main/gui/Console.cpp 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/source/main/gui/Console.cpp 2011-05-12 07:39:51 UTC (rev 1918) @@ -63,8 +63,6 @@ setVisible(true); - pthread_mutex_init(&mWaitingMessagesMutex, NULL); - MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate( this, &Console::frameEntered ); bool ogre_log = BSETTING("Enable Ingame Console"); @@ -76,8 +74,6 @@ { Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this); MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate( this, &Console::frameEntered ); - - pthread_mutex_destroy(&mWaitingMessagesMutex); } void Console::addTab(Ogre::String name) @@ -149,12 +145,10 @@ void Console::print(const MyGUI::UString &_text, Ogre::String channel) { - pthread_mutex_lock(&mWaitingMessagesMutex); msg_t t; t.txt = _text; t.channel = channel; - mWaitingMessages.push_back(t); - pthread_mutex_unlock(&mWaitingMessagesMutex); + push(t); } void Console::printUTF(const Ogre::UTFString &_text, Ogre::String channel) @@ -199,12 +193,9 @@ // only copy the content and then unlock again // this prevents that loggers are hung due to time consuming iteration over it std::vector<msg_t> tmpWaitingMessages; - pthread_mutex_lock(&mWaitingMessagesMutex); - tmpWaitingMessages = mWaitingMessages; - mWaitingMessages.clear(); - pthread_mutex_unlock(&mWaitingMessagesMutex); + int results = pull(tmpWaitingMessages); - if (tmpWaitingMessages.empty()) + if (results == 0) return; for (std::vector<msg_t>::iterator iter = tmpWaitingMessages.begin(); iter != tmpWaitingMessages.end(); ++iter) Modified: trunk/source/main/gui/Console.h =================================================================== --- trunk/source/main/gui/Console.h 2011-05-11 18:10:25 UTC (rev 1917) +++ trunk/source/main/gui/Console.h 2011-05-12 07:39:51 UTC (rev 1918) @@ -26,9 +26,10 @@ #include "Singleton.h" #include "mygui/BaseLayout.h" +#include "InterThreadStoreVector.h" + #include <OgreLog.h> #include <OgreUTFString.h> -#include <pthread.h> #define NETCHAT Console::get() @@ -43,22 +44,23 @@ } irc_ctx_t; +typedef struct msg_t { + MyGUI::UString txt; + Ogre::String channel; +} msg_t; + + ATTRIBUTE_CLASS_LAYOUT(Console, "Console.layout"); class Console : public wraps::BaseLayout, public Singleton2<Console>, - public Ogre::LogListener + public Ogre::LogListener, + public InterThreadStoreVector<msg_t> { friend class Singleton2<Console>; Console(); ~Console(); public: - - typedef struct msg_t { - MyGUI::UString txt; - Ogre::String channel; - } msg_t; - typedef struct tabctx_t { Ogre::String name; @@ -99,9 +101,6 @@ Network *net; - pthread_mutex_t mWaitingMessagesMutex; - std::vector<msg_t> mWaitingMessages; - std::map<Ogre::String , tabctx_t > tabs; tabctx_t *current_tab; Added: trunk/source/main/gui/LobbyGUI.cpp =================================================================== --- trunk/source/main/gui/LobbyGUI.cpp (rev 0) +++ trunk/source/main/gui/LobbyGUI.cpp 2011-05-12 07:39:51 UTC (rev 1918) @@ -0,0 +1,44 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2011 Pierre-Michel Ricordel +Copyright 2007-2011 Thomas Fischer + +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 +published by the Free Software Foundation. + +Rigs of Rods is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifdef USE_MYGUI + +#include "LobbyGUI.h" +#include "ScriptEngine.h" +#include "InputEngine.h" +#include "OgreLogManager.h" + +#include "Settings.h" +#include "RoRFrameListener.h" +#include "network.h" + +#include "libircclient.h" + +// class + +LobbyGUI::LobbyGUI() +{ + initialiseByAttributes(this); +} + +LobbyGUI::~LobbyGUI() +{ +} + +#endif //USE_MYGUI Added: trunk/source/main/gui/LobbyGUI.h =================================================================== --- trunk/source/main/gui/LobbyGUI.h (rev 0) +++ trunk/source/main/gui/LobbyGUI.h 2011-05-12 07:39:51 UTC (rev 1918) @@ -0,0 +1,58 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2011 Pierre-Michel Ricordel +Copyright 2007-2011 Thomas Fischer + +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 +published by the Free Software Foundation. + +Rigs of Rods is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifdef USE_MYGUI + +#ifndef LOBBYGUI_H__ +#define LOBBYGUI_H__ + +#include "RoRPrerequisites.h" +#include "Singleton.h" +#include "mygui/BaseLayout.h" + +#include <OgreLog.h> +#include <OgreUTFString.h> + +ATTRIBUTE_CLASS_LAYOUT(LobbyGUI, "Lobby.layout"); +class LobbyGUI : + public wraps::BaseLayout, + public Singleton2<LobbyGUI>, + public Ogre::LogListener +{ + friend class Singleton2<LobbyGUI>; + LobbyGUI(); + ~LobbyGUI(); +public: + + void setVisible(bool _visible); + bool getVisible(); + + void select(); + + void setNetwork(Network *net); + + // print waiting messages + void frameEntered(float _frame); +protected: +}; + +#endif // LOBBYGUI_H__ + +#endif //MYGUI + Added: trunk/source/main/utils/InterThreadStoreVector.h =================================================================== --- trunk/source/main/utils/InterThreadStoreVector.h (rev 0) +++ trunk/source/main/utils/InterThreadStoreVector.h 2011-05-12 07:39:51 UTC (rev 1918) @@ -0,0 +1,66 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2011 Pierre-Michel Ricordel +Copyright 2007-2011 Thomas Fischer + +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 +published by the Free Software Foundation. + +Rigs of Rods is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef INTERTHREADSTORE_H__ +#define INTERTHREADSTORE_H__ + +#include "RoRPrerequisites.h" +#include <pthread.h> + + +/// this class is a helper to exchange data in a class between different threads, it can be pushed and pulled in various threads +template <class T> +class InterThreadStoreVector +{ +public: + InterThreadStoreVector() + { + pthread_mutex_init(&lock, NULL); + } + + ~InterThreadStoreVector() + { + pthread_mutex_destroy(&lock); + } + + void push(T &v) + { + pthread_mutex_lock(&lock); + store.push_back(v); + pthread_mutex_unlock(&lock); + } + + int pull(std::vector < T > &res) + { + int results = 0; + std::vector<msg_t> tmpWaitingMessages; + pthread_mutex_lock(&lock); + res = store; + results = res.size(); + store.clear(); + pthread_mutex_unlock(&lock); + return results; + } + +protected: + pthread_mutex_t lock; + std::vector < T > store; +}; + +#endif //INTERTHREADSTORE_H__ \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel