News:

Currently available MegaGlest gameservers are listed on Play.MG.

Main Menu

adding new files

Started by discodowney, 11 January 2011, 16:48:40

discodowney

If i add new files do i need to run through Cmake again?

Omega

What "new files"? A new source file? Yes. New data files? No.

Data files are anything in the folders of Glest, such as the menu models, factions, maps, the menu XML, language files, etc, etc;
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

hailstone

CMake is used to generate the project files and generate installer (?). So if you have added a source file you can manually add the file to your project but when other people get the source file they will most likely need to run CMake because they don't want to add it manually. Also if there's a project wide setting modified in the CMake files.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

discodowney

Ive added 4 files (2 .h and .cpp's). But Im getting the following error when i try to compile them (im not including the files in any other existing files yet, ive just aadded them to the project) :

2>svm.cpp
2>..\..\..\source\game\ai\svm.cpp(8) : warning C4627: '#include "svm.h"': skipped when looking for precompiled header use
2>        Add directive to 'pch.h' or rebuild precompiled header
2>..\..\..\source\game\ai\svm.cpp(3068) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
2>SVM_Wrapper.cpp
2>..\..\..\source\game\ai\SVM_Wrapper.cpp(1) : warning C4627: '#include "SVM_Wrapper.h"': skipped when looking for precompiled header use
2>        Add directive to 'pch.h' or rebuild precompiled header
2>..\..\..\source\game\ai\SVM_Wrapper.cpp(166) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?

I dont know what source the error message is talking about there. I tried including the pch.h in the files i added but it makes no difference

Omega

Looks like you have pre compiled headers. Those would have to be rebuilt. Precompiled headers are header files that are compiled ahead of time (ie: generally ones that won't change, or in this case, ones that were distributed primarily to allow the user to just compile the program, not to change it as you are trying.

http://en.wikipedia.org/wiki/Precompiled_header

I'd say download from the SVN.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

silnarm

you must #include "pch.h" in the new cpp files, and in each it must be the very first #include.

This is required to use pre-compiled headers, it would build now if you disable GAE_USE_PRECOMILED_HDR in CMake, but don't do that, your build times will take a nasty hit.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

discodowney

Cheers silnarm it builds fine now.

So ive tried to include the files in the existing code, specifically ai.h, but i get the following:

2>..\..\..\source\game\world\world.cpp(374) : error C2872: 'fixed' : ambiguous symbol
2>        could be 'C:\Users\Downey\Documents\College\Masters\Gae\source\shared_lib\include\math\fixed.h(91) : Shared::Math::fixed'
2>        or       'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\ios(183) : std::ios_base &std::fixed(std::ios_base &)'
2>        or       'C:\Users\Downey\Documents\College\Masters\Gae\source\shared_lib\include\math\fixed.h(91) : Shared::Math::fixed'
2>        or       'C:\Users\Downey\Documents\College\Masters\Gae\source\shared_lib\include\math\fixed.h(91) : Shared::Math::fixed'
2>..\..\..\source\game\world\world.cpp(378) : error C2872: 'fixed' : ambiguous symbol

Anyone know what causes these? The pre-compiled headers mess this up again?

So if i download from the SVM, compile with CMAKE the normal way, i should have no problems with headers again? Ill give it a go.

hailstone

The problem is std::ios_base &std::fixed(std::ios_base &)'. Some where the whole std namespace is being included which results in the std::fixed function being included and conflicts with Shared::Math::fixed. You can either reduce the scope of the included std namespace or explicitly specify the namespace of Shared::Math::fixed so it's not ambiguous.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

discodowney

Good man hailstone, worked a treat. Thanks

discodowney

Actually quick question. The files i added, one of them had using namespace std.

The file uses file stream and line stream. So i just did
char p[255];
int numFeatures=0;
vecOfVec vecs;

std::ifstream file(patternsFile);

while(file.getline(p,sizeof(p)))
{
std::istringstream linestream(p);
vecOfStr stringVec;

while(linestream.getline(p,sizeof(p),','))
stringVec.push_back(p);

if (!numFeatures)
numFeatures=stringVec.size();

vecs.push_back(stringVec);
}

file.close();


The problem im having now though is that the ifstream variable doesnt seem to hold the patternsFile doesnt seem to have anything in it when it gets to the while loop. This code works fine when i have it running just as a simple console application that prints out the contents of that file. The code above is used the exact same, except for the std:: at the start of the ifstream and linestream. Would that make any difference?

discodowney

Quote from: hailstone on 14 January 2011, 00:14:45
The problem is std::ios_base &std::fixed(std::ios_base &)'. Some where the whole std namespace is being included which results in the std::fixed function being included and conflicts with Shared::Math::fixed. You can either reduce the scope of the included std namespace or explicitly specify the namespace of Shared::Math::fixed so it's not ambiguous.

Right, sorry bout the multiple posts, but its 4 in the morning here and i can feel my brain oozing out my ears.

Anyway....You say to reduce the scope of the included std namespace. How do i reduce the scope to just the class i call it in?

silnarm

instead of a using directive,
using namespace std;

use using declarations,
using std::ifstream;
using std::istringstream;


As to not finding your patternsFile, is this a path problem?
Ie. Where is this 'patterns-file', where is the game running from (working dir) and what is the path you are providing in the variable 'patternsFile'

Note also that the working directory is not set in stone, and is allowed to be different from run to run... We load files through PhysFS, which neatly skips any path problems that this would cause, but I must admit special support for text files is sadly still lacking...
Glest Advanced Engine - Code Monkey

Timeline | Downloads

Yggdrasil

Quote from: silnarm on 14 January 2011, 04:28:02
As to not finding your patternsFile, is this a path problem?
I think so too. Most likely a path problem.

Quote from: silnarm on 14 January 2011, 04:28:02
Note also that the working directory is not set in stone, and is allowed to be different from run to run... We load files through PhysFS, which neatly skips any path problems that this would cause, but I must admit special support for text files is sadly still lacking...
What about FSFactory::getIStream? Can be used the same way as ifstream in the example above. TinyXml uses it.

discodowney

#13
Yeah it seems that the file isnt being found. I have it in the AI folder where the new files are aswell. Ill try that method later Yggdrasil. Cheers

EDIT: What is TinyXML?

Yggdrasil

PhysFS doesn't mount the source folder. So you can't access any files there. Just store this file in your config directory and open it with:

istream *file = FSFactory::getInstance()->getIStream("filename"); //only filename
...
// do something, be aware file is a pointer now
...
delete file; // close it


discodowney

#15
which is the config directory? Only thing resembling that name is configurator and i doubt you mean that. Do you mean the build folder?

Yggdrasil

The config directory is where the configuration files are stored. When you start the game you should see an output "config-dir: ...". By default this is a folder glestadv in your user's home directory (on linux it's hidden).

TinyXml is our XML parser.

discodowney

Alright, cool.

Im having a compilation problem with FSFactory

Ive included FSFactory.hpp in the .h file of the class im gonna use it in. Then i have as you have

std::istream *file = FSFactory::getInstance()->getIStream(patternsFile);

But im getting errors:

2>..\..\..\source\game\ai\SVM_Wrapper.cpp(60) : error C2653: 'FSFactory' : is not a class or namespace name
2>..\..\..\source\game\ai\SVM_Wrapper.cpp(60) : error C2227: left of '->getIStream' must point to class/struct/union/generic type
2>        type is ''unknown-type''
2>..\..\..\source\game\ai\SVM_Wrapper.cpp(60) : error C3861: 'getInstance': identifier not found

All of which stem from the FSFactory not being recognized. Any ideas why this is happening?

Yggdrasil

Shared_lib is splitted into many namespaces. FSFactory is in Shared::PhysFS.

So either:
using Shared::PhysFS::FSFactory;
or
Shared::PhysFS::FSFactory::getInstance()...

discodowney

Good stuff. Hopefully it goes off without a hitch now (fat chance)