Revision: 2560 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2560&view=rev Author: ulteq Date: 2012-05-14 16:54:57 +0000 (Mon, 14 May 2012) Log Message: ----------- -Codechange: Major code cleanup removed 'using namespace Ogre;' from network.h reduced and corrected includes in headers added 'class Character' to RoRPrerequisites.h style++
Modified Paths: -------------- trunk/source/main/RoRPrerequisites.h trunk/source/main/gameplay/Character.cpp trunk/source/main/gameplay/Character.h trunk/source/main/gameplay/CharacterFactory.cpp trunk/source/main/gameplay/CharacterFactory.h trunk/source/main/gameplay/ChatSystem.cpp trunk/source/main/gameplay/ChatSystem.h trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gameplay/RoRFrameListener.h trunk/source/main/gameplay/Savegame.cpp trunk/source/main/gfx/MovableText.h trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp trunk/source/main/gfx/camera/CameraManager.cpp trunk/source/main/gfx/camera/CameraManager.h trunk/source/main/gui/Console.cpp trunk/source/main/gui/Console.h trunk/source/main/gui/gui_menu.cpp trunk/source/main/network/IRCWrapper.cpp trunk/source/main/network/IRCWrapper.h trunk/source/main/network/NetworkStreamManager.h trunk/source/main/network/Streamable.cpp trunk/source/main/network/Streamable.h trunk/source/main/network/StreamableFactory.h trunk/source/main/network/StreamableFactoryInterface.h trunk/source/main/network/network.cpp trunk/source/main/network/network.h trunk/source/main/physics/Beam.cpp trunk/source/main/physics/BeamFactory.cpp trunk/source/main/physics/BeamFactory.h trunk/source/main/physics/collision/collisions.cpp trunk/source/main/scripting/GameScript.cpp trunk/source/main/utils/InterThreadStoreVector.h Modified: trunk/source/main/RoRPrerequisites.h =================================================================== --- trunk/source/main/RoRPrerequisites.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/RoRPrerequisites.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -18,8 +18,8 @@ along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. */ // created on 30th of April 2010 by Thomas Fischer -#ifndef RORPREREQUISITES_H__ -#define RORPREREQUISITES_H__ +#ifndef __RoRPrerequisites_H_ +#define __RoRPrerequisites_H_ // Defines whether Checked Iterators are enabled. If defined as 1, unsafe iterator use causes a runtime error. If defined as 0, checked iterators are disabled. // TBD - tdev @@ -106,25 +106,26 @@ // BITMASK(2) = 0x00000002 = 0b00....0010 class AeroEngine; +class Airbrake; class Airfoil; -class Airbrake; +class AppState; class Autopilot; -class AppState; class Axle; class Beam; class BeamEngine; class BeamThreadStats; class Buoyance; +class Cache_Entry; +class Character; class ChatSystem; class CmdKeyInertia; -class Cache_Entry; class Collisions; class ColoredTextAreaOverlayElement; class Dashboard; class DashBoard; class DashBoardManager; +class DOFManager; class DotSceneLoader; -class DOFManager; class DustPool; class Editor; class Flexable; @@ -132,14 +133,14 @@ class FlexBody; class FlexMesh; class FlexObj; +class HDRListener; class HeatHaze; -class HDRListener; class HeightFinder; -class MaterialReplacer; -class MaterialFunctionMapper; class MapControl; class MapEntity; class MapTextureCreator; +class MaterialFunctionMapper; +class MaterialReplacer; class MeshObject; class Mirrors; class Network; @@ -151,21 +152,21 @@ class RailGroup; class Replay; class RigsOfRods; +class Road2; class Road; -class Road2; class RoRFrameListener; +class ScopeLog; class Screwprop; -class ScopeLog; class Skidmark; class Skin; class SlideNode; +class SoundManager; class SoundScriptInstance; class SoundScriptManager; -class SoundManager; -class Turboprop; class TorqueCurve; +class TruckEditor; class TruckHUD; -class TruckEditor; +class Turboprop; class VideoCamera; class Water; @@ -224,4 +225,4 @@ HIDE_MIRROR = BITMASK(3), }; -#endif //RORPREREQUISITES_H__ +#endif // __RoRPrerequisites_H_ Modified: trunk/source/main/gameplay/Character.cpp =================================================================== --- trunk/source/main/gameplay/Character.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/Character.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -1,4 +1,4 @@ -/* +/*/ This source file is part of Rigs of Rods Copyright 2005-2012 Pierre-Michel Ricordel Copyright 2007-2012 Thomas Fischer @@ -17,23 +17,20 @@ 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/>. */ - #include "Character.h" -#include "water.h" +#include "BeamFactory.h" +#include "CameraManager.h" #include "collisions.h" #include "heightfinder.h" +#include "InputEngine.h" #include "MapControl.h" #include "MapEntity.h" -#include "InputEngine.h" #include "network.h" #include "NetworkStreamManager.h" -#include "BeamFactory.h" -#include "RoRFrameListener.h" -#include "ColoredTextAreaOverlayElement.h" #include "PlayerColours.h" - #include "utils.h" +#include "water.h" using namespace Ogre; @@ -297,9 +294,8 @@ { if(physicsEnabled && !remote) { - // disable character movement when using the free camera mode or when chatting - // OLD! - //if(RoRFrameListener::eflsingleton && (RoRFrameListener::eflsingleton->cameramode == CAMERA_FREE || RoRFrameListener::eflsingleton->isUserChatting())) return; + // disable character movement when using the free camera mode or when the menu is opened + if(!CameraManager::singletonExists() || CameraManager::getSingleton().getCameraMode() == CameraManager::CAMERA_BEHAVIOR_FREE) return; // small hack: if not visible do not apply physics //mode perso Modified: trunk/source/main/gameplay/Character.h =================================================================== --- trunk/source/main/gameplay/Character.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/Character.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -17,16 +17,13 @@ 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 __Character_H_ +#define __Character_H_ -#ifndef CHARACTER_H_ -#define CHARACTER_H_ - #include "RoRPrerequisites.h" -#include <Ogre.h> -#include <OgreVector3.h> -#include "Streamable.h" #include "MovableText.h" +#include "Streamable.h" enum {CHARCMD_POSITION, CHARCMD_ATTACH}; @@ -36,71 +33,72 @@ friend class Network; public: + Character(Ogre::Camera *cam, Collisions *c, Network *net, HeightFinder *h, Water *w, MapControl *m, Ogre::SceneManager *scm, int source=-1, unsigned int streamid=0, int colourNumber=0, bool remote=true); ~Character(); - - void setVisible(bool v); - bool getVisible(); - void setOrientation(Ogre::Quaternion); Ogre::Quaternion getOrientation(); - void setPosition(Ogre::Vector3 pos); - Ogre::Vector3 getPosition(); - - void updateNetLabel(); - void updateCharacterColour(); - - void move(Ogre::Vector3 v); - int setBeamCoupling(bool enabled, Beam *truck=0); - - void update(float dt); Ogre::SceneNode *getSceneNode() { return personode; }; - + Ogre::Vector3 getPosition(); + bool getPhysicsEnabled() { return physicsEnabled; }; + bool getVisible(); + bool isRemote() { return remote; }; float getAngle() { return persoangle; }; - void setAngle(float angle); - void setColour(int number) { this->colourNumber = number; }; - + int getUID() { return source; }; + int setBeamCoupling(bool enabled, Beam *truck=0); static unsigned int characterCounter; - void updateMapIcon(); + void move(Ogre::Vector3 v); + void setAngle(float angle); void setCollisions(Collisions *c); + void setColour(int number) { this->colourNumber = number; }; void setHFinder(HeightFinder *h); + void setOrientation(Ogre::Quaternion); + void setPhysicsEnabled(bool val) { physicsEnabled=val; }; + void setPosition(Ogre::Vector3 pos); + void setVisible(bool v); void setWater(Water *w); - int getUID() { return source; }; - bool getPhysicsEnabled() { return physicsEnabled; }; - void setPhysicsEnabled(bool val) { physicsEnabled=val; }; - bool isRemote() { return remote; }; + void update(float dt); + void updateCharacterColour(); + void updateMapIcon(); + void updateNetLabel(); protected: - Ogre::Vector3 position; + + Beam *beamCoupling; Collisions *collisions; HeightFinder *hfinder; - Ogre::Camera *mCamera; - Water *water; - Beam *beamCoupling; MapControl *map; - Ogre::SceneManager *scm; + MapEntity *mapEnt; Network *net; - int source; - unsigned int streamid; - bool remote; + Water *water; + + bool perso_canjump; bool physicsEnabled; - int colourNumber; - Ogre::MovableText *netMT; - MapEntity *mapEnt; - Ogre::UTFString networkUsername; - int networkAuthLevel; - Ogre::String lastmode; + bool remote; - Ogre::SceneNode *personode; - Ogre::AnimationStateSet *persoanim; - unsigned int myNumber; - Ogre::String myName; float persoangle; float persospeed; float persovspeed; - bool perso_canjump; + + int colourNumber; + int networkAuthLevel; + int source; + + Ogre::AnimationStateSet *persoanim; + Ogre::Camera *mCamera; + Ogre::MovableText *netMT; + Ogre::SceneManager *scm; + Ogre::SceneNode *personode; + Ogre::String lastmode; + Ogre::String myName; + Ogre::UTFString networkUsername; Ogre::Vector3 lastpersopos; + Ogre::Vector3 position; + + unsigned int myNumber; + unsigned int streamid; + void setAnimationMode(Ogre::String mode, float time=0); typedef struct header_netdata_t @@ -108,7 +106,6 @@ int command; } header_netdata_t; - typedef struct pos_netdata_t { int command; @@ -130,12 +127,13 @@ // overloaded from Streamable: Ogre::Timer netTimer; int last_net_time; - void sendStreamSetup(); - void sendStreamData(); + void receiveStreamData(unsigned int &type, int &source, unsigned int &streamid, char *buffer, unsigned int &len); + void sendStreamData(); + void sendStreamSetup(); void setUID(int uid); void updateNetLabelSize(); }; -#endif +#endif // __Character_H_ Modified: trunk/source/main/gameplay/CharacterFactory.cpp =================================================================== --- trunk/source/main/gameplay/CharacterFactory.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/CharacterFactory.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -21,15 +21,9 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 7th of August 2009 #include "CharacterFactory.h" -#include "Streamable.h" + #include "Character.h" -#include "Ogre.h" -#include "network.h" -#include "utils.h" -#include "sha1.h" -#include "pthread.h" - using namespace Ogre; Modified: trunk/source/main/gameplay/CharacterFactory.h =================================================================== --- trunk/source/main/gameplay/CharacterFactory.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/CharacterFactory.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,44 +20,44 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 17th of August 2009 -#ifndef CHARACTERFACTORY_H__ -#define CHARACTERFACTORY_H__ +#ifndef __CharacterFactory_H_ +#define __CharacterFactory_H_ #include "RoRPrerequisites.h" -#include "OgrePrerequisites.h" +#include "Character.h" #include "StreamableFactory.h" -#include <map> -#include "Character.h" class CharacterFactory : public StreamableFactory < CharacterFactory, Character > { friend class Network; + public: + CharacterFactory(Ogre::Camera *cam, Network *net, Collisions *c, HeightFinder *h, Water *w, MapControl *m, Ogre::SceneManager *scm); ~CharacterFactory(); Character *createLocal(int playerColour); + Character *createRemoteInstance(stream_reg_t *reg); - Character *createRemoteInstance(stream_reg_t *reg); void setNetwork(Network *net) { this->net = net; }; void updateCharacters(float dt); void updateLabels(); + protected: - Ogre::Camera *cam; + Collisions *c; - Network *net; HeightFinder *h; - Water *w; MapControl *m; + Network *net; + Ogre::Camera *cam; Ogre::SceneManager *scm; + Water *w; // functions used by friends void netUserAttributesChanged(int source, int streamid); void localUserAttributesChanged(int newid); }; - - -#endif //CHARACTERFACTORY_H__ +#endif // __CharacterFactory_H_ Modified: trunk/source/main/gameplay/ChatSystem.cpp =================================================================== --- trunk/source/main/gameplay/ChatSystem.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/ChatSystem.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,17 +20,12 @@ #include "ChatSystem.h" -#include "water.h" #include "collisions.h" -#include "heightfinder.h" -#include "MapControl.h" -#include "InputEngine.h" -#include "network.h" -#include "NetworkStreamManager.h" -#include "ColoredTextAreaOverlayElement.h" +#include "Console.h" #include "language.h" -#include "utils.h" +#include "network.h" #include "PlayerColours.h" +#include "utils.h" #ifdef USE_MYGUI #include "gui_mp.h" @@ -103,10 +98,10 @@ /////////////////////////////////// // ChatSystem -const Ogre::UTFString ChatSystem::commandColour = U("#941e8d"); -const Ogre::UTFString ChatSystem::normalColour = U("#000000"); -const Ogre::UTFString ChatSystem::whisperColour = U("#967417"); -const Ogre::UTFString ChatSystem::scriptCommandColour = U("#32436f"); +const UTFString ChatSystem::commandColour = U("#941e8d"); +const UTFString ChatSystem::normalColour = U("#000000"); +const UTFString ChatSystem::whisperColour = U("#967417"); +const UTFString ChatSystem::scriptCommandColour = U("#32436f"); @@ -204,13 +199,13 @@ #endif //USE_MYGUI } -void ChatSystem::sendChat(Ogre::UTFString chatline) +void ChatSystem::sendChat(UTFString chatline) { const char *utf8_line = chatline.asUTF8_c_str(); this->addPacket(MSG2_UTF_CHAT, (unsigned int)strlen(utf8_line), (char *)utf8_line); } -int ChatSystem::getChatUserNames(std::vector<Ogre::UTFString> &names) +int ChatSystem::getChatUserNames(std::vector<UTFString> &names) { #ifdef USE_SOCKETW client_t c[MAX_PEERS]; @@ -226,7 +221,7 @@ #endif // USE_SOCKETW } -void ChatSystem::sendPrivateChat(Ogre::UTFString targetUsername, Ogre::UTFString chatline) +void ChatSystem::sendPrivateChat(UTFString targetUsername, UTFString chatline) { #ifdef USE_SOCKETW // first: find id to username: @@ -259,7 +254,7 @@ -void ChatSystem::sendPrivateChat(int target_uid, Ogre::UTFString chatline, Ogre::UTFString username) +void ChatSystem::sendPrivateChat(int target_uid, UTFString chatline, UTFString username) { #ifdef USE_SOCKETW char buffer[MAX_MESSAGE_LENGTH] = ""; @@ -289,19 +284,19 @@ #endif // USE_SOCKETW } -Ogre::UTFString ChatSystem::getColouredName(client_t &c) +UTFString ChatSystem::getColouredName(client_t &c) { return getColouredName(c.user); } -Ogre::UTFString ChatSystem::getColouredName(user_info_t &u) +UTFString ChatSystem::getColouredName(user_info_t &u) { return ChatSystem::getColouredName(UTFString(u.username), u.authstatus, u.colournum); } -Ogre::UTFString ChatSystem::getColouredName(Ogre::UTFString nick, int auth, int colourNumber) +UTFString ChatSystem::getColouredName(UTFString nick, int auth, int colourNumber) { - Ogre::ColourValue col_val = PlayerColours::getSingleton().getColour(colourNumber); + ColourValue col_val = PlayerColours::getSingleton().getColour(colourNumber); char tmp[255] = ""; sprintf(tmp, "#%02X%02X%02X", (unsigned int)(col_val.r * 255.0f), (unsigned int)(col_val.g * 255.0f), (unsigned int)(col_val.b * 255.0f)); Modified: trunk/source/main/gameplay/ChatSystem.h =================================================================== --- trunk/source/main/gameplay/ChatSystem.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/ChatSystem.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -17,18 +17,13 @@ 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 __ChatSystem_H_ +#define __ChatSystem_H_ -#ifndef ChatSystem_H_ -#define ChatSystem_H_ - #include "RoRPrerequisites.h" -#include <Ogre.h> -#include <OgreVector3.h> #include "Streamable.h" -#include "MovableText.h" #include "StreamableFactory.h" -#include "Console.h" class ChatSystem : public Streamable { @@ -36,6 +31,7 @@ friend class Network; public: + ChatSystem(Network *net, int source=-1, unsigned int streamid=0, int colourNumber=0, bool remote=true); ~ChatSystem(); @@ -52,6 +48,7 @@ static const Ogre::UTFString commandColour, normalColour, whisperColour, scriptCommandColour; protected: + Network *net; int source; int streamid; @@ -67,7 +64,9 @@ class ChatSystemFactory : public StreamableFactory < ChatSystemFactory, ChatSystem > { friend class Network; + public: + ChatSystemFactory(Network *net); ~ChatSystemFactory(); @@ -78,6 +77,7 @@ ChatSystem *getFirstChatSystem(); protected: + Network *net; // functions used by friends void netUserAttributesChanged(int source, int streamid) {}; @@ -86,4 +86,4 @@ bool syncRemoteStreams(); }; -#endif +#endif // __ChatSystem_H_ Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -29,9 +29,12 @@ #include "AdvancedScreen.h" #include "autopilot.h" +#include "Beam.h" +#include "BeamEngine.h" #include "BeamFactory.h" #include "CameraManager.h" #include "CacheSystem.h" +#include "Character.h" #include "CharacterFactory.h" #include "ChatSystem.h" #include "CollisionTools.h" @@ -43,6 +46,7 @@ #include "errorutils.h" #include "ExtinguishableFireAffector.h" #include "FlexAirfoil.h" +#include "ForceFeedback.h" #include "GlowMaterialListener.h" #include "hdrlistener.h" #include "Heathaze.h" @@ -63,6 +67,7 @@ #include "RoRVersion.h" #include "SceneMouse.h" #include "ScopeLog.h" +#include "SoundScriptManager.h" #include "screwprop.h" #include "Scripting.h" #include "Settings.h" @@ -859,9 +864,6 @@ trucked = 0; #endif - // init camera manager after mygui - new CameraManager(scm, mCamera, this, hfinder); - gameStartTime = getTimeStamp(); //network @@ -1121,10 +1123,12 @@ } else #endif //SOCKETW - { - // no network - person = (Character *)CharacterFactory::getSingleton().createLocal(-1); - } + + // no network + person = (Character *)CharacterFactory::getSingleton().createLocal(-1); + + // init camera manager after mygui and after we have a character + new CameraManager(mSceneMgr, mCamera, this, hfinder); person->setVisible(false); @@ -3215,13 +3219,13 @@ } } else if (loading_state==TERRAIN_LOADED) { - Cache_Entry *selt = SelectorWindow::getSingleton().getSelection(); + Cache_Entry *selection = SelectorWindow::getSingleton().getSelection(); Skin *skin = SelectorWindow::getSingleton().getSelectedSkin(); std::vector<Ogre::String> config = SelectorWindow::getSingleton().getTruckConfig(); std::vector<Ogre::String> *configptr = &config; if (config.size() == 0) configptr = 0; - if (selt) - initTrucks(true, selt->fname, selt->fext, configptr, false, skin); + if (selection) + initTrucks(true, selection->fname, selection->fext, configptr, false, skin); } else if (loading_state==RELOADING) { @@ -3240,8 +3244,6 @@ freeTruckPosition=false; // reset this, only to be used once } - - if (bigMap && localTruck) { MapEntity *e = bigMap->createNamedMapEntity("Truck"+TOSTRING(localTruck->trucknum), MapControl::getTypeByDriveable(localTruck->driveable)); Modified: trunk/source/main/gameplay/RoRFrameListener.h =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/RoRFrameListener.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -23,11 +23,14 @@ #include "RoRPrerequisites.h" #include "BeamData.h" // for localizer_t -#include "Character.h" -#include "ForceFeedback.h" +#include "Ogre.h" +#include <pthread.h> + // Forward declarations +class Character; class Envmap; +class ForceFeedback; namespace MOC { Modified: trunk/source/main/gameplay/Savegame.cpp =================================================================== --- trunk/source/main/gameplay/Savegame.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gameplay/Savegame.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -25,6 +25,7 @@ #include "Beam.h" #include "BeamFactory.h" #include "CameraManager.h" +#include "Character.h" #include "Console.h" #include "language.h" #include "RoRFrameListener.h" Modified: trunk/source/main/gfx/MovableText.h =================================================================== --- trunk/source/main/gfx/MovableText.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gfx/MovableText.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -30,6 +30,7 @@ #define __include_MovableText_H__ #include "RoRPrerequisites.h" +#include "Ogre.h" namespace Ogre { Modified: trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gfx/camera/CameraBehaviorCharacter.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -19,7 +19,7 @@ */ #include "CameraBehaviorCharacter.h" -#include "RoRFrameListener.h" +#include "Character.h" using namespace Ogre; @@ -32,11 +32,9 @@ void CameraBehaviorCharacter::update(const CameraManager::cameraContext_t &ctx) { - Character *person = ctx.mEfl->person; + targetDirection = -ctx.mCharacter->getAngle() - Math::HALF_PI; + camCenterPosition = ctx.mCharacter->getPosition() + camPositionOffset; - targetDirection = -person->getAngle() - Math::HALF_PI; - camCenterPosition = person->getPosition() + camPositionOffset; - CameraBehavior::update(ctx); } @@ -68,13 +66,12 @@ if ( camMode == CHARACTER_FIRST_PERSON ) { const OIS::MouseState ms = _arg.state; - Character *person = ctx.mEfl->person; - float angle = person->getAngle(); + float angle = ctx.mCharacter->getAngle(); camRotY += Degree((float)ms.Y.rel * 0.13f); angle += ms.X.rel * 0.01f; - person->setAngle(angle); + ctx.mCharacter->setAngle(angle); return true; } Modified: trunk/source/main/gfx/camera/CameraManager.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gfx/camera/CameraManager.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -59,6 +59,7 @@ createGlobalBehaviors(); ctx.mCamera = cam; + ctx.mCharacter = efl->person; ctx.mCurrTruck = 0; ctx.mEfl = efl; ctx.mHfinder = hf; Modified: trunk/source/main/gfx/camera/CameraManager.h =================================================================== --- trunk/source/main/gfx/camera/CameraManager.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gfx/camera/CameraManager.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -38,6 +38,7 @@ typedef struct cameraContext { Beam *mCurrTruck; + Character *mCharacter; HeightFinder *mHfinder; Ogre::Camera *mCamera; Ogre::Degree mRotScale; Modified: trunk/source/main/gui/Console.cpp =================================================================== --- trunk/source/main/gui/Console.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gui/Console.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,36 +20,31 @@ #ifdef USE_MYGUI #include "Console.h" -#include "Scripting.h" -#include "InputEngine.h" -#include "OgreLogManager.h" -#include "gui_manager.h" -#include "gui_menu.h" -#include "OverlayWrapper.h" -#include "ChatSystem.h" -#include "HighScoreWindow.h" -#include "Settings.h" -#include "RoRFrameListener.h" -#include "network.h" -#include "heightfinder.h" - #include "Beam.h" #include "BeamFactory.h" - +#include "Character.h" +#include "ChatSystem.h" +#include "gui_manager.h" +#include "gui_menu.h" +#include "heightfinder.h" +#include "HighScoreWindow.h" #include "language.h" +#include "network.h" +#include "OverlayWrapper.h" +#include "RoRFrameListener.h" +#include "Scripting.h" +#include "Settings.h" #include "utils.h" -#include "libircclient.h" - #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX #include <iconv.h> #endif // LINUX -using namespace std; +using namespace Ogre; // the delimiters that decide where a word is finished -const Ogre::UTFString Console::wordDelimiters = " \\\"\'|.,`!;<>~{}()+&%$@"; +const UTFString Console::wordDelimiters = " \\\"\'|.,`!;<>~{}()+&%$@"; const char *builtInCommands[] = {"/help", "/log", "/pos", "/goto", "/terrainheight", "/ver", "/save", "/whisper", "/as", NULL}; // class @@ -62,7 +57,7 @@ memset(&lines, 0, sizeof(lines)); - mHistory.push_back(Ogre::UTFString()); + mHistory.push_back(UTFString()); // and the textbox inside mCommandEdit = mMainWidget->createWidget<MyGUI::EditBox>("EditBoxChat", 0, 0, 304, lineheight * 1.2f, MyGUI::Align::Default, "ConsoleInput"); @@ -117,12 +112,12 @@ MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate( this, &Console::frameEntered ); - Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this); + LogManager::getSingleton().getDefaultLog()->addListener(this); } Console::~Console() { - Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this); + LogManager::getSingleton().getDefaultLog()->removeListener(this); MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate( this, &Console::frameEntered ); } @@ -146,7 +141,7 @@ } -void Console::select(Ogre::UTFString start) +void Console::select(UTFString start) { MyGUI::InputManager::getInstance().setKeyFocusWidget(mCommandEdit); mCommandEdit->setEnabled(true); @@ -279,7 +274,7 @@ void Console::findCurrentWord() { - Ogre::UTFString line = convertFromMyGUIString(mCommandEdit->getCaption()); + UTFString line = convertFromMyGUIString(mCommandEdit->getCaption()); autoCompletionCursor = (int)mCommandEdit->getTextCursor(); // look for word start @@ -347,17 +342,17 @@ // Auto-completion for the network usernames if(net && netChat) { - std::vector<Ogre::UTFString> names; + std::vector<UTFString> names; int res = netChat->getChatUserNames(names); for(unsigned int i = 0; i < names.size(); i++) { - // TODO: case insensitive comparison between Ogre::UTFString + // TODO: case insensitive comparison between UTFString - Ogre::UTFString a = names[i].substr(0, autoCompletionWord.size()); + UTFString a = names[i].substr(0, autoCompletionWord.size()); //std::transform(a.begin(), a.end(), a.begin(), tolower); - Ogre::UTFString b = autoCompletionWord; + UTFString b = autoCompletionWord; //std::transform(b.begin(), b.end(), b.begin(), tolower); if(a == b) @@ -373,7 +368,7 @@ { for(int i = 0; builtInCommands[i]; i++) { - Ogre::UTFString us = Ogre::UTFString(builtInCommands[i]); + UTFString us = UTFString(builtInCommands[i]); if(us.substr(0, autoCompletionWord.size()) == autoCompletionWord) { autoCompleteChoices.push_back(us); @@ -446,18 +441,18 @@ autoCompleteChoices.clear(); mAutoCompleteList->removeAllItems(); mAutoCompleteList->setVisible(false); - autoCompletionWord = Ogre::UTFString(); + autoCompletionWord = UTFString(); } void Console::finalizeAutoCompletion() { // now add the word we chose - Ogre::UTFString line = convertFromMyGUIString(mCommandEdit->getCaption()); + UTFString line = convertFromMyGUIString(mCommandEdit->getCaption()); // construct final string - Ogre::UTFString strA = line.substr(0, autoCompletionWordStart) + autoCompleteChoices[autoCompleteIndex]; - Ogre::UTFString strB = line.substr(autoCompletionWordEnd + 1); - Ogre::UTFString str = strA + strB; + UTFString strA = line.substr(0, autoCompletionWordStart) + autoCompleteChoices[autoCompleteIndex]; + UTFString strB = line.substr(autoCompletionWordEnd + 1); + UTFString str = strA + strB; // and set the text mCommandEdit->setCaption(convertToMyGUIString(str)); @@ -471,7 +466,7 @@ void Console::eventCommandAccept(MyGUI::Edit* _sender) { - Ogre::UTFString msg = convertFromMyGUIString(_sender->getCaption()); + UTFString msg = convertFromMyGUIString(_sender->getCaption()); // did we do auto completion?! if(autoCompleteIndex != -1) @@ -643,7 +638,7 @@ String command = (angelscriptMode ? msg : msg.substr(1)); - Ogre::StringUtil::trim(command); + StringUtil::trim(command); if(command.empty()) return; String nmsg = ChatSystem::scriptCommandColour + ">>> " + ChatSystem::normalColour + command; @@ -673,12 +668,12 @@ } #if OGRE_VERSION < ((1 << 16) | (8 << 8 ) | 0) -void Console::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName) +void Console::messageLogged( const String& message, LogMessageLevel lml, bool maskDebug, const String &logName) #else -void Console::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool& skipThisMessage) +void Console::messageLogged( const String& message, LogMessageLevel lml, bool maskDebug, const String &logName, bool& skipThisMessage) #endif // OGRE_VERSION { - Ogre::String msg = message; + String msg = message; //this->print(logName+": "+message); // strip script engine things if(message.substr(0,4) == "SE| ") @@ -801,7 +796,7 @@ msg_t &m = messages[msgid]; // check if TTL expired - unsigned long t = Ogre::Root::getSingleton().getTimer()->getMilliseconds() - m.time; + unsigned long t = Root::getSingleton().getTimer()->getMilliseconds() - m.time; if(t > m.ttl && !inputMode) { // expired, take the next message instead, when not in input mode @@ -847,7 +842,7 @@ //MyGUI::RotatingSkin* rotatingIcon = lines[i].iconctrl->getSubWidgetMain()->castType<MyGUI::RotatingSkin>(); //rotatingIcon->setAngle(rotatingIcon->getAngle() + Math::PI / 360.0f); - unsigned long ot = Ogre::Root::getSingleton().getTimer()->getMilliseconds(); + unsigned long ot = Root::getSingleton().getTimer()->getMilliseconds(); unsigned long t = ot - lines[i].msg->time; if(t > lines[i].msg->ttl && !inputMode) { @@ -932,13 +927,13 @@ return r; } -void Console::putMessage( int type, int sender_uid, Ogre::UTFString txt, Ogre::String icon, unsigned long ttl, bool forcevisible ) +void Console::putMessage( int type, int sender_uid, UTFString txt, String icon, unsigned long ttl, bool forcevisible ) { msg_t t; t.type = type; t.sender_uid = sender_uid; - t.time = Ogre::Root::getSingleton().getTimer()->getMilliseconds(); + t.time = Root::getSingleton().getTimer()->getMilliseconds(); t.ttl = ttl; t.forcevisible = forcevisible; //strncpy(t.txt, txt.c_str(), 2048); @@ -952,7 +947,7 @@ void Console::saveChat(String filename) { // use C++ for easier wstring usage ... :-/ - ofstream f(filename.c_str(), ios_base::app|ios_base::out); // in append mode + std::ofstream f(filename.c_str(), std::ios_base::app|std::ios_base::out); // in append mode if(!f.is_open()) { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_NOTICE, ChatSystem::commandColour + _L("Unable to open file ") + filename, "error.png"); @@ -960,10 +955,10 @@ } // now save the chat - f << " ==== " << endl; + f << " ==== " << std::endl; for(unsigned int i = 0; i < message_counter; i++) { - f << messages[i].time << " | " << messages[i].txt << endl; + f << messages[i].time << " | " << messages[i].txt << std::endl; } f.close(); @@ -1004,7 +999,7 @@ putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Terrain height at position: ") + String("#dd0000") + TOSTRING(pos.x) + String("#000000, #0000dd") + TOSTRING(pos.z) + String("#000000 = #00dd00") + TOSTRING(h), "world.png"); } -void Console::jumpToPosition( Ogre::Vector3 pos ) +void Console::jumpToPosition( Vector3 pos ) { Beam *b = BeamFactory::getSingleton().getCurrentTruck(); if(!b && RoRFrameListener::eflsingleton->person) Modified: trunk/source/main/gui/Console.h =================================================================== --- trunk/source/main/gui/Console.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gui/Console.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -17,30 +17,25 @@ 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/>. */ - -// this must be outside of the other macro -#ifdef USE_MYGUI -# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c,d,e,f); } -# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c); } +#ifndef USE_MYGUI +#ifndef __Console_H__ +#define __Console_H__ +#define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) +#define CONSOLE_PUTMESSAGE_SHORT(a,b,c) +#endif // __CONSOLE_H__ #else -# define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) -# define CONSOLE_PUTMESSAGE_SHORT(a,b,c) -#endif // USE_MYGUI - -#ifdef USE_MYGUI - #ifndef __CONSOLE_H__ #define __CONSOLE_H__ +#define CONSOLE_PUTMESSAGE(a,b,c,d,e,f) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c,d,e,f); } +#define CONSOLE_PUTMESSAGE_SHORT(a,b,c) while(0) { Console *console = Console::getSingletonPtrNoCreation(); if(console) console->putMessage(a,b,c); } + #include "RoRPrerequisites.h" -#include "Singleton.h" -#include "mygui/BaseLayout.h" #include "InterThreadStoreVector.h" +#include "mygui/BaseLayout.h" +#include "Singleton.h" -#include <OgreLog.h> -#include <OgreUTFString.h> - typedef struct msg_t { char type; int sender_uid; @@ -189,7 +184,5 @@ #endif // OGRE_VERSION }; -#endif // __CONSOLE_H__ - -#endif //MYGUI - +#endif // __Console_H__ +#endif // USE_MYGUI Modified: trunk/source/main/gui/gui_menu.cpp =================================================================== --- trunk/source/main/gui/gui_menu.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/gui/gui_menu.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -23,16 +23,18 @@ #include "gui_menu.h" #include "BeamFactory.h" +#include "Character.h" #include "ChatSystem.h" +#include "Console.h" +#include "gui_friction.h" +#include "gui_manager.h" +#include "language.h" +#include "network.h" #include "RoRFrameListener.h" #include "Savegame.h" #include "SelectorWindow.h" #include "Settings.h" #include "TextureToolWindow.h" -#include "gui_friction.h" -#include "gui_manager.h" -#include "language.h" -#include "network.h" #include "utils.h" using namespace Ogre; Modified: trunk/source/main/network/IRCWrapper.cpp =================================================================== --- trunk/source/main/network/IRCWrapper.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/IRCWrapper.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -22,44 +22,39 @@ #include "IRCWrapper.h" -#include <Ogre.h> // for Ogre::String -#include <OgreLogManager.h> // for LOG() +#include "errorutils.h" +#include "ImprovedConfigFile.h" +#include "rornet.h" +#include "RoRVersion.h" +#include "Settings.h" +#include "utils.h" #ifdef USE_CURL #define CURL_STATICLIB #include <stdio.h> #include <curl/curl.h> -//#include <curl/types.h> #include <curl/easy.h> #endif //USE_CURL -#include "rornet.h" -#include "Settings.h" -#include "errorutils.h" -#include "ImprovedConfigFile.h" -#include "utils.h" -#include "RoRVersion.h" - -using namespace std; // primary for string - // some function forward declarations void *s_ircthreadstart(void* arg); +using namespace Ogre; // some utils // helps to fill our struct message_t constructMessage(int type, const char *channel, const char *nick, const char *message, const char *arg = 0) { message_t t; t.type = type; - t.channel = std::string(); - t.nick = std::string(); - t.message = std::string(); - t.arg = std::string(); + t.channel = String(); + t.nick = String(); + t.message = String(); + t.arg = String(); - if(channel) t.channel = std::string(channel); - if(nick) t.nick = std::string(nick); - if(message) t.message = std::string(message); - if(arg) t.arg = std::string(arg); + if(channel) t.channel = String(channel); + if(nick) t.nick = String(nick); + if(message) t.message = String(message); + if(arg) t.arg = String(arg); return t; } @@ -124,7 +119,7 @@ } } -int IRCWrapper::sendMessage(std::string msg, std::string channelOrNick) +int IRCWrapper::sendMessage(String msg, String channelOrNick) { if(!irc_session) return 1; if(channelOrNick.empty()) @@ -133,7 +128,7 @@ return irc_cmd_msg(irc_session, channelOrNick.c_str(), msg.c_str()); } -int IRCWrapper::sendMeMessage(std::string msg, std::string channelOrNick) +int IRCWrapper::sendMeMessage(String msg, String channelOrNick) { if(!irc_session) return 1; if(channelOrNick.empty()) @@ -142,13 +137,13 @@ return irc_cmd_me(irc_session, channelOrNick.c_str(), msg.c_str()); } -int IRCWrapper::changeNick(std::string newNick) +int IRCWrapper::changeNick(String newNick) { if(!irc_session) return 1; return irc_cmd_nick(irc_session, newNick.c_str()); } -int IRCWrapper::joinChannel(std::string channel, std::string channelKeyStr) +int IRCWrapper::joinChannel(String channel, String channelKeyStr) { if(!irc_session) return 1; const char *channelKey = channelKeyStr.c_str(); @@ -156,22 +151,22 @@ return irc_cmd_join (irc_session, channel.c_str(), channelKey); } -int IRCWrapper::leaveChannel(std::string channel) +int IRCWrapper::leaveChannel(String channel) { if(!irc_session) return 1; return irc_cmd_part (irc_session, channel.c_str()); } -int IRCWrapper::quit(std::string reason) +int IRCWrapper::quit(String reason) { if(!irc_session) return 1; return irc_cmd_quit (irc_session, reason.c_str()); } -std::string IRCWrapper::getLastErrorMessage() +String IRCWrapper::getLastErrorMessage() { if(!irc_session) return "not connected"; - return std::string(irc_strerror(irc_errno(irc_session))); + return String(irc_strerror(irc_errno(irc_session))); } @@ -239,7 +234,7 @@ char *curl_err_str[CURL_ERROR_SIZE]; memset(curl_err_str, 0, CURL_ERROR_SIZE); - string url = "http://" + string(REPO_SERVER) + "/auth_lobby/"; + String url = "http://" + String(REPO_SERVER) + "/auth_lobby/"; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); /* send all data to this function */ @@ -271,14 +266,14 @@ //printf("%lu bytes retrieved\n", (long)chunk.size); - string result; + String result; curl_formfree(formpost); if(chunk.memory) { - // convert memory into std::string now - result = string(chunk.memory); + // convert memory into String now + result = String(chunk.memory); // then free free(chunk.memory); @@ -301,9 +296,9 @@ #endif //USE_CURL } -int IRCWrapper::processAuthenticationResults(std::string &results) +int IRCWrapper::processAuthenticationResults(String &results) { - Ogre::ImprovedConfigFile cfg; + ImprovedConfigFile cfg; cfg.loadFromString(results, "=", true); // TODO: improve the checks if the config is valid or not ... @@ -350,7 +345,7 @@ if(!origin) return false; // we store the nickname without the host information, so cut off the host to find out if its us - std::string org = std::string(origin); + String org = String(origin); size_t s = org.find("!"); if(s != org.npos) { @@ -373,7 +368,7 @@ #endif va_end (va_alist); - LOG("IRC| " + string(buf)); + LOG("IRC| " + String(buf)); } void dump_event (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) @@ -745,7 +740,7 @@ if (irc_connect (ctx->irc_session, serverName, ctx->serverPort, serverPassword, nick, userName, realName)) { - LOG ("Could not connect: " + Ogre::String(irc_strerror (irc_errno(ctx->irc_session)))); + LOG ("Could not connect: " + String(irc_strerror (irc_errno(ctx->irc_session)))); return 0; } Modified: trunk/source/main/network/IRCWrapper.h =================================================================== --- trunk/source/main/network/IRCWrapper.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/IRCWrapper.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -22,18 +22,16 @@ #ifdef USE_SOCKETW -#ifndef IRCWRAPPER_H__ -#define IRCWRAPPER_H__ +#ifndef __IRCWrapper_H_ +#define __IRCWrapper_H_ #include "RoRPrerequisites.h" #include "InterThreadStoreVector.h" +#include <libircclient.h> #include <pthread.h> -#include <string> -#include <libircclient.h> - enum message_types { MT_Channel, // someone said something in a channel MT_NickChangeOther, // someone changed his nick @@ -60,11 +58,11 @@ typedef struct message_t { - int type; - std::string channel; - std::string nick; - std::string message; - std::string arg; + int type; + Ogre::String channel; + Ogre::String nick; + Ogre::String message; + Ogre::String arg; } message_t; class IRCWrapper : public InterThreadStoreVector<message_t> @@ -78,14 +76,14 @@ void process(); // update function virtual void processIRCEvent(message_t &msg) = 0; // single event - int sendMessage(std::string msg, std::string channelOrNick = std::string()); - int sendMeMessage(std::string msg, std::string channelOrNick = std::string()); - int changeNick(std::string newNick); - int joinChannel(std::string channel, std::string channelKey); - int leaveChannel(std::string channel); - int quit(std::string reason); + int sendMessage(Ogre::String msg, Ogre::String channelOrNick = Ogre::String()); + int sendMeMessage(Ogre::String msg, Ogre::String channelOrNick = Ogre::String()); + int changeNick(Ogre::String newNick); + int joinChannel(Ogre::String channel, Ogre::String channelKey); + int leaveChannel(Ogre::String channel); + int quit(Ogre::String reason); - std::string getLastErrorMessage(); + Ogre::String getLastErrorMessage(); // TODO: // inviteChannel @@ -99,7 +97,7 @@ int authenticate(); - std::string serverName, serverPassword, nick, userName, realName, channel, channelKey; + Ogre::String serverName, serverPassword, nick, userName, realName, channel, channelKey; unsigned int serverPort, retryCounter; bool reJoin, reConnect, wasConnected; @@ -107,9 +105,8 @@ protected: pthread_t ircthread; - int processAuthenticationResults(std::string &results); + int processAuthenticationResults(Ogre::String &results); }; -#endif //IRCWRAPPER_H__ - -#endif //USE_SOCKETW +#endif // __IRCWrapper_H_ +#endif // USE_SOCKETW Modified: trunk/source/main/network/NetworkStreamManager.h =================================================================== --- trunk/source/main/network/NetworkStreamManager.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/NetworkStreamManager.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,26 +20,26 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 7th of August 2009 -#ifndef NETWORKSTREAMMANAGER_H__ -#define NETWORKSTREAMMANAGER_H__ +#ifndef __NetworkStreamManager_H_ +#define __NetworkStreamManager_H_ #include "RoRPrerequisites.h" -#include "OgrePrerequisites.h" + +#include <pthread.h> +#include "rornet.h" #include "Singleton.h" -#include "pthread.h" +#include "StreamableFactoryInterface.h" + #ifdef USE_SOCKETW #include "SocketW.h" #endif //SOCKETW -#include "rornet.h" -#include <map> - -#include "StreamableFactoryInterface.h" - class NetworkStreamManager : public RoRSingleton< NetworkStreamManager > { friend class Network; + public: + NetworkStreamManager(); ~NetworkStreamManager(); @@ -65,6 +65,7 @@ void addFactory(StreamableFactoryInterface *factory); protected: + pthread_mutex_t stream_mutex; pthread_mutex_t send_work_mutex; pthread_cond_t send_work_cv; @@ -81,6 +82,4 @@ void receiveStreams(); }; - - -#endif //NETWORKSTREAMMANAGER_H__ +#endif // __NetworkStreamManager_H_ Modified: trunk/source/main/network/Streamable.cpp =================================================================== --- trunk/source/main/network/Streamable.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/Streamable.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,14 +20,9 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 7th of August 2009 #include "Streamable.h" -#include "NetworkStreamManager.h" -#include "Ogre.h" #include "network.h" -#include "utils.h" -#include "sha1.h" -#include "pthread.h" -#include "network.h" +#include "NetworkStreamManager.h" using namespace Ogre; Modified: trunk/source/main/network/Streamable.h =================================================================== --- trunk/source/main/network/Streamable.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/Streamable.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -26,10 +26,8 @@ #include "RoRPrerequisites.h" #include "rornet.h" -#include <map> #include <pthread.h> - typedef struct recvPacket_t { header_t header; Modified: trunk/source/main/network/StreamableFactory.h =================================================================== --- trunk/source/main/network/StreamableFactory.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/StreamableFactory.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,22 +20,20 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 12th of August 2009 -#ifndef STREAMABLEFACTORY_H__ -#define STREAMABLEFACTORY_H__ +#ifndef __StreamableFactory_H_ +#define __StreamableFactory_H_ #include "RoRPrerequisites.h" -#include "OgrePrerequisites.h" -#include "pthread.h" -#ifdef USE_SOCKETW -#include "SocketW.h" -#endif //SOCKETW -#include "rornet.h" + #include "NetworkStreamManager.h" #include "StreamableFactoryInterface.h" -#include <map> -#include <Ogre.h> +#include <pthread.h> +#ifdef USE_SOCKETW +#include "SocketW.h" +#endif //SOCKETW + template<class T, class X> class StreamableFactory : public StreamableFactoryInterface { friend class Network; @@ -363,6 +361,4 @@ }; - - -#endif //STREAMABLEFACTORY_H__ +#endif // __StreamableFactory_H_ Modified: trunk/source/main/network/StreamableFactoryInterface.h =================================================================== --- trunk/source/main/network/StreamableFactoryInterface.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/StreamableFactoryInterface.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,17 +20,15 @@ // created by Thomas Fischer thomas{AT}thomasfischer{DOT}biz, 22th of December 2009 -#ifndef STREAMABLEFACTORYINTERFACE_H__ -#define STREAMABLEFACTORYINTERFACE_H__ +#ifndef __StreamableFactoryInterface_H_ +#define __StreamableFactoryInterface_H_ #include "RoRPrerequisites.h" -#include "OgrePrerequisites.h" -#include "pthread.h" + #include "rornet.h" -#include "Streamable.h" -#include "NetworkStreamManager.h" -#include <map> +class Streamable; + typedef struct stream_reg_t { int sourceid; @@ -45,10 +43,10 @@ int streamid; } stream_del_t; - class StreamableFactoryInterface { public: + virtual void netUserAttributesChanged(int source, int streamid) = 0; virtual Streamable *createRemoteInstance(stream_reg_t *reg) = 0; virtual void createRemote(int sourceid, int streamid, stream_register_t *reg, int colour) = 0; @@ -57,6 +55,4 @@ virtual void removeInstance(stream_del_t *del) = 0; }; - - -#endif //STREAMABLEFACTORYINTERFACE_H__ +#endif // __StreamableFactoryInterface_H_ Modified: trunk/source/main/network/network.cpp =================================================================== --- trunk/source/main/network/network.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/network.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -20,35 +20,32 @@ #ifdef USE_SOCKETW #include "network.h" -#include "NetworkStreamManager.h" -#include "RoRFrameListener.h" -#include "Console.h" -#include "CacheSystem.h" + #include "BeamFactory.h" #include "CharacterFactory.h" #include "ChatSystem.h" +#include "Console.h" +#include "errorutils.h" +#include "gui_menu.h" +#include "gui_mp.h" +#include "language.h" +#include "RoRFrameListener.h" +#include "RoRVersion.h" #include "Scripting.h" -#include "turboprop.h" -#include "sha1.h" #include "Settings.h" +#include "sha1.h" #include "utils.h" -#include "language.h" -#include "errorutils.h" -#include "RoRVersion.h" -#include "gui_mp.h" -#include "gui_menu.h" - #ifdef USE_CRASHRPT # include "crashrpt.h" #endif -using namespace RoR; //CSHA1 - #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE //#include <CFUserNotification.h> #endif +using namespace Ogre; + Network *net_instance; void *s_sendthreadstart(void* vid) @@ -226,10 +223,10 @@ memset(sha1pwresult, 0, 250); if(strnlen(pwbuffer, 250)>0) { - CSHA1 sha1; + RoR::CSHA1 sha1; sha1.UpdateHash((uint8_t *)pwbuffer, (uint32_t)strnlen(pwbuffer, 250)); sha1.Final(); - sha1.ReportHash(sha1pwresult, CSHA1::REPORT_HEX_SHORT); + sha1.ReportHash(sha1pwresult, RoR::CSHA1::REPORT_HEX_SHORT); } String usertokenhash = SSETTING("User Token Hash", ""); @@ -722,10 +719,10 @@ memset(sha1result, 0, 250); if(buffer) { - CSHA1 sha1; + RoR::CSHA1 sha1; sha1.UpdateHash((uint8_t *)buffer, header->size); sha1.Final(); - sha1.ReportHash(sha1result, CSHA1::REPORT_HEX_SHORT); + sha1.ReportHash(sha1result, RoR::CSHA1::REPORT_HEX_SHORT); } char tmp[256]=""; @@ -735,6 +732,4 @@ //LOG(hex); } -#endif //SOCKETW - - +#endif // USE_SOCKETW \ No newline at end of file Modified: trunk/source/main/network/network.h =================================================================== --- trunk/source/main/network/network.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/network/network.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -17,63 +17,23 @@ 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_SOCKETW +#ifndef __Network_H_ +#define __Network_H_ -#ifndef __Network_H__ -#define __Network_H__ #include "RoRPrerequisites.h" -#include "Ogre.h" -using namespace Ogre; -#include "SocketW.h" +#include "BeamData.h" #include "rornet.h" -#include "pthread.h" -#include "Beam.h" -#include "BeamEngine.h" -#include "SoundScriptManager.h" +#include "SocketW.h" +#include <pthread.h> class Network { -private: - SWInetSocket socket; - static unsigned int myuid; - int myauthlevel; - pthread_t sendthread; - pthread_t receivethread; - pthread_t downloadthread; - static Timer timer; - int last_time; - int speed_time; - int speed_bytes_sent, speed_bytes_sent_tmp, speed_bytes_recv, speed_bytes_recv_tmp; - char* send_buffer; - int send_buffer_len; - oob_t send_oob; - pthread_mutex_t dl_data_mutex; - pthread_mutex_t send_work_mutex; - pthread_cond_t send_work_cv; - client_t clients[MAX_PEERS]; - pthread_mutex_t clients_mutex; - Ogre::UTFString mySname; - long mySport; - char sendthreadstart_buffer[MAX_MESSAGE_LENGTH]; - pthread_mutex_t msgsend_mutex; - RoRFrameListener *mefl; - Ogre::UTFString nickname; - int rconauthed; - bool shutdown; - user_info_t userdata; - Ogre::UTFString getUserChatName(client_t *c); - void calcSpeed(); - std::map<int, float> lagDataClients; - //std::map<Ogre::String, Ogre::String> downloadingMods; - void updatePlayerList(); - server_info_t server_settings; - bool initiated; public: - Network(std::string servername, long sport, RoRFrameListener *efl); + Network(Ogre::String servername, long sport, RoRFrameListener *efl); ~Network(); // messaging functions @@ -85,7 +45,7 @@ // methods bool connect(); void disconnect(); - void netFatalError(UTFString error, bool exit=true); + void netFatalError(Ogre::UTFString error, bool exit=true); void sendthreadstart(); void receivethreadstart(); @@ -104,13 +64,47 @@ static unsigned int getUID() { return myuid; }; - static void debugPacket(const char *name, header_t *header, char *buffer); -protected: -}; +private: -#endif + Ogre::UTFString mySname; + Ogre::UTFString nickname; + RoRFrameListener *mefl; + SWInetSocket socket; + bool initiated; + bool shutdown; + char sendthreadstart_buffer[MAX_MESSAGE_LENGTH]; + char* send_buffer; + client_t clients[MAX_PEERS]; + int last_time; + int myauthlevel; + int rconauthed; + int send_buffer_len; + int speed_bytes_sent, speed_bytes_sent_tmp, speed_bytes_recv, speed_bytes_recv_tmp; + int speed_time; + long mySport; + oob_t send_oob; + pthread_cond_t send_work_cv; + pthread_mutex_t clients_mutex; + pthread_mutex_t dl_data_mutex; + pthread_mutex_t msgsend_mutex; + pthread_mutex_t send_work_mutex; + pthread_t downloadthread; + pthread_t receivethread; + pthread_t sendthread; + server_info_t server_settings; + static Ogre::Timer timer; + static unsigned int myuid; + std::map<int, float> lagDataClients; + user_info_t userdata; -#endif // USE_SOCKETW + void calcSpeed(); + void updatePlayerList(); + Ogre::UTFString getUserChatName(client_t *c); +}; + +#endif // __Network_H_ + +#endif // USE_SOCKETW Modified: trunk/source/main/physics/Beam.cpp =================================================================== --- trunk/source/main/physics/Beam.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/physics/Beam.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -55,6 +55,7 @@ #include "Settings.h" #include "Skidmark.h" #include "SlideNode.h" +#include "SoundScriptManager.h" #include "turbojet.h" #include "turboprop.h" #include "water.h" Modified: trunk/source/main/physics/BeamFactory.cpp =================================================================== --- trunk/source/main/physics/BeamFactory.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/physics/BeamFactory.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -22,10 +22,12 @@ #include "BeamFactory.h" +#include "BeamEngine.h" +#include "collisions.h" +#include "network.h" #include "RoRFrameListener.h" #include "Settings.h" -#include "collisions.h" -#include "network.h" +#include "SoundScriptManager.h" #ifdef USE_MYGUI #include "gui_mp.h" Modified: trunk/source/main/physics/BeamFactory.h =================================================================== --- trunk/source/main/physics/BeamFactory.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/physics/BeamFactory.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -26,10 +26,11 @@ #include "RoRPrerequisites.h" #include "Beam.h" -#include "pthread.h" #include "StreamableFactory.h" #include "TwoDReplay.h" +#include <pthread.h> + class BeamFactory : public StreamableFactory < BeamFactory, Beam > { friend class Network; Modified: trunk/source/main/physics/collision/collisions.cpp =================================================================== --- trunk/source/main/physics/collision/collisions.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/physics/collision/collisions.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -25,6 +25,7 @@ #include "heightfinder.h" #include "Landusemap.h" #include "language.h" +#include "MovableText.h" #include "RoRFrameListener.h" #include "Scripting.h" #include "Settings.h" Modified: trunk/source/main/scripting/GameScript.cpp =================================================================== --- trunk/source/main/scripting/GameScript.cpp 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/scripting/GameScript.cpp 2012-05-14 16:54:57 UTC (rev 2560) @@ -39,6 +39,7 @@ #include "Beam.h" #include "BeamFactory.h" +#include "Character.h" #include "Console.h" #include "heightfinder.h" #include "RoRFrameListener.h" Modified: trunk/source/main/utils/InterThreadStoreVector.h =================================================================== --- trunk/source/main/utils/InterThreadStoreVector.h 2012-05-14 14:29:24 UTC (rev 2559) +++ trunk/source/main/utils/InterThreadStoreVector.h 2012-05-14 16:54:57 UTC (rev 2560) @@ -17,13 +17,13 @@ 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__ +#ifndef __InterThreadStoreVector_H_ +#define __InterThreadStoreVector_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 @@ -72,4 +72,4 @@ std::vector < T > store; }; -#endif //INTERTHREADSTORE_H__ +#endif // __InterThreadStoreVector_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel