2014-07-25 04:30:44 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef _GAMESTATE_HPP_
|
|
|
|
#define _GAMESTATE_HPP_
|
|
|
|
#include <glm/glm.hpp>
|
2015-01-26 02:16:25 +01:00
|
|
|
#include <glm/gtx/quaternion.hpp>
|
2014-07-27 01:38:01 +02:00
|
|
|
#include <string>
|
2014-07-30 14:44:25 +02:00
|
|
|
#include <map>
|
2014-07-30 16:48:51 +02:00
|
|
|
#include <vector>
|
2015-05-01 04:53:42 +02:00
|
|
|
#include <objects/ObjectTypes.hpp>
|
2014-07-25 04:30:44 +02:00
|
|
|
|
2015-04-27 16:31:39 +02:00
|
|
|
class GameWorld;
|
2014-12-17 01:39:52 +01:00
|
|
|
class GameObject;
|
2015-06-14 03:44:51 +02:00
|
|
|
class ScriptMachine;
|
2014-07-25 04:30:44 +02:00
|
|
|
class PlayerController;
|
2014-08-11 18:58:43 +02:00
|
|
|
struct CutsceneData;
|
2014-07-25 04:30:44 +02:00
|
|
|
|
2016-04-09 03:21:22 +02:00
|
|
|
struct SystemTime
|
|
|
|
{
|
|
|
|
uint16_t year;
|
|
|
|
uint16_t month;
|
|
|
|
uint16_t dayOfWeek;
|
|
|
|
uint16_t day;
|
|
|
|
uint16_t hour;
|
|
|
|
uint16_t minute;
|
|
|
|
uint16_t second;
|
|
|
|
uint16_t millisecond;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Block 0 State */
|
|
|
|
struct BasicState
|
|
|
|
{
|
|
|
|
/// /!\ This is wchar_t[24] in the original format /!\ we convert on load for convenience
|
|
|
|
char saveName[48];
|
|
|
|
SystemTime saveTime;
|
2016-04-09 23:29:32 +02:00
|
|
|
uint32_t unknown;
|
2016-04-09 03:21:22 +02:00
|
|
|
uint16_t islandNumber;
|
|
|
|
glm::vec3 cameraPosition;
|
2016-04-09 23:29:32 +02:00
|
|
|
uint32_t gameMinuteMS;
|
|
|
|
uint32_t lastTick;
|
2016-04-09 03:21:22 +02:00
|
|
|
uint8_t gameHour;
|
|
|
|
uint8_t _align0[3];
|
|
|
|
uint8_t gameMinute;
|
|
|
|
uint8_t _align1[3];
|
|
|
|
uint16_t padMode;
|
|
|
|
uint8_t _align2[2];
|
2016-04-09 23:29:32 +02:00
|
|
|
uint32_t timeMS;
|
2016-04-09 03:21:22 +02:00
|
|
|
float timeScale;
|
|
|
|
float timeStep;
|
|
|
|
float timeStep_unclipped; // Unknown purpose
|
2016-04-09 23:29:32 +02:00
|
|
|
uint32_t frameCounter;
|
2016-04-09 03:21:22 +02:00
|
|
|
float timeStep2;
|
|
|
|
float framesPerUpdate;
|
|
|
|
float timeScale2;
|
|
|
|
uint16_t lastWeather;
|
|
|
|
uint8_t _align3[2];
|
|
|
|
uint16_t nextWeather;
|
|
|
|
uint8_t _align4[2];
|
|
|
|
uint16_t forcedWeather;
|
|
|
|
uint8_t _align5[2];
|
|
|
|
float weatherInterpolation;
|
|
|
|
uint8_t dateTime[24]; // Unused
|
2016-04-09 23:29:32 +02:00
|
|
|
uint32_t weatherType;
|
2016-04-09 03:21:22 +02:00
|
|
|
float cameraData;
|
|
|
|
float cameraData2;
|
|
|
|
};
|
|
|
|
|
2016-04-09 23:29:32 +02:00
|
|
|
/** Block 15 player info */
|
|
|
|
struct PlayerInfo
|
|
|
|
{
|
|
|
|
uint16_t money;
|
|
|
|
uint8_t unknown1;
|
|
|
|
uint16_t unknown2;
|
|
|
|
uint8_t unknown3;
|
|
|
|
float unknown4;
|
|
|
|
uint16_t displayedMoney;
|
|
|
|
uint16_t hiddenPackagesCollected;
|
|
|
|
uint16_t hiddenPackageCount;
|
|
|
|
uint8_t neverTired;
|
|
|
|
uint8_t fastReload;
|
|
|
|
uint8_t thaneOfLibertyCity;
|
|
|
|
uint8_t singlePayerHealthcare;
|
|
|
|
uint8_t unknown5[70];
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Block 17 */
|
|
|
|
struct GameStats
|
|
|
|
{
|
|
|
|
uint16_t playerKills;
|
|
|
|
uint16_t otherKills;
|
|
|
|
uint16_t carsExploded;
|
|
|
|
uint16_t shotsHit;
|
|
|
|
uint16_t pedTypesKilled[23];
|
|
|
|
uint16_t helicoptersDestroyed;
|
|
|
|
uint16_t playerProgress;
|
|
|
|
uint16_t explosiveKgsUsed;
|
|
|
|
uint16_t bulletsFired;
|
|
|
|
uint16_t bulletsHit;
|
|
|
|
uint16_t carsCrushed;
|
|
|
|
uint16_t headshots;
|
|
|
|
uint16_t timesBusted;
|
|
|
|
uint16_t timesHospital;
|
|
|
|
uint16_t daysPassed;
|
|
|
|
uint16_t mmRainfall;
|
|
|
|
uint16_t insaneJumpMaxDistance;
|
|
|
|
uint16_t insaneJumpMaxHeight;
|
|
|
|
uint16_t insaneJumpMaxFlips;
|
|
|
|
uint16_t insangeJumpMaxRotation;
|
|
|
|
/*
|
|
|
|
* 0 none completed
|
|
|
|
* 1 insane stunt
|
|
|
|
* 2 perfect insane stunt
|
|
|
|
* 3 double insane stunt
|
|
|
|
* 4 perfect double insane stunt
|
|
|
|
* 5 triple insane stunt
|
|
|
|
* 6 perfect " " "
|
|
|
|
* 7 quadruple
|
|
|
|
* 8 perfect quadruple
|
|
|
|
*/
|
|
|
|
uint16_t bestStunt;
|
|
|
|
uint16_t uniqueStuntsFound;
|
|
|
|
uint16_t uniqueStuntsTotal;
|
|
|
|
uint16_t missionAttempts;
|
|
|
|
uint16_t missionsPassed;
|
|
|
|
uint16_t passengersDroppedOff;
|
|
|
|
uint16_t taxiRevenue;
|
|
|
|
uint16_t portlandPassed;
|
|
|
|
uint16_t stauntonPassed;
|
|
|
|
uint16_t shoresidePassed;
|
|
|
|
uint16_t bestTurismoTime;
|
|
|
|
float distanceWalked;
|
|
|
|
float distanceDriven;
|
|
|
|
uint16_t patriotPlaygroundTime;
|
|
|
|
uint16_t aRideInTheParkTime;
|
|
|
|
uint16_t grippedTime;
|
|
|
|
uint16_t multistoryMayhemTime;
|
|
|
|
uint16_t peopleSaved;
|
|
|
|
uint16_t criminalsKilled;
|
|
|
|
uint16_t highestParamedicLevel;
|
|
|
|
uint16_t firesExtinguished;
|
|
|
|
uint16_t longestDodoFlight;
|
|
|
|
uint16_t bombDefusalTime;
|
|
|
|
uint16_t rampagesPassed;
|
|
|
|
uint16_t totalRampages;
|
|
|
|
uint16_t totalMissions;
|
|
|
|
uint16_t fastestTime[16]; // not used
|
|
|
|
uint16_t highestScore[16];
|
|
|
|
uint16_t peopleKilledSinceCheckpoint; // ?
|
|
|
|
uint16_t peopleKilledSinceLastBustedOrWasted;
|
|
|
|
char lastMissionGXT[8];
|
|
|
|
};
|
|
|
|
|
2014-07-30 16:48:51 +02:00
|
|
|
struct TextDisplayData
|
|
|
|
{
|
|
|
|
// This is set by the final display text command.
|
|
|
|
std::string text;
|
|
|
|
glm::vec2 position;
|
|
|
|
|
|
|
|
glm::vec4 colourFG;
|
|
|
|
glm::vec4 colourBG;
|
|
|
|
};
|
|
|
|
|
2014-12-16 20:17:22 +01:00
|
|
|
struct OnscreenText
|
|
|
|
{
|
2014-12-17 01:39:52 +01:00
|
|
|
std::string id;
|
2014-12-16 20:17:22 +01:00
|
|
|
std::string osTextString;
|
|
|
|
float osTextStart;
|
|
|
|
float osTextTime;
|
|
|
|
unsigned short osTextStyle;
|
2015-05-09 05:02:15 +02:00
|
|
|
std::string osTextVar;
|
2015-02-15 13:41:51 +01:00
|
|
|
|
|
|
|
enum /*TextStyle*/
|
|
|
|
{
|
|
|
|
/// Used for subtitles
|
|
|
|
HighPriority = 0,
|
|
|
|
/// Mission completed message
|
|
|
|
CenterBig = 1,
|
|
|
|
/// Right aligned mission names
|
|
|
|
MissionName = 2,
|
|
|
|
/// Help text (top left, black background)
|
|
|
|
Help = 12
|
|
|
|
};
|
2016-04-28 01:54:42 +02:00
|
|
|
|
|
|
|
OnscreenText(const std::string& id,
|
|
|
|
const std::string& string,
|
|
|
|
float start,
|
|
|
|
float time,
|
|
|
|
unsigned short style,
|
|
|
|
const std::string& var = "")
|
|
|
|
: id (id)
|
|
|
|
, osTextString(string)
|
|
|
|
, osTextStart(start)
|
|
|
|
, osTextTime(time)
|
|
|
|
, osTextStyle(style)
|
|
|
|
, osTextVar(var)
|
|
|
|
{ }
|
2014-12-16 20:17:22 +01:00
|
|
|
};
|
|
|
|
|
2014-12-16 00:56:47 +01:00
|
|
|
/**
|
|
|
|
* Stores information about where the game can generate vehicles.
|
|
|
|
*/
|
|
|
|
struct VehicleGenerator
|
|
|
|
{
|
|
|
|
glm::vec3 position;
|
|
|
|
float heading;
|
|
|
|
/** ID of the vehicle to spawn, or -1 for random. */
|
|
|
|
int vehicleID;
|
|
|
|
int colourFG;
|
|
|
|
int colourBG;
|
|
|
|
bool alwaysSpawn;
|
|
|
|
short alarmThreshold;
|
|
|
|
short lockedThreshold;
|
|
|
|
|
|
|
|
int minDelay;
|
|
|
|
int maxDelay;
|
|
|
|
/** Incrementing timer (in ms), will only spawn a vehicle when minDelay < spawnTimer and will always spawn if maxDelay < spawnTimer */
|
|
|
|
int lastSpawnTime;
|
|
|
|
|
|
|
|
/** Number of vehicles left to spawn 0-100, 101 = never decrement. */
|
|
|
|
int remainingSpawns;
|
|
|
|
};
|
|
|
|
|
2015-01-26 02:16:25 +01:00
|
|
|
/**
|
|
|
|
* Data about a blip
|
|
|
|
*/
|
|
|
|
struct BlipData
|
|
|
|
{
|
|
|
|
int id;
|
2015-06-24 02:48:26 +02:00
|
|
|
|
|
|
|
enum BlipType
|
|
|
|
{
|
|
|
|
Location = 0,
|
|
|
|
Vehicle = 1,
|
|
|
|
Pickup = 2,
|
|
|
|
Character = 3,
|
|
|
|
};
|
|
|
|
BlipType type;
|
2015-05-03 06:22:03 +02:00
|
|
|
GameObjectID target;
|
2015-01-26 02:16:25 +01:00
|
|
|
// If target is null then use coord
|
|
|
|
glm::vec3 coord;
|
|
|
|
|
|
|
|
/* Texture for use in the radar */
|
|
|
|
std::string texture;
|
2015-01-27 01:48:09 +01:00
|
|
|
|
|
|
|
enum DisplayMode
|
|
|
|
{
|
|
|
|
Hide = 0,
|
|
|
|
RadarOnly = 1,
|
|
|
|
Show = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Should the blip be displayed? */
|
|
|
|
DisplayMode display;
|
|
|
|
|
|
|
|
BlipData()
|
2015-06-24 02:48:26 +02:00
|
|
|
: id(-1), type(Location), target(0), display(Show)
|
2015-01-27 01:48:09 +01:00
|
|
|
{ }
|
2015-01-26 02:16:25 +01:00
|
|
|
};
|
|
|
|
|
2015-06-14 03:44:51 +02:00
|
|
|
/**
|
|
|
|
* Data for garages
|
|
|
|
*/
|
|
|
|
struct GarageInfo
|
|
|
|
{
|
|
|
|
enum /*GarageType*/ {
|
|
|
|
GARAGE_MISSION = 1,
|
|
|
|
GARAGE_BOMBSHOP1 = 2,
|
|
|
|
GARAGE_BOMBSHOP2 = 3,
|
|
|
|
GARAGE_BOMBSHOP3 = 4,
|
|
|
|
GARAGE_RESPRAY = 5,
|
|
|
|
GARAGE_INVALID = 6,
|
|
|
|
GARAGE_SPECIFIC_CARS_ONLY = 7, /* See Opcode 0x21B */
|
|
|
|
GARAGE_COLLECTCARS1 = 8, /* See Opcode 0x03D4 */
|
|
|
|
GARAGE_COLLECTCARS2 = 9,
|
|
|
|
GARAGE_COLLECTCARS3 = 10, /* Unused */
|
|
|
|
GARAGE_OPENFOREXIT = 11,
|
|
|
|
GARAGE_INVALID2 = 12,
|
|
|
|
GARAGE_CRUSHER = 13, /* Unused */
|
|
|
|
GARAGE_MISSION_KEEPCAR = 14,
|
|
|
|
GARAGE_FOR_SCRIPT = 15,
|
|
|
|
GARAGE_HIDEOUT_ONE = 16, /* Portland */
|
|
|
|
GARAGE_HIDEOUT_TWO = 17, /* Staunton */
|
|
|
|
GARAGE_HIDEOUT_THREE = 18, /* Shoreside */
|
|
|
|
GARAGE_FOR_SCRIPT2 = 19,
|
|
|
|
GARAGE_OPENS_FOR_SPECIFIC_CAR = 20,
|
|
|
|
GARAGE_OPENS_ONCE = 21
|
|
|
|
};
|
|
|
|
glm::vec3 min;
|
|
|
|
glm::vec3 max;
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
2015-04-27 04:55:18 +02:00
|
|
|
/**
|
2015-04-27 16:31:39 +02:00
|
|
|
* Gameplay state object that holds persistent state, and references runtime
|
|
|
|
* world state.
|
2015-04-27 04:55:18 +02:00
|
|
|
*/
|
2014-07-25 04:30:44 +02:00
|
|
|
struct GameState
|
|
|
|
{
|
2016-04-09 23:29:32 +02:00
|
|
|
/**
|
|
|
|
Basic Game State
|
|
|
|
*/
|
|
|
|
BasicState basic;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Player stats
|
|
|
|
*/
|
|
|
|
PlayerInfo playerInfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Game Stats
|
|
|
|
*/
|
|
|
|
GameStats gameStats;
|
|
|
|
|
2015-05-03 06:22:03 +02:00
|
|
|
/**
|
|
|
|
* Second since game was started
|
|
|
|
*/
|
|
|
|
float gameTime;
|
2015-01-22 12:11:16 +01:00
|
|
|
unsigned int currentProgress;
|
2014-07-25 04:30:44 +02:00
|
|
|
unsigned int maxProgress;
|
2016-04-09 23:29:32 +02:00
|
|
|
|
2014-07-25 04:30:44 +02:00
|
|
|
unsigned int maxWantedLevel;
|
2015-07-02 00:16:06 +02:00
|
|
|
|
2015-05-01 04:53:42 +02:00
|
|
|
GameObjectID playerObject;
|
2014-07-25 04:30:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stores a pointer to script global that stores the on-mission state.
|
|
|
|
*/
|
|
|
|
unsigned int *scriptOnMissionFlag;
|
2014-12-17 23:53:25 +01:00
|
|
|
|
2015-03-30 04:34:03 +02:00
|
|
|
/** Objects created by the current mission */
|
2015-05-01 04:53:42 +02:00
|
|
|
std::vector<GameObjectID> missionObjects;
|
2015-03-30 04:34:03 +02:00
|
|
|
|
2014-12-17 23:53:25 +01:00
|
|
|
bool overrideNextStart;
|
|
|
|
glm::vec4 nextRestartLocation;
|
2014-07-25 04:30:44 +02:00
|
|
|
|
2014-07-28 03:27:55 +02:00
|
|
|
bool fadeOut;
|
2014-07-27 01:38:01 +02:00
|
|
|
float fadeStart;
|
2014-07-25 04:30:44 +02:00
|
|
|
float fadeTime;
|
2014-07-27 01:38:01 +02:00
|
|
|
bool fadeSound;
|
2014-07-28 03:27:55 +02:00
|
|
|
glm::u16vec3 fadeColour;
|
|
|
|
|
2014-08-01 23:03:00 +02:00
|
|
|
std::string currentSplash;
|
|
|
|
|
2014-12-17 01:39:52 +01:00
|
|
|
bool skipCutscene;
|
2014-07-25 04:30:44 +02:00
|
|
|
bool isIntroPlaying;
|
2014-07-28 03:27:55 +02:00
|
|
|
CutsceneData* currentCutscene;
|
2014-07-27 01:38:01 +02:00
|
|
|
float cutsceneStartTime;
|
2014-12-16 20:17:22 +01:00
|
|
|
/** Flag for rendering cutscene letterbox */
|
|
|
|
bool isCinematic;
|
|
|
|
|
2015-01-22 12:11:16 +01:00
|
|
|
std::string lastMissionName;
|
2014-12-16 20:17:22 +01:00
|
|
|
|
2014-07-30 14:44:25 +02:00
|
|
|
/// Stores the "special" character and cutscene model indices.
|
|
|
|
std::map<unsigned short, std::string> specialCharacters;
|
|
|
|
std::map<unsigned short, std::string> specialModels;
|
|
|
|
|
2015-04-05 03:08:51 +02:00
|
|
|
/**
|
|
|
|
* Stores long-lasting on screen messages
|
|
|
|
*/
|
2014-12-16 20:17:22 +01:00
|
|
|
std::vector<OnscreenText> text;
|
|
|
|
|
2014-07-30 16:48:51 +02:00
|
|
|
TextDisplayData nextText;
|
2015-04-05 03:08:51 +02:00
|
|
|
/**
|
|
|
|
* Stores temporary, one-tick messages
|
|
|
|
*/
|
2014-07-30 16:48:51 +02:00
|
|
|
std::vector<TextDisplayData> texts;
|
|
|
|
|
2014-08-12 22:15:26 +02:00
|
|
|
/** The camera near value currently set by the script */
|
|
|
|
float cameraNear;
|
2014-12-16 20:17:22 +01:00
|
|
|
bool cameraFixed;
|
|
|
|
glm::vec3 cameraPosition;
|
|
|
|
glm::quat cameraRotation;
|
2015-05-01 04:53:42 +02:00
|
|
|
|
|
|
|
GameObjectID cameraTarget;
|
2014-12-17 01:39:52 +01:00
|
|
|
|
2014-12-16 00:56:47 +01:00
|
|
|
std::vector<VehicleGenerator> vehicleGenerators;
|
2015-01-26 02:16:25 +01:00
|
|
|
|
|
|
|
std::map<int, BlipData> radarBlips;
|
2014-08-12 22:15:26 +02:00
|
|
|
|
2015-06-14 03:44:51 +02:00
|
|
|
std::vector<GarageInfo> garages;
|
|
|
|
|
2015-04-27 16:31:39 +02:00
|
|
|
/**
|
|
|
|
* World to use for this state, this isn't saved, just used at runtime
|
|
|
|
*/
|
|
|
|
GameWorld* world;
|
|
|
|
|
2015-06-14 03:44:51 +02:00
|
|
|
/**
|
|
|
|
* Script Machine associated with this state if it exists.
|
|
|
|
*/
|
|
|
|
ScriptMachine* script;
|
|
|
|
|
2015-04-27 04:55:18 +02:00
|
|
|
GameState();
|
|
|
|
|
2015-01-26 02:16:25 +01:00
|
|
|
/**
|
|
|
|
* Adds a blip to the state, returning it's ID.
|
|
|
|
*/
|
|
|
|
int addRadarBlip(BlipData& blip);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a blip
|
|
|
|
*/
|
|
|
|
void removeBlip(int blip);
|
2014-07-25 04:30:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|