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::vector<std::pair<std::string, 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::vector<std::string> _countriesIndex, _regionsIndex, _facilitiesIndex, _craftsIndex, _craftWeaponsIndex, _itemsIndex, _invsIndex, _ufosIndex;
145 std::vector<std::string> _soldiersIndex, _aliensIndex, _deploymentsIndex, _armorsIndex, _ufopaediaIndex, _ufopaediaCatIndex, _researchIndex, _manufactureIndex, _MCDPatchesIndex;
146 std::vector<std::string> _alienMissionsIndex, _terrainIndex, _extraSpritesIndex, _extraSoundsIndex, _extraStringsIndex, _missionScriptIndex;
147 std::vector<std::vector<int> > _alienItemLevels;
148 std::vector<SDL_Color> _transparencies;
149 int _facilityListOrder, _craftListOrder, _itemListOrder, _researchListOrder, _manufactureListOrder, _ufopaediaListOrder, _invListOrder;
151 std::vector<std::string> _psiRequirements;
154 void loadFile(
const std::string &filename);
156 template <
typename T>
157 T *loadRule(
const YAML::Node &node, std::map<std::string, T*> *map, std::vector<std::string> *index = 0,
const std::string &key =
"type")
const;
159 template <
typename T>
160 T *getRule(
const std::string &
id,
const std::string &name,
const std::map<std::string, T*> &map,
bool error)
const;
162 Music *getRandomMusic(
const std::string &name)
const;
164 SoundSet *getSoundSet(
const std::string &name,
bool error =
true)
const;
166 void loadBattlescapeResources();
168 bool isImageFile(std::string extension)
const;
172 void createTransparencyLUT(
Palette *pal);
174 void loadMod(
const std::vector<std::string> &rulesetFiles,
size_t modIdx);
176 void loadVanillaResources();
178 void loadExtraResources();
184 static int DOOR_OPEN;
185 static int SLIDING_DOOR_OPEN;
186 static int SLIDING_DOOR_CLOSE;
187 static int SMALL_EXPLOSION;
188 static int LARGE_EXPLOSION;
189 static int EXPLOSION_OFFSET;
190 static int SMOKE_OFFSET;
191 static int UNDERWATER_SMOKE_OFFSET;
192 static int ITEM_DROP;
193 static int ITEM_THROW;
194 static int ITEM_RELOAD;
195 static int WALK_OFFSET;
196 static int FLYING_SOUND;
197 static int BUTTON_PRESS;
198 static int WINDOW_POPUP[3];
201 static int UFO_CRASH;
202 static int UFO_EXPLODE;
203 static int INTERCEPTOR_HIT;
204 static int INTERCEPTOR_EXPLODE;
205 static int GEOSCAPE_CURSOR;
206 static int BASESCAPE_CURSOR;
207 static int BATTLESCAPE_CURSOR;
208 static int UFOPAEDIA_CURSOR;
209 static int GRAPHS_CURSOR;
210 static int DAMAGE_RANGE;
211 static int EXPLOSIVE_DAMAGE_RANGE;
212 static int FIRE_DAMAGE_RANGE[2];
213 static std::string DEBRIEF_MUSIC_GOOD;
214 static std::string DEBRIEF_MUSIC_BAD;
215 static int DIFFICULTY_COEFFICIENT[5];
217 static void resetGlobalStatics();
224 Font *
getFont(
const std::string &name,
bool error =
true)
const;
230 Music *
getMusic(
const std::string &name,
bool error =
true)
const;
232 void playMusic(
const std::string &name,
int id = 0);
234 Sound *
getSound(
const std::string &
set,
unsigned int sound,
bool error =
true)
const;
238 void setPalette(SDL_Color *colors,
int firstcolor = 0,
int ncolors = 256);
244 const std::vector<std::vector<Uint8> > *
getLUTs()
const;
253 void loadAll(
const std::vector< std::pair< std::string, std::vector<std::string> > > &mods);
281 RuleUfo *
getUfo(
const std::string &
id,
bool error =
false)
const;
283 const std::vector<std::string> &
getUfosList()
const;
297 Unit *
getUnit(
const std::string &name,
bool error =
false)
const;
307 Armor *
getArmor(
const std::string &name,
bool error =
false)
const;
353 std::vector<std::pair<std::string, ExtraSprites *> >
getExtraSprites()
const;
355 std::vector<std::pair<std::string, ExtraSounds *> >
getExtraSounds()
const;
363 const std::vector<std::string> &
getInvsList()
const;
388 const std::vector<MapScript*> *getMapScript(
const std::string&
id)
const;
391 const std::map<std::string, RuleMusic *> *getMusic()
const;
392 const std::vector<std::string> *getMissionScriptList()
const;
393 RuleMissionScript *getMissionScript(
const std::string &name,
bool error =
false)
const;
394 std::string getFinalResearch()
const;
RuleUfo * getUfo(const std::string &id, bool error=false) const
Gets the ruleset for a UFO type.
Definition: Mod.cpp:1573
RuleSoldier * getSoldier(const std::string &name, bool error=false) const
Gets soldier unit rules.
Definition: Mod.cpp:1633
RuleItem * getItem(const std::string &id, bool error=false) const
Gets the ruleset for an item type.
Definition: Mod.cpp:1549
const std::map< std::string, SoundDefinition * > * getSoundDefinitions() const
Gets the list of selective files for insertion into our cat files.
Definition: Mod.cpp:2266
const RuleAlienMission * getAlienMission(const std::string &id, bool error=false) const
Gets the ruleset for a specific alien mission.
Definition: Mod.cpp:1890
int getDefeatFunds() const
Returns the minimum amount of funds the player can have, otherwise they are defeated.
Definition: Mod.cpp:3479
RuleInterface * getInterface(const std::string &id, bool error=true) const
Gets information on an interface element.
Definition: Mod.cpp:2243
const UfoTrajectory * getUfoTrajectory(const std::string &id, bool error=false) const
Gets a specific UfoTrajectory.
Definition: Mod.cpp:1880
std::vector< std::string > getPsiRequirements() const
Gets the research-requirements for Psi-Lab (it's a cache for psiStrengthEval)
Definition: Mod.cpp:2133
int getModOffset() const
Gets the mod offset.
Definition: Mod.cpp:628
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:667
~Mod()
Cleans up the mod.
Definition: Mod.cpp:209
RuleTerrain * getTerrain(const std::string &name, bool error=false) const
Gets terrains for battlescape games.
Definition: Mod.cpp:1593
int getMinRadarRange() const
Gets the minimum radar's range.
Definition: Mod.cpp:2217
Mod()
Creates a blank mod.
Definition: Mod.cpp:190
Container of a set of sounds.
Definition: SoundSet.h:33
const std::vector< std::string > & getSoldiersList() const
Gets the available soldiers.
Definition: Mod.cpp:1643
RuleGlobe * getGlobe() const
Gets the ruleset for the globe.
Definition: Mod.cpp:2252
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:1930
SurfaceSet * getSurfaceSet(const std::string &name, bool error=true) const
Gets a particular surface set.
Definition: Mod.cpp:427
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:1603
Soldier * genSoldier(SavedGame *save, std::string type="") const
Generates a new soldier.
Definition: Mod.cpp:2144
std::vector< std::pair< std::string, ExtraSprites * > > getExtraSprites() const
Gets the list of external Sprites.
Definition: Mod.cpp:1977
std::map< std::string, RuleCommendations * > getCommendation() const
Gets commendation rules.
Definition: Mod.cpp:1652
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:486
int getPersonnelTime() const
Gets the transfer time of personnel.
Definition: Mod.cpp:1752
MapDataSet * getMapDataSet(const std::string &name)
Gets mapdatafile for battlescape games.
Definition: Mod.cpp:1613
std::string getAlienFuelName() const
Gets the item to be used as fuel for ships.
Definition: Mod.cpp:2190
const std::vector< std::string > & getUfosList() const
Gets the available UFOs.
Definition: Mod.cpp:1583
RuleCraft * getCraft(const std::string &id, bool error=false) const
Gets the ruleset for a craft type.
Definition: Mod.cpp:1509
Definition: RuleInterface.h:35
const std::vector< std::vector< Uint8 > > * getLUTs() const
Gets list of LUT data.
Definition: Mod.cpp:619
AlienDeployment * getDeployment(const std::string &name, bool error=false) const
Gets deployment rules.
Definition: Mod.cpp:1692
Container for sound effects.
Definition: Sound.h:30
Armor * getArmor(const std::string &name, bool error=false) const
Gets armor rules.
Definition: Mod.cpp:1712
std::string getFontName() const
Gets the font name.
Definition: Mod.cpp:2208
const std::vector< std::string > & getDeploymentsList() const
Gets the available alien deployments.
Definition: Mod.cpp:1702
const std::vector< std::string > & getBaseFacilitiesList() const
Gets the available facilities.
Definition: Mod.cpp:1499
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets a new palette.
Definition: Mod.cpp:575
AlienRace * getAlienRace(const std::string &name, bool error=false) const
Gets alien race rules.
Definition: Mod.cpp:1672
RuleCraftWeapon * getCraftWeapon(const std::string &id, bool error=false) const
Gets the ruleset for a craft weapon type.
Definition: Mod.cpp:1529
Represents a specific type of item.
Definition: RuleItem.h:40
std::map< std::string, RuleInventory * > * getInventories()
Gets the inventory list.
Definition: Mod.cpp:1791
const GameTime & getStartingTime() const
Gets the game starting time.
Definition: Mod.cpp:1957
Container of a set of surfaces.
Definition: SurfaceSet.h:35
int getScientistCost() const
Gets the cost of a scientist.
Definition: Mod.cpp:1742
const YAML::Node & getStartingBase() const
Gets the player starting base.
Definition: Mod.cpp:1948
const std::vector< std::string > & getUfopaediaCategoryList() const
Gets the available article categories.
Definition: Mod.cpp:1782
RuleManufacture * getManufacture(const std::string &id, bool error=false) const
Gets the ruleset for a specific manufacture project.
Definition: Mod.cpp:1839
int getSpriteOffset(int sprite, const std::string &set) const
Gets the mod offset for a certain sprite.
Definition: Mod.cpp:639
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:45
std::vector< std::pair< std::string, ExtraSounds * > > getExtraSounds() const
Gets the list of external Sounds.
Definition: Mod.cpp:1986
const std::vector< std::string > & getInvsList() const
Returns the sorted list of inventories.
Definition: Mod.cpp:1810
const std::vector< std::string > & getAlienRacesList() const
Gets the available alien races.
Definition: Mod.cpp:1682
const std::vector< std::string > & getCraftWeaponsList() const
Gets the available craft weapons.
Definition: Mod.cpp:1539
Represents a specific race "family", or a "main race" if you wish.
Definition: AlienRace.h:33
std::vector< Uint16 > * getVoxelData()
Gets list of voxel data.
Definition: Mod.cpp:596
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:1449
int getEngineerCost() const
Gets the cost of an engineer.
Definition: Mod.cpp:1732
RuleResearch * getResearch(const std::string &id, bool error=false) const
Gets the ruleset for a specific research project.
Definition: Mod.cpp:1820
const std::vector< std::string > & getManufactureList() const
Gets the list of all manufacture projects.
Definition: Mod.cpp:1848
Font * getFont(const std::string &name, bool error=true) const
Gets a particular font.
Definition: Mod.cpp:407
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:1762
Sound * getSound(const std::string &set, unsigned int sound, bool error=true) const
Gets a particular sound.
Definition: Mod.cpp:532
int getTurnAIUseBlaster() const
Gets first turn when AI can use Blaster launcher.
Definition: Mod.h:375
std::vector< StatString * > getStatStrings() const
Gets the list of StatStrings.
Definition: Mod.cpp:2004
const std::vector< std::string > & getCraftsList() const
Gets the available crafts.
Definition: Mod.cpp:1519
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:2294
Represents the contents of the Geoscape globe, such as world polygons, polylines, etc...
Definition: RuleGlobe.h:36
MCDPatch * getMCDPatch(const std::string &name) const
Gets an MCDPatch.
Definition: Mod.cpp:1967
Represents a specific type of craft.
Definition: RuleCraft.h:36
Element that is blit (rendered) onto the screen.
Definition: Surface.h:36
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:1489
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:1479
const std::vector< std::string > & getItemsList() const
Gets the available items.
Definition: Mod.cpp:1563
An MCD data Patch.
Definition: MCDPatch.h:30
const RuleAlienMission * getRandomMission(MissionObjective objective, size_t monthsPassed) const
Gets the ruleset for a random alien mission.
Definition: Mod.cpp:1900
int getDefeatScore() const
Returns the minimum amount of score the player can have, otherwise they are defeated.
Definition: Mod.cpp:3469
Represents the information needed to manufacture an object.
Definition: RuleManufacture.h:30
std::map< std::string, ExtraStrings * > getExtraStrings() const
Gets the list of external Strings.
Definition: Mod.cpp:1995
Container for palettes (sets of 8bpp colors).
Definition: Palette.h:31
RuleConverter * getConverter() const
Gets the ruleset for the converter.
Definition: Mod.cpp:2261
int getAlienFuelQuantity() const
Gets the amount of alien fuel to recover.
Definition: Mod.cpp:2199
Represents the creation data for an X-COM unit.
Definition: RuleSoldier.h:35
Definition: RuleVideo.h:44
const std::vector< std::vector< int > > & getAlienItemLevels() const
Gets the alien item level table.
Definition: Mod.cpp:1939
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:373
Music * getMusic(const std::string &name, bool error=true) const
Gets a particular music.
Definition: Mod.cpp:437
Unit * getUnit(const std::string &name, bool error=false) const
Gets generated unit rules.
Definition: Mod.cpp:1662
Represents a specific type of Alien Deployment.
Definition: AlienDeployment.h:63
SavedGame * newSave() const
Generates the starting saved game.
Definition: Mod.cpp:1325
Palette * getPalette(const std::string &name, bool error=true) const
Gets a particular palette.
Definition: Mod.cpp:564
RuleRegion * getRegion(const std::string &id, bool error=false) const
Gets the ruleset for a region type.
Definition: Mod.cpp:1469
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:607
Represents a specific type of UFO.
Definition: RuleUfo.h:35
Surface * getSurface(const std::string &name, bool error=true) const
Gets a particular surface.
Definition: Mod.cpp:417
const std::vector< SDL_Color > * getTransparencies() const
Gets the list of transparency colors,.
Definition: Mod.cpp:2271
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:1722
Subclass of CatFile to handle gm.cat files that contain MIDI music streams.
Definition: GMCat.h:31
const std::vector< std::string > & getCountriesList() const
Gets the available countries.
Definition: Mod.cpp:1459
std::vector< RuleBaseFacility * > getCustomBaseFacilities() const
Gets facilities for custom bases.
Definition: Mod.cpp:1859
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:654
Represents a Terrain Map Datafile.
Definition: MapDataSet.h:37
RuleInventory * getInventory(const std::string &id, bool error=false) const
Gets the ruleset for a specific inventory.
Definition: Mod.cpp:1801
const std::vector< std::string > & getUfopaediaList() const
Gets the available articles.
Definition: Mod.cpp:1772
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:1829
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