1 /***************************************************************************
2  *      Mechanized Assault and Exploration Reloaded Projectfile            *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19 
20 #ifndef game_data_reports_savedreportH
21 #define game_data_reports_savedreportH
22 
23 #include <string>
24 #include <memory>
25 
26 #include "tinyxml2.h"
27 
28 class cNetMessage;
29 class cSoundManager;
30 class cPosition;
31 struct sID;
32 
33 enum class eSavedReportType
34 {
35 	// fixed numbers for save backward-compatibility
36 	// Simple reports
37 	MetalInsufficient    = 0,
38 	FuelInsufficient     = 1,
39 	GoldInsufficient     = 2,
40 	EnergyInsufficient   = 3,
41 	TeamInsufficient     = 4,
42 
43 	MetalLow             = 5,
44 	FuelLow              = 6,
45 	GoldLow              = 7,
46 	EnergyLow            = 8,
47 	TeamLow              = 9,
48 
49 	EnergyToLow          = 10,
50 	EnergyIsNeeded       = 11,
51 
52 	BuildingDisabled     = 12,
53 
54 	ProducingError       = 13,
55 
56 	TurnWait             = 14,
57 	TurnAutoMove         = 15,
58 
59 	// Special reports
60 	HostCommand          = 16,
61 
62 	ResourceChanged      = 17,
63 
64 	LostConnection       = 18,
65 
66 	PlayerEndedTurn      = 19,
67 	PlayerDefeated       = 20,
68 	PlayerLeft           = 21,
69 	Upgraded             = 22,
70 	TurnStart            = 23,
71 
72 	// Unit reports
73 	Attacked             = 24,
74 	AttackingEnemy       = 25,
75 	CapturedByEnemy      = 26,
76 	Destroyed            = 27,
77 	Detected             = 28,
78 	Disabled             = 29,
79 	PathInterrupted      = 30,
80 	SurveyorAiConfused   = 31,
81 	SurveyorAiSenseless  = 32,
82 
83 	// Chat report
84 	Chat                 = 33
85 };
86 
87 class cSavedReport
88 {
89 public:
~cSavedReport()90 	virtual ~cSavedReport() {}
91 
92 	virtual eSavedReportType getType() const = 0;
93 
94 	virtual std::string getMessage() const = 0;
95 
96 	virtual bool isAlert() const = 0;
97 
98 	virtual bool hasUnitId() const;
99 	virtual const sID& getUnitId() const;
100 
101 	virtual bool hasPosition() const;
102 	virtual const cPosition& getPosition() const;
103 
104 	virtual void playSound (cSoundManager& soundManager) const;
105 
106 	virtual void pushInto (cNetMessage& message) const;
107 	virtual void pushInto (tinyxml2::XMLElement& element) const;
108 
109 	static std::unique_ptr<cSavedReport> createFrom (cNetMessage& message);
110 	static std::unique_ptr<cSavedReport> createFrom (const tinyxml2::XMLElement& element);
111 };
112 
113 #endif // game_data_reports_savedreportH
114