getAvailableRenderers returns a reference, not a pointer

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Post Reply
Message
Author
User avatar
bhelyer
Space Floater
Posts: 41
Joined: Tue Aug 28, 2007 3:51 am

getAvailableRenderers returns a reference, not a pointer

#1 Post by bhelyer »

So I've had to make these changes so far:

Code: Select all

Index: SConstruct
===================================================================
--- SConstruct	(revision 3090)
+++ SConstruct	(working copy)
@@ -12,6 +12,7 @@
                              'INCLUDE' : os.environ['INCLUDE']})
 else:
     env = Environment()
+    env['CPPDEFINES'] = ''
 
 # Do not put a .sconsign file into every directory
 env.SConsignFile()
Index: client/human/chmain.cpp
===================================================================
--- client/human/chmain.cpp	(revision 3090)
+++ client/human/chmain.cpp	(working copy)
@@ -131,11 +131,11 @@
 
         root = new Root((GetGlobalDir() / "ogre_plugins.cfg").string());
 
-        RenderSystemList* renderers_list = root->getAvailableRenderers();
+        RenderSystemList renderers_list = root->getAvailableRenderers();
         bool failed = true;
         RenderSystem* selected_render_system = 0;
-        for (unsigned int i = 0; i < renderers_list->size(); ++i) {
-            selected_render_system = renderers_list->at(i);
+        for (unsigned int i = 0; i < renderers_list.size(); ++i) {
+            selected_render_system = renderers_list.at(i);
             String name = selected_render_system->getName();
             if (name.compare("OpenGL Rendering Subsystem") == 0) {
                 failed = false;
I don't know if the second one is just the version of Ogre I'm using (which is their svn trunk), or what. The first one is because other wise scons crashes with a KeyError if you don't initialise env["CPPDEFINES"] with something (why scons doesn't predefine these things as empty strings I don't know).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: getAvailableRenderers returns a reference, not a pointer

#2 Post by Geoff the Medio »

bhelyer wrote:I don't know if the second one is just the version of Ogre I'm using (which is their svn trunk), or what.
OgreRoot.h contains:

Code: Select all

        RenderSystemList* getAvailableRenderers(void);
for me. FreeOrion officially requires Ogre 1.6.1 and the latest version if 1.6.2, so if they've changed that function's interface, it's probably going to be unsupported until we update the requirement.

That said, if there's an easy way to check the Ogre version with preprocessor or run-time checks, I could add an alternate bit of code to work with a returned reference.

Also, since if it's returning a reference, you should probably use

Code: Select all

RenderSystemList& renderers_list = root->getAvailableRenderers();
instead of assigning the value to a new RenderSystemList.

User avatar
bhelyer
Space Floater
Posts: 41
Joined: Tue Aug 28, 2007 3:51 am

Re: getAvailableRenderers returns a reference, not a pointer

#3 Post by bhelyer »

instead of assigning the value to a new RenderSystemList
True. I am currently in 'shooty shooty bang die compile errors' mode, so most stuff I write comes off pretty hackish. It's a reference in my version; keeping local changes doesn't bug me.

New one:

Code: Select all

===================================================================
--- UI/PagedGeometry/PagedGeometry.cpp	(revision 3090)
+++ UI/PagedGeometry/PagedGeometry.cpp	(working copy)
@@ -371,7 +371,7 @@
 
 float PagedGeometry::getCustomParam(string paramName, float defaultParamValue) const
 {
-	map<string, float>::const_iterator it;
+	std::map<std::string, float>::const_iterator it;
 	it = customParam.find(paramName);
 	if (it != customParam.end()) {
 		float x = it->second;
Finally got it to compile. Using an ATI card, so it segfaults on start up.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: getAvailableRenderers returns a reference, not a pointer

#4 Post by Geoff the Medio »

bhelyer wrote:

Code: Select all

-	map<string, float>::const_iterator it;
+	std::map<std::string, float>::const_iterator it;
I've got to blame your compiler for that one; line 23 is:

Code: Select all

using namespace std;

User avatar
bhelyer
Space Floater
Posts: 41
Joined: Tue Aug 28, 2007 3:51 am

Re: getAvailableRenderers returns a reference, not a pointer

#5 Post by bhelyer »

Ogre has their own map, apparently. Perhaps it is new.

Code: Select all

UI/PagedGeometry/PagedGeometry.cpp:374: error: reference to 'map' is ambiguous
/usr/include/c++/4.3/bits/stl_map.h:91: error: candidates are: template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map
/usr/local/stow/ogre/include/OGRE/OgrePrerequisites.h:589: error:                 template<class K, class V, class P, class A> struct Ogre::map
The std::string thing is probably unnecessary. I must admit to not really reading template error messages; my mind just sort of glazes over. :oops:

Post Reply