FreeOrion

Forums for the FreeOrion project
It is currently Mon Dec 11, 2017 7:49 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Apr 29, 2017 1:53 am 
Offline
Space Krill

Joined: Sun Apr 16, 2017 4:29 pm
Posts: 4
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.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 3:02 am 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4390
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.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 4:57 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 358
It may be down for scheduled maintenance today, but some of that info can be seen on https://www.openhub.net/p/freeorion


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 6:01 am 
Offline
Psionic Snowflake

Joined: Wed Aug 26, 2015 6:15 pm
Posts: 498
From what I know of C++ work, the answer for a project as complex as this would be "lots and lots".


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 8:55 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12039
Location: Munich
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.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 9:14 am 
Offline
Programmer
User avatar

Joined: Fri Mar 01, 2013 9:52 am
Posts: 1040
Location: Germany
Voyager wrote:
How many source files does FreeOrion use?

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.

Code:
find -type f -iname '*.h' -or -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' -or -iname '*.py' | wc -l


Quote:
About how many functions does the game use in the code?


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.

Code:
grep -r '\<def\>' default/python/ | wc -l

Code:
# 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


Quote:
How long basically is the games code?


sloccount reports the following source lines of code, but I didn't bother code check if it counts the right thing:

Code:
$ sloccount .
# … left out for brevity …
Totals grouped by language (dominant language first):
cpp:         150985 (88.65%)
python:       18691 (10.97%)
ansic:          645 (0.38%)


Quote:
I am at still just learning so I don't know how advanced the code in this game is.


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.

Quote:
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.


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.

_________________
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 9:30 am 
Offline
Dyson Forest
User avatar

Joined: Mon Apr 10, 2017 4:25 pm
Posts: 238
adrian_broher wrote:
Code:
find -type f -iname '*.h' -or -iname '*.cpp' -or -iname '*.hpp' -or -iname '*.ipp' -or -iname '*.py' | wc -l
Code:
grep -r '\<def\>' default/python/ | wc -l
Code:
# 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:
$ sloccount .
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!


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 9:41 am 
Offline
Programmer
User avatar

Joined: Fri Mar 01, 2013 9:52 am
Posts: 1040
Location: Germany
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!


Here, have two additional ones:

Code:
$ 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:
$ 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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group