|
From: <qr...@us...> - 2006-12-10 01:06:16
|
Revision: 290
http://svn.sourceforge.net/opengate/?rev=290&view=rev
Author: qrstuvw
Date: 2006-12-09 17:06:16 -0800 (Sat, 09 Dec 2006)
Log Message:
-----------
Basic ALPHA framework
Modified Paths:
--------------
trunk/current/src/Makefile.am
Added Paths:
-----------
trunk/current/src/Client.cpp
trunk/current/src/Server.cpp
trunk/current/src/client/
trunk/current/src/client/GameState.h
trunk/current/src/client/GameStateManager.cpp
trunk/current/src/client/GameStateManager.h
trunk/current/src/client/Global.h
trunk/current/src/client/GraphicsSetup.cpp
trunk/current/src/client/GraphicsSetup.h
trunk/current/src/client/Makefile.am
trunk/current/src/client/OpenGateApp.cpp
trunk/current/src/client/OpenGateApp.h
trunk/current/src/client/logic/
trunk/current/src/client/logic/Makefile.am
trunk/current/src/client/state/
trunk/current/src/client/state/IntroState.cpp
trunk/current/src/client/state/IntroState.h
trunk/current/src/client/state/Makefile.am
trunk/current/src/common/
trunk/current/src/common/Makefile.am
trunk/current/src/deps/
trunk/current/src/deps/Makefile.am
trunk/current/src/deps/tinyxml/
trunk/current/src/deps/tinyxml/Makefile.am
trunk/current/src/deps/tinyxml/tinyxml.cpp
trunk/current/src/deps/tinyxml/tinyxml.h
trunk/current/src/deps/tinyxml/tinyxmlerror.cpp
trunk/current/src/deps/tinyxml/tinyxmlparser.cpp
trunk/current/src/server/
trunk/current/src/server/Makefile.am
Added: trunk/current/src/Client.cpp
===================================================================
--- trunk/current/src/Client.cpp (rev 0)
+++ trunk/current/src/Client.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * eGore eg...@us... *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+#include <cstdlib>
+
+#include "OpenGateApp.h"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+ // Create application object
+ OpenGateApp app;
+
+ try
+ {
+ app.go();
+ }
+ catch( Exception& e )
+ {
+ fprintf(stderr, "An exception has occured: %s\n",
+ e.getFullDescription().c_str());
+ }
+
+ return EXIT_SUCCESS;
+}
Property changes on: trunk/current/src/Client.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/current/src/Makefile.am
===================================================================
--- trunk/current/src/Makefile.am 2006-12-10 00:30:25 UTC (rev 289)
+++ trunk/current/src/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -1,5 +1,10 @@
# set the include path found by configure
-INCLUDES= $(all_includes)
+INCLUDES = $(all_includes)
# the library search path.
+bin_PROGRAMS = client server
+
+server_SOURCES = Server.cpp
+client_SOURCES = Client.cpp
+SUBDIRS = deps common client server
Added: trunk/current/src/Server.cpp
===================================================================
--- trunk/current/src/Server.cpp (rev 0)
+++ trunk/current/src/Server.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * eg...@us... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
Property changes on: trunk/current/src/Server.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/GameState.h
===================================================================
--- trunk/current/src/client/GameState.h (rev 0)
+++ trunk/current/src/client/GameState.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,158 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef GAMESTATE_H
+#define GAMESTATE_H
+
+#include "Global.h"
+
+class GameState;
+
+/** \class GameStateListener
+ Allows a GameStateManager to recieve callbacks from a GameState. */
+class GameStateListener
+ {
+ // Attributes ------------------------------------------------------------------------------
+
+ // Methods ---------------------------------------------------------------------------------
+ public:
+ /** Constructor */
+ GameStateListener(void)
+ {}
+ ;
+
+ /** Virtual Deconstructor */
+ virtual ~GameStateListener(void)
+ {}
+ ;
+
+ /** Store a game state to manage. */
+ virtual void ManageGameState(Ogre::String state_name, GameState* state) = 0;
+
+ /** Find a state by name. */
+ virtual GameState* findByName(Ogre::String state_name) = 0;
+
+ /** Request a change to state. */
+ virtual void changeGameState(GameState* state) = 0;
+
+ /** Push state onto the stack. */
+ virtual bool pushGameState(GameState* state) = 0;
+
+ /** Pop a game state off the stack. */
+ virtual void popGameState() = 0;
+
+ /** Cause a shutdown. */
+ virtual void Shutdown() = 0;
+ };
+
+/** \class GameState
+ Inherit this class to make a game state capable
+ of being mananged by the game state manager.
+*/
+class GameState
+ {
+ // Attributes ------------------------------------------------------------------------------
+ protected:
+ /** Stores the GameStateManager which is managing this state. */
+ GameStateListener* parent;
+
+ /** Keeps a method of device interaction. */
+ framework_info* mFramework;
+
+ // Methods ---------------------------------------------------------------------------------
+ protected:
+ /** Constructor: This should be a private member of an inherited class. */
+ GameState(void)
+ {}
+ ;
+
+ /** Destructor: This should be a private member of an inherited class. */
+ virtual ~GameState(void)
+ {}
+ ;
+
+ /** Find a state by its name. */
+ GameState* findByName(Ogre::String state_name)
+ {
+ return parent->findByName(state_name);
+ }
+
+ /** Request a change to game state. */
+ void changeGameState(GameState* state)
+ {
+ parent->changeGameState(state);
+ }
+
+ /** Push game state onto the stack. */
+ bool pushGameState(GameState* state)
+ {
+ return parent->pushGameState(state);
+ }
+
+ /** Pop a game state off the stack. */
+ void popGameState(void)
+ {
+ parent->popGameState();
+ }
+
+ /** Cause a shutdown. */
+ void Shutdown(void)
+ {
+ parent->Shutdown();
+ }
+
+ public:
+ /** Do not inherit this directly! */
+ void Create(GameStateListener* parent, const Ogre::String name)
+ {}
+ ;
+
+ /** Destroy self. */
+ void destroy(void)
+ {
+ delete this;
+ }
+
+ /** Initialize the game state with device information. */
+ void init(framework_info* framework)
+ {
+ mFramework = framework;
+ }
+
+ /** Inherit to supply game state enter code. */
+ virtual void enter(void) = 0;
+
+ /** Inherit to supply state exit code. */
+ virtual void exit(void) = 0;
+
+ /** Inherit to supply pause code. Inherit only if this game state can be paused.
+ Return true for successful pause, or false to deny pause. */
+ virtual bool pause(void)
+ {
+ return false;
+ }
+
+ /** Inherit to supply resume code. Inherit only if this game state can be paused. */
+ virtual void resume(void)
+ {}
+ ;
+ };
+
+#endif
Property changes on: trunk/current/src/client/GameState.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/GameStateManager.cpp
===================================================================
--- trunk/current/src/client/GameStateManager.cpp (rev 0)
+++ trunk/current/src/client/GameStateManager.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,193 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "GameStateManager.h"
+
+//--------------------------------------------------------------------------------//
+/** Constructs the GameStateManager. */
+GameStateManager::GameStateManager(framework_info* framework)
+{
+ mFramework = framework;
+}
+
+//--------------------------------------------------------------------------------//
+/** Cleans up the game states before the instance dies. */
+GameStateManager::~GameStateManager()
+{
+ // Clean up all the states on the stack
+ while (!mStateStack.empty())
+ {
+ cleanup(mStateStack.back());
+ mStateStack.pop_back();
+ }
+
+ // Destroy the game states
+ while(!mStates.empty())
+ {
+ mStates.back().state->destroy();
+ mStates.pop_back();
+ }
+}
+
+//--------------------------------------------------------------------------------//
+/** Store a game state to manage. */
+void GameStateManager::ManageGameState(Ogre::String state_name,GameState* state)
+{
+ state_info new_state_info;
+ new_state_info.name = state_name;
+ new_state_info.state = state;
+ new_state_info.state->init(mFramework);
+ mStates.push_back(new_state_info);
+}
+
+//--------------------------------------------------------------------------------//
+
+/** Find a game state by name.
+ @Remarks returns 0 on failure.*/
+GameState* GameStateManager::findByName(Ogre::String state_name)
+{
+ std::vector<state_info>::iterator itr;
+
+ for(itr=mStates.begin();itr!=mStates.end();itr++)
+ {
+ if(itr->name==state_name)
+ return itr->state;
+ }
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------//
+/** Start game state. This is used to start the game state
+ manager functioning with a particular state.
+ This function also does the main game loop and
+ takes care of the Windows message pump.*/
+void GameStateManager::start(GameState* state)
+{
+ changeGameState(state);
+
+ while (!mShutdown)
+ {
+ // HACK: For some reason renderOneFrame() does not work,
+ // manually updating the window.
+ mFramework->ogreRoot->_fireFrameStarted();
+
+ // Run the message pump
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ {
+ MSG msg;
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (msg.message = WM_QUIT)
+ Shutdown();
+ else
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+#endif
+
+ mFramework->renderWindow->update();
+ mFramework->ogreRoot->_fireFrameEnded();
+ }
+}
+
+//--------------------------------------------------------------------------------//
+/** Change to a game state. This replaces the current game state
+ with a new game state. The current game state ends before
+ the new begins. */
+void GameStateManager::changeGameState(GameState* state)
+{
+ // Cleanup the current game state
+ if ( !mStateStack.empty() )
+ {
+ cleanup(mStateStack.back());
+ mStateStack.back()->exit();
+ mStateStack.pop_back();
+ }
+
+ mStateStack.push_back(state);
+ init(state);
+ mStateStack.back()->enter();
+}
+
+//--------------------------------------------------------------------------------//
+/** Push a game state onto the stack. This pauses the current game state
+ and begins a new game state. If the current game state refuses to
+ be paused, this will return false. */
+bool GameStateManager::pushGameState(GameState* state)
+{
+ // Pause current game state
+ if ( !mStateStack.empty() )
+ {
+ if(!mStateStack.back()->pause())
+ return false;
+ cleanup(mStateStack.back());
+ }
+
+ // Store and init the new state
+ mStateStack.push_back(state);
+ init(state);
+ mStateStack.back()->enter();
+
+ return true;
+}
+
+//--------------------------------------------------------------------------------//
+/** Pop a game state off the stack. This destroys the current game state
+ and returns control to the previous game state. */
+void GameStateManager::popGameState(void)
+{
+ // Cleanup the current game state
+ if ( !mStateStack.empty() )
+ {
+ cleanup(mStateStack.back());
+ mStateStack.back()->exit();
+ mStateStack.pop_back();
+ }
+
+ // Resume previous game state or quit if there isn't one
+ if ( !mStateStack.empty() )
+ {
+ init(mStateStack.back());
+ mStateStack.back()->resume();
+ }
+ else
+ Shutdown();
+}
+
+//--------------------------------------------------------------------------------//
+/** Special case function to shutdown the system. */
+void GameStateManager::Shutdown()
+{
+ mShutdown = true;
+}
+
+//--------------------------------------------------------------------------------//
+/** This initializes a game state. */
+void GameStateManager::init(GameState* state)
+{}
+
+//--------------------------------------------------------------------------------//
+/** Cleans up a previous state. */
+void GameStateManager::cleanup(GameState* state)
+{}
Property changes on: trunk/current/src/client/GameStateManager.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/GameStateManager.h
===================================================================
--- trunk/current/src/client/GameStateManager.h (rev 0)
+++ trunk/current/src/client/GameStateManager.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef GAMESTATEMANAGER_H
+#define GAMESTATEMANAGER_H
+
+#include "GameState.h"
+
+/** \class GameStateManager
+ The GameStateManager manages changes in the game states
+ in the game. It holds a stack of all open game states
+ and maps all events. */
+class GameStateManager: public GameStateListener
+ {
+ // Attributes ------------------------------------------------------------------------------
+ protected:
+ /** Holds information about the states in order to
+ manage them properly and provide access. */
+ typedef struct
+ {
+ Ogre::String name;
+ GameState* state;
+ }
+ state_info;
+
+ /** This is the stack where the active states are stored. */
+ std::vector<GameState*> mStateStack;
+
+ /** This holds the states that are being managed. */
+ std::vector<state_info> mStates;
+
+ /** System Information. */
+ framework_info* mFramework;
+
+ /** If this is set to true, the game state manager prepares to exit. */
+ bool mShutdown;
+
+ // Methods ---------------------------------------------------------------------------------
+ protected:
+ /** This initializes a state. */
+ void init(GameState* state);
+
+ /** Cleans up a previous state. */
+ void cleanup(GameState* state);
+
+ public:
+ /** Constructs the GameStateManager. Must have all
+ input, output, gui functions in order to manage
+ states. */
+ GameStateManager(framework_info* framework);
+
+ /** Cleans up the states before the instance dies. */
+ ~GameStateManager();
+
+ /** Store a game state to manage. */
+ void ManageGameState(Ogre::String state_name, GameState* state);
+
+ /** Find a game state by name. */
+ GameState* findByName(Ogre::String state_name);
+
+ /** Start game state */
+ void start(GameState* state);
+
+ /** Change to a new game state */
+ void changeGameState(GameState* state);
+
+ /** Push game state onto the stack. */
+ bool pushGameState(GameState* state);
+
+ /** Pop a game state off the stack. */
+ void popGameState(void);
+
+ /** This is a special case function to cause a shutdown. */
+ void Shutdown(void);
+ };
+
+#endif
Property changes on: trunk/current/src/client/GameStateManager.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/Global.h
===================================================================
--- trunk/current/src/client/Global.h (rev 0)
+++ trunk/current/src/client/Global.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include <OGRE/Ogre.h>
+#include <OIS/OISMouse.h>
+#include <OIS/OISKeyboard.h>
+#include <OIS/OISJoyStick.h>
+#include <OIS/OISInputManager.h>
+/** This file eases an issue CEGUI has with OGRE's memory manager. Simply include this in
+ any files that are going to be doing 'CEGUI stuff', rather than CEGUI.h,
+ OgreCEGUIRender.h, OgreCEGUIResourceProvider.h, and OgreCEGUITexture.h (etc).
+ You will be in for smooth(er) sailing. **/
+#include <OGRE/OgreNoMemoryMacros.h>
+#include <CEGUI/CEGUIImageset.h>
+#include <CEGUI/CEGUISystem.h>
+#include <CEGUI/CEGUILogger.h>
+#include <CEGUI/CEGUISchemeManager.h>
+#include <CEGUI/CEGUIWindowManager.h>
+#include <CEGUI/CEGUIWindow.h>
+#include <OGRE/OgreCEGUIRenderer.h>
+#include <OGRE/OgreCEGUIResourceProvider.h>
+#include <OGRE/OgreMemoryMacros.h>
+
+#include <CEGUI/elements/CEGUIEditbox.h>
+#include <CEGUI/elements/CEGUIPushButton.h>
+#include <CEGUI/elements/CEGUIEditbox.h>
+#include <CEGUI/elements/CEGUIFrameWindow.h>
+#include <CEGUI/elements/CEGUIStaticImage.h>
+#include <CEGUI/elements/CEGUIProgressBar.h>
+#include <CEGUI/elements/CEGUIStaticText.h>
+
+/** Information structure to facilitate the transfer of information between
+ GameState states. */
+typedef struct
+ {
+ Ogre::Root* ogreRoot;
+ Ogre::SceneManager* sceneMgr;
+ Ogre::Camera* camera;
+ Ogre::Viewport* viewport;
+ Ogre::RenderWindow* renderWindow;
+ CEGUI::OgreCEGUIRenderer* GUIRenderer;
+ CEGUI::System* GUISystem;
+ }
+framework_info;
+
+#endif
Property changes on: trunk/current/src/client/Global.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/GraphicsSetup.cpp
===================================================================
--- trunk/current/src/client/GraphicsSetup.cpp (rev 0)
+++ trunk/current/src/client/GraphicsSetup.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,204 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "GraphicsSetup.h"
+
+/** Defaul constructor. */
+//--------------------------------------------------------------------------------//
+GraphicsSetup::GraphicsSetup()
+{}
+
+/** Default destructor. */
+//--------------------------------------------------------------------------------//
+GraphicsSetup::~GraphicsSetup()
+{}
+
+/** This function initialises Ogre and CEGUI. */
+//--------------------------------------------------------------------------------//
+bool GraphicsSetup::initGraphics(framework_info* mFramework)
+{
+ // Create root object and store a pointer to it in mFramework
+ mFramework->ogreRoot = new Ogre::Root("", "", "OpenGate.log");
+
+ // Load the render system (Linux only has OpenGL)
+ mFramework->ogreRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL.so");
+
+ // Load engines settings
+ if (!loadEngineSettings(mFramework))
+ {
+ // Create the Graphics.xml file using default options
+ if (!saveEngineSettings(mFramework))
+ return false;
+ return false;
+ }
+
+ // Write all the currently available settings as comment
+ if (!saveEngineSettings(mFramework))
+ return false;
+
+ // Load all resources from XML
+ if (!setupResources())
+ return false;
+
+ // FIXME: Make this do something. Returns an empty string if options are valid
+ mRenderSystem->validateConfigOptions();
+
+ // Tell the Ogre what render system to use
+ mFramework->ogreRoot->setRenderSystem(mRenderSystem);
+
+ // Create our window
+ mFramework->renderWindow = mFramework->ogreRoot->initialise(true, "OpenGate 0.0.1ALPHA");
+
+ // Pick a scene manager
+ mFramework->sceneMgr = mFramework->ogreRoot->createSceneManager(Ogre::ST_GENERIC, "SMInstance");
+
+ // Setup CEGUI Logging
+ CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Insane);
+ CEGUI::Logger::getSingleton().setLogFilename("OpenGate.log", true);
+
+ // Tell CEGUI about our window and what scene manager to use
+ mFramework->GUIRenderer = new CEGUI::OgreCEGUIRenderer(mFramework->renderWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mFramework->sceneMgr);
+
+ // Hook the CEGUI system to the renderer
+ mFramework->GUISystem = new CEGUI::System(mFramework->GUIRenderer);
+
+ return true;
+}
+
+/** Get all the options from Graphics.xml and feed them to the RenderSystem. */
+//--------------------------------------------------------------------------------//
+bool GraphicsSetup::loadEngineSettings(framework_info* mFramework)
+{
+ TiXmlDocument doc( "Graphics.xml" );
+ if (!doc.LoadFile())
+ return false;
+ doc.LoadFile();
+ TiXmlHandle hDoc(&doc);
+ TiXmlElement* pElem;
+ TiXmlHandle hRoot(0);
+
+ pElem = hDoc.FirstChildElement().Element();
+ hRoot = TiXmlHandle(pElem);
+
+ pElem = hRoot.FirstChild( "Subsystem" ).FirstChild().Element();
+ mRenderSystem = mFramework->ogreRoot->getRenderSystemByName(pElem->Attribute("value"));
+ for (pElem = hRoot.FirstChild( "GraphicsSetup" ).FirstChild().Element(); pElem != 0; pElem = pElem->NextSiblingElement())
+ {
+ mRenderSystem->setConfigOption(pElem->Attribute("name"), pElem->Attribute("value"));
+ }
+
+ return true;
+}
+
+/** (re)Create Graphics.xml with options taken from the current RenderSystem. */
+//--------------------------------------------------------------------------------//
+bool GraphicsSetup::saveEngineSettings(framework_info* mFramework)
+{
+ int i;
+ std::string s;
+ TiXmlElement* _option;
+ TiXmlDocument doc;
+ TiXmlDeclaration* _decl = new TiXmlDeclaration( "1.0", "UTF-8", "No" );
+ doc.LinkEndChild( _decl );
+ TiXmlElement* _root = new TiXmlElement( "OpenGate" );
+ doc.LinkEndChild( _root );
+
+ TiXmlComment* _comment;
+ _comment = new TiXmlComment();
+ _comment->SetValue(" Automatically (re-)generated ");
+ _root->LinkEndChild( _comment );
+ _comment = new TiXmlComment();
+ _comment->SetValue(" Let's judge him by what he does next... ");
+ _root->LinkEndChild( _comment );
+
+ TiXmlElement* _subsys = new TiXmlElement( "Subsystem" );
+ _root->LinkEndChild( _subsys );
+ _option = new TiXmlElement( "Option" );
+ _option->SetAttribute("name", "Rendering Subsystem");
+ _option->SetAttribute("value", mRenderSystem->getName());
+ _subsys->LinkEndChild( _option );
+ Ogre::RenderSystemList* _rslist;
+ _rslist = mFramework->ogreRoot->getAvailableRenderers();
+ s.clear();
+ for (Ogre::RenderSystemList::iterator itr = _rslist->begin();
+ itr != _rslist->end(); itr++)
+ {
+ s += " " + (*itr)->getName();
+ }
+ s += " ";
+ _comment = new TiXmlComment();
+ _comment->SetValue(s);
+ _subsys->LinkEndChild( _comment );
+
+ TiXmlElement* _graphics = new TiXmlElement( "Graphics" );
+ _root->LinkEndChild( _graphics );
+ Ogre::ConfigOptionMap _optmap;
+ _optmap = mRenderSystem->getConfigOptions();
+ for (Ogre::ConfigOptionMap::iterator itr = _optmap.begin();
+ itr != _optmap.end(); itr++)
+ {
+ _option = new TiXmlElement( "Option" );
+ _option->SetAttribute("name", itr->second.name);
+ _option->SetAttribute("value", itr->second.currentValue);
+ _graphics->LinkEndChild( _option );
+ s.clear();
+ for (i = 0; i < (int)itr->second.possibleValues.size(); i++)
+ {
+ s += " " + itr->second.possibleValues.at(i);
+ }
+ s += " ";
+ _comment = new TiXmlComment();
+ _comment->SetValue(s);
+ _graphics->LinkEndChild( _comment );
+ }
+
+ doc.SaveFile( "Graphics.xml" );
+
+ return true;
+}
+
+/** Create and populate resource groups from Resources.xml. */
+//--------------------------------------------------------------------------------//
+bool GraphicsSetup::setupResources()
+{
+ TiXmlDocument doc( "Resources.xml" );
+ if (!doc.LoadFile())
+ return false;
+ doc.LoadFile();
+ TiXmlHandle hDoc(&doc);
+ TiXmlElement* pElem;
+ TiXmlElement* pGroup;
+ TiXmlHandle hGroup(0);
+ TiXmlHandle hRoot(0);
+
+ pElem = hDoc.FirstChildElement().Element();
+ hRoot = TiXmlHandle(pElem);
+
+ for (pGroup = hRoot.FirstChild( "Resources" ).FirstChild( "Group" ).Element(); pGroup != 0; pGroup = pGroup->NextSiblingElement())
+ {
+ hGroup = TiXmlHandle(pGroup);
+ for (pElem = hGroup.FirstChild( "Resource" ).Element(); pElem != 0; pElem = pElem->NextSiblingElement())
+ {
+ Ogre::ResourceGroupManager::getSingleton().addResourceLocation(pElem->Attribute("location"), pElem->Attribute("type"), pGroup->Attribute("name"), false);
+ }
+ }
+
+ return true;
+}
Property changes on: trunk/current/src/client/GraphicsSetup.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/GraphicsSetup.h
===================================================================
--- trunk/current/src/client/GraphicsSetup.h (rev 0)
+++ trunk/current/src/client/GraphicsSetup.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef GRAPHICSSETUP_H
+#define GRAPHICSSETUP_H
+
+#include "Global.h"
+#include <tinyxml/tinyxml.h>
+
+/** \class GraphicsSetup
+ This class initialises the Ogre engine and CEGUI. It is inherited by the
+ OpenGateApp class */
+class GraphicsSetup
+ {
+ // Attributes ------------------------------------------------------------------------------
+ private:
+ Ogre::RenderSystem* mRenderSystem;
+
+ // Methods ---------------------------------------------------------------------------------
+ private:
+ /** Create resource groups from Resources.xml. */
+ bool setupResources();
+
+ /** Get all the options from Graphics.xml and feed them to the RenderSystem. */
+ bool loadEngineSettings(framework_info* mFramework);
+
+ /** (re)Create Graphics.xml according to the options taken from the current RenderSystem. */
+ bool saveEngineSettings(framework_info* mFramework);
+
+ protected:
+ /** Defaul constructor. */
+ GraphicsSetup();
+
+ /** Default destructor. */
+ ~GraphicsSetup();
+
+ /** This function initialises Ogre and CEGUI. */
+ bool initGraphics(framework_info* mFramework);
+ };
+
+#endif
Property changes on: trunk/current/src/client/GraphicsSetup.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/Makefile.am
===================================================================
--- trunk/current/src/client/Makefile.am (rev 0)
+++ trunk/current/src/client/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,7 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+SUBDIRS = logic state
+lib_LTLIBRARIES = libClient.la
+libClient_la_SOURCES = GameStateManager.cpp GraphicsSetup.cpp OpenGateApp.cpp
+noinst_HEADERS = GameStateManager.h GameState.h Global.h OpenGateApp.h \
+ GraphicsSetup.h
Property changes on: trunk/current/src/client/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/OpenGateApp.cpp
===================================================================
--- trunk/current/src/client/OpenGateApp.cpp (rev 0)
+++ trunk/current/src/client/OpenGateApp.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#include "OpenGateApp.h"
+#include "GameStateManager.h"
+
+// Game states
+#include "state/IntroState.h"
+
+//--------------------------------------------------------------------------------//
+/** Default constructor. */
+OpenGateApp::OpenGateApp()
+{}
+
+//--------------------------------------------------------------------------------//
+/** Default destructor. */
+OpenGateApp::~OpenGateApp()
+{}
+
+//--------------------------------------------------------------------------------//
+/** go() starts the OpenGate client. */
+void OpenGateApp::go()
+{
+ // Initialise Ogre and CEGUI
+ if (!initGraphics(&mFramework))
+ return;
+
+ // Start the GameStateManager and register the game states
+ setupGameStateManager();
+
+ // Start the first game state
+ GameStateMgr.start(GameStateMgr.findByName("IntroState"));
+}
+
+//--------------------------------------------------------------------------------//
+/** Create the GameStateManager and register the game states. */
+void OpenGateApp::setupGameStateManager()
+{
+ // Create the gamestate manager
+ GameStateManager GameStateMgr(&mFramework);
+
+ // Create and register game states
+ IntroState::Create(&GameStateMgr,"IntroState");
+}
Property changes on: trunk/current/src/client/OpenGateApp.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/OpenGateApp.h
===================================================================
--- trunk/current/src/client/OpenGateApp.h (rev 0)
+++ trunk/current/src/client/OpenGateApp.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef OPENGATEAPP_H
+#define OPENGATEAPP_H
+
+#include "Global.h"
+#include "GraphicsSetup.h"
+
+/** \class OpenGateApp
+ The OpenGateApp class handles the creation and destruction of singleton objects,
+ populates the framework_info structure, registers the game states and
+ starts the first game state. It does all this and more by simply calling
+ go()... */
+class OpenGateApp : private GraphicsSetup
+ {
+ // Attributes ------------------------------------------------------------------------------
+ private:
+ /** Information structure to facilitate the transfer of information between
+ GameState states. */
+ framework_info mFramework;
+
+ // Methods ---------------------------------------------------------------------------------
+ public:
+ /** Default constructor. */
+ OpenGateApp();
+
+ /** Default destructor. */
+ ~OpenGateApp();
+
+ /** go() starts the OpenGate client. */
+ void go();
+
+ private:
+ /** Create the GameStateManager and register the game states. */
+ void setupGameStateManager();
+ };
+
+#endif
Property changes on: trunk/current/src/client/OpenGateApp.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/logic/Makefile.am
===================================================================
--- trunk/current/src/client/logic/Makefile.am (rev 0)
+++ trunk/current/src/client/logic/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,2 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
Property changes on: trunk/current/src/client/logic/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/state/IntroState.cpp
===================================================================
--- trunk/current/src/client/state/IntroState.cpp (rev 0)
+++ trunk/current/src/client/state/IntroState.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "IntroState.h"
+
+//--------------------------------------------------------------------------------//
+/** Game state enter code. */
+void IntroState::enter()
+{}
+
+//--------------------------------------------------------------------------------//
+/** Game state exit code. */
+void IntroState::exit()
+{}
Property changes on: trunk/current/src/client/state/IntroState.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/state/IntroState.h
===================================================================
--- trunk/current/src/client/state/IntroState.h (rev 0)
+++ trunk/current/src/client/state/IntroState.h 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * Copyright (C) 2006 by OpenGate development team *
+ * Qrstuvw ab...@sl... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#ifndef INTROSTATE_H
+#define INTROSTATE_H
+
+#include "GameState.h"
+
+class IntroState : public GameState
+ {
+ // Self-creation & registering function ----------------------------------------------------
+ public:
+ /** Create and register the state so that it can be managed by the GameStateManager. */
+ static void Create(GameStateListener *parent,const Ogre::String name)
+ {
+ IntroState *myGameState = new IntroState();
+ myGameState->parent = parent;
+ parent->ManageGameState(name,myGameState);
+ }
+
+ // Attributes ------------------------------------------------------------------------------
+
+ // Methods ---------------------------------------------------------------------------------
+ public:
+ /** Default constructor. */
+ IntroState()
+ {}
+
+ /** Default destructor. */
+ ~IntroState()
+ {}
+
+ /** Game state enter code. */
+ void enter();
+
+ /** Game state exit code. */
+ void exit();
+
+ };
+
+#endif
Property changes on: trunk/current/src/client/state/IntroState.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/client/state/Makefile.am
===================================================================
--- trunk/current/src/client/state/Makefile.am (rev 0)
+++ trunk/current/src/client/state/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,5 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+lib_LTLIBRARIES = libStates.la
+noinst_HEADERS = IntroState.h
+libStates_la_SOURCES = IntroState.cpp
Property changes on: trunk/current/src/client/state/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/common/Makefile.am
===================================================================
--- trunk/current/src/common/Makefile.am (rev 0)
+++ trunk/current/src/common/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,2 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
Property changes on: trunk/current/src/common/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/deps/Makefile.am
===================================================================
--- trunk/current/src/deps/Makefile.am (rev 0)
+++ trunk/current/src/deps/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,3 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+SUBDIRS = tinyxml
Property changes on: trunk/current/src/deps/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/deps/tinyxml/Makefile.am
===================================================================
--- trunk/current/src/deps/tinyxml/Makefile.am (rev 0)
+++ trunk/current/src/deps/tinyxml/Makefile.am 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,4 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+lib_LTLIBRARIES = libTinyXML.la
+libTinyXML_la_SOURCES = tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp
Property changes on: trunk/current/src/deps/tinyxml/Makefile.am
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/current/src/deps/tinyxml/tinyxml.cpp
===================================================================
--- trunk/current/src/deps/tinyxml/tinyxml.cpp (rev 0)
+++ trunk/current/src/deps/tinyxml/tinyxml.cpp 2006-12-10 01:06:16 UTC (rev 290)
@@ -0,0 +1,1866 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include <ctype.h>
+
+#ifdef TIXML_USE_STL
+#include <sstream>
+#include <iostream>
+#endif
+
+#include "tinyxml.h"
+
+
+bool TiXmlBase::condenseWhiteSpace = true;
+
+void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
+{
+ int i=0;
+
+ while( i<(int)str.length() )
+ {
+ unsigned char c = (unsigned char) str[i];
+
+ if ( c == '&'
+ && i < ( (int)str.length() - 2 )
+ && str[i+1] == '#'
+ && str[i+2] == 'x' )
+ {
+ // Hexadecimal character reference.
+ // Pass through unchanged.
+ // © -- copyright symbol, for example.
+ //
+ // The -1 is a bug fix from Rob Laveaux. It keeps
+ // an overflow from happening if there is no ';'.
+ // There are actually 2 ways to exit this loop -
+ // while fails (error case) and break (semicolon found).
+ // However, there is no mechanism (currently) for
+ // this function to return an error.
+ while ( i<(int)str.length()-1 )
+ {
+ outString->append( str.c_str() + i, 1 );
+ ++i;
+ if ( str[i] == ';' )
+ break;
+ }
+ }
+ else if ( c == '&' )
+ {
+ outString->append( entity[0].str, entity[0].strLength );
+ ++i;
+ }
+ else if ( c == '<' )
+ {
+ outString->append( entity[1].str, entity[1].strLength );
+ ++i;
+ }
+ else if ( c == '>' )
+ {
+ outString->append( entity[2].str, entity[2].strLength );
+ ++i;
+ }
+ else if ( c == '\"' )
+ {
+ outString->append( entity[3].str, entity[3].strLength );
+ ++i;
+ }
+ else if ( c == '\'' )
+ {
+ outString->append( entity[4].str, entity[4].strLength );
+ ++i;
+ }
+ else if ( c < 32 )
+ {
+ // Easy pass at non-alpha/numeric/symbol
+ // Below 32 is symbolic.
+ char buf[ 32 ];
+
+ #if defined(TIXML_SNPRINTF)
+ TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
+ #else
+ sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
+ #endif
+
+ //*ME: warning C4267: convert 'size_t' to 'int'
+ //*ME: Int-Cast to make compiler happy ...
+ outString->append( buf, (int)strlen( buf ) );
+ ++i;
+ }
+ else
+ {
+ //char realc = (char) c;
+ //outString->append( &realc, 1 );
+ *outString += (char) c; // somewhat more efficient function call.
+ ++i;
+ }
+ }
+}
+
+
+TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
+{
+ parent = 0;
+ type = _type;
+ firstChild = 0;
+ lastChild = 0;
+ prev = 0;
+ next = 0;
+}
+
+
+TiXmlNode::~TiXmlNode()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
+}
+
+
+void TiXmlNode::CopyTo( TiXmlNode* target ) const
+{
+ target->SetValue (value.c_str() );
+ target->userData = userData;
+}
+
+
+void TiXmlNode::Clear()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
+
+ firstChild = 0;
+ lastChild = 0;
+}
+
+
+TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
+{
+ assert( node->parent == 0 || node->parent == this );
+ assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
+
+ if ( node->Type() == TiXmlNode::DOCUMENT )
+ {
+ delete node;
+ if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+
+ node->parent = this;
+
+ node->prev = lastChild;
+ node->next = 0;
+
+ if ( lastChild )
+ lastChild->next = node;
+ else
+ firstChild = node; // it was an empty list.
+
+ lastChild = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
+{
+ if ( addThis.Type() == TiXmlNode::DOCUMENT )
+ {
+ if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+
+ return LinkEndChild( node );
+}
+
+
+TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
+{
+ if ( !beforeThis || beforeThis->parent != this ) {
+ return 0;
+ }
+ if ( addThis.Type() == TiXmlNode::DOCUMENT )
+ {
+ if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+ node->parent = this;
+
+ node->next = beforeThis;
+ node->prev = beforeThis->prev;
+ if ( beforeThis->prev )
+ {
+ beforeThis->prev->next = node;
+ }
+ else
+ {
+ assert( firstChild == beforeThis );
+ firstChild = node;
+ }
+ beforeThis->prev = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
+{
+ if ( !afterThis || afterThis->parent != this ) {
+ return 0;
+ }
+ if ( addThis.Type() == TiXmlNode::DOCUMENT )
+ {
+ if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+ node->parent = this;
+
+ node->prev = afterThis;
+ node->next = afterThis->next;
+ if ( afterThis->next )
+ {
+ afterThis->next->prev = node;
+ }
+ else
+ {
+ assert( lastChild == afterThis );
+ lastChild = node;
+ }
+ afterThis->next = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
+{
+ if ( replaceThis->parent != this )
+ return 0;
+
+ TiXmlNode* node = withThis.Clone();
+ if ( !node )
+ return 0;
+
+ node->next = replaceThis->next;
+ node->prev = replaceThis->prev;
+
+ if ( replaceThis->next )
+ replaceThis->next->prev = node;
+ else
+ lastChild = node;
+
+ if ( replaceThis->prev )
+ replaceThis->prev->next = node;
+ else
+ firstChild = node;
+
+ delete replaceThis;
+ node->parent = this;
+ return node;
+}
+
+
+bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
+{
+ if ( removeThis->parent != this )
+ {
+ assert( 0 );
+ return false;
+ }
+
+ if ( removeThis->next )
+ removeThis->next->prev = removeThis->prev;
+ else
+ lastChild = removeThis->prev;
+
+ if ( removeThis->prev )
+ removeThis->prev->next = removeThis->next;
+ else
+ firstChild = removeThis->next;
+
+ delete removeThis;
+ return true;
+}
+
+const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
+{
+ const TiXmlNode* node;
+ for ( node = firstChild; node; node = node->next )
+ {
+ if ( strcmp( node->Value(), _value ) == 0 )
+ return node;
+ }
+ return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
+{
+ const TiXmlNode* node;
+ for ( node = lastChild; node; node = node->prev )
+ {
+ if ( strcmp( node->Value(), _value ) == 0 )
+ return node;
+ }
+ return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
+{
+ if ( !previous )
+ {
+ return F...
[truncated message content] |