24 #include <yaml-cpp/yaml.h> 25 #include "../Engine/Options.h" 26 #include "../Savegame/GameTime.h" 28 #include "RuleAlienMission.h" 48 class RuleBaseFacility;
50 class RuleCraftWeapon;
58 class ArticleDefinition;
61 class RuleManufacture;
63 class AlienDeployment;
65 class RuleAlienMission;
71 class RuleCommendations;
76 class SoundDefinition;
80 class RuleMissionScript;
81 struct StatAdjustment;
92 std::string _playingMusic;
94 std::map<std::string, Palette*> _palettes;
95 std::map<std::string, Font*> _fonts;
96 std::map<std::string, Surface*> _surfaces;
97 std::map<std::string, SurfaceSet*> _sets;
98 std::map<std::string, SoundSet*> _sounds;
99 std::map<std::string, Music*> _musics;
100 std::vector<Uint16> _voxelData;
101 std::vector<std::vector<Uint8> > _transparencyLUTs;
103 std::map<std::string, RuleCountry*> _countries;
104 std::map<std::string, RuleRegion*> _regions;
105 std::map<std::string, RuleBaseFacility*> _facilities;
106 std::map<std::string, RuleCraft*> _crafts;
107 std::map<std::string, RuleCraftWeapon*> _craftWeapons;
108 std::map<std::string, RuleItem*> _items;
109 std::map<std::string, RuleUfo*> _ufos;
110 std::map<std::string, RuleTerrain*> _terrains;
111 std::map<std::string, MapDataSet*> _mapDataSets;
112 std::map<std::string, RuleSoldier*> _soldiers;
113 std::map<std::string, Unit*> _units;
114 std::map<std::string, AlienRace*> _alienRaces;
115 std::map<std::string, AlienDeployment*> _alienDeployments;
116 std::map<std::string, Armor*> _armors;
117 std::map<std::string, ArticleDefinition*> _ufopaediaArticles;
118 std::map<std::string, RuleInventory*> _invs;
119 std::map<std::string, RuleResearch *> _research;
120 std::map<std::string, RuleManufacture *> _manufacture;
121 std::map<std::string, UfoTrajectory *> _ufoTrajectories;
122 std::map<std::string, RuleAlienMission *> _alienMissions;
123 std::map<std::string, RuleInterface *> _interfaces;
124 std::map<std::string, SoundDefinition *> _soundDefs;
125 std::map<std::string, RuleVideo *>_videos;
126 std::map<std::string, MCDPatch *> _MCDPatches;
127 std::map<std::string, std::vector<MapScript *> > _mapScripts;
128 std::map<std::string, RuleCommendations *> _commendations;
129 std::map<std::string, RuleMissionScript*> _missionScripts;
130 std::map<std::string, std::vector<ExtraSprites *> > _extraSprites;
131 std::vector<std::pair<std::string, ExtraSounds *> > _extraSounds;
132 std::map<std::string, ExtraStrings *> _extraStrings;
133 std::vector<StatString*> _statStrings;
134 std::map<std::string, RuleMusic *> _musicDefs;
137 int _costEngineer, _costScientist, _timePersonnel, _initialFunding, _turnAIUseGrenade, _turnAIUseBlaster, _defeatScore, _defeatFunds;
138 std::pair<std::string, int> _alienFuel;
139 std::string _fontName, _finalResearch;
140 YAML::Node _startingBase;
144 std::map<std::string, int> _ufopaediaSections;
145 std::vector<std::string> _countriesIndex, _regionsIndex, _facilitiesIndex, _craftsIndex, _craftWeaponsIndex, _itemsIndex, _invsIndex, _ufosIndex;
146 std::vector<std::string> _soldiersIndex, _aliensIndex, _deploymentsIndex, _armorsIndex, _ufopaediaIndex, _ufopaediaCatIndex, _researchIndex, _manufactureIndex;
147 std::vector<std::string> _alienMissionsIndex, _terrainIndex, _missionScriptIndex;
148 std::vector<std::vector<int> > _alienItemLevels;
149 std::vector<SDL_Color> _transparencies;
150 int _facilityListOrder, _craftListOrder, _itemListOrder, _researchListOrder, _manufactureListOrder, _ufopaediaListOrder, _invListOrder;
152 SDL_Color *_statePalette;
153 std::vector<std::string> _psiRequirements;
156 void loadFile(
const std::string &filename);
158 template <
typename T>
159 T *loadRule(
const YAML::Node &node, std::map<std::string, T*> *map, std::vector<std::string> *index = 0,
const std::string &key =
"type")
const;
161 template <
typename T>
162 T *getRule(
const std::string &
id,
const std::string &name,
const std::map<std::string, T*> &map,
bool error)
const;
164 Music *getRandomMusic(
const std::string &name)
const;
166 SoundSet *getSoundSet(
const std::string &name,
bool error =
true)
const;
168 void loadBattlescapeResources();
172 void createTransparencyLUT(
Palette *pal);
174 void loadMod(
const std::vector<std::string> &rulesetFiles,
size_t modIdx);
176 void loadVanillaResources();
178 void loadExtraResources();
180 void lazyLoadSurface(
const std::string &name);
188 static int DOOR_OPEN;
189 static int SLIDING_DOOR_OPEN;
190 static int SLIDING_DOOR_CLOSE;
191 static int SMALL_EXPLOSION;
192 static int LARGE_EXPLOSION;
193 static int EXPLOSION_OFFSET;
194 static int SMOKE_OFFSET;
195 static int UNDERWATER_SMOKE_OFFSET;
196 static int ITEM_DROP;
197 static int ITEM_THROW;
198 static int ITEM_RELOAD;
199 static int WALK_OFFSET;
200 static int FLYING_SOUND;
201 static int BUTTON_PRESS;
202 static int WINDOW_POPUP[3];
205 static int UFO_CRASH;
206 static int UFO_EXPLODE;
207 static int INTERCEPTOR_HIT;
208 static int INTERCEPTOR_EXPLODE;
209 static int GEOSCAPE_CURSOR;
210 static int BASESCAPE_CURSOR;
211 static int BATTLESCAPE_CURSOR;
212 static int UFOPAEDIA_CURSOR;
213 static int GRAPHS_CURSOR;
214 static int DAMAGE_RANGE;
215 static int EXPLOSIVE_DAMAGE_RANGE;
216 static int FIRE_DAMAGE_RANGE[2];
217 static std::string DEBRIEF_MUSIC_GOOD;
218 static std::string DEBRIEF_MUSIC_BAD;
219 static int DIFFICULTY_COEFFICIENT[5];
221 static void resetGlobalStatics();
231 Font *
getFont(
const std::string &name,
bool error =
true)
const;
237 Music *getMusic(
const std::string &name,
bool error =
true)
const;
239 void playMusic(
const std::string &name,
int id = 0);
241 Sound *
getSound(
const std::string &
set,
unsigned int sound,
bool error =
true)
const;
245 void setPalette(SDL_Color *colors,
int firstcolor = 0,
int ncolors = 256);
251 const std::vector<std::vector<Uint8> > *
getLUTs()
const;
262 void loadAll(
const std::vector< std::pair< std::string, std::vector<std::string> > > &mods);
290 RuleUfo *
getUfo(
const std::string &
id,
bool error =
false)
const;
292 const std::vector<std::string> &
getUfosList()
const;
308 Unit *
getUnit(
const std::string &name,
bool error =
false)
const;
318 Armor *
getArmor(
const std::string &name,
bool error =
false)
const;
364 const std::map<std::string, std::vector<ExtraSprites *> > &
getExtraSprites()
const;
366 const std::vector<std::pair<std::string, ExtraSounds *> > &
getExtraSounds()
const;
374 const std::vector<std::string> &
getInvsList()
const;
399 const std::vector<MapScript*> *getMapScript(
const std::string&
id)
const;
402 const std::map<std::string, RuleMusic *> *getMusic()
const;
403 const std::vector<std::string> *getMissionScriptList()
const;
404 RuleMissionScript *getMissionScript(
const std::string &name,
bool error =
false)
const;
405 std::string getFinalResearch()
const;
RuleUfo * getUfo(const std::string &id, bool error=false) const
Gets the ruleset for a UFO type.
Definition: Mod.cpp:1657
const std::map< std::string, ExtraStrings * > & getExtraStrings() const
Gets the list of external Strings.
Definition: Mod.cpp:2089
RuleSoldier * getSoldier(const std::string &name, bool error=false) const
Gets soldier unit rules.
Definition: Mod.cpp:1717
RuleItem * getItem(const std::string &id, bool error=false) const
Gets the ruleset for an item type.
Definition: Mod.cpp:1633
const std::map< std::string, SoundDefinition * > * getSoundDefinitions() const
Gets the list of selective files for insertion into our cat files.
Definition: Mod.cpp:2372
const RuleAlienMission * getAlienMission(const std::string &id, bool error=false) const
Gets the ruleset for a specific alien mission.
Definition: Mod.cpp:1984
int getDefeatFunds() const
Returns the minimum amount of funds the player can have, otherwise they are defeated.
Definition: Mod.cpp:3418
RuleInterface * getInterface(const std::string &id, bool error=true) const
Gets information on an interface element.
Definition: Mod.cpp:2349
const std::vector< std::pair< std::string, ExtraSounds * > > & getExtraSounds() const
Gets the list of external Sounds.
Definition: Mod.cpp:2080
const UfoTrajectory * getUfoTrajectory(const std::string &id, bool error=false) const
Gets a specific UfoTrajectory.
Definition: Mod.cpp:1974
int getModOffset() const
Gets the mod offset.
Definition: Mod.cpp:656
Container for music tracks.
Definition: Music.h:30
void loadAll(const std::vector< std::pair< std::string, std::vector< std::string > > > &mods)
Loads a list of mods.
Definition: Mod.cpp:709
~Mod()
Cleans up the mod.
Definition: Mod.cpp:211
RuleTerrain * getTerrain(const std::string &name, bool error=false) const
Gets terrains for battlescape games.
Definition: Mod.cpp:1677
int getMinRadarRange() const
Gets the minimum radar's range.
Definition: Mod.cpp:2323
Mod()
Creates a blank mod.
Definition: Mod.cpp:192
Container of a set of sounds.
Definition: SoundSet.h:34
const std::vector< std::string > & getSoldiersList() const
Gets the available soldiers.
Definition: Mod.cpp:1727
RuleGlobe * getGlobe() const
Gets the ruleset for the globe.
Definition: Mod.cpp:2358
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
const std::vector< std::string > & getAlienMissionList() const
Gets the list of all alien missions.
Definition: Mod.cpp:2024
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
const std::vector< std::string > & getTerrainList() const
Gets the available terrains.
Definition: Mod.cpp:1687
Soldier * genSoldier(SavedGame *save, std::string type="") const
Generates a new soldier.
Definition: Mod.cpp:2250
Represents a specific type of commendation.
Definition: RuleCommendations.h:31
Represents game-specific contents needed for save convertion and ID matching.
Definition: RuleConverter.h:33
void playMusic(const std::string &name, int id=0)
Plays a particular music.
Definition: Mod.cpp:513
int getPersonnelTime() const
Gets the transfer time of personnel.
Definition: Mod.cpp:1846
MapDataSet * getMapDataSet(const std::string &name)
Gets mapdatafile for battlescape games.
Definition: Mod.cpp:1697
std::string getAlienFuelName() const
Gets the item to be used as fuel for ships.
Definition: Mod.cpp:2296
const std::vector< std::string > & getUfosList() const
Gets the available UFOs.
Definition: Mod.cpp:1667
RuleCraft * getCraft(const std::string &id, bool error=false) const
Gets the ruleset for a craft type.
Definition: Mod.cpp:1593
Definition: RuleInterface.h:35
const std::vector< std::vector< Uint8 > > * getLUTs() const
Gets list of LUT data.
Definition: Mod.cpp:647
AlienDeployment * getDeployment(const std::string &name, bool error=false) const
Gets deployment rules.
Definition: Mod.cpp:1786
const std::vector< StatString * > & getStatStrings() const
Gets the list of StatStrings.
Definition: Mod.cpp:2098
Container for sound effects.
Definition: Sound.h:30
Armor * getArmor(const std::string &name, bool error=false) const
Gets armor rules.
Definition: Mod.cpp:1806
std::string getFontName() const
Gets the font name.
Definition: Mod.cpp:2314
const std::vector< std::string > & getDeploymentsList() const
Gets the available alien deployments.
Definition: Mod.cpp:1796
const std::vector< std::string > & getBaseFacilitiesList() const
Gets the available facilities.
Definition: Mod.cpp:1583
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets a new palette.
Definition: Mod.cpp:602
AlienRace * getAlienRace(const std::string &name, bool error=false) const
Gets alien race rules.
Definition: Mod.cpp:1766
RuleCraftWeapon * getCraftWeapon(const std::string &id, bool error=false) const
Gets the ruleset for a craft weapon type.
Definition: Mod.cpp:1613
Represents a specific type of item.
Definition: RuleItem.h:40
std::map< std::string, RuleInventory * > * getInventories()
Gets the inventory list.
Definition: Mod.cpp:1885
const GameTime & getStartingTime() const
Gets the game starting time.
Definition: Mod.cpp:2051
Container of a set of surfaces.
Definition: SurfaceSet.h:35
int getScientistCost() const
Gets the cost of a scientist.
Definition: Mod.cpp:1836
const YAML::Node & getStartingBase() const
Gets the player starting base.
Definition: Mod.cpp:2042
const std::vector< std::string > & getUfopaediaCategoryList() const
Gets the available article categories.
Definition: Mod.cpp:1876
RuleManufacture * getManufacture(const std::string &id, bool error=false) const
Gets the ruleset for a specific manufacture project.
Definition: Mod.cpp:1933
int getSpriteOffset(int sprite, const std::string &set) const
Gets the mod offset for a certain sprite.
Definition: Mod.cpp:667
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:46
const std::vector< std::string > & getInvsList() const
Returns the sorted list of inventories.
Definition: Mod.cpp:1904
const std::vector< std::string > & getAlienRacesList() const
Gets the available alien races.
Definition: Mod.cpp:1776
const std::vector< std::string > & getCraftWeaponsList() const
Gets the available craft weapons.
Definition: Mod.cpp:1623
int getOffset(int id, int max) const
Gets the mod offset for a generic value.
Definition: Mod.cpp:697
Represents a specific race "family", or a "main race" if you wish.
Definition: AlienRace.h:33
const std::vector< std::string > & getPsiRequirements() const
Gets the research-requirements for Psi-Lab (it's a cache for psiStrengthEval)
Definition: Mod.cpp:2239
MCDPatch * getMCDPatch(const std::string &id) const
Gets an MCDPatch.
Definition: Mod.cpp:2061
std::vector< Uint16 > * getVoxelData()
Gets list of voxel data.
Definition: Mod.cpp:624
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:47
RuleCountry * getCountry(const std::string &id, bool error=false) const
Gets the ruleset for a country type.
Definition: Mod.cpp:1533
int getEngineerCost() const
Gets the cost of an engineer.
Definition: Mod.cpp:1826
RuleResearch * getResearch(const std::string &id, bool error=false) const
Gets the ruleset for a specific research project.
Definition: Mod.cpp:1914
SurfaceSet * getSurfaceSet(const std::string &name, bool error=true)
Gets a particular surface set.
Definition: Mod.cpp:453
const std::vector< std::string > & getManufactureList() const
Gets the list of all manufacture projects.
Definition: Mod.cpp:1942
Font * getFont(const std::string &name, bool error=true) const
Gets a particular font.
Definition: Mod.cpp:412
Stores the current ingame time/date according to GMT.
Definition: GameTime.h:38
Represents a specific type of armor.
Definition: Armor.h:35
ArticleDefinition * getUfopaediaArticle(const std::string &name, bool error=false) const
Gets Ufopaedia article definition.
Definition: Mod.cpp:1856
Sound * getSound(const std::string &set, unsigned int sound, bool error=true) const
Gets a particular sound.
Definition: Mod.cpp:559
int getTurnAIUseBlaster() const
Gets first turn when AI can use Blaster launcher.
Definition: Mod.h:386
const std::vector< std::string > & getCraftsList() const
Gets the available crafts.
Definition: Mod.cpp:1603
Represents a soldier hired by the player.
Definition: Soldier.h:48
RuleVideo * getVideo(const std::string &id, bool error=false) const
Gets a video for intro/outro etc.
Definition: Mod.cpp:2400
Represents the contents of the Geoscape globe, such as world polygons, polylines, etc...
Definition: RuleGlobe.h:36
Represents a specific type of craft.
Definition: RuleCraft.h:36
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
Represents one research project.
Definition: RuleResearch.h:38
Definition: RuleMissionScript.h:30
RuleBaseFacility * getBaseFacility(const std::string &id, bool error=false) const
Gets the ruleset for a facility type.
Definition: Mod.cpp:1573
Stores fixed information about a mission type.
Definition: RuleAlienMission.h:67
ArticleDefinition is the base class for all article types.
Definition: ArticleDefinition.h:54
const std::vector< std::string > & getRegionsList() const
Gets the available regions.
Definition: Mod.cpp:1563
const std::vector< std::string > & getItemsList() const
Gets the available items.
Definition: Mod.cpp:1647
An MCD data Patch.
Definition: MCDPatch.h:29
const RuleAlienMission * getRandomMission(MissionObjective objective, size_t monthsPassed) const
Gets the ruleset for a random alien mission.
Definition: Mod.cpp:1994
int getDefeatScore() const
Returns the minimum amount of score the player can have, otherwise they are defeated.
Definition: Mod.cpp:3408
Represents the information needed to manufacture an object.
Definition: RuleManufacture.h:30
Container for palettes (sets of 8bpp colors).
Definition: Palette.h:31
RuleConverter * getConverter() const
Gets the ruleset for the converter.
Definition: Mod.cpp:2367
int getAlienFuelQuantity() const
Gets the amount of alien fuel to recover.
Definition: Mod.cpp:2305
Represents the creation data for an X-COM unit.
Definition: RuleSoldier.h:35
Definition: RuleVideo.h:44
RuleCommendations * getCommendation(const std::string &id, bool error=false) const
Gets commendation rules.
Definition: Mod.cpp:1737
const std::vector< std::vector< int > > & getAlienItemLevels() const
Gets the alien item level table.
Definition: Mod.cpp:2033
Subclass of std::ifstream to handle CAT files.
Definition: CatFile.h:28
int getTurnAIUseGrenade() const
Gets first turn when AI can use grenade.
Definition: Mod.h:384
Unit * getUnit(const std::string &name, bool error=false) const
Gets generated unit rules.
Definition: Mod.cpp:1756
Represents a specific type of Alien Deployment.
Definition: AlienDeployment.h:63
SavedGame * newSave() const
Generates the starting saved game.
Definition: Mod.cpp:1406
const std::map< std::string, int > & getUfopaediaSections() const
For internal use only.
Definition: Mod.h:228
Palette * getPalette(const std::string &name, bool error=true) const
Gets a particular palette.
Definition: Mod.cpp:591
Surface * getSurface(const std::string &name, bool error=true)
Gets a particular surface.
Definition: Mod.cpp:442
RuleRegion * getRegion(const std::string &id, bool error=false) const
Gets the ruleset for a region type.
Definition: Mod.cpp:1553
Sound * getSoundByDepth(unsigned int depth, unsigned int sound, bool error=true) const
Returns a specific sound from either the land or underwater sound set.
Definition: Mod.cpp:635
Represents a specific type of UFO.
Definition: RuleUfo.h:35
const std::vector< SDL_Color > * getTransparencies() const
Gets the list of transparency colors,.
Definition: Mod.cpp:2377
Represents a specific funding country.
Definition: RuleCountry.h:31
MIDI track.
Definition: GMCat.cpp:40
Represents a specific type of Battlescape Terrain.
Definition: RuleTerrain.h:39
const std::vector< std::string > & getArmorsList() const
Gets the available armors.
Definition: Mod.cpp:1816
Subclass of CatFile to handle gm.cat files that contain MIDI music streams.
Definition: GMCat.h:31
const std::map< std::string, RuleCommendations * > & getCommendationsList() const
Gets the available commendations.
Definition: Mod.cpp:1746
const std::vector< std::string > & getCountriesList() const
Gets the available countries.
Definition: Mod.cpp:1543
std::vector< RuleBaseFacility * > getCustomBaseFacilities() const
Gets facilities for custom bases.
Definition: Mod.cpp:1953
Represents a specific region of the world.
Definition: RuleRegion.h:71
int getSoundOffset(int sound, const std::string &set) const
Gets the mod offset for a certain sound.
Definition: Mod.cpp:682
Represents a Terrain Map Datafile.
Definition: MapDataSet.h:37
const std::map< std::string, std::vector< ExtraSprites * > > & getExtraSprites() const
Gets the list of external Sprites.
Definition: Mod.cpp:2071
RuleInventory * getInventory(const std::string &id, bool error=false) const
Gets the ruleset for a specific inventory.
Definition: Mod.cpp:1895
const std::vector< std::string > & getUfopaediaList() const
Gets the available articles.
Definition: Mod.cpp:1866
Represents a specific type of craft weapon.
Definition: RuleCraftWeapon.h:35
Definition: BaseInfoState.cpp:40
Represents the static data for a unit that is generated on the battlescape, this includes: HWPs...
Definition: Unit.h:57
const std::vector< std::string > & getResearchList() const
Gets the list of all research projects.
Definition: Mod.cpp:1923
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:42
Represents a specific type of base facility.
Definition: RuleBaseFacility.h:35