A few questions about FreeOrion programming
A few questions about FreeOrion programming
I am learning C++ and I am curious to know a few things about the games code. How many source files does FreeOrion use? About how many functions does the game use in the code? How long basically is the games code? I am at still just learning so I don't know how advanced the code in this game is. Do my questions make sense? I just know that a function is a group of statements with a certain job to do, and that many source files may be used for organizational purposes. That's where my questions stem from, some basic knowledge.
Re: A few questions about FreeOrion programming
Your questions make sense in terms of semantics, but a quick check of the FO executable and associated libraries should tell you that FO is complex enough that we couldn't answer those "how many" questions from mere visual inspection, and there is not enough point to them for my IDE to even offer me a report of the statistics you ask about.
You can peruse or download/clone the code from our GitHub repository.
You can peruse or download/clone the code from our GitHub repository.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: A few questions about FreeOrion programming
It may be down for scheduled maintenance today, but some of that info can be seen on https://www.openhub.net/p/freeorion
-
- Juggernaut
- Posts: 854
- Joined: Wed Aug 26, 2015 6:15 pm
Re: A few questions about FreeOrion programming
From what I know of C++ work, the answer for a project as complex as this would be "lots and lots".
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: A few questions about FreeOrion programming
Not all of it should "count", but a quick search for *.cpp lists 250 files. *.h lists 237 files. This is an incomplete count of "source" files, however.
- adrian_broher
- Programmer
- Posts: 1156
- Joined: Fri Mar 01, 2013 9:52 am
- Location: Germany
Re: A few questions about FreeOrion programming
Around 561 C++ and Python files with GG included. Without GG it's around 433 files. GG is the UI library we use and should be considered a separate project which just happen to live inside the FreeOrion source tree. This is not an exact number as there are probably Python scripts in this result that are not part of the game but utilities to build the project or do other utility non-game related thingies.Voyager wrote:How many source files does FreeOrion use?
Code: Select all
find -type f -iname '*.h' -or -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' -or -iname '*.py' | wc -l
Around 1936 python functions within default/python. Around 4122 C++ functions (class members or not) for FreeOrion only, around 6012 for FreeOrion and GG. However the method of measurement may gobble up inlined functions and I didn't clear out some symbols that are compiler internal, but that's around 10 or so.About how many functions does the game use in the code?
Code: Select all
grep -r '\<def\>' default/python/ | wc -l
Code: Select all
# needs to be compiled without -fvisibility=hidden
# FreeOrion only
nm -D --demangle --defined-only freeorion libfreeorion* | grep -vE '(\<(boost|std|vtable|typeinfo|GG|thunk|utf8)\>|_br_)' | grep -E '\<[TW]\>' | cut -c 20- | sort -u | wc -l
# FreeOrion + GG
nm -D --demangle --defined-only freeorion libfreeorion* libGiGi* | grep -vE '(\<(boost|std|vtable|typeinfo|thunk|utf8)\>|_br_)' | grep -E '\<[TW]\>' | cut -c 20- | sort -u | wc -l
sloccount reports the following source lines of code, but I didn't bother code check if it counts the right thing:How long basically is the games code?
Code: Select all
$ sloccount .
# … left out for brevity …
Totals grouped by language (dominant language first):
cpp: 150985 (88.65%)
python: 18691 (10.97%)
ansic: 645 (0.38%)
I would consider this Project medium sized by contributors and general metrics. The code is more complex as we use some advanced language features and have an average amount of code cruft and inconsistencies due to project age.I am at still just learning so I don't know how advanced the code in this game is.
That depends on what knowledge you want to gain. The questions you asked do make sense by itself, but they are mostly of technical nature and are only interesting for project management.Do my questions make sense? I just know that a function is a group of statements with a certain job to do, and that many source files may be used for organizational purposes. That's where my questions stem from, some basic knowledge.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz
Re: A few questions about FreeOrion programming
Although I'm using Linux since I finished my degree in 2005, half of this commands (sloccount, nm) I haven't ever seen. Good to know!adrian_broher wrote:Code: Select all
find -type f -iname '*.h' -or -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' -or -iname '*.py' | wc -l
Code: Select all
grep -r '\<def\>' default/python/ | wc -l
Code: Select all
# needs to be compiled without -fvisibility=hidden # FreeOrion only nm -D --demangle --defined-only freeorion libfreeorion* | grep -vE '(\<(boost|std|vtable|typeinfo|GG|thunk|utf8)\>|_br_)' | grep -E '\<[TW]\>' | cut -c 20- | sort -u | wc -l # FreeOrion + GG nm -D --demangle --defined-only freeorion libfreeorion* libGiGi* | grep -vE '(\<(boost|std|vtable|typeinfo|thunk|utf8)\>|_br_)' | grep -E '\<[TW]\>' | cut -c 20- | sort -u | wc -l
Code: Select all
$ sloccount .
- adrian_broher
- Programmer
- Posts: 1156
- Joined: Fri Mar 01, 2013 9:52 am
- Location: Germany
Re: A few questions about FreeOrion programming
Here, have two additional ones:Oberlus wrote:Although I'm using Linux since I finished my degree in 2005, half of this commands (sloccount, nm) I haven't ever seen. Good to know!
Code: Select all
$ whatis -s 1 sloccount nm cut find grep cut sort wc
sloccount (1) - count source lines of code (SLOC)
nm (1p) - write the name list of an object file (DEVELOPMENT)
nm (1) - list symbols from object files
cut (1p) - cut out selected fields of each line of a file
cut (1) - remove sections from each line of files
find (1p) - find files
find (1) - search for files in a directory hierarchy
grep (1p) - search a file for a pattern
grep (1) - print lines matching a pattern
sort (1p) - sort, merge, or sequence check text files
sort (1) - sort lines of text files
wc (1p) - word, line, and byte or character count
wc (1) - print newline, word, and byte counts for each file
Code: Select all
$ apropos -a count lines
sloccount (1) - count source lines of code (SLOC)
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz