Author Topic: adding new files  (Read 3892 times)

discodowney

  • Guest
adding new files
« on: 11 January 2011, 16:48:40 »
If i add new files do i need to run through Cmake again?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: adding new files
« Reply #1 on: 11 January 2011, 22:40:44 »
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

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding new files
« Reply #2 on: 12 January 2011, 01:42:11 »
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

  • Guest
Re: adding new files
« Reply #3 on: 12 January 2011, 14:50:44 »
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

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: adding new files
« Reply #4 on: 12 January 2011, 17:46:04 »
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

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: adding new files
« Reply #5 on: 12 January 2011, 20:11:02 »
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

  • Guest
Re: adding new files
« Reply #6 on: 13 January 2011, 21:00:44 »
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

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding new files
« Reply #7 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.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

discodowney

  • Guest
Re: adding new files
« Reply #8 on: 14 January 2011, 03:32:18 »
Good man hailstone, worked a treat. Thanks

discodowney

  • Guest
Re: adding new files
« Reply #9 on: 14 January 2011, 03:50:46 »
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
Code: [Select]
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

  • Guest
Re: adding new files
« Reply #10 on: 14 January 2011, 04:10:00 »
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

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: adding new files
« Reply #11 on: 14 January 2011, 04:28:02 »
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

  • Local Moderator
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: adding new files
« Reply #12 on: 14 January 2011, 10:33:49 »
As to not finding your patternsFile, is this a path problem?
I think so too. Most likely a path problem.

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

  • Guest
Re: adding new files
« Reply #13 on: 14 January 2011, 12:00:09 »
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?
« Last Edit: 14 January 2011, 14:19:11 by discodowney »

Yggdrasil

  • Local Moderator
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: adding new files
« Reply #14 on: 14 January 2011, 13:40:39 »
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:
Code: [Select]
istream *file = FSFactory::getInstance()->getIStream("filename"); //only filename
...
// do something, be aware file is a pointer now
...
delete file; // close it

discodowney

  • Guest
Re: adding new files
« Reply #15 on: 14 January 2011, 14:22:20 »
which is the config directory? Only thing resembling that name is configurator and i doubt you mean that. Do you mean the build folder?
« Last Edit: 14 January 2011, 14:50:20 by discodowney »

Yggdrasil

  • Local Moderator
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: adding new files
« Reply #16 on: 14 January 2011, 14:45:05 »
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

  • Guest
Re: adding new files
« Reply #17 on: 14 January 2011, 14:50:52 »
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

  • Local Moderator
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: adding new files
« Reply #18 on: 14 January 2011, 14:56:17 »
Shared_lib is splitted into many namespaces. FSFactory is in Shared::PhysFS.

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

discodowney

  • Guest
Re: adding new files
« Reply #19 on: 14 January 2011, 15:08:23 »
Good stuff. Hopefully it goes off without a hitch now (fat chance)