Skip to content

Commit a4b08b7

Browse files
allow to set complevel by COMPDB lump (#2125)
* allow to set complevel by COMPDB lump Fixes #2121 * do not apply comp[] options in complevel Vanilla * check for DV_NONE, do not apply comp options if not MBF21 * minor restructuring * do not even need old_demover, it will always be MBF21 anyway * fix blank line in compdb.lmp
1 parent bfe338f commit a4b08b7

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

base/all-all/compdb.lmp

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
}
2020
]
2121
},
22+
{
23+
"name": "doomsday_of_uac_e1m8",
24+
"md5": "32fc3115a3162b623f0d0f4e7dee6861",
25+
"complevel": "1.9"
26+
},
2227
{
2328
"name": "hell_revealed_map19",
2429
"md5": "811a0c97777a198bc9b2bb558cb46e6a",
@@ -34,7 +39,6 @@
3439
"md5": "145c4dfcf843f2b92c73036ba0e1d98a",
3540
"options": [ {"name": "comp_vile", "value": 1} ]
3641
},
37-
3842
{
3943
"name": "hell_to_pay_map14",
4044
"md5": "5379c080299eb961792b50ad96821543",

src/g_compatibility.c

+37-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "doomstat.h"
2222
#include "doomtype.h"
23+
#include "g_game.h"
2324
#include "i_printf.h"
2425
#include "m_array.h"
2526
#include "m_misc.h"
@@ -77,6 +78,7 @@ typedef struct
7778
{
7879
md5_digest_t checksum;
7980
option_t *options;
81+
demo_version_t complevel;
8082
} comp_record_t;
8183

8284
static comp_record_t *comp_database;
@@ -125,6 +127,18 @@ void G_ParseCompDatabase(void)
125127
I_Printf(VB_ERROR, "COMPDB: wrong key %s", md5);
126128
continue;
127129
}
130+
131+
record.complevel = DV_MBF21;
132+
const char *complevel = JS_GetStringValue(level, "complevel");
133+
if (complevel)
134+
{
135+
demo_version_t new_complevel = G_GetNamedComplevel(complevel);
136+
if (new_complevel != DV_NONE)
137+
{
138+
record.complevel = new_complevel;
139+
}
140+
}
141+
128142
json_t *js_options = JS_GetObject(level, "options");
129143
json_t *js_option = NULL;
130144
JS_ArrayForEach(js_option, js_options)
@@ -184,19 +198,23 @@ static void GetLevelCheckSum(int lump, md5_checksum_t* cksum)
184198

185199
void G_ApplyLevelCompatibility(int lump)
186200
{
187-
if (demorecording || demoplayback || netgame || !mbf21)
188-
{
189-
return;
190-
}
191-
192201
static boolean restore_comp;
193202
static int old_comp[COMP_TOTAL];
194203

195204
if (restore_comp)
196205
{
206+
if (demo_version != DV_MBF21)
207+
{
208+
demo_version = DV_MBF21;
209+
G_ReloadDefaults(true);
210+
}
197211
memcpy(comp, old_comp, sizeof(*comp));
198212
restore_comp = false;
199213
}
214+
else if (demorecording || demoplayback || netgame || !mbf21)
215+
{
216+
return;
217+
}
200218

201219
md5_checksum_t cksum;
202220

@@ -212,6 +230,20 @@ void G_ApplyLevelCompatibility(int lump)
212230
memcpy(old_comp, comp, sizeof(*comp));
213231
restore_comp = true;
214232

233+
demo_version_t new_demover = record->complevel;
234+
if (new_demover != DV_MBF21)
235+
{
236+
demo_version = new_demover;
237+
G_ReloadDefaults(true);
238+
I_Printf(VB_INFO, "Automatically setting compatibility level \"%s\"",
239+
G_GetCurrentComplevelName());
240+
}
241+
242+
if (!mbf21)
243+
{
244+
return;
245+
}
246+
215247
option_t *option;
216248
array_foreach(option, record->options)
217249
{

0 commit comments

Comments
 (0)