2009-05-08 13:28:41 +00:00
/*
* OpenClonk , http : //www.openclonk.org
*
2013-12-17 20:01:09 +00:00
* Copyright ( c ) 1998 - 2000 , Matthes Bender
* Copyright ( c ) 2001 - 2009 , RedWolf Design GmbH , http : //www.clonk.de/
* Copyright ( c ) 2009 - 2013 , The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* Distributed under the terms of the ISC license ; see accompanying file
* " COPYING " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* " Clonk " is a registered trademark of Matthes Bender , used with permission .
* See accompanying file " TRADEMARK " for details .
2009-05-08 13:28:41 +00:00
*
2013-12-17 20:01:09 +00:00
* To redistribute this file separately , substitute the full license texts
* for the above references .
2009-05-08 13:28:41 +00:00
*/
/* Core component of a scenario file */
# ifndef INC_C4Scenario
# define INC_C4Scenario
# include <C4NameList.h>
# include <C4IDList.h>
class C4SVal
2010-03-28 17:58:21 +00:00
{
public :
C4SVal ( int32_t std = 0 , int32_t rnd = 0 , int32_t min = 0 , int32_t max = 100 ) ;
public :
int32_t Std , Rnd , Min , Max ;
public :
void Default ( ) ;
void Set ( int32_t std = 0 , int32_t rnd = 0 , int32_t min = 0 , int32_t max = 100 ) ;
int32_t Evaluate ( ) ;
void CompileFunc ( StdCompiler * pComp ) ;
public :
inline bool operator = = ( const C4SVal & rhs ) const
2010-03-27 16:05:02 +00:00
{
2010-03-28 17:58:21 +00:00
return rhs . Std = = Std & & rhs . Rnd = = Rnd & & rhs . Min = = Min & & rhs . Max = = Max ;
}
} ;
2009-05-08 13:28:41 +00:00
# define C4SGFXMODE_NEWGFX 1
# define C4SGFXMODE_OLDGFX 2
# define C4S_SECTIONLOAD 1 /* parts of the C4S that are modifyable for different landcape sections */
// flags for section reloading
# define C4S_SAVE_LANDSCAPE 1
# define C4S_SAVE_OBJECTS 2
# define C4S_KEEP_EFFECTS 4
enum C4SFilmMode
2010-03-28 17:58:21 +00:00
{
2009-05-08 13:28:41 +00:00
C4SFilm_None = 0 ,
C4SFilm_Normal = 1 ,
2010-01-25 04:00:59 +00:00
C4SFilm_Cinematic = 2
2010-03-28 17:58:21 +00:00
} ;
2009-05-08 13:28:41 +00:00
class C4SHead
2010-03-28 17:58:21 +00:00
{
public :
2014-12-12 20:57:52 +00:00
int32_t C4XVer [ 2 ] ;
2010-03-28 17:58:21 +00:00
char Title [ C4MaxTitle + 1 ] ;
char Loader [ C4MaxTitle + 1 ] ;
char Font [ C4MaxTitle + 1 ] ; // scenario specific font; may be 0
int32_t Difficulty ;
int32_t Icon ;
2010-04-07 01:12:28 +00:00
bool NoInitialize ;
2010-03-28 17:58:21 +00:00
int32_t MaxPlayer , MinPlayer , MaxPlayerLeague ;
2010-04-07 01:12:28 +00:00
bool SaveGame ;
bool Replay ;
2010-03-28 17:58:21 +00:00
int32_t Film ;
int32_t StartupPlayerCount ; // set for Frame0-replay!
int32_t RandomSeed ;
char Engine [ C4MaxTitle + 1 ] ; // Relative filename of engine to be used for this scenario
char MissionAccess [ C4MaxTitle + 1 ] ;
bool NetworkGame ;
bool NetworkRuntimeJoin ;
StdCopyStrBuf Origin ; // original oath and filename to scenario (for records and savegames)
public :
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp , bool fSection ) ;
} ;
2009-05-08 13:28:41 +00:00
const int32_t C4S_MaxDefinitions = 10 ;
class C4SDefinitions
2010-03-28 17:58:21 +00:00
{
public :
2010-04-07 01:12:28 +00:00
bool LocalOnly ;
bool AllowUserChange ;
2010-03-28 17:58:21 +00:00
C4IDList SkipDefs ;
void SetModules ( const char * szList , const char * szRelativeToPath = NULL , const char * szRelativeToPath2 = NULL ) ;
bool GetModules ( StdStrBuf * psOutModules ) const ;
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp ) ;
2011-05-15 12:10:22 +00:00
private :
char Definition [ C4S_MaxDefinitions ] [ _MAX_PATH + 1 ] ;
2010-03-28 17:58:21 +00:00
} ;
2009-05-08 13:28:41 +00:00
class C4SRealism
2010-03-28 17:58:21 +00:00
{
public :
C4IDList ValueOverloads ;
2010-04-07 01:12:28 +00:00
bool LandscapePushPull ; // Use new experimental push-pull-algorithms
bool LandscapeInsertThrust ; // Inserted material may thrust material of lower density aside
2009-05-08 13:28:41 +00:00
2010-03-28 17:58:21 +00:00
public :
void Default ( ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4SGame
2010-03-28 17:58:21 +00:00
{
public :
C4IDList Goals ;
C4IDList Rules ;
2009-05-08 13:28:41 +00:00
2010-03-28 17:58:21 +00:00
uint32_t FoWColor ; // color of FoW; may contain transparency
2009-05-08 13:28:41 +00:00
2010-03-28 17:58:21 +00:00
C4SRealism Realism ;
2009-05-08 13:28:41 +00:00
2010-03-28 17:58:21 +00:00
public :
bool IsMelee ( ) ;
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp , bool fSection ) ;
} ;
2009-05-08 13:28:41 +00:00
// Maximum map player extend factor
const int32_t C4S_MaxMapPlayerExtend = 4 ;
class C4SPlrStart
2010-03-28 17:58:21 +00:00
{
public :
C4SVal Wealth ;
int32_t Position [ 2 ] ;
int32_t EnforcePosition ;
C4IDList ReadyCrew ;
C4IDList ReadyBase ;
C4IDList ReadyVehic ;
C4IDList ReadyMaterial ;
C4IDList BuildKnowledge ;
2014-04-16 12:06:30 +00:00
C4IDList BaseMaterial ;
C4IDList BaseProduction ;
2010-03-28 17:58:21 +00:00
public :
void Default ( ) ;
bool EquipmentEqual ( C4SPlrStart & rhs ) ;
bool operator = = ( const C4SPlrStart & rhs ) ;
void CompileFunc ( StdCompiler * pComp ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4SLandscape
2010-03-28 17:58:21 +00:00
{
public :
2010-04-07 01:12:28 +00:00
bool ExactLandscape ;
2010-03-28 17:58:21 +00:00
C4SVal VegLevel ;
C4IDList Vegetation ;
C4SVal InEarthLevel ;
C4IDList InEarth ;
2013-03-30 13:54:51 +00:00
int32_t BottomOpen , TopOpen ;
2010-03-28 17:58:21 +00:00
int32_t LeftOpen , RightOpen ;
2010-04-07 01:12:28 +00:00
bool AutoScanSideOpen ;
2010-03-28 17:58:21 +00:00
char SkyDef [ C4MaxDefString + 1 ] ;
int32_t SkyDefFade [ 6 ] ;
2010-04-07 01:12:28 +00:00
bool NoScan ;
2010-03-28 17:58:21 +00:00
C4SVal Gravity ;
// Dynamic map
C4SVal MapWdt , MapHgt , MapZoom ;
C4SVal Amplitude , Phase , Period , Random ;
C4SVal LiquidLevel ;
int32_t MapPlayerExtend ;
C4NameList Layers ;
char Material [ C4M_MaxDefName + 1 ] ;
char Liquid [ C4M_MaxDefName + 1 ] ;
2010-04-07 01:12:28 +00:00
bool KeepMapCreator ; // set if the mapcreator will be needed in the scenario (for DrawDefMap)
2010-03-28 17:58:21 +00:00
int32_t SkyScrollMode ; // sky scrolling mode for newgfx
int32_t FoWRes ; // chunk size of FoGOfWar
2012-11-05 17:17:12 +00:00
int32_t MaterialZoom ;
2013-01-20 11:51:33 +00:00
bool FlatChunkShapes ; // if true, all material chunks are drawn flat
2010-03-28 17:58:21 +00:00
public :
void Default ( ) ;
void GetMapSize ( int32_t & rWdt , int32_t & rHgt , int32_t iPlayerNum ) ;
void CompileFunc ( StdCompiler * pComp ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4SWeather
2010-03-28 17:58:21 +00:00
{
public :
C4SVal Climate ;
C4SVal StartSeason , YearSpeed ;
2012-04-01 21:03:52 +00:00
C4SVal Wind ;
2010-04-07 01:12:28 +00:00
bool NoGamma ;
2010-03-28 17:58:21 +00:00
public :
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4SAnimals
2010-03-28 17:58:21 +00:00
{
public :
C4IDList FreeLife ;
C4IDList EarthNest ;
public :
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4SEnvironment
2010-03-28 17:58:21 +00:00
{
public :
C4IDList Objects ;
public :
void Default ( ) ;
void CompileFunc ( StdCompiler * pComp ) ;
} ;
2009-05-08 13:28:41 +00:00
class C4Scenario
2010-03-28 17:58:21 +00:00
{
public :
C4Scenario ( ) ;
public :
C4SHead Head ;
C4SDefinitions Definitions ;
C4SGame Game ;
C4SPlrStart PlrStart [ C4S_MaxPlayer ] ;
C4SLandscape Landscape ;
C4SAnimals Animals ;
C4SWeather Weather ;
C4SEnvironment Environment ;
public :
void SetExactLandscape ( ) ;
void Clear ( ) ;
void Default ( ) ;
bool Load ( C4Group & hGroup , bool fLoadSection = false ) ;
bool Save ( C4Group & hGroup , bool fSaveSection = false ) ;
void CompileFunc ( StdCompiler * pComp , bool fSection ) ;
int32_t GetMinPlayer ( ) ; // will try to determine the minimum player count for this scenario
} ;
2009-05-08 13:28:41 +00:00
extern const char * C4ScenSect_Main ;
// ref to one scenario section
class C4ScenarioSection
2010-03-28 17:58:21 +00:00
{
public :
C4ScenarioSection ( char * szName ) ; // ctor
~ C4ScenarioSection ( ) ; // dtor
public :
char * szName ; // section name
char * szTempFilename ; // filename of data file if in temp dir
char * szFilename ; // filename of section in scenario file
bool fModified ; // if set, the file is temp and contains runtime landscape and/or object data
2013-12-22 22:47:40 +00:00
class C4ScenarioObjectsScriptHost * pObjectScripts ; // points to loaded script file for section Objects.c
2010-03-28 17:58:21 +00:00
C4ScenarioSection * pNext ; // next member of linked list
public :
2013-12-22 22:47:40 +00:00
bool ScenarioLoad ( C4Group & rGrp , char * szFilename ) ; // called when scenario is loaded: extract to temp store
2010-03-28 17:58:21 +00:00
C4Group * GetGroupfile ( C4Group & rGrp ) ; // get group at section file (returns temp group, scenario subgroup or scenario group itself)
bool EnsureTempStore ( bool fExtractLandscape , bool fExtractObjects ) ; // make sure that a temp file is created, and nothing is modified within the main scenario file
} ;
2009-05-08 13:28:41 +00:00
2014-09-23 21:02:03 +00:00
2009-05-08 13:28:41 +00:00
# endif // INC_C4Scenario