EngineSource for GameDevs: Difference between revisions

From Spring
Jump to navigationJump to search
Knorke (talk | contribs)
created page, not if worth to continue?
 
Knorke (talk | contribs)
No edit summary
Line 1: Line 1:
==Intro==
==Intro==
During creation of a Spring game you will soon notice that not everything is documentated.
During creation of a Spring game you will soon notice that not everything is documentated.
Fortunately, the engine is open source and thus some things can be figured out by looking at it.
Fortunately, the engine is open source and thus some things can be figured out by looking at it. Wait, isn't that like, super cryptic? Yes, scroll past those parts. A few things are comprehendible.  


Wait, isn't that like, super cryptic? Yes, scroll past those parts.  
 
A few things are comprehendible.  
==downloading source and opening the files==
Download this https://github.com/spring/spring/zipball/master and unpack the zip file.


==Text==
==Text==
Line 33: Line 34:


'''GetFloat3''' - 3 floats, for example coordinates in case of "modelCenterOffset" or a vector in case of "flareDropVector"
'''GetFloat3''' - 3 floats, for example coordinates in case of "modelCenterOffset" or a vector in case of "flareDropVector"
==searching text in files==
It is usefull to have an text editor that can search for text in multiple files at once, for example this one: http://notepad-plus-plus.org/


==Interessting files==
==Interessting files==

Revision as of 16:08, 14 December 2011

Intro

During creation of a Spring game you will soon notice that not everything is documentated. Fortunately, the engine is open source and thus some things can be figured out by looking at it. Wait, isn't that like, super cryptic? Yes, scroll past those parts. A few things are comprehendible.


downloading source and opening the files

Download this https://github.com/spring/spring/zipball/master and unpack the zip file.

Text

For example the code to load UnitDefs can be found here: https://github.com/spring/spring/blob/develop/rts/Sim/Units/UnitDef.cpp

Scroll down to about line 270:
Notice how there are lines like for example this:

metalStorage = udTable.GetFloat("metalStorage", 0.0f);

The word in double quotes ("metalStorage") is the UnitDef tag as it is read from the unit file.

If a tag can not be found in this file in this form, it is very likely that it does nothing and you can remove it from the unit file.

GetFloat means that this tag is a float number. The number, in this case 0.0f, is the default value that is used, when the tag can not be found in the unit file.

Since the engine expects a number (eg 100.0) it is understandable that metalStorage = "a lot", or metalStorage=false will not work.

Beside GetFloat there are:

GetBool - true or false

GetInt - an integer number

GetString - a string, that means a word eg a unit name or a file name

GetFloat3 - 3 floats, for example coordinates in case of "modelCenterOffset" or a vector in case of "flareDropVector"


searching text in files

It is usefull to have an text editor that can search for text in multiple files at once, for example this one: http://notepad-plus-plus.org/

Interessting files

Most things outside "Sim" folder are uninteressting.

The files where XYdefs get loaded:

https://github.com/spring/spring/blob/develop/rts/Sim/Units/UnitDef.cpp

https://github.com/spring/spring/blob/develop/rts/Sim/Weapons/WeaponDefHandler.cpp

https://github.com/spring/spring/blob/develop/rts/Sim/Features/FeatureHandler.cpp

https://github.com/spring/spring/blob/develop/rts/Sim/MoveTypes/MoveInfo.cpp

Unit actions (damage, kill, experience,...):
https://github.com/spring/spring/blob/develop/rts/Sim/Units/Unit.cpp