engine: reject mbf21 and shit24 wads. there is no way to know if it is safe to ignore...
[k8vavoom.git] / source / utils / qs_data.h
blobb33ea9ee0b43a75d1cc158da699c629b46bcd30a
1 //**************************************************************************
2 //**
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
9 //**
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
21 //**
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 //** quicksave data
27 //**************************************************************************
28 #ifndef VAVOOM_QSDATA_HEADER
29 #define VAVOOM_QSDATA_HEADER
32 enum QSPhase {
33 QSP_None,
34 QSP_Load,
35 QSP_Save,
38 extern QSPhase qsPhase;
41 enum QSType {
42 QST_Void,
43 QST_Int,
44 QST_Name,
45 QST_Str,
46 QST_Float,
49 struct QSValue {
50 QSType type;
51 VEntity *ent; // owner (nullptr: player)
52 VStr name; // value name
53 // not a union
54 vint32 ival;
55 VName nval;
56 VStr sval;
57 float fval;
58 // used to map entities; 0 is player, 1.. -- entities
59 vint32 objidx;
61 QSValue ()
62 : type(QSType::QST_Void)
63 , ent(nullptr)
64 , name()
65 , ival(0)
66 , nval(NAME_None)
67 , sval()
68 , fval(0)
69 , objidx(0)
72 QSValue (VEntity *aent, VStr aname, QSType atype)
73 : type(atype)
74 , ent(aent)
75 , name(aname)
76 , ival(0)
77 , nval(NAME_None)
78 , sval()
79 , fval(0)
80 , objidx(0)
83 static inline QSValue CreateInt (VEntity *ent, VStr name, vint32 value) { QSValue aval(ent, name, QSType::QST_Int); aval.ival = value; return aval; }
84 static inline QSValue CreateName (VEntity *ent, VStr name, VName value) { QSValue aval(ent, name, QSType::QST_Name); aval.nval = value; return aval; }
85 static inline QSValue CreateStr (VEntity *ent, VStr name, VStr value) { QSValue aval(ent, name, QSType::QST_Str); aval.sval = value; return aval; }
86 static inline QSValue CreateFloat (VEntity *ent, VStr name, float value) { QSValue aval(ent, name, QSType::QST_Float); aval.fval = value; return aval; }
88 inline bool isEmpty () const { return (type == QSType::QST_Void); }
90 void Serialise (VStream &strm);
92 VStr toString () const;
96 extern TArray<QSValue> QS_GetCurrentArray ();
98 extern void QS_StartPhase (QSPhase aphase);
99 extern void QS_PutValue (const QSValue &val);
100 extern QSValue QS_GetValue (VEntity *ent, VStr name);
102 // this is used in loader to build qs data
103 extern void QS_EnterValue (const QSValue &val);
106 #endif