File: wad.h

package info (click to toggle)
glbsp 2.24-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,220 kB
  • sloc: cpp: 10,762; ansic: 6,953; makefile: 121; sh: 14
file content (153 lines) | stat: -rw-r--r-- 3,249 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//------------------------------------------------------------------------
//  WAD : Wad file read/write functions.
//------------------------------------------------------------------------
//
//  GL-Node Viewer (C) 2004-2007 Andrew Apted
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//------------------------------------------------------------------------

#ifndef __NODEVIEW_WAD_H__
#define __NODEVIEW_WAD_H__


class lump_c;


typedef enum { IWAD, PWAD } wad_kind_e;

// wad header

class wad_c
{
public:
  wad_c();
  ~wad_c();

  FILE *in_file;

  // kind of wad file (-1 if not opened yet)
  int kind;

  // number of entries in directory (original)
  int num_entries;

  // offset to start of directory
  int dir_start;

  // current directory entries
  list_c dir;

  // current level
  lump_c *current_level;

  // array of level names found
  const char ** level_names;
  int num_level_names;

public:
  // open the input wad file and read the contents into memory.
  static wad_c *Load(const char *filename);

  bool CheckLevelName(const char *name);
  bool CheckLevelNameGL(const char *name);

  // find a particular level in the wad directory, and store the
  // reference in 'wad.current_level'.  Returns false if not
  // found.
  bool FindLevel(const char *map_name);

  // name of first level in the wad.  Returns NULL if there
  // are no levels at all.
  const char *FirstLevelName();

  // find the level lump with the given name in the current level, and
  // return a reference to it.  Returns NULL if no such lump exists.
  // Level lumps are always present in memory (i.e. never marked
  // copyable).
  lump_c *FindLumpInLevel(const char *name);

  void CacheLump(lump_c *lump);

private:
  bool ReadHeader();
  void ReadDirEntry();
  void ReadDirectory();

  void ProcessDirEntry(lump_c *lump);

  void AddLevelName(const char *name);
  void DetermineLevelNames();
};


// level information

class level_c
{
public:
  level_c();
  ~level_c();

  // various flags
  int flags;

  // the child lump list
  list_c children;

  // information on overflow
  int soft_limit;
  int hard_limit;
  int v3_switch;
};

/* this level information holds GL lumps */
#define LEVEL_IS_GL   0x0002


// directory entry

class lump_c : public listnode_c
{
public:
  lump_c();
  ~lump_c();

  // name of lump
  const char *name;

  // offset/length of lump in wad
  int start;
  int length;

  // various flags
  int flags;

  // data of lump
  void *data;

  // level information, usually NULL
  level_c *lev_info;

public:
  inline lump_c *LumpNext() { return (lump_c*) NodeNext(); }
  inline lump_c *LumpPrev() { return (lump_c*) NodePrev(); }
};


/* ------ Global variables ------ */

extern wad_c *the_wad;
extern wad_c *the_gwa;


#endif /* __NODEVIEW_WAD_H__ */