Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

 

 

 

Doom source code

 

 

 

Id Software

 

 

 

June 5, 2006

Contents

 

1

Common code

4

 

1.1

doomdata.h . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

 

1.2

doomdef.c . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

 

1.3

doomdef.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

 

1.4

doomstat.c . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

 

1.5

doomstat.h . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

 

1.6

doomtype.h . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

 

1.7

dstrings.c . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

 

1.8

dstrings.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2

Automap

22

 

2.1

am map.c . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

 

2.2

am map.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

3

Initialisation/general code

43

 

3.1

d englsh.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

 

3.2

d event.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

 

3.3

d french.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

 

3.4

d items.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

 

3.5

d items.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

 

3.6

d main.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

 

3.7

d main.h . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

 

3.8

d net.c . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

 

3.9

d net.h . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

 

3.10

d player.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

 

3.11

d textur.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

 

3.12

d think.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

 

3.13

d ticcmd.h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

4

Finale code

106

 

4.1

f finale.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

 

4.2

f finale.h . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

 

4.3

f wipe.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

 

4.4

f wipe.h . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

5

Main game loop

124

 

5.1

g game.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

 

5.2

g game.h . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

6

Heads-up display

151

 

6.1

hu lib.c . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

 

6.2

hu lib.h . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

 

6.3

hu stu .c . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

 

6.4

hu stu .h . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

1

7

System-specific code

173

 

7.1

i main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

173

 

7.2

i net.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

174

 

7.3

i net.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

179

 

7.4

i sound.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

180

 

7.5

i sound.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

195

 

7.6

i system.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

197

 

7.7

i system.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

200

 

7.8

i video.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

201

 

7.9

i video.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

217

8

Miscellaneous

219

 

8.1

m argv.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

219

 

8.2

m argv.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

219

 

8.3

m bbox.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

220

 

8.4

m bbox.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

221

 

8.5

m cheat.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

222

 

8.6

m cheat.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

224

 

8.7

m fixed.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

225

 

8.8

m fixed.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

226

 

8.9

m menu.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

227

 

8.10

m menu.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

256

 

8.11

m misc.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

257

 

8.12

m misc.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

266

 

8.13

m random.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

267

 

8.14

m random.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

268

 

8.15

m swap.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

269

 

8.16

m swap.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

270

9

Game logic/behaviour

270

 

9.1

info.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

270

 

9.2

info.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

342

 

9.3

p ceilng.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

363

 

9.4

p doors.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

368

 

9.5

p enemy.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

380

 

9.6

p floor.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

411

 

9.7

p inter.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

420

 

9.8

p inter.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

434

 

9.9

p lights.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

434

 

9.10

p local.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

440

 

9.11

p map.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

445

 

9.12

p maputl.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

465

 

9.13

p mobj.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

479

 

9.14

p mobj.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

494

 

9.15

p plats.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

499

 

9.16

p pspr.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

504

 

9.17

p pspr.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

517

 

9.18

p saveg.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

518

 

9.19

p saveg.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

528

 

9.20

p setup.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

528

 

9.21

p setup.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

539

 

9.22

p sight.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

540

 

9.23

p spec.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

546

 

9.24

p spec.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

567

 

9.25

p switch.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

577

 

9.26

p telept.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

587

 

9.27

p tick.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

589

 

9.28

p tick.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

591

 

9.29

p user.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

592

2

10 Rendering engine

598

10.1

r bsp.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

598

10.2

r bsp.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

607

10.3

r data.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

608

10.4

r data.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

621

10.5

r defs.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

622

10.6

r draw.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

630

10.7

r draw.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

644

10.8

r local.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

645

10.9

r main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

646

10.10r

main.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

660

10.11r

plane.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

663

10.12r

plane.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

670

10.13r

segs.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

671

10.14r

segs.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

683

10.15r

sky.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

684

10.16r

sky.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

685

10.17r

state.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

685

10.18r

things.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

688

10.19r

things.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

703

11 Sound code

704

11.1

s sound.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

704

11.2

s sound.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

718

11.3

sounds.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

719

11.4

sounds.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

723

12 Status bar

728

12.1

st lib.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

728

12.2

st lib.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

732

12.3

st stu .c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

736

12.4

st stu .h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

758

13 General graphic drawing

760

13.1

v video.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

760

13.2

v video.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

767

14 WAD file loading

769

14.1

w wad.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

769

14.2

w wad.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

778

15 Intermission screen

780

15.1

wi stu .c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

780

15.2

wi stu .h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

808

16 Zone memory allocation system

809

16.1

z zone.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

809

16.2

z zone.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

816

3

1 Common code

1.1 doomdata.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//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.

//

//DESCRIPTION:

//all external data is defined here

//most of the data is loaded into different structures at run time

//some internal structures shared by many modules are here

//

//-----------------------------------------------------------------------------

#ifndef __DOOMDATA__ #define __DOOMDATA__

//The most basic types we use, portability. #include "doomtype.h"

//Some global defines, that configure the game. #include "doomdef.h"

//

//Map level types.

//The following data structures define the persistent format

//used in the lumps of the WAD files.

//

//Lump order in a map WAD: each map needs a couple of lumps

//to provide a complete scene geometry description.

enum

 

{

 

ML_LABEL,

// A separator, name, ExMx or MAPxx

ML_THINGS,

// Monsters, items..

ML_LINEDEFS,

// LineDefs, from editing

ML_SIDEDEFS,

// SideDefs, from editing

ML_VERTEXES,

// Vertices, edited and BSP splits generated

ML_SEGS,

// LineSegs, from LineDefs split by BSP

ML_SSECTORS,

// SubSectors, list of LineSegs

ML_NODES,

// BSP nodes

ML_SECTORS,

// Sectors, from editing

ML_REJECT,

// LUT, sector-sector visibility

ML_BLOCKMAP

// LUT, motion clipping, walls/grid element

};

 

// A single Vertex.

 

typedef struct

 

{

 

4

short

x;

short

y;

} mapvertex_t;

 

//A SideDef, defining the visual appearance of a wall,

//by setting textures and offsets.

typedef struct

 

{

 

short

textureoffset;

short

rowoffset;

char

toptexture[8];

char

bottomtexture[8];

char

midtexture[8];

// Front sector, towards viewer.

short

sector;

} mapsidedef_t;

 

//A LineDef, as used for editing, and as input

//to the BSP builder.

typedef struct

 

{

 

short

v1;

short

v2;

short

flags;

short

special;

short

tag;

// sidenum[1] will be -1 if one sided

short

sidenum[2];

} maplinedef_t;

 

//

//LineDef attributes.

//Solid, is an obstacle.

#define

ML_BLOCKING

1

// Blocks monsters only.

 

#define

ML_BLOCKMONSTERS

2

//Backside will not be present at all

//if not two sided.

#define ML_TWOSIDED

4

//If a texture is pegged, the texture will have

//the end exposed to air held constant at the

//top or bottom of the texture (stairs or pulled

//down things) and will move with a height change

//of one of the neighbor sectors.

//Unpegged textures allways have the first row of

//the texture at the top pixel of the line for both

//top and bottom textures (use next to windows).

//upper texture unpegged

#define ML_DONTPEGTOP

8

//

lower texture unpegged

 

#define

ML_DONTPEGBOTTOM

16

//

In AutoMap: don’t map as two sided: IT’S A SECRET!

#define

ML_SECRET

32

5

// Sound rendering: don’t let sound cross two of these.

#define ML_SOUNDBLOCK

64

//

Don’t draw on the automap at all.

#define

ML_DONTDRAW

128

//

Set if already seen, thus drawn in automap.

#define

ML_MAPPED

256

// Sector definition, from editing.

typedef

struct

{

 

short

floorheight;

short

ceilingheight;

char

floorpic[8];

char

ceilingpic[8];

short

lightlevel;

short

special;

short

tag;

} mapsector_t;

 

// SubSector, as generated by BSP.

typedef struct

 

{

 

short

numsegs;

// Index of first one, segs are stored sequentially.

short

firstseg;

} mapsubsector_t;

 

//LineSeg, generated by splitting LineDefs

//using partition lines selected by BSP builder. typedef struct

{

short

v1;

short

v2;

short

angle;

short

linedef;

short

side;

short

offset;

} mapseg_t;

 

//BSP node structure.

//Indicate a leaf.

#define NF_SUBSECTOR 0x8000

typedef struct

{

// Partition line from (x,y) to x+dx,y+dy)

short

x;

short

y;

short

dx;

short

dy;

//Bounding box for each child,

//clip against view frustum.

short

bbox[2][4];

6

//If NF_SUBSECTOR its a subsector,

//else it’s a node of another subtree.

unsigned short

children[2];

} mapnode_t;

//Thing definition, position, orientation and type,

//plus skill/visibility flags and attributes. typedef struct

{

short

x;

short

y;

short

angle;

short

type;

short

options;

} mapthing_t;

 

#endif

// __DOOMDATA__

//-----------------------------------------------------------------------------

 

//

 

// $Log:$

 

//

 

//-----------------------------------------------------------------------------

 

1.2 doomdef.c

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//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.

//

//$Log:$

//DESCRIPTION:

//DoomDef - basic defines for DOOM, e.g. Version, game mode

//and skill level, and display parameters.

//

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";

#ifdef __GNUG__

#pragma implementation "doomdef.h"

7

#endif

#include "doomdef.h"

//Location for any defines turned variables.

//None.

1.3doomdef.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//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.

//

//DESCRIPTION:

//Internally used data structures for virtually everything,

//key definitions, lots of other stuff.

//

//-----------------------------------------------------------------------------

#ifndef __DOOMDEF__ #define __DOOMDEF__

#include <stdio.h> #include <string.h>

//

//Global parameters/defines.

//DOOM version

enum { VERSION = 110 };

//Game mode handling - identify IWAD version

//to handle IWAD dependend animations etc. typedef enum

{

shareware,

// DOOM 1 shareware, E1, M9

registered,

// DOOM 1

registered, E3, M27

commercial,

// DOOM 2

retail,

E1 M34

// DOOM 2 german edition not

handled

 

retail,

// DOOM 1 retail, E4,

M36

indetermined

// Well,

no IWAD

found.

} GameMode_t;

// Mission packs - might be useful for TC stuff? typedef enum

{

doom,

// DOOM 1

8

doom2,

// DOOM 2

 

pack_tnt,

// TNT

mission pack

pack_plut,

// Plutonia pack

none

 

 

} GameMission_t;

// Identify language to use, software localization. typedef enum

{

english,

french,

german, unknown

} Language_t;

//If rangecheck is undefined,

//most parameter validation debugging code will not be compiled #define RANGECHECK

//Do or do not use external soundserver.

//The sndserver binary to be run separately

//has been introduced by Dave Taylor.

//The integrated sound support is experimental,

//and unfinished. Default is synchronous.

//Experimental asynchronous timer based is

//handled by SNDINTR.

#define SNDSERV 1

//#define SNDINTR 1

//This one switches between MIT SHM (no proper mouse)

//and XFree86 DGA (mickey sampling). The original

//linuxdoom used SHM, which is default.

//#define X11_DGA

1

//

//For resize of screen, at start of game.

//It will not work dynamically, see visplanes.

#define

BASE_WIDTH

320

//It is educational but futile to change this

//scaling e.g. to 2. Drawing of status bar,

//menues etc. is tied to the scale implied

//by the graphics.

#define

SCREEN_MUL

1

#define

INV_ASPECT_RATIO

0.625 // 0.75, ideally

//Defines suck. C sucks.

//C++ might sucks for OOP, but it sure is a better C.

//So there.

#define SCREENWIDTH 320 //SCREEN_MUL*BASE_WIDTH //320 #define SCREENHEIGHT 200

//(int)(SCREEN_MUL*BASE_WIDTH*INV_ASPECT_RATIO) //200

// The maximum number of players, multiplayer/networking.

9

#define MAXPLAYERS

4

// State updates, number of tics / second.

#define TICRATE

35

//The current state of the game: whether we are

//playing, gazing at the intermission screen,

//the game final animation, or a demo.

typedef enum

{

GS_LEVEL,

GS_INTERMISSION,

GS_FINALE,

GS_DEMOSCREEN

} gamestate_t;

//

//Difficulty/skill settings/filters.

//Skill flags.

#define

MTF_EASY

1

#define

MTF_NORMAL

2

#define

MTF_HARD

4

// Deaf monsters/do not react to sound.

 

#define

MTF_AMBUSH

8

typedef enum

{

sk_baby, sk_easy, sk_medium, sk_hard, sk_nightmare

} skill_t;

//

// Key cards.

//

typedef enum

{

it_bluecard, it_yellowcard, it_redcard, it_blueskull, it_yellowskull, it_redskull,

NUMCARDS

} card_t;

//The defined weapons,

//including a marker indicating

//user has not changed weapon. typedef enum

{

wp_fist, wp_pistol,

10

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]