Debian Codegraph @

prboom2/src/dsda/gameinfo.cpp

raw
1 //
2 // Copyright(C) 2025 by Andrik Powell
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (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 // DESCRIPTION:
15 // DSDA GAMEINFO
16 //
17
18 #include <string.h>
19
20 extern "C" {
21 #include "d_main.h"
22 #include "w_wad.h"
23 #include "lprintf.h"
24 #include "z_zone.h"
25 }
26
27 #include "scanner.h"
28
29 #include "gameinfo.h"
30
31 void dsda_ParseGameInfoLine(Scanner &scanner) {
32
33 if (!scanner.CheckString()) {
34 scanner.GetNextToken();
35 scanner.SkipLine();
36 return;
37 }
38
39 if (!stricmp(scanner.string, "IWAD")) {
40 scanner.MustGetToken('=');
41 scanner.MustGetString();
42
43 if (iwadlump)
44 Z_Free(iwadlump);
45
46 iwadlump = Z_Strdup(scanner.string);
47 }
48 }
49
50 void dsda_LoadGameInfo(void) {
51 int lump;
52
53 lump = W_CheckNumForName("GAMEINFO");
54
55 if (lump == LUMP_NOT_FOUND)
56 return;
57
58 Scanner scanner((const char*) W_LumpByNum(lump), W_LumpLength(lump));
59
60 scanner.SetErrorCallback(I_Error);
61
62 while (scanner.TokensLeft())
63 dsda_ParseGameInfoLine(scanner);
64 }