doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

commit bbf26755d34df958b1990f250d051e896956389c
parent 0ff58e8b175a51562047958b47886003a2657f3e
Author: ssnf <ssnf@ssnf.xyz>
Date:   Sun, 17 Oct 2021 01:24:31 +0000

synchronize with actual work dir

previous commits were made to try to keep a history of changes
back then, I was making changes to the code without commiting them
but honestly, it's too much of a drag to reenact everything

Diffstat:
Msndserv/Makefile | 50++++++++++++--------------------------------------
Dsndserv/README.sndserv | 16----------------
Msndserv/linux.c | 102++++++++++++++++---------------------------------------------------------------
Msndserv/sounds.c | 415++++++++++++++++++++++++++++++++++---------------------------------------------
Msndserv/sounds.h | 156+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Msndserv/soundsrv.c | 279+++++++------------------------------------------------------------------------
Msndserv/soundsrv.h | 59+++++++----------------------------------------------------
Dsndserv/soundst.h | 312-------------------------------------------------------------------------------
Msndserv/wadread.c | 147++++++++++---------------------------------------------------------------------
Dsndserv/wadread.h | 62--------------------------------------------------------------
Msrc/Makefile | 112+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/am_map.c | 1478++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/am_map.h | 11+++++++----
Dsrc/d_englsh.h | 522-------------------------------------------------------------------------------
Msrc/d_event.h | 95++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/d_french.h | 139++++++++++---------------------------------------------------------------------
Msrc/d_items.c | 92++++++++++++-------------------------------------------------------------------
Msrc/d_items.h | 35+++++++++++++++++++++++++++++++++++
Msrc/d_main.c | 982++++++++++++++++++++-----------------------------------------------------------
Msrc/d_main.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_net.c | 871+++++++++++++++++++++++++++++++++++++------------------------------------------
Msrc/d_net.h | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_player.h | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_textur.h | 43++++++++++++++++++++++++++++++++++++++++++-
Msrc/d_think.h | 31++++++++++++++++++-------------
Msrc/d_ticcmd.h | 39++++++++++++++++++++++++++++++++++++++-
Msrc/doom1.wad | 0
Msrc/doomdata.h | 131++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/doomdef.h | 460+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/doomstat.c | 6++----
Msrc/doomstat.h | 152+++++++++++++++++++++++++++++++++++++++----------------------------------------
Dsrc/doomtype.h | 9---------
Dsrc/dstrings.c | 26--------------------------
Msrc/dstrings.h | 12+++++-------
Msrc/f_finale.c | 827++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/f_finale.h | 5++++-
Msrc/f_wipe.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/f_wipe.h | 42++++++++++++++++++++++++++++++++++++++++++
Msrc/g_game.c | 2016++++++++++++++++++++++++++++++++++---------------------------------------------
Msrc/g_game.h | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/hu_lib.c | 99++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Msrc/hu_lib.h | 89++++++++++++++++++++++++++++++-------------------------------------------------
Msrc/hu_stuff.c | 1006+++++++++++++++++++++++++++++++++++++------------------------------------------
Msrc/hu_stuff.h | 6+++++-
Msrc/i_main.c | 8++++----
Msrc/i_net.c | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Msrc/i_net.h | 37+++++++++++++++++++++++++++++++++++++
Msrc/i_sound.c | 499++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/i_sound.h | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/i_system.c | 105+++++++++++++++++++++++++++----------------------------------------------------
Msrc/i_system.h | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/i_video.h | 49++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/info.c | 6994++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/info.h | 45++++++++++++++++++++++++++++++++-------------
Asrc/lang-gen.sh | 1+
Asrc/lang.c | 550+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/m_argv.c | 19++++++++++---------
Msrc/m_argv.h | 36++++++++++++++++++++++++++++++++++++
Msrc/m_bbox.c | 33+++++++++++++++------------------
Msrc/m_bbox.h | 16++++++++--------
Msrc/m_cheat.c | 24++++++++++++++++++++++++
Msrc/m_cheat.h | 39+++++++++++++++++++++++++++++++++++++++
Msrc/m_fixed.c | 37++++++++++++++-----------------------
Msrc/m_fixed.h | 17+++++++++--------
Msrc/m_menu.c | 2165++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/m_menu.h | 9++++++---
Msrc/m_misc.c | 431++++++++++++++++++++-----------------------------------------------------------
Msrc/m_misc.h | 26+++++++-------------------
Msrc/m_random.c | 9+++++++++
Msrc/m_random.h | 42+++++++++++++++++++++++++++++++++++++++++-
Msrc/m_swap.c | 15+++++++++------
Msrc/m_swap.h | 5++---
Msrc/p_ceilng.c | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_doors.c | 311++++++++++++++++++++++++++++---------------------------------------------------
Msrc/p_enemy.c | 2278++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/p_floor.c | 402+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/p_inter.c | 998+++++++++++++++++++++++++++++++++----------------------------------------------
Msrc/p_inter.h | 5++---
Msrc/p_lights.c | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_local.h | 127++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Msrc/p_map.c | 1388++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Msrc/p_maputl.c | 334++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Msrc/p_mobj.c | 333+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_mobj.h | 215+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_plats.c | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_pspr.c | 760++++++++++++++++++++++++++++++++++---------------------------------------------
Msrc/p_pspr.h | 27+++++++++++++++++++++++++++
Msrc/p_saveg.c | 151+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Msrc/p_saveg.h | 36++++++++++++++++++++++++++++++++++++
Msrc/p_setup.h | 14++++----------
Msrc/p_sight.c | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_spec.c | 1313++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/p_spec.h | 265+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_switch.c | 739++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/p_telept.c | 37+++++++++++++++++++++++++++++++++++++
Msrc/p_tick.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_tick.h | 37+++++++++++++++++++++++++++++++++++++
Msrc/p_user.c | 348+++++++++++++++++++++++++++++++++++--------------------------------------------
Asrc/parameters | 38++++++++++++++++++++++++++++++++++++++
Msrc/r_bsp.c | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_bsp.h | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_data.c | 1-
Msrc/r_data.h | 21+++++++++------------
Msrc/r_defs.h | 142++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/r_draw.c | 728++++++++++++++++++++++++++++---------------------------------------------------
Msrc/r_draw.h | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_local.h | 5+++++
Msrc/r_main.c | 812++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/r_main.h | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_plane.c | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
Msrc/r_plane.h | 47+++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_segs.c | 735+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/r_segs.h | 33+++++++++++++++++++++++++++++++++
Dsrc/r_sky.c | 13-------------
Dsrc/r_sky.h | 11-----------
Msrc/r_state.h | 11++++++++---
Msrc/r_things.c | 1010++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/r_things.h | 23+++++++++++++++++++++++
Msrc/s_sound.c | 732++++++++++++++++++++++++++++++-------------------------------------------------
Msrc/s_sound.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/sndserver | 0
Msrc/sounds.c | 356++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/sounds.h | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_lib.c | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_lib.h | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_stuff.c | 1173+++++++++++++++++++++++++++++++------------------------------------------------
Msrc/st_stuff.h | 63++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/tables.c | 4125+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/tables.h | 24++++++++++++------------
Asrc/todo | 2++
Msrc/v_video.c | 377+++++++++++++++++++++++++------------------------------------------------------
Msrc/v_video.h | 69++++++++++++++++++---------------------------------------------------
Msrc/w_wad.c | 193++++++++++++++++++++++---------------------------------------------------------
Msrc/wi_stuff.c | 1897+++++++++++++++++++++++++++++++++++--------------------------------------------
Msrc/wi_stuff.h | 41+++++++++++++++++++++++++++++++++++++++++
Msrc/z_zone.c | 322+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/z_zone.h | 61++++++++++++++++++++++++++++++++++---------------------------
137 files changed, 24339 insertions(+), 23085 deletions(-)

diff --git a/sndserv/Makefile b/sndserv/Makefile @@ -1,39 +1,13 @@ -########################################################## -# -# $Id:$ -# -# $Log:$ -# -# - -CC=gcc -CFLAGS=-O -DNORMALUNIX -DLINUX -LDFLAGS= -LIBS=-lm - -O=linux - -all: $(O)/sndserver - +CC = c89 +CFLAGS = -Os +LIBS = +LDFLAGS = ${LIBS} +SRC = soundsrv.c sounds.c wadread.c linux.c +OBJ = ${SRC:.c=.o} +all: sndserver clean: - rm -f *.o *~ *.flc - rm -f linux/* - -# Target -$(O)/sndserver: \ - $(O)/soundsrv.o \ - $(O)/sounds.o \ - $(O)/wadread.o \ - $(O)/linux.o - $(CC) $(CFLAGS) $(LDFLAGS) \ - $(O)/soundsrv.o \ - $(O)/sounds.o \ - $(O)/wadread.o \ - $(O)/linux.o -o $(O)/sndserver $(LIBS) - echo make complete. - -# Rule -$(O)/%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - - + rm -f *.o sndserver +%.o: %.c + ${CC} ${CFLAGS} -c $< -o $@ +sndserver: ${OBJ} + ${CC} ${LDFLAGS} ${OBJ} -o sndserver diff --git a/sndserv/README.sndserv b/sndserv/README.sndserv @@ -1,15 +0,0 @@ - -This is the soundserver as used by the original -Linuxdoom release. I separated the source from -the actual Linuxduum source. For various reasons -the separate sound process seems to give the -best results - both synchronous and timer driven -output demonstrate glitches. These might either -be timing issues, or introduced by the changes -I made to the linux sound code while merging it -back into the main tree. - -Note that neither John Carmack nor Dave Taylor -are responsible for the current sound handling. - - -\ No newline at end of file diff --git a/sndserv/linux.c b/sndserv/linux.c @@ -1,118 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static const char rcsid[] = "$Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $"; - - +#include <errno.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> - +#include <sys/ioctl.h> #include <linux/soundcard.h> - #include "soundsrv.h" - int audio_fd; - void -myioctl -( int fd, - int command, - int* arg ) +myioctl(int fd, int command, int* arg) { - int rc; - extern int errno; - + int rc; rc = ioctl(fd, command, arg); - if (rc < 0) - { - fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command); - fprintf(stderr, "errno=%d\n", errno); - exit(-1); + if (rc < 0) { + fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command); + fprintf(stderr, "errno=%d\n", errno); + exit(-1); } } - -void I_InitMusic(void) +void +I_InitMusic(void) { } - void -I_InitSound -( int samplerate, - int samplesize ) +I_InitSound(int samplerate, int samplesize) { - int i; - audio_fd = open("/dev/dsp", O_WRONLY); - if (audio_fd<0) - fprintf(stderr, "Could not open /dev/dsp\n"); - - - i = 11 | (2<<16); + if (audio_fd < 0) fprintf(stderr, "Could not open /dev/dsp\n"); + i = 11 | (2 << 16); myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); - myioctl(audio_fd, SNDCTL_DSP_RESET, 0); i=11025; myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); i=1; myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); - myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); - if (i&=AFMT_S16_LE) - myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); - else - fprintf(stderr, "Could not play signed 16 data\n"); - + if (i&=AFMT_S16_LE) myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); + else fprintf(stderr, "Could not play signed 16 data\n"); } - void -I_SubmitOutputBuffer -( void* samples, - int samplecount ) +I_SubmitOutputBuffer(void* samples, int samplecount) { write(audio_fd, samples, samplecount*4); } - -void I_ShutdownSound(void) +void +I_ShutdownSound(void) { - close(audio_fd); - } - -void I_ShutdownMusic(void) +void +I_ShutdownMusic(void) { } diff --git a/sndserv/sounds.c b/sndserv/sounds.c @@ -1,239 +1,184 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: sounds.c,v 1.3 1997/01/29 22:40:44 b1 Exp $"; - - - - -enum { false, true }; - #include "sounds.h" - - - - -musicinfo_t S_music[] = -{ - { 0 }, - { "e1m1", 0 }, - { "e1m2", 0 }, - { "e1m3", 0 }, - { "e1m4", 0 }, - { "e1m5", 0 }, - { "e1m6", 0 }, - { "e1m7", 0 }, - { "e1m8", 0 }, - { "e1m9", 0 }, - { "e2m1", 0 }, - { "e2m2", 0 }, - { "e2m3", 0 }, - { "e2m4", 0 }, - { "e2m5", 0 }, - { "e2m6", 0 }, - { "e2m7", 0 }, - { "e2m8", 0 }, - { "e2m9", 0 }, - { "e3m1", 0 }, - { "e3m2", 0 }, - { "e3m3", 0 }, - { "e3m4", 0 }, - { "e3m5", 0 }, - { "e3m6", 0 }, - { "e3m7", 0 }, - { "e3m8", 0 }, - { "e3m9", 0 }, - { "inter", 0 }, - { "intro", 0 }, - { "bunny", 0 }, - { "victor", 0 }, - { "introa", 0 }, - { "runnin", 0 }, - { "stalks", 0 }, - { "countd", 0 }, - { "betwee", 0 }, - { "doom", 0 }, - { "the_da", 0 }, - { "shawn", 0 }, - { "ddtblu", 0 }, - { "in_cit", 0 }, - { "dead", 0 }, - { "stlks2", 0 }, - { "theda2", 0 }, - { "doom2", 0 }, - { "ddtbl2", 0 }, - { "runni2", 0 }, - { "dead2", 0 }, - { "stlks3", 0 }, - { "romero", 0 }, - { "shawn2", 0 }, - { "messag", 0 }, - { "count2", 0 }, - { "ddtbl3", 0 }, - { "ampie", 0 }, - { "theda3", 0 }, - { "adrian", 0 }, - { "messg2", 0 }, - { "romer2", 0 }, - { "tense", 0 }, - { "shawn3", 0 }, - { "openin", 0 }, - { "evil", 0 }, - { "ultima", 0 }, - { "read_m", 0 }, - { "dm2ttl", 0 }, - { "dm2int", 0 } +enum { false, true }; +MusicInfo S_music[] = { + { 0 }, + { "e1m1", 0 }, + { "e1m2", 0 }, + { "e1m3", 0 }, + { "e1m4", 0 }, + { "e1m5", 0 }, + { "e1m6", 0 }, + { "e1m7", 0 }, + { "e1m8", 0 }, + { "e1m9", 0 }, + { "e2m1", 0 }, + { "e2m2", 0 }, + { "e2m3", 0 }, + { "e2m4", 0 }, + { "e2m5", 0 }, + { "e2m6", 0 }, + { "e2m7", 0 }, + { "e2m8", 0 }, + { "e2m9", 0 }, + { "e3m1", 0 }, + { "e3m2", 0 }, + { "e3m3", 0 }, + { "e3m4", 0 }, + { "e3m5", 0 }, + { "e3m6", 0 }, + { "e3m7", 0 }, + { "e3m8", 0 }, + { "e3m9", 0 }, + { "inter", 0 }, + { "intro", 0 }, + { "bunny", 0 }, + { "victor", 0 }, + { "introa", 0 }, + { "runnin", 0 }, + { "stalks", 0 }, + { "countd", 0 }, + { "betwee", 0 }, + { "doom", 0 }, + { "the_da", 0 }, + { "shawn", 0 }, + { "ddtblu", 0 }, + { "in_cit", 0 }, + { "dead", 0 }, + { "stlks2", 0 }, + { "theda2", 0 }, + { "doom2", 0 }, + { "ddtbl2", 0 }, + { "runni2", 0 }, + { "dead2", 0 }, + { "stlks3", 0 }, + { "romero", 0 }, + { "shawn2", 0 }, + { "messag", 0 }, + { "count2", 0 }, + { "ddtbl3", 0 }, + { "ampie", 0 }, + { "theda3", 0 }, + { "adrian", 0 }, + { "messg2", 0 }, + { "romer2", 0 }, + { "tense", 0 }, + { "shawn3", 0 }, + { "openin", 0 }, + { "evil", 0 }, + { "ultima", 0 }, + { "read_m", 0 }, + { "dm2ttl", 0 }, + { "dm2int", 0 } }; - - - - - - -sfxinfo_t S_sfx[] = -{ - { 0 }, - { "pistol", false, 64, 0, -1, -1, 0 }, - { "shotgn", false, 64, 0, -1, -1, 0 }, - { "sgcock", false, 64, 0, -1, -1, 0 }, - { "dshtgn", false, 64, 0, -1, -1, 0 }, - { "dbopn", false, 64, 0, -1, -1, 0 }, - { "dbcls", false, 64, 0, -1, -1, 0 }, - { "dbload", false, 64, 0, -1, -1, 0 }, - { "plasma", false, 64, 0, -1, -1, 0 }, - { "bfg", false, 64, 0, -1, -1, 0 }, - { "sawup", false, 64, 0, -1, -1, 0 }, - { "sawidl", false, 118, 0, -1, -1, 0 }, - { "sawful", false, 64, 0, -1, -1, 0 }, - { "sawhit", false, 64, 0, -1, -1, 0 }, - { "rlaunc", false, 64, 0, -1, -1, 0 }, - { "rxplod", false, 70, 0, -1, -1, 0 }, - { "firsht", false, 70, 0, -1, -1, 0 }, - { "firxpl", false, 70, 0, -1, -1, 0 }, - { "pstart", false, 100, 0, -1, -1, 0 }, - { "pstop", false, 100, 0, -1, -1, 0 }, - { "doropn", false, 100, 0, -1, -1, 0 }, - { "dorcls", false, 100, 0, -1, -1, 0 }, - { "stnmov", false, 119, 0, -1, -1, 0 }, - { "swtchn", false, 78, 0, -1, -1, 0 }, - { "swtchx", false, 78, 0, -1, -1, 0 }, - { "plpain", false, 96, 0, -1, -1, 0 }, - { "dmpain", false, 96, 0, -1, -1, 0 }, - { "popain", false, 96, 0, -1, -1, 0 }, - { "vipain", false, 96, 0, -1, -1, 0 }, - { "mnpain", false, 96, 0, -1, -1, 0 }, - { "pepain", false, 96, 0, -1, -1, 0 }, - { "slop", false, 78, 0, -1, -1, 0 }, - { "itemup", true, 78, 0, -1, -1, 0 }, - { "wpnup", true, 78, 0, -1, -1, 0 }, - { "oof", false, 96, 0, -1, -1, 0 }, - { "telept", false, 32, 0, -1, -1, 0 }, - { "posit1", true, 98, 0, -1, -1, 0 }, - { "posit2", true, 98, 0, -1, -1, 0 }, - { "posit3", true, 98, 0, -1, -1, 0 }, - { "bgsit1", true, 98, 0, -1, -1, 0 }, - { "bgsit2", true, 98, 0, -1, -1, 0 }, - { "sgtsit", true, 98, 0, -1, -1, 0 }, - { "cacsit", true, 98, 0, -1, -1, 0 }, - { "brssit", true, 94, 0, -1, -1, 0 }, - { "cybsit", true, 92, 0, -1, -1, 0 }, - { "spisit", true, 90, 0, -1, -1, 0 }, - { "bspsit", true, 90, 0, -1, -1, 0 }, - { "kntsit", true, 90, 0, -1, -1, 0 }, - { "vilsit", true, 90, 0, -1, -1, 0 }, - { "mansit", true, 90, 0, -1, -1, 0 }, - { "pesit", true, 90, 0, -1, -1, 0 }, - { "sklatk", false, 70, 0, -1, -1, 0 }, - { "sgtatk", false, 70, 0, -1, -1, 0 }, - { "skepch", false, 70, 0, -1, -1, 0 }, - { "vilatk", false, 70, 0, -1, -1, 0 }, - { "claw", false, 70, 0, -1, -1, 0 }, - { "skeswg", false, 70, 0, -1, -1, 0 }, - { "pldeth", false, 32, 0, -1, -1, 0 }, - { "pdiehi", false, 32, 0, -1, -1, 0 }, - { "podth1", false, 70, 0, -1, -1, 0 }, - { "podth2", false, 70, 0, -1, -1, 0 }, - { "podth3", false, 70, 0, -1, -1, 0 }, - { "bgdth1", false, 70, 0, -1, -1, 0 }, - { "bgdth2", false, 70, 0, -1, -1, 0 }, - { "sgtdth", false, 70, 0, -1, -1, 0 }, - { "cacdth", false, 70, 0, -1, -1, 0 }, - { "skldth", false, 70, 0, -1, -1, 0 }, - { "brsdth", false, 32, 0, -1, -1, 0 }, - { "cybdth", false, 32, 0, -1, -1, 0 }, - { "spidth", false, 32, 0, -1, -1, 0 }, - { "bspdth", false, 32, 0, -1, -1, 0 }, - { "vildth", false, 32, 0, -1, -1, 0 }, - { "kntdth", false, 32, 0, -1, -1, 0 }, - { "pedth", false, 32, 0, -1, -1, 0 }, - { "skedth", false, 32, 0, -1, -1, 0 }, - { "posact", true, 120, 0, -1, -1, 0 }, - { "bgact", true, 120, 0, -1, -1, 0 }, - { "dmact", true, 120, 0, -1, -1, 0 }, - { "bspact", true, 100, 0, -1, -1, 0 }, - { "bspwlk", true, 100, 0, -1, -1, 0 }, - { "vilact", true, 100, 0, -1, -1, 0 }, - { "noway", false, 78, 0, -1, -1, 0 }, - { "barexp", false, 60, 0, -1, -1, 0 }, - { "punch", false, 64, 0, -1, -1, 0 }, - { "hoof", false, 70, 0, -1, -1, 0 }, - { "metal", false, 70, 0, -1, -1, 0 }, - { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, - { "tink", false, 60, 0, -1, -1, 0 }, - { "bdopn", false, 100, 0, -1, -1, 0 }, - { "bdcls", false, 100, 0, -1, -1, 0 }, - { "itmbk", false, 100, 0, -1, -1, 0 }, - { "flame", false, 32, 0, -1, -1, 0 }, - { "flamst", false, 32, 0, -1, -1, 0 }, - { "getpow", false, 60, 0, -1, -1, 0 }, - { "bospit", false, 70, 0, -1, -1, 0 }, - { "boscub", false, 70, 0, -1, -1, 0 }, - { "bossit", false, 70, 0, -1, -1, 0 }, - { "bospn", false, 70, 0, -1, -1, 0 }, - { "bosdth", false, 70, 0, -1, -1, 0 }, - { "manatk", false, 70, 0, -1, -1, 0 }, - { "mandth", false, 70, 0, -1, -1, 0 }, - { "sssit", false, 70, 0, -1, -1, 0 }, - { "ssdth", false, 70, 0, -1, -1, 0 }, - { "keenpn", false, 70, 0, -1, -1, 0 }, - { "keendt", false, 70, 0, -1, -1, 0 }, - { "skeact", false, 70, 0, -1, -1, 0 }, - { "skesit", false, 70, 0, -1, -1, 0 }, - { "skeatk", false, 70, 0, -1, -1, 0 }, - { "radio", false, 60, 0, -1, -1, 0 } +SfxInfo S_sfx[] = { + { 0 }, + { "pistol", false, 64, 0, -1, -1, 0 }, + { "shotgn", false, 64, 0, -1, -1, 0 }, + { "sgcock", false, 64, 0, -1, -1, 0 }, + { "dshtgn", false, 64, 0, -1, -1, 0 }, + { "dbopn", false, 64, 0, -1, -1, 0 }, + { "dbcls", false, 64, 0, -1, -1, 0 }, + { "dbload", false, 64, 0, -1, -1, 0 }, + { "plasma", false, 64, 0, -1, -1, 0 }, + { "bfg", false, 64, 0, -1, -1, 0 }, + { "sawup", false, 64, 0, -1, -1, 0 }, + { "sawidl", false, 118, 0, -1, -1, 0 }, + { "sawful", false, 64, 0, -1, -1, 0 }, + { "sawhit", false, 64, 0, -1, -1, 0 }, + { "rlaunc", false, 64, 0, -1, -1, 0 }, + { "rxplod", false, 70, 0, -1, -1, 0 }, + { "firsht", false, 70, 0, -1, -1, 0 }, + { "firxpl", false, 70, 0, -1, -1, 0 }, + { "pstart", false, 100, 0, -1, -1, 0 }, + { "pstop", false, 100, 0, -1, -1, 0 }, + { "doropn", false, 100, 0, -1, -1, 0 }, + { "dorcls", false, 100, 0, -1, -1, 0 }, + { "stnmov", false, 119, 0, -1, -1, 0 }, + { "swtchn", false, 78, 0, -1, -1, 0 }, + { "swtchx", false, 78, 0, -1, -1, 0 }, + { "plpain", false, 96, 0, -1, -1, 0 }, + { "dmpain", false, 96, 0, -1, -1, 0 }, + { "popain", false, 96, 0, -1, -1, 0 }, + { "vipain", false, 96, 0, -1, -1, 0 }, + { "mnpain", false, 96, 0, -1, -1, 0 }, + { "pepain", false, 96, 0, -1, -1, 0 }, + { "slop", false, 78, 0, -1, -1, 0 }, + { "itemup", true, 78, 0, -1, -1, 0 }, + { "wpnup", true, 78, 0, -1, -1, 0 }, + { "oof", false, 96, 0, -1, -1, 0 }, + { "telept", false, 32, 0, -1, -1, 0 }, + { "posit1", true, 98, 0, -1, -1, 0 }, + { "posit2", true, 98, 0, -1, -1, 0 }, + { "posit3", true, 98, 0, -1, -1, 0 }, + { "bgsit1", true, 98, 0, -1, -1, 0 }, + { "bgsit2", true, 98, 0, -1, -1, 0 }, + { "sgtsit", true, 98, 0, -1, -1, 0 }, + { "cacsit", true, 98, 0, -1, -1, 0 }, + { "brssit", true, 94, 0, -1, -1, 0 }, + { "cybsit", true, 92, 0, -1, -1, 0 }, + { "spisit", true, 90, 0, -1, -1, 0 }, + { "bspsit", true, 90, 0, -1, -1, 0 }, + { "kntsit", true, 90, 0, -1, -1, 0 }, + { "vilsit", true, 90, 0, -1, -1, 0 }, + { "mansit", true, 90, 0, -1, -1, 0 }, + { "pesit", true, 90, 0, -1, -1, 0 }, + { "sklatk", false, 70, 0, -1, -1, 0 }, + { "sgtatk", false, 70, 0, -1, -1, 0 }, + { "skepch", false, 70, 0, -1, -1, 0 }, + { "vilatk", false, 70, 0, -1, -1, 0 }, + { "claw", false, 70, 0, -1, -1, 0 }, + { "skeswg", false, 70, 0, -1, -1, 0 }, + { "pldeth", false, 32, 0, -1, -1, 0 }, + { "pdiehi", false, 32, 0, -1, -1, 0 }, + { "podth1", false, 70, 0, -1, -1, 0 }, + { "podth2", false, 70, 0, -1, -1, 0 }, + { "podth3", false, 70, 0, -1, -1, 0 }, + { "bgdth1", false, 70, 0, -1, -1, 0 }, + { "bgdth2", false, 70, 0, -1, -1, 0 }, + { "sgtdth", false, 70, 0, -1, -1, 0 }, + { "cacdth", false, 70, 0, -1, -1, 0 }, + { "skldth", false, 70, 0, -1, -1, 0 }, + { "brsdth", false, 32, 0, -1, -1, 0 }, + { "cybdth", false, 32, 0, -1, -1, 0 }, + { "spidth", false, 32, 0, -1, -1, 0 }, + { "bspdth", false, 32, 0, -1, -1, 0 }, + { "vildth", false, 32, 0, -1, -1, 0 }, + { "kntdth", false, 32, 0, -1, -1, 0 }, + { "pedth", false, 32, 0, -1, -1, 0 }, + { "skedth", false, 32, 0, -1, -1, 0 }, + { "posact", true, 120, 0, -1, -1, 0 }, + { "bgact", true, 120, 0, -1, -1, 0 }, + { "dmact", true, 120, 0, -1, -1, 0 }, + { "bspact", true, 100, 0, -1, -1, 0 }, + { "bspwlk", true, 100, 0, -1, -1, 0 }, + { "vilact", true, 100, 0, -1, -1, 0 }, + { "noway", false, 78, 0, -1, -1, 0 }, + { "barexp", false, 60, 0, -1, -1, 0 }, + { "punch", false, 64, 0, -1, -1, 0 }, + { "hoof", false, 70, 0, -1, -1, 0 }, + { "metal", false, 70, 0, -1, -1, 0 }, + { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, + { "tink", false, 60, 0, -1, -1, 0 }, + { "bdopn", false, 100, 0, -1, -1, 0 }, + { "bdcls", false, 100, 0, -1, -1, 0 }, + { "itmbk", false, 100, 0, -1, -1, 0 }, + { "flame", false, 32, 0, -1, -1, 0 }, + { "flamst", false, 32, 0, -1, -1, 0 }, + { "getpow", false, 60, 0, -1, -1, 0 }, + { "bospit", false, 70, 0, -1, -1, 0 }, + { "boscub", false, 70, 0, -1, -1, 0 }, + { "bossit", false, 70, 0, -1, -1, 0 }, + { "bospn", false, 70, 0, -1, -1, 0 }, + { "bosdth", false, 70, 0, -1, -1, 0 }, + { "manatk", false, 70, 0, -1, -1, 0 }, + { "mandth", false, 70, 0, -1, -1, 0 }, + { "sssit", false, 70, 0, -1, -1, 0 }, + { "ssdth", false, 70, 0, -1, -1, 0 }, + { "keenpn", false, 70, 0, -1, -1, 0 }, + { "keendt", false, 70, 0, -1, -1, 0 }, + { "skeact", false, 70, 0, -1, -1, 0 }, + { "skesit", false, 70, 0, -1, -1, 0 }, + { "skeatk", false, 70, 0, -1, -1, 0 }, + { "radio", false, 60, 0, -1, -1, 0 } }; - diff --git a/sndserv/sounds.h b/sndserv/sounds.h @@ -1,49 +1,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __SOUNDSH__ -#define __SOUNDSH__ - -#include "soundst.h" - - - - - -typedef enum -{ +#define S_MAX_VOLUME 127 +#define S_CLIPPING_DIST (1200*0x10000) +#define S_CLOSE_DIST (200*0x10000) +#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) +#define NORM_PITCH 128 +#define NORM_PRIORITY 64 +#define NORM_VOLUME snd_MaxVolume +#define S_PITCH_PERTURB 1 +#define NORM_SEP 128 +#define S_STEREO_SWING (96*0x10000) +#define S_IFRACVOL 30 +#define NA 0 +#define S_NUMCHANNELS 2 +#define FREQ_LOW 0x40 +#define FREQ_NORM 0x80 +#define FREQ_HIGH 0xff +typedef struct MusicInfo MusicInfo; +typedef struct SfxInfo SfxInfo; +typedef struct Channel Channel; +typedef enum MusicEnum MusicEnum; +typedef enum SfxEnum SfxEnum; +struct MusicInfo { + char* name; /*up to 6 chars*/ + long lumpnum; + void* data; + long handle; +}; +struct SfxInfo { + char* name; /*up to 6*/ + int singularity; + int priority; + SfxInfo* link; + int pitch; + int volume; + void* data; + int usefulness; + int lumpnum; +}; +struct Channel { + SfxInfo* sfxinfo; + void* origin; + int handle; +}; +enum { + Music, + Sfx, + SfxLink +}; +enum { + PC = 1, + Adlib = 2, + SB = 4, + Midi = 8 +}; +enum { + sfxThrowOut = -1, + sfxNotUsed = 0 +}; +void S_Init(int, int); +void S_Start(); +void S_Pause(); +void S_Resume(); +void S_SetMusicVolume(int volume); +void S_SetSfxVolume(int volume); +extern void S_StartSound(void* origin, int sound_id); +extern void S_StartSoundAtVolume(void* origin, int sound_id, int volume); +extern void S_StopSound(void* origin); +extern void S_StartMusic(int music_id); +extern void S_ChangeMusic(int music_id, int looping); +extern void S_StopMusic(); +extern void S_UpdateSounds(void* listener); +void I_SetMusicVolume(int volume); +void I_SetSfxVolume(int volume); +void I_PauseSong(int handle); +void I_ResumeSong(int handle); +void I_PlaySong(int handle, int looping); +void I_StopSong(int handle); +int I_RegisterSong(void *data); +void I_UnRegisterSong(int handle); +int I_IsSongPlaying(int handle); +void I_SetChannels(int channels); +int I_GetSfxLumpNum (SfxInfo*); +int I_StartSound(int id, void* data, int vol, int sep, int pitch, int priority); +void I_UpdateSoundParams(int handle, int vol, int sep, int pitch); +void I_StopSound(int handle); +int I_IsSoundPlaying(int handle); +enum MusicEnum { mus_None, mus_e1m1, mus_e1m2, @@ -112,16 +153,9 @@ typedef enum mus_read_m, mus_dm2ttl, mus_dm2int, - NUMMUSIC -} musicenum_t; - - - - - - -typedef enum -{ + MUS_COUNT +}; +enum SfxEnum { sfx_None, sfx_pistol, sfx_shotgn, @@ -232,10 +266,6 @@ typedef enum sfx_skeatk, sfx_radio, NUMSFX -} sfxenum_t; - -extern musicinfo_t S_music[]; -extern sfxinfo_t S_sfx[]; - -#endif - +}; +extern SfxInfo S_sfx[]; +extern MusicInfo S_music[]; diff --git a/sndserv/soundsrv.c b/sndserv/soundsrv.c @@ -1,46 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $"; - - - -#include <math.h> +#define LENGTH(x) (sizeof(x)/sizeof(x[0])) +#include <string.h> #include <sys/types.h> #include <stdio.h> #include <fcntl.h> @@ -50,121 +9,66 @@ static const char rcsid[] = "$Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $" #include <malloc.h> #include <sys/stat.h> #include <sys/time.h> - #include "sounds.h" #include "soundsrv.h" -#include "wadread.h" - - - - - typedef struct wadinfo_struct { - char identification[4]; int numlumps; int infotableofs; - } wadinfo_t; - typedef struct filelump_struct { int filepos; int size; char name[8]; - } filelump_t; - - static int mytime = 0; - - int numsounds; - - int longsound; - - int lengths[NUMSFX]; - - signed short mixbuffer[MIXBUFFERSIZE]; - - int sfxdevice; - - int musdevice; - - unsigned char* channels[8]; - - unsigned int channelstep[8]; - - unsigned int channelstepremainder[8]; - - unsigned char* channelsend[8]; - - int channelstart[8]; - - int channelhandles[8]; - - int* channelleftvol_lookup[8]; - - int* channelrightvol_lookup[8]; - - int channelids[8]; - int snd_verbose=1; - -int steptable[256]; - +int steptable[256] = { +16384, 16562, 16742, 16925, 17109, 17295, 17484, 17674, 17866, 18061, 18258, 18456, 18657, 18861, 19066, 19274, 19483, 19696, 19910, 20127, 20346, 20568, 20792, 21018, 21247, 21478, 21712, 21949, 22188, 22429, 22673, 22920, 23170, 23422, 23677, 23935, 24196, 24459, 24726, 24995, 25267, 25542, 25820, 26102, 26386, 26673, 26964, 27257, 27554, 27854, 28157, 28464, 28774, 29087, 29404, 29724, 30048, 30375, 30706, 31040, 31378, 31720, 32065, 32415, 32768, 33124, 33485, 33850, 34218, 34591, 34968, 35348, 35733, 36122, 36516, 36913, 37315, 37722, 38132, 38548, 38967, 39392, 39821, 40254, 40693, 41136, 41584, 42037, 42494, 42957, 43425, 43898, 44376, 44859, 45347, 45841, 46340, 46845, 47355, 47871, 48392, 48919, 49452, 49990, 50535, 51085, 51641, 52204, 52772, 53347, 53928, 54515, 55108, 55709, 56315, 56928, 57548, 58175, 58809, 59449, 60096, 60751, 61412, 62081, 62757, 63440, 64131, 64830, 65536, 66249, 66971, 67700, 68437, 69182, 69936, 70697, 71467, 72245, 73032, 73827, 74631, 75444, 76265, 77096, 77935, 78784, 79642, 80509, 81386, 82272, 83168, 84074, 84989, 85915, 86850, 87796, 88752, 89718, 90695, 91683, 92681, 93691, 94711, 95742, 96785, 97839, 98904, 99981, 101070, 102170, 103283, 104408, 105545, 106694, 107856, 109030, 110217, 111418, 112631, 113857, 115097, 116351, 117618, 118898, 120193, 121502, 122825, 124162, 125514, 126881, 128263, 129660, 131072, 132499, 133942, 135400, 136875, 138365, 139872, 141395, 142935, 144491, 146064, 147655, 149263, 150888, 152531, 154192, 155871, 157569, 159284, 161019, 162772, 164545, 166337, 168148, 169979, 171830, 173701, 175592, 177504, 179437, 181391, 183367, 185363, 187382, 189422, 191485, 193570, 195678, 197809, 199963, 202140, 204341, 206566, 208816, 211090, 213388, 215712, 218061, 220435, 222836, 225262, 227715, 230195, 232702, 235236, 237797, 240387, 243004, 245650, 248325, 251029, 253763, 256526, 259320 +}; int vol_lookup[128*256]; - static void derror(char* msg) { fprintf(stderr, "error: %s\n", msg); exit(-1); } - int mix(void) { - register int dl; register int dr; register unsigned int sample; - signed short* leftout; signed short* rightout; signed short* leftend; - int step; - leftout = mixbuffer; rightout = mixbuffer+1; step = 2; - leftend = mixbuffer + SAMPLECOUNT*step; - - while (leftout != leftend) { - dl = 0; dr = 0; - if (channels[0]) { sample = *channels[0]; @@ -173,11 +77,9 @@ int mix(void) channelstepremainder[0] += channelstep[0]; channels[0] += channelstepremainder[0] >> 16; channelstepremainder[0] &= 65536-1; - if (channels[0] >= channelsend[0]) channels[0] = 0; } - if (channels[1]) { sample = *channels[1]; @@ -186,11 +88,9 @@ int mix(void) channelstepremainder[1] += channelstep[1]; channels[1] += channelstepremainder[1] >> 16; channelstepremainder[1] &= 65536-1; - if (channels[1] >= channelsend[1]) channels[1] = 0; } - if (channels[2]) { sample = *channels[2]; @@ -199,7 +99,6 @@ int mix(void) channelstepremainder[2] += channelstep[2]; channels[2] += channelstepremainder[2] >> 16; channelstepremainder[2] &= 65536-1; - if (channels[2] >= channelsend[2]) channels[2] = 0; } @@ -212,7 +111,6 @@ int mix(void) channelstepremainder[3] += channelstep[3]; channels[3] += channelstepremainder[3] >> 16; channelstepremainder[3] &= 65536-1; - if (channels[3] >= channelsend[3]) channels[3] = 0; } @@ -225,7 +123,6 @@ int mix(void) channelstepremainder[4] += channelstep[4]; channels[4] += channelstepremainder[4] >> 16; channelstepremainder[4] &= 65536-1; - if (channels[4] >= channelsend[4]) channels[4] = 0; } @@ -238,7 +135,6 @@ int mix(void) channelstepremainder[5] += channelstep[5]; channels[5] += channelstepremainder[5] >> 16; channelstepremainder[5] &= 65536-1; - if (channels[5] >= channelsend[5]) channels[5] = 0; } @@ -251,7 +147,6 @@ int mix(void) channelstepremainder[6] += channelstep[6]; channels[6] += channelstepremainder[6] >> 16; channelstepremainder[6] &= 65536-1; - if (channels[6] >= channelsend[6]) channels[6] = 0; } @@ -263,16 +158,13 @@ int mix(void) channelstepremainder[7] += channelstep[7]; channels[7] += channelstepremainder[7] >> 16; channelstepremainder[7] &= 65536-1; - if (channels[7] >= channelsend[7]) channels[7] = 0; } - - @@ -283,25 +175,21 @@ int mix(void) *leftout = -0x8000; else *leftout = dl; - if (dr > 0x7fff) *rightout = 0x7fff; else if (dr < -0x8000) *rightout = -0x8000; else *rightout = dr; - leftout += step; rightout += step; - } return 1; } - - - void -grabdata(int argc, char** argv) +grabdata +( int c, + char** v ) { int i; char* name; @@ -310,48 +198,29 @@ grabdata(int argc, char** argv) char* doomuwad; char* doom2wad; char* doom2fwad; - - - char* doomwaddir; - doomwaddir = getenv("DOOMWADDIR"); - if (!doomwaddir) doomwaddir = "."; - doom1wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom1wad, "%s/doom1.wad", doomwaddir); - doom2wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom2wad, "%s/doom2.wad", doomwaddir); - doom2fwad = malloc(strlen(doomwaddir)+1+10+1); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - doomuwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomuwad, "%s/doomu.wad", doomwaddir); - doomwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomwad, "%s/doom.wad", doomwaddir); - - - - - - - - for (i=1 ; i<argc ; i++) + for (i=1 ; i<c ; i++) { - if (!strcmp(argv[i], "-quiet")) + if (!strcmp(v[i], "-quiet")) { snd_verbose = 0; } } - numsounds = NUMSFX; longsound = 0; - if (! access(doom2fwad, R_OK) ) name = doom2fwad; else if (! access(doom2wad, R_OK) ) @@ -362,21 +231,14 @@ grabdata(int argc, char** argv) name = doomwad; else if (! access(doom1wad, R_OK) ) name = doom1wad; - - - - else { fprintf(stderr, "Could not find wadfile anywhere\n"); exit(-1); } - - openwad(name); if (snd_verbose) fprintf(stderr, "loading from [%s]\n", name); - for (i=1 ; i<NUMSFX ; i++) { if (!S_sfx[i].link) @@ -385,7 +247,7 @@ grabdata(int argc, char** argv) if (longsound < lengths[i]) longsound = lengths[i]; } else { S_sfx[i].data = S_sfx[i].link->data; - lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)]; + lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(SfxInfo)]; } @@ -397,22 +259,12 @@ grabdata(int argc, char** argv) } - } - -static struct timeval last={0,0}; - - -static struct timezone whocares; - void updatesounds(void) { - mix(); I_SubmitOutputBuffer(mixbuffer, SAMPLECOUNT); - } - int addsfx ( int sfxid, @@ -421,18 +273,13 @@ addsfx int seperation ) { static unsigned short handlenums = 0; - int i; int rc = -1; - int oldest = mytime; int oldestnum = 0; int slot; int rightvol; int leftvol; - - - if ( sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful @@ -449,7 +296,6 @@ addsfx } } } - for (i=0 ; i<8 && channels[i] ; i++) { if (channelstart[i] < oldest) @@ -458,62 +304,37 @@ addsfx oldest = channelstart[i]; } } - if (i == 8) slot = oldestnum; else slot = i; - channels[slot] = (unsigned char *) S_sfx[sfxid].data; channelsend[slot] = channels[slot] + lengths[sfxid]; - if (!handlenums) handlenums = 100; - channelhandles[slot] = rc = handlenums++; channelstep[slot] = step; channelstepremainder[slot] = 0; channelstart[slot] = mytime; - - seperation += 1; - - leftvol = volume - (volume*seperation*seperation)/(256*256); - seperation = seperation - 257; - - rightvol = volume - (volume*seperation*seperation)/(256*256); - - if (rightvol < 0 || rightvol > 127) derror("rightvol out of bounds"); - if (leftvol < 0 || leftvol > 127) derror("leftvol out of bounds"); - - - channelleftvol_lookup[slot] = &vol_lookup[leftvol*256]; channelrightvol_lookup[slot] = &vol_lookup[rightvol*256]; - channelids[slot] = sfxid; - return rc; - } - - void outputushort(int num) { - static unsigned char buff[5] = { 0, 0, 0, 0, '\n' }; static char* badbuff = "xxxx\n"; - - if (num < 0) { write(1, badbuff, 5); @@ -531,109 +352,62 @@ void outputushort(int num) write(1, buff, 5); } } - void initdata(void) { - - int i; - int j; - - int* steptablemid = steptable + 128; - - for (i=0 ; - i<sizeof(channels)/sizeof(unsigned char *) ; - i++) - { - channels[i] = 0; - } - - gettimeofday(&last, &whocares); - - for (i=-128 ; i<128 ; i++) - steptablemid[i] = pow(2.0, (i/64.0))*65536.0; - - - - - - - - - for (i=0 ; i<128 ; i++) - for (j=0 ; j<256 ; j++) - vol_lookup[i*256+j] = (i*(j-128)*256)/127; - + int i, j; + int* steptablemid; + steptablemid = steptable + 128; + for (i = 0 ; i < LENGTH(channels); ++i) + channels[i] = 0; + for (i = 0; i < 128; ++i) + for (j=0 ; j<256 ; j++) + vol_lookup[i*256+j] = (i*(j-128)*256)/127; } - - - - void quit(void) { I_ShutdownMusic(); I_ShutdownSound(); exit(0); } - - - fd_set fdset; fd_set scratchset; - - int -main(int argc, char** argv) +main(int c, char** v) { int done = 0; int rc; int nrc; int sndnum; int handle = 0; - unsigned char commandbuf[10]; struct timeval zerowait = { 0, 0 }; - int step; int vol; int sep; - int i; int waitingtofinish=0; - - - grabdata(argc, argv); - - + grabdata(c, v); initdata(); - I_InitSound(11025, 16); - I_InitMusic(); - if (snd_verbose) fprintf(stderr, "ready\n"); - - FD_ZERO(&fdset); FD_SET(0, &fdset); - while (!done) { mytime++; - if (!waitingtofinish) { do { scratchset = fdset; rc = select(FD_SETSIZE, &scratchset, 0, 0, &zerowait); - if (rc > 0) { nrc = read(0, commandbuf, 1); - if (!nrc) { done = 1; @@ -642,20 +416,17 @@ main(int argc, char** argv) else { if (snd_verbose) - fprintf(stderr, "cmd: %argc", commandbuf[0]); - + fprintf(stderr, "cmd: %c", commandbuf[0]); switch (commandbuf[0]) { case 'p': read(0, commandbuf, 9); - if (snd_verbose) { commandbuf[9]=0; fprintf(stderr, "%s\n", commandbuf); } - commandbuf[0] -= commandbuf[0]>='a' ? 'a'-10 : '0'; commandbuf[1] -= @@ -672,14 +443,12 @@ main(int argc, char** argv) commandbuf[6]>='a' ? 'a'-10 : '0'; commandbuf[7] -= commandbuf[7]>='a' ? 'a'-10 : '0'; - sndnum = (commandbuf[0]<<4) + commandbuf[1]; step = (commandbuf[2]<<4) + commandbuf[3]; step = steptable[step]; vol = (commandbuf[4]<<4) + commandbuf[5]; sep = (commandbuf[6]<<4) + commandbuf[7]; - handle = addsfx(sndnum, vol, step, sep); @@ -716,9 +485,7 @@ main(int argc, char** argv) } } while (rc > 0); } - updatesounds(); - if (waitingtofinish) { for(i=0 ; i<8 && !channels[i] ; i++); @@ -726,9 +493,7 @@ main(int argc, char** argv) if (i==8) done=1; } - } - quit(); return 0; } diff --git a/sndserv/soundsrv.h b/sndserv/soundsrv.h @@ -1,58 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __SNDSERVER_H__ #define __SNDSERVER_H__ - #define SAMPLECOUNT 512 #define MIXBUFFERSIZE (SAMPLECOUNT*2*2) #define SPEED 11025 - - -void I_InitMusic(void); - -void -I_InitSound -( int samplerate, - int samplesound ); - -void -I_SubmitOutputBuffer -( void* samples, - int samplecount ); - -void I_ShutdownSound(void); -void I_ShutdownMusic(void); - +void I_InitMusic(); +void I_InitSound(int samplerate, int samplesound); +void I_SubmitOutputBuffer(void* samples, int samplecount); +void I_ShutdownSound(); +void I_ShutdownMusic(); +extern void openwad(char* wadname); +extern void* getsfx(char* sfxname, int* len); #endif diff --git a/sndserv/soundst.h b/sndserv/soundst.h @@ -1,312 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __SOUNDSTH__ -#define __SOUNDSTH__ - -#define S_MAX_VOLUME 127 - - - -#define S_CLIPPING_DIST (1200*0x10000) - - -#define S_CLOSE_DIST (200*0x10000) - - -#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) - -#define NORM_PITCH 128 -#define NORM_PRIORITY 64 -#define NORM_VOLUME snd_MaxVolume - -#define S_PITCH_PERTURB 1 -#define NORM_SEP 128 -#define S_STEREO_SWING (96*0x10000) - - -#define S_IFRACVOL 30 - -#define NA 0 -#define S_NUMCHANNELS 2 - - - - - - - -typedef struct -{ - - char* name; - - - int lumpnum; - - - void* data; - - - int handle; - -} musicinfo_t; - - - - - - -typedef struct sfxinfo_struct sfxinfo_t; - -struct sfxinfo_struct -{ - - char* name; - - - int singularity; - - - int priority; - - - sfxinfo_t* link; - - - int pitch; - - - int volume; - - - void* data; - - - - - int usefulness; - - - int lumpnum; -}; - - - -typedef struct -{ - - sfxinfo_t* sfxinfo; - - - void* origin; - - - int handle; - -} channel_t; - - - -enum -{ - Music, - Sfx, - SfxLink -}; - -enum -{ - PC=1, - Adlib=2, - SB=4, - Midi=8 -}; - -enum -{ - sfxThrowOut=-1, - sfxNotUsed=0 -}; - - - - - -void S_Start(void); - - - - - -extern void -S_StartSound -( void* origin, - int sound_id ); - - - - -extern void -S_StartSoundAtVolume -( void* origin, - int sound_id, - int volume ); - - - -extern void S_StopSound(void* origin); - - -extern void S_StartMusic(int music_id); - - - -extern void -S_ChangeMusic -( int music_id, - int looping ); - - - -extern void S_StopMusic(void); - -void S_PauseSound(void); -void S_ResumeSound(void); - - - - - -extern void S_UpdateSounds(void* listener); - -void S_SetMusicVolume(int volume); -void S_SetSfxVolume(int volume); - - - - -void -S_Init -( int , - int ); - - - - - - -#define FREQ_LOW 0x40 -#define FREQ_NORM 0x80 -#define FREQ_HIGH 0xff - - -void I_SetMusicVolume(int volume); -void I_SetSfxVolume(int volume); - - - - -void I_PauseSong(int handle); -void I_ResumeSong(int handle); - - - - - - -void -I_PlaySong -( int handle, - int looping ); - - - -void I_StopSong(int handle); - - -int I_RegisterSong(void *data); - - -void I_UnRegisterSong(int handle); - - -int I_QrySongPlaying(int handle); - - - - - -void I_SetChannels(int channels); - -int I_GetSfxLumpNum (sfxinfo_t*); - - - -int -I_StartSound -( int id, - void* data, - int vol, - int sep, - int pitch, - int priority ); - - - - -void -I_UpdateSoundParams -( int handle, - int vol, - int sep, - int pitch ); - - - -void I_StopSound(int handle); - - - -int I_SoundIsPlaying(int handle); - - - -extern sfxinfo_t S_sfx[]; - - -extern musicinfo_t S_music[]; - -#endif diff --git a/sndserv/wadread.c b/sndserv/wadread.c @@ -1,45 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $"; - - - -#include <malloc.h> #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> @@ -47,64 +5,35 @@ static const char rcsid[] = "$Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $"; #include <stdlib.h> #include <ctype.h> #include <unistd.h> - #include "soundsrv.h" -#include "wadread.h" - - -int* sfxlengths; - -typedef struct wadinfo_struct -{ - char identification[4]; - int numlumps; - int infotableofs; - +int* sfxlengths; +typedef struct wadinfo_struct { + char identification[4]; + int numlumps; + int infotableofs; } wadinfo_t; - -typedef struct filelump_struct -{ - int filepos; - int size; - char name[8]; - +typedef struct filelump_struct { + int filepos; + int size; + char name[8]; } filelump_t; - -typedef struct lumpinfo_struct -{ - int handle; - int filepos; - int size; - char name[8]; - +typedef struct lumpinfo_struct { + int handle; + int filepos; + int size; + char name[8]; } lumpinfo_t; - - - -lumpinfo_t* lumpinfo; -int numlumps; - -void** lumpcache; - - +lumpinfo_t* lumpinfo; +int numlumps; +void** lumpcache; #define strcmpi strcasecmp - - - - - - #ifndef __BIG_ENDIAN__ - #define LONG(x) (x) #define SHORT(x) (x) - #else - #define LONG(x) ((long)SwapLONG((unsigned long) (x))) #define SHORT(x) ((short)SwapSHORT((unsigned short) (x))) - -unsigned long SwapLONG(unsigned long x) +ulong SwapLONG(unsigned long x) { return (x>>24) @@ -112,46 +41,31 @@ unsigned long SwapLONG(unsigned long x) | ((x<<8) & 0xff0000) | (x<<24); } - unsigned short SwapSHORT(unsigned short x) { return (x>>8) | (x<<8); } - #endif - - - - static void derror(char* msg) { fprintf(stderr, "\nwadread error: %s\n", msg); exit(-1); } - - void strupr (char *s) { while (*s) *s++ = toupper(*s); } - int filelength (int handle) { struct stat fileinfo; - if (fstat (handle,&fileinfo) == -1) fprintf (stderr, "Error fstating\n"); - return fileinfo.st_size; } - - - void openwad(char* wadname) { - int wadfile; int tableoffset; int tablelength; @@ -159,30 +73,20 @@ void openwad(char* wadname) int i; wadinfo_t header; filelump_t* filetable; - - wadfile = open(wadname, O_RDONLY); - if (wadfile < 0) derror("Could not open wadfile"); - read(wadfile, &header, sizeof header); - if (strncmp(header.identification, "IWAD", 4)) derror("wadfile has weirdo header"); - numlumps = LONG(header.numlumps); tableoffset = LONG(header.infotableofs); tablelength = numlumps * sizeof(lumpinfo_t); tablefilelength = numlumps * sizeof(filelump_t); lumpinfo = (lumpinfo_t *) malloc(tablelength); filetable = (filelump_t *) ((char*)lumpinfo + tablelength - tablefilelength); - - lseek(wadfile, tableoffset, SEEK_SET); read(wadfile, filetable, tablefilelength); - - for (i=0 ; i<numlumps ; i++) { strncpy(lumpinfo[i].name, filetable[i].name, 8); @@ -191,24 +95,19 @@ void openwad(char* wadname) lumpinfo[i].size = LONG(filetable[i].size); } - } - void* loadlump ( char* lumpname, int* size ) { - int i; void* lump; - for (i=0 ; i<numlumps ; i++) { if (!strncasecmp(lumpinfo[i].name, lumpname, 8)) break; } - if (i == numlumps) { @@ -222,35 +121,25 @@ loadlump read(lumpinfo[i].handle, lump, lumpinfo[i].size); *size = lumpinfo[i].size; } - return lump; - } - void* getsfx ( char* sfxname, int* len ) { - unsigned char* sfx; unsigned char* paddedsfx; int i; int size; int paddedsize; char name[20]; - sprintf(name, "ds%s", sfxname); - sfx = (unsigned char *) loadlump(name, &size); - - paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT; paddedsfx = (unsigned char *) realloc(sfx, paddedsize+8); for (i=size ; i<paddedsize+8 ; i++) paddedsfx[i] = 128; - *len = paddedsize; return (void *) (paddedsfx + 8); - } diff --git a/sndserv/wadread.h b/sndserv/wadread.h @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __WADREAD_H__ -#define __WADREAD_H__ - - - - - - -void openwad(char* wadname); - - - - - - - - - -void* -getsfx -( char* sfxname, - int* len ); - -#endif diff --git a/src/Makefile b/src/Makefile @@ -1,75 +1,79 @@ CC = c89 CFLAGS = -g -Wall -Wpedantic -D_DEFAULT_SOURCE -Wno-deprecated-declarations -LIBS = -lXext -lX11 -lnsl -lm +LIBS = -lXext -lX11 -lm LDFLAGS = ${LIBS} -L/usr/X11R6/lib -SRC = am_map.c \ - d_items.c \ - d_main.c \ - d_net.c \ - doomstat.c \ - dstrings.c \ - f_finale.c \ - f_wipe.c \ - g_game.c \ - hu_lib.c \ - hu_stuff.c \ - i_main.c \ - i_net.c \ - i_sound.c \ + +SRC = doomstat.c \ i_system.c \ - i_video.c \ - info.c \ - m_argv.c \ - m_bbox.c \ - m_cheat.c \ - m_fixed.c \ - m_menu.c \ - m_misc.c \ + i_sound.c \ + i_video.c \ + i_net.c \ + i_main.c \ + tables.c \ + f_finale.c \ + f_wipe.c \ + d_main.c \ + d_net.c \ + d_items.c \ + g_game.c \ + m_menu.c \ + m_misc.c \ + m_argv.c \ + m_bbox.c \ + m_fixed.c \ + m_swap.c \ + m_cheat.c \ m_random.c \ - m_swap.c \ + am_map.c \ p_ceilng.c \ - p_doors.c \ - p_enemy.c \ - p_floor.c \ - p_inter.c \ + p_doors.c \ + p_enemy.c \ + p_floor.c \ + p_inter.c \ p_lights.c \ - p_map.c \ + p_map.c \ p_maputl.c \ - p_mobj.c \ - p_plats.c \ - p_pspr.c \ - p_saveg.c \ - p_setup.c \ - p_sight.c \ - p_spec.c \ + p_plats.c \ + p_pspr.c \ + p_setup.c \ + p_sight.c \ + p_spec.c \ p_switch.c \ + p_mobj.c \ p_telept.c \ - p_tick.c \ - p_user.c \ - r_bsp.c \ - r_data.c \ - r_draw.c \ - r_main.c \ - r_plane.c \ - r_segs.c \ - r_sky.c \ + p_tick.c \ + p_saveg.c \ + p_user.c \ + r_bsp.c \ + r_data.c \ + r_draw.c \ + r_main.c \ + r_plane.c \ + r_segs.c \ r_things.c \ - s_sound.c \ - sounds.c \ - st_lib.c \ - st_stuff.c \ - tables.c \ - v_video.c \ - w_wad.c \ + w_wad.c \ wi_stuff.c \ - z_zone.c + v_video.c \ + st_lib.c \ + st_stuff.c \ + hu_stuff.c \ + hu_lib.c \ + s_sound.c \ + z_zone.c \ + info.c \ + lang.c \ + sounds.c + OBJ = ${SRC:.c=.o} + all: doom + clean: rm -f *.o doom + doom: ${OBJ} ${CC} ${CFLAGS} ${LDFLAGS} ${OBJ} -o $@ + %.o: %.c ${CC} ${CFLAGS} -c $< -o $@ - diff --git a/src/am_map.c b/src/am_map.c @@ -1,4 +1,6 @@ #include <stdio.h> +#include <limits.h> + #include "z_zone.h" #include "doomdef.h" #include "st_stuff.h" @@ -11,6 +13,7 @@ #include "r_state.h" #include "dstrings.h" #include "am_map.h" + #define REDS (256-5*16) #define REDRANGE 16 #define BLUES (256-4*16+8) @@ -67,78 +70,91 @@ #define CXMTOF(x) (f_x + MTOF((x)-m_x)) #define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) #define LINE_NEVERSEE ML_DONTDRAW -typedef struct -{ - int x, y; -} fpoint_t; -typedef struct -{ - fpoint_t a, b; -} fline_t; -typedef struct -{ - fixed_t x,y; -} mpoint_t; -typedef struct -{ - mpoint_t a, b; -} mline_t; -typedef struct -{ - fixed_t slp, islp; -} islope_t; +#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) +#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) +#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) +#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) +#define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) +#define DOOUTCODE(oc, mx, my) \ + (oc) = 0; \ + if ((my) < 0) (oc) |= TOP; \ + if ((my) >= f_h) (oc) |= BOTTOM; \ + if ((mx) < 0) (oc) |= LEFT; \ + if ((mx) >= f_w) (oc) |= RIGHT; + +typedef struct { + int x, y; +}fpoint_t; + +typedef struct { + fpoint_t a, b; +}fline_t; + +typedef struct { + fixed_t x,y; +}mpoint_t; + +typedef struct { + mpoint_t a, b; +}mline_t; + +typedef struct { + fixed_t slp, islp; +}islope_t; + #define R ((8*PLAYERRADIUS)/7) + mline_t player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, - { { R, 0 }, { R-R/2, R/4 } }, - { { R, 0 }, { R-R/2, -R/4 } }, - { { -R+R/8, 0 }, { -R-R/8, R/4 } }, - { { -R+R/8, 0 }, { -R-R/8, -R/4 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, - { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } + {{ -R+R/8, 0 }, { R, 0 }}, + {{ R, 0 }, { R-R/2, R/4 }}, + {{ R, 0 }, { R-R/2, -R/4 }}, + {{ -R+R/8, 0 }, { -R-R/8, R/4 }}, + {{ -R+R/8, 0 }, { -R-R/8, -R/4 }}, + {{ -R+3*R/8, 0 }, { -R+R/8, R/4 }}, + {{ -R+3*R/8, 0 }, { -R+R/8, -R/4 }} }; #undef R -#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) + #define R ((8*PLAYERRADIUS)/7) mline_t cheat_player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, - { { R, 0 }, { R-R/2, R/6 } }, - { { R, 0 }, { R-R/2, -R/6 } }, - { { -R+R/8, 0 }, { -R-R/8, R/6 } }, - { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, - { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, - { { -R/2, 0 }, { -R/2, -R/6 } }, - { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, - { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, - { { -R/6, 0 }, { -R/6, -R/6 } }, - { { -R/6, -R/6 }, { 0, -R/6 } }, - { { 0, -R/6 }, { 0, R/4 } }, - { { R/6, R/4 }, { R/6, -R/7 } }, - { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, - { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } + { { -R+R/8, 0 }, { R, 0 } }, + { { R, 0 }, { R-R/2, R/6 } }, + { { R, 0 }, { R-R/2, -R/6 } }, + { { -R+R/8, 0 }, { -R-R/8, R/6 } }, + { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, + { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, + { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, + { { -R/2, 0 }, { -R/2, -R/6 } }, + { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, + { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, + { { -R/6, 0 }, { -R/6, -R/6 } }, + { { -R/6, -R/6 }, { 0, -R/6 } }, + { { 0, -R/6 }, { 0, R/4 } }, + { { R/6, R/4 }, { R/6, -R/7 } }, + { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, + { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } }; #undef R -#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) + #define R (FRACUNIT) mline_t triangle_guy[] = { - { { -.867*R, -.5*R }, { .867*R, -.5*R } }, - { { .867*R, -.5*R } , { 0, R } }, - { { 0, R }, { -.867*R, -.5*R } } + { { -.867*R, -.5*R }, { .867*R, -.5*R } }, + { { .867*R, -.5*R } , { 0, R } }, + { { 0, R }, { -.867*R, -.5*R } } }; #undef R -#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) + #define R (FRACUNIT) mline_t thintriangle_guy[] = { - { { -.5*R, -.7*R }, { R, 0 } }, - { { R, 0 }, { -.5*R, .7*R } }, - { { -.5*R, .7*R }, { -.5*R, -.7*R } } + { { -.5*R, -.7*R }, { R, 0 } }, + { { R, 0 }, { -.5*R, .7*R } }, + { { -.5*R, .7*R }, { -.5*R, -.7*R } } }; #undef R -#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) + static int cheating = 0; static int grid = 0; -static int leveljuststarted = 1; +static int leveljuststarted = 1; boolean automapactive = false; static int finit_width = SCREENWIDTH; static int finit_height = SCREENHEIGHT - 32; @@ -146,794 +162,716 @@ static int f_x; static int f_y; static int f_w; static int f_h; -static int lightlev; -static byte* fb; +static int lightlev; +static byte* fb; static int amclock; -static mpoint_t m_paninc; -static fixed_t mtof_zoommul; -static fixed_t ftom_zoommul; -static fixed_t m_x, m_y; -static fixed_t m_x2, m_y2; +static mpoint_t m_paninc; +static fixed_t mtof_zoommul; +static fixed_t ftom_zoommul; +static fixed_t m_x, m_y; +static fixed_t m_x2, m_y2; static fixed_t m_w; static fixed_t m_h; static fixed_t min_x; -static fixed_t min_y; +static fixed_t min_y; static fixed_t max_x; static fixed_t max_y; -static fixed_t max_w; -static fixed_t max_h; +static fixed_t max_w; +static fixed_t max_h; static fixed_t min_w; static fixed_t min_h; -static fixed_t min_scale_mtof; -static fixed_t max_scale_mtof; +static fixed_t min_scale_mtof; +static fixed_t max_scale_mtof; static fixed_t old_m_w, old_m_h; static fixed_t old_m_x, old_m_y; static mpoint_t f_oldloc; static fixed_t scale_mtof = INITSCALEMTOF; static fixed_t scale_ftom; -static player_t *plr; -static patch_t *marknums[10]; -static mpoint_t markpoints[AM_NUMMARKPOINTS]; -static int markpointnum = 0; -static int followplayer = 1; +static player_t *plr; +static patch_t *marknums[10]; +static mpoint_t markpoints[AM_NUMMARKPOINTS]; +static int markpointnum = 0; +static int followplayer = 1; static unsigned char cheat_amap_seq[] = { 0xb2, 0x26, 0x26, 0x2e, 0xff }; static cheatseq_t cheat_amap = { cheat_amap_seq, 0 }; static boolean stopped = true; extern boolean viewactive; + +void V_MarkRect(int x, int y, int width, int height); + +void +AM_getIslope(mline_t* ml, islope_t* is) +{ + int dx, dy; + + dy = ml->a.y - ml->b.y; + dx = ml->b.x - ml->a.x; + if (!dy) is->islp = (dx<0?-INT_MAX:INT_MAX); + else is->islp = FixedDiv(dx, dy); + if (!dx) is->slp = (dy<0?-INT_MAX:INT_MAX); + else is->slp = FixedDiv(dy, dx); +} + +void +AM_activateNewScale() +{ + m_x += m_w/2; + m_y += m_h/2; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + m_x -= m_w/2; + m_y -= m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; +} + void -V_MarkRect -( int x, - int y, - int width, - int height ); +AM_saveScaleAndLoc() +{ + old_m_x = m_x; + old_m_y = m_y; + old_m_w = m_w; + old_m_h = m_h; +} + void -AM_getIslope -( mline_t* ml, - islope_t* is ) -{ - int dx, dy; - dy = ml->a.y - ml->b.y; - dx = ml->b.x - ml->a.x; - if (!dy) is->islp = (dx<0?-MAXINT:MAXINT); - else is->islp = FixedDiv(dx, dy); - if (!dx) is->slp = (dy<0?-MAXINT:MAXINT); - else is->slp = FixedDiv(dy, dx); -} -void AM_activateNewScale(void) -{ - m_x += m_w/2; - m_y += m_h/2; - m_w = FTOM(f_w); - m_h = FTOM(f_h); - m_x -= m_w/2; - m_y -= m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; -} -void AM_saveScaleAndLoc(void) -{ - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; -} -void AM_restoreScaleAndLoc(void) -{ - m_w = old_m_w; - m_h = old_m_h; - if (!followplayer) - { - m_x = old_m_x; - m_y = old_m_y; - } else { +AM_restoreScaleAndLoc() +{ + m_w = old_m_w; + m_h = old_m_h; + if (!followplayer) { + m_x = old_m_x; + m_y = old_m_y; + } else { + m_x = plr->mo->x - m_w/2; + m_y = plr->mo->y - m_h/2; + } + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; + scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); +} + +void +AM_addMark() +{ + markpoints[markpointnum].x = m_x + m_w/2; + markpoints[markpointnum].y = m_y + m_h/2; + markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; +} + +void +AM_findMinMaxBoundaries() +{ + int i; + fixed_t a; + fixed_t b; + + min_x = min_y = INT_MAX; + max_x = max_y = -INT_MAX; + for (i = 0; i < numvertexes; ++i) { + if (vertexes[i].x < min_x) min_x = vertexes[i].x; + if (vertexes[i].x > max_x) max_x = vertexes[i].x; + if (vertexes[i].y < min_y) min_y = vertexes[i].y; + if (vertexes[i].y > max_y) max_y = vertexes[i].y; + } + max_w = max_x - min_x; + max_h = max_y - min_y; + min_w = 2 * PLAYERRADIUS; + min_h = 2 * PLAYERRADIUS; + a = FixedDiv(f_w << FRACBITS, max_w); + b = FixedDiv(f_h << FRACBITS, max_h); + min_scale_mtof = a < b ? a : b; + max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS); +} + +void +AM_changeWindowLoc() +{ + if (m_paninc.x || m_paninc.y) { + followplayer = 0; + f_oldloc.x = INT_MAX; + } + m_x += m_paninc.x; + m_y += m_paninc.y; + if (m_x + m_w/2 > max_x) m_x = max_x - m_w/2; + if (m_x + m_w/2 < min_x) m_x = min_x - m_w/2; + if (m_y + m_h/2 > max_y) m_y = max_y - m_h/2; + if (m_y + m_h/2 < min_y) m_y = min_y - m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; +} + +void +AM_initVariables() +{ + static event_t st_notify = { ev_keyup, AM_MSGENTERED }; + int pnum; + + automapactive = true; + fb = screens[0]; + f_oldloc.x = INT_MAX; + amclock = 0; + lightlev = 0; + m_paninc.x = m_paninc.y = 0; + ftom_zoommul = FRACUNIT; + mtof_zoommul = FRACUNIT; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + if (!playeringame[pnum = consoleplayer]) + for (pnum=0;pnum<MAXPLAYERS;pnum++) + if (playeringame[pnum]) break; + plr = &players[pnum]; m_x = plr->mo->x - m_w/2; m_y = plr->mo->y - m_h/2; - } - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; - scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); -} -void AM_addMark(void) -{ - markpoints[markpointnum].x = m_x + m_w/2; - markpoints[markpointnum].y = m_y + m_h/2; - markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; -} -void AM_findMinMaxBoundaries(void) -{ - int i; - fixed_t a; - fixed_t b; - min_x = min_y = MAXINT; - max_x = max_y = -MAXINT; - for (i=0;i<numvertexes;i++) - { - if (vertexes[i].x < min_x) - min_x = vertexes[i].x; - else if (vertexes[i].x > max_x) - max_x = vertexes[i].x; - if (vertexes[i].y < min_y) - min_y = vertexes[i].y; - else if (vertexes[i].y > max_y) - max_y = vertexes[i].y; - } - max_w = max_x - min_x; - max_h = max_y - min_y; - min_w = 2*PLAYERRADIUS; - min_h = 2*PLAYERRADIUS; - a = FixedDiv(f_w<<FRACBITS, max_w); - b = FixedDiv(f_h<<FRACBITS, max_h); - min_scale_mtof = a < b ? a : b; - max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS); -} -void AM_changeWindowLoc(void) -{ - if (m_paninc.x || m_paninc.y) - { - followplayer = 0; - f_oldloc.x = MAXINT; - } - m_x += m_paninc.x; - m_y += m_paninc.y; - if (m_x + m_w/2 > max_x) - m_x = max_x - m_w/2; - else if (m_x + m_w/2 < min_x) - m_x = min_x - m_w/2; - if (m_y + m_h/2 > max_y) - m_y = max_y - m_h/2; - else if (m_y + m_h/2 < min_y) - m_y = min_y - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; -} -void AM_initVariables(void) -{ - int pnum; - static event_t st_notify = { ev_keyup, AM_MSGENTERED }; - automapactive = true; - fb = screens[0]; - f_oldloc.x = MAXINT; - amclock = 0; - lightlev = 0; - m_paninc.x = m_paninc.y = 0; - ftom_zoommul = FRACUNIT; - mtof_zoommul = FRACUNIT; - m_w = FTOM(f_w); - m_h = FTOM(f_h); - if (!playeringame[pnum = consoleplayer]) - for (pnum=0;pnum<MAXPLAYERS;pnum++) - if (playeringame[pnum]) - break; - plr = &players[pnum]; - m_x = plr->mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; - AM_changeWindowLoc(); - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; - ST_Responder(&st_notify); -} -void AM_loadPics(void) -{ - int i; - char namebuf[9]; - for (i=0;i<10;i++) - { - sprintf(namebuf, "AMMNUM%d", i); - marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); - } -} -void AM_unloadPics(void) -{ - int i; - for (i=0;i<10;i++) - Z_ChangeTag(marknums[i], PU_CACHE); + AM_changeWindowLoc(); + old_m_x = m_x; + old_m_y = m_y; + old_m_w = m_w; + old_m_h = m_h; + ST_Responder(&st_notify); } -void AM_clearMarks(void) + +void +AM_loadPics() +{ + int i; + char namebuf[9]; + + for (i = 0; i < 10; ++i) { + sprintf(namebuf, "AMMNUM%d", i); + marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); + } +} + +void +AM_unloadPics() { - int i; - for (i=0;i<AM_NUMMARKPOINTS;i++) - markpoints[i].x = -1; - markpointnum = 0; + int i; + + for (i=0;i<10;i++) + Z_ChangeTag(marknums[i], PU_CACHE); + } -void AM_LevelInit(void) + +void AM_clearMarks() { - leveljuststarted = 0; - f_x = f_y = 0; - f_w = finit_width; - f_h = finit_height; - AM_clearMarks(); - AM_findMinMaxBoundaries(); - scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); - if (scale_mtof > max_scale_mtof) - scale_mtof = min_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + int i; + + for (i=0;i<AM_NUMMARKPOINTS;i++) + markpoints[i].x = -1; + markpointnum = 0; +} + +void +AM_LevelInit() +{ + leveljuststarted = 0; + f_x = f_y = 0; + f_w = finit_width; + f_h = finit_height; + AM_clearMarks(); + AM_findMinMaxBoundaries(); + scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); + if (scale_mtof > max_scale_mtof) scale_mtof = min_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } -void AM_Stop (void) + +void +AM_Stop() { - static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; - AM_unloadPics(); - automapactive = false; - ST_Responder(&st_notify); - stopped = true; + static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; + + AM_unloadPics(); + automapactive = false; + ST_Responder(&st_notify); + stopped = true; } -void AM_Start (void) + +void +AM_Start() { - static int lastlevel = -1, lastepisode = -1; - if (!stopped) AM_Stop(); - stopped = false; - if (lastlevel != gamemap || lastepisode != gameepisode) - { - AM_LevelInit(); - lastlevel = gamemap; - lastepisode = gameepisode; - } - AM_initVariables(); - AM_loadPics(); + static int lastlevel = -1, lastepisode = -1; + + if (!stopped) + AM_Stop(); + stopped = false; + if (lastlevel != gamemap || lastepisode != gameepisode) { + AM_LevelInit(); + lastlevel = gamemap; + lastepisode = gameepisode; + } + AM_initVariables(); + AM_loadPics(); } -void AM_minOutWindowScale(void) + +void +AM_minOutWindowScale() { - scale_mtof = min_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + scale_mtof = min_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + AM_activateNewScale(); } -void AM_maxOutWindowScale(void) + +void +AM_maxOutWindowScale() { - scale_mtof = max_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + scale_mtof = max_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + AM_activateNewScale(); } + boolean -AM_Responder -( event_t* ev ) -{ - int rc; - static int bigstate=0; - static char buffer[20]; - rc = false; - if (!automapactive) - { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) - { - AM_Start (); - viewactive = false; - rc = true; +AM_Responder(event_t* ev) +{ + static int bigstate=0; + static char buffer[20]; + int rc; + + rc = false; + if (!automapactive) { + if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) { + AM_Start(); + viewactive = false; + rc = true; + } } - } - else if (ev->type == ev_keydown) - { - rc = true; - switch(ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = -FTOM(F_PANINC); - else rc = false; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = -FTOM(F_PANINC); - else rc = false; - break; - case AM_ZOOMOUTKEY: - mtof_zoommul = M_ZOOMOUT; - ftom_zoommul = M_ZOOMIN; - break; - case AM_ZOOMINKEY: - mtof_zoommul = M_ZOOMIN; - ftom_zoommul = M_ZOOMOUT; - break; - case AM_ENDKEY: - bigstate = 0; - viewactive = true; - AM_Stop (); - break; - case AM_GOBIGKEY: - bigstate = !bigstate; - if (bigstate) - { - AM_saveScaleAndLoc(); - AM_minOutWindowScale(); - } - else AM_restoreScaleAndLoc(); - break; - case AM_FOLLOWKEY: - followplayer = !followplayer; - f_oldloc.x = MAXINT; - plr->message = followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF; - break; - case AM_GRIDKEY: - grid = !grid; - plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; - break; - case AM_MARKKEY: - sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); - plr->message = buffer; - AM_addMark(); - break; - case AM_CLEARMARKKEY: - AM_clearMarks(); - plr->message = AMSTR_MARKSCLEARED; - break; - default: - rc = false; + else if (ev->type == ev_keydown) { + rc = true; + switch (ev->data1) { + case AM_PANRIGHTKEY: + if (!followplayer) m_paninc.x = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANLEFTKEY: + if (!followplayer) m_paninc.x = -FTOM(F_PANINC); + else rc = false; + break; + case AM_PANUPKEY: + if (!followplayer) m_paninc.y = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANDOWNKEY: + if (!followplayer) m_paninc.y = -FTOM(F_PANINC); + else rc = false; + break; + case AM_ZOOMOUTKEY: + mtof_zoommul = M_ZOOMOUT; + ftom_zoommul = M_ZOOMIN; + break; + case AM_ZOOMINKEY: + mtof_zoommul = M_ZOOMIN; + ftom_zoommul = M_ZOOMOUT; + break; + case AM_ENDKEY: + bigstate = 0; + viewactive = true; + AM_Stop(); + break; + case AM_GOBIGKEY: + bigstate = !bigstate; + if (bigstate) { + AM_saveScaleAndLoc(); + AM_minOutWindowScale(); + } + else AM_restoreScaleAndLoc(); + break; + case AM_FOLLOWKEY: + followplayer = !followplayer; + f_oldloc.x = INT_MAX; + plr->message = followplayer ? lang[AMSTR_FOLLOWON] : lang[AMSTR_FOLLOWOFF]; + break; + case AM_GRIDKEY: + grid = !grid; + plr->message = grid ? lang[AMSTR_GRIDON] : lang[AMSTR_GRIDOFF]; + break; + case AM_MARKKEY: + sprintf(buffer, "%s %d", lang[AMSTR_MARKEDSPOT], markpointnum); + plr->message = buffer; + AM_addMark(); + break; + case AM_CLEARMARKKEY: + AM_clearMarks(); + plr->message = lang[AMSTR_MARKSCLEARED]; + break; + default: + rc = false; + } + if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) { + rc = false; + cheating = (cheating+1) % 3; + } } - if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) - { - rc = false; - cheating = (cheating+1) % 3; + else if (ev->type == ev_keyup) { + rc = false; + switch (ev->data1) { + case AM_PANRIGHTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANLEFTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANUPKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_PANDOWNKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_ZOOMOUTKEY: + case AM_ZOOMINKEY: + mtof_zoommul = FRACUNIT; + ftom_zoommul = FRACUNIT; + break; + } } - } - else if (ev->type == ev_keyup) - { - rc = false; - switch (ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_ZOOMOUTKEY: - case AM_ZOOMINKEY: - mtof_zoommul = FRACUNIT; - ftom_zoommul = FRACUNIT; - break; + return rc; +} + +void +AM_changeWindowScale() +{ + scale_mtof = FixedMul(scale_mtof, mtof_zoommul); + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); + if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); + else AM_activateNewScale(); +} + +void +AM_doFollowPlayer() +{ + if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { + m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; + m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; + f_oldloc.x = plr->mo->x; + f_oldloc.y = plr->mo->y; } - } - return rc; -} -void AM_changeWindowScale(void) -{ - scale_mtof = FixedMul(scale_mtof, mtof_zoommul); - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - if (scale_mtof < min_scale_mtof) - AM_minOutWindowScale(); - else if (scale_mtof > max_scale_mtof) - AM_maxOutWindowScale(); - else - AM_activateNewScale(); } -void AM_doFollowPlayer(void) + +void +AM_updateLightLev() { - if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) - { - m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; - m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; - f_oldloc.x = plr->mo->x; - f_oldloc.y = plr->mo->y; - } + static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; + static int nexttic = 0; + static int litelevelscnt = 0; + + if (amclock>nexttic) { + lightlev = litelevels[litelevelscnt++]; + if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; + nexttic = amclock + 6 - (amclock % 6); + } } -void AM_Ticker (void) +void +AM_Ticker() { - if (!automapactive) - return; - amclock++; - if (followplayer) - AM_doFollowPlayer(); - if (ftom_zoommul != FRACUNIT) + if (!automapactive) + return; + amclock++; + if (followplayer) AM_doFollowPlayer(); + if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); - if (m_paninc.x || m_paninc.y) + if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); } -void AM_clearFB(int color) + +void +AM_clearFB(int color) { - memset(fb, color, f_w*f_h); + memset(fb, color, f_w * f_h); } + boolean -AM_clipMline -( mline_t* ml, - fline_t* fl ) -{ - enum - { - LEFT =1, - RIGHT =2, - BOTTOM =4, - TOP =8 - }; - int outside; - int outcode1 = 0; - int outcode2 = 0; - fpoint_t tmp; - int dx; - int dy; -#define DOOUTCODE(oc, mx, my) \ - (oc) = 0; \ - if ((my) < 0) (oc) |= TOP; \ - else if ((my) >= f_h) (oc) |= BOTTOM; \ - if ((mx) < 0) (oc) |= LEFT; \ - else if ((mx) >= f_w) (oc) |= RIGHT; - if (ml->a.y > m_y2) - outcode1 = TOP; - else if (ml->a.y < m_y) - outcode1 = BOTTOM; - if (ml->b.y > m_y2) - outcode2 = TOP; - else if (ml->b.y < m_y) - outcode2 = BOTTOM; - if (outcode1 & outcode2) - return false; - if (ml->a.x < m_x) - outcode1 |= LEFT; - else if (ml->a.x > m_x2) - outcode1 |= RIGHT; - if (ml->b.x < m_x) - outcode2 |= LEFT; - else if (ml->b.x > m_x2) - outcode2 |= RIGHT; - if (outcode1 & outcode2) - return false; - fl->a.x = CXMTOF(ml->a.x); - fl->a.y = CYMTOF(ml->a.y); - fl->b.x = CXMTOF(ml->b.x); - fl->b.y = CYMTOF(ml->b.y); - DOOUTCODE(outcode1, fl->a.x, fl->a.y); - DOOUTCODE(outcode2, fl->b.x, fl->b.y); - if (outcode1 & outcode2) - return false; - while (outcode1 | outcode2) - { - if (outcode1) - outside = outcode1; - else - outside = outcode2; - if (outside & TOP) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y))/dy; - tmp.y = 0; - } - else if (outside & BOTTOM) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy; - tmp.y = f_h-1; - } - else if (outside & RIGHT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx; - tmp.x = f_w-1; - } - else if (outside & LEFT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; - tmp.x = 0; +AM_clipMline(mline_t* ml, fline_t* fl) +{ + enum { + LEFT =1, + RIGHT =2, + BOTTOM =4, + TOP =8 + }; + + int outcode1, outcode2, outside, dx, dy; + fpoint_t tmp; + + outcode1 = outcode2 = 0; + if (ml->a.y > m_y2) outcode1 = TOP; + if (ml->a.y < m_y) outcode1 = BOTTOM; + if (ml->b.y > m_y2) outcode2 = TOP; + if (ml->b.y < m_y) outcode2 = BOTTOM; + if (outcode1 & outcode2) return false; + if (ml->a.x < m_x) outcode1 |= LEFT; + if (ml->a.x > m_x2) outcode1 |= RIGHT; + if (ml->b.x < m_x) outcode2 |= LEFT; + if (ml->b.x > m_x2) outcode2 |= RIGHT; + if (outcode1 & outcode2) return false; + fl->a.x = CXMTOF(ml->a.x); + fl->a.y = CYMTOF(ml->a.y); + fl->b.x = CXMTOF(ml->b.x); + fl->b.y = CYMTOF(ml->b.y); + DOOUTCODE(outcode1, fl->a.x, fl->a.y); + DOOUTCODE(outcode2, fl->b.x, fl->b.y); + if (outcode1 & outcode2) return false; + + while (outcode1 | outcode2) { + if (outcode1) outside = outcode1; + else outside = outcode2; + if (outside & TOP) { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx*(fl->a.y))/dy; + tmp.y = 0; + } + if (outside & BOTTOM) { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy; + tmp.y = f_h-1; + } + if (outside & RIGHT) { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx; + tmp.x = f_w-1; + } + if (outside & LEFT) { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; + tmp.x = 0; + } + if (outside == outcode1) { + fl->a = tmp; + DOOUTCODE(outcode1, fl->a.x, fl->a.y); + } else { + fl->b = tmp; + DOOUTCODE(outcode2, fl->b.x, fl->b.y); + } + if (outcode1 & outcode2) return false; } - if (outside == outcode1) - { - fl->a = tmp; - DOOUTCODE(outcode1, fl->a.x, fl->a.y); + return true; +} +#undef DOOUTCODE + +void +AM_drawFline(fline_t* fl, int color) +{ + static int fuck = 0; + int x, y, dx, dy, sx, sy, ax, ay, d; + if (fl->a.x < 0 || fl->a.x >= f_w || fl->a.y < 0 || fl->a.y >= f_h || fl->b.x < 0 || fl->b.x >= f_w || fl->b.y < 0 || fl->b.y >= f_h) { + fprintf(stderr, "fuck %d \r", fuck++); + return; } - else - { - fl->b = tmp; - DOOUTCODE(outcode2, fl->b.x, fl->b.y); + dx = fl->b.x - fl->a.x; + ax = 2 * (dx<0 ? -dx : dx); + sx = dx<0 ? -1 : 1; + dy = fl->b.y - fl->a.y; + ay = 2 * (dy<0 ? -dy : dy); + sy = dy<0 ? -1 : 1; + x = fl->a.x; + y = fl->a.y; + if (ax > ay) { + d = ay - ax/2; + for (;;) { + PUTDOT(x,y,color); + if (x == fl->b.x) return; + if (d>=0) { + y += sy; + d -= ax; + } + x += sx; + d += ay; + } + } else { + d = ax - ay/2; + for (;;) { + PUTDOT(x, y, color); + if (y == fl->b.y) return; + if (d >= 0) { + x += sx; + d -= ay; + } + y += sy; + d += ax; + } } - if (outcode1 & outcode2) - return false; - } - return true; } -#undef DOOUTCODE + void -AM_drawFline -( fline_t* fl, - int color ) -{ - register int x; - register int y; - register int dx; - register int dy; - register int sx; - register int sy; - register int ax; - register int ay; - register int d; - static int fuck = 0; - if ( fl->a.x < 0 || fl->a.x >= f_w - || fl->a.y < 0 || fl->a.y >= f_h - || fl->b.x < 0 || fl->b.x >= f_w - || fl->b.y < 0 || fl->b.y >= f_h) - { - fprintf(stderr, "fuck %d \r", fuck++); - return; - } -#define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) - dx = fl->b.x - fl->a.x; - ax = 2 * (dx<0 ? -dx : dx); - sx = dx<0 ? -1 : 1; - dy = fl->b.y - fl->a.y; - ay = 2 * (dy<0 ? -dy : dy); - sy = dy<0 ? -1 : 1; - x = fl->a.x; - y = fl->a.y; - if (ax > ay) - { - d = ay - ax/2; - while (1) - { - PUTDOT(x,y,color); - if (x == fl->b.x) return; - if (d>=0) - { - y += sy; - d -= ax; - } - x += sx; - d += ay; +AM_drawMline(mline_t* ml, int color) +{ + static fline_t fl; + + if (AM_clipMline(ml, &fl)) AM_drawFline(&fl, color); +} + +void +AM_drawGrid(int color) +{ + fixed_t x, y, start, end; + mline_t ml; + + start = m_x; + if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); + end = m_x + m_w; + ml.a.y = m_y; + ml.b.y = m_y+m_h; + for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) { + ml.a.x = x; + ml.b.x = x; + AM_drawMline(&ml, color); } - } - else - { - d = ax - ay/2; - while (1) - { - PUTDOT(x, y, color); - if (y == fl->b.y) return; - if (d >= 0) - { - x += sx; - d -= ay; - } - y += sy; - d += ax; + start = m_y; + if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); + end = m_y + m_h; + ml.a.x = m_x; + ml.b.x = m_x + m_w; + for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) { + ml.a.y = y; + ml.b.y = y; + AM_drawMline(&ml, color); } - } } + void -AM_drawMline -( mline_t* ml, - int color ) -{ - static fline_t fl; - if (AM_clipMline(ml, &fl)) - AM_drawFline(&fl, color); -} -void AM_drawGrid(int color) -{ - fixed_t x, y; - fixed_t start, end; - mline_t ml; - start = m_x; - if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) - start += (MAPBLOCKUNITS<<FRACBITS) - - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); - end = m_x + m_w; - ml.a.y = m_y; - ml.b.y = m_y+m_h; - for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) - { - ml.a.x = x; - ml.b.x = x; - AM_drawMline(&ml, color); - } - start = m_y; - if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) - start += (MAPBLOCKUNITS<<FRACBITS) - - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); - end = m_y + m_h; - ml.a.x = m_x; - ml.b.x = m_x + m_w; - for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) - { - ml.a.y = y; - ml.b.y = y; - AM_drawMline(&ml, color); - } -} -void AM_drawWalls(void) -{ - int i; - static mline_t l; - for (i=0;i<numlines;i++) - { - l.a.x = lines[i].v1->x; - l.a.y = lines[i].v1->y; - l.b.x = lines[i].v2->x; - l.b.y = lines[i].v2->y; - if (cheating || (lines[i].flags & ML_MAPPED)) - { - if ((lines[i].flags & LINE_NEVERSEE) && !cheating) - continue; - if (!lines[i].backsector) - { - AM_drawMline(&l, WALLCOLORS+lightlev); - } - else - { - if (lines[i].special == 39) - { - AM_drawMline(&l, WALLCOLORS+WALLRANGE/2); - } - else if (lines[i].flags & ML_SECRET) - { - if (cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev); - else AM_drawMline(&l, WALLCOLORS+lightlev); - } - else if (lines[i].backsector->floorheight - != lines[i].frontsector->floorheight) { - AM_drawMline(&l, FDWALLCOLORS + lightlev); - } - else if (lines[i].backsector->ceilingheight - != lines[i].frontsector->ceilingheight) { - AM_drawMline(&l, CDWALLCOLORS+lightlev); - } - else if (cheating) { - AM_drawMline(&l, TSWALLCOLORS+lightlev); +AM_drawWalls() +{ + static mline_t l; + int i; + + for (i=0;i<numlines;i++) { + l.a.x = lines[i].v1->x; + l.a.y = lines[i].v1->y; + l.b.x = lines[i].v2->x; + l.b.y = lines[i].v2->y; + if (cheating || (lines[i].flags & ML_MAPPED)) { + if ((lines[i].flags & LINE_NEVERSEE) && !cheating) continue; + if (!lines[i].backsector) AM_drawMline(&l, WALLCOLORS+lightlev); + else { + if (lines[i].special == 39) AM_drawMline(&l, WALLCOLORS+WALLRANGE/2); + if (lines[i].flags & ML_SECRET) { + if (cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev); + else AM_drawMline(&l, WALLCOLORS+lightlev); + } + if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) AM_drawMline(&l, FDWALLCOLORS + lightlev); + if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) AM_drawMline(&l, CDWALLCOLORS+lightlev); + if (cheating) AM_drawMline(&l, TSWALLCOLORS+lightlev); + } } - } - } - else if (plr->powers[pw_allmap]) - { - if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); + if (plr->powers[pw_allmap]) + if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); } - } } + void -AM_rotate -( fixed_t* x, - fixed_t* y, - angle_t a ) -{ - fixed_t tmpx; - tmpx = - FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); - *y = - FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) - + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); - *x = tmpx; +AM_rotate(fixed_t* x, fixed_t* y, angle_t a) +{ + fixed_t tmpx; + + tmpx = FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); + *y = FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); + *x = tmpx; } + void -AM_drawLineCharacter -( mline_t* lineguy, - int lineguylines, - fixed_t scale, - angle_t angle, - int color, - fixed_t x, - fixed_t y ) -{ - int i; - mline_t l; - for (i=0;i<lineguylines;i++) - { - l.a.x = lineguy[i].a.x; - l.a.y = lineguy[i].a.y; - if (scale) - { - l.a.x = FixedMul(scale, l.a.x); - l.a.y = FixedMul(scale, l.a.y); - } - if (angle) - AM_rotate(&l.a.x, &l.a.y, angle); - l.a.x += x; - l.a.y += y; - l.b.x = lineguy[i].b.x; - l.b.y = lineguy[i].b.y; - if (scale) - { - l.b.x = FixedMul(scale, l.b.x); - l.b.y = FixedMul(scale, l.b.y); +AM_drawLineCharacter(mline_t* lineguy, int lineguylines, fixed_t scale, angle_t angle, int color, fixed_t x, fixed_t y) +{ + mline_t l; + int i; + + for (i = 0; i < lineguylines; ++i) { + l.a.x = lineguy[i].a.x; + l.a.y = lineguy[i].a.y; + if (scale) { + l.a.x = FixedMul(scale, l.a.x); + l.a.y = FixedMul(scale, l.a.y); + } + if (angle) AM_rotate(&l.a.x, &l.a.y, angle); + l.a.x += x; + l.a.y += y; + l.b.x = lineguy[i].b.x; + l.b.y = lineguy[i].b.y; + if (scale) { + l.b.x = FixedMul(scale, l.b.x); + l.b.y = FixedMul(scale, l.b.y); + } + if (angle) AM_rotate(&l.b.x, &l.b.y, angle); + l.b.x += x; + l.b.y += y; + AM_drawMline(&l, color); } - if (angle) - AM_rotate(&l.b.x, &l.b.y, angle); - l.b.x += x; - l.b.y += y; - AM_drawMline(&l, color); - } -} -void AM_drawPlayers(void) -{ - int i; - player_t* p; - static int their_colors[] = { GREENS, GRAYS, BROWNS, REDS }; - int their_color = -1; - int color; - if (!netgame) - { - if (cheating) - AM_drawLineCharacter - (cheat_player_arrow, NUMCHEATPLYRLINES, 0, - plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); - else - AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, plr->mo->angle, - WHITE, plr->mo->x, plr->mo->y); - return; - } - for (i=0;i<MAXPLAYERS;i++) - { - their_color++; - p = &players[i]; - if ( (deathmatch && !singledemo) && p != plr) - continue; - if (!playeringame[i]) - continue; - if (p->powers[pw_invisibility]) - color = 246; - else - color = their_colors[their_color]; - AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, p->mo->angle, - color, p->mo->x, p->mo->y); - } } + void -AM_drawThings -( int colors, - int colorrange) -{ - int i; - mobj_t* t; - for (i=0;i<numsectors;i++) - { - t = sectors[i].thinglist; - while (t) - { - AM_drawLineCharacter - (thintriangle_guy, NUMTHINTRIANGLEGUYLINES, - 16<<FRACBITS, t->angle, colors+lightlev, t->x, t->y); - t = t->snext; +AM_drawPlayers() +{ + static int their_colors[] = { GREENS, GRAYS, BROWNS, REDS }; + player_t* p; + int i, color, their_color; + + their_color = -1; + if (!netgame) { + if (cheating) AM_drawLineCharacter(cheat_player_arrow, NUMCHEATPLYRLINES, 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); + else AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); + return; } - } -} -void AM_drawMarks(void) -{ - int i, fx, fy, w, h; - for (i=0;i<AM_NUMMARKPOINTS;i++) - { - if (markpoints[i].x != -1) - { - w = 5; - h = 6; - fx = CXMTOF(markpoints[i].x); - fy = CYMTOF(markpoints[i].y); - if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) - V_DrawPatch(fx, fy, FB, marknums[i]); + for (i = 0; i < MAXPLAYERS; ++i) { + ++their_color; + p = &players[i]; + if ((deathmatch && !singledemo) && p != plr) continue; + if (!playeringame[i]) continue; + if (p->powers[pw_invisibility]) color = 246; + else color = their_colors[their_color]; + AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y); } - } } -void AM_drawCrosshair(int color) + +void +AM_drawThings(int colors, int colorrange) { - fb[(f_w*(f_h+1))/2] = color; + mobj_t* t; + int i; + + for (i = 0; i < numsectors; ++i) + for (t = sectors[i].thinglist; t; t = t->snext) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors+lightlev, t->x, t->y); } -void AM_Drawer (void) + +void +AM_drawMarks() { - if (!automapactive) return; - AM_clearFB(BACKGROUND); - if (grid) - AM_drawGrid(GRIDCOLORS); - AM_drawWalls(); - AM_drawPlayers(); - if (cheating==2) - AM_drawThings(THINGCOLORS, THINGRANGE); - AM_drawCrosshair(XHAIRCOLORS); - AM_drawMarks(); - V_MarkRect(f_x, f_y, f_w, f_h); + int i, fx, fy, w, h; + + for (i = 0; i < AM_NUMMARKPOINTS; ++i) { + if (markpoints[i].x != -1) { + w = 5; + h = 6; + fx = CXMTOF(markpoints[i].x); + fy = CYMTOF(markpoints[i].y); + if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) V_DrawPatch(fx, fy, FB, marknums[i]); + } + } +} + +void +AM_drawCrosshair(int color) +{ + fb[(f_w*(f_h+1))/2] = color; +} + +void +AM_Drawer() +{ + if (!automapactive) + return; + AM_clearFB(BACKGROUND); + if (grid) AM_drawGrid(GRIDCOLORS); + AM_drawWalls(); + AM_drawPlayers(); + if (cheating==2) AM_drawThings(THINGCOLORS, THINGRANGE); + AM_drawCrosshair(XHAIRCOLORS); + AM_drawMarks(); + V_MarkRect(f_x, f_y, f_w, f_h); } diff --git a/src/am_map.h b/src/am_map.h @@ -1,10 +1,13 @@ #ifndef __AMMAP_H__ #define __AMMAP_H__ + #define AM_MSGHEADER (('a'<<24)+('m'<<16)) #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) -boolean AM_Responder (event_t* ev); -void AM_Ticker (void); -void AM_Drawer (void); -void AM_Stop (void); + +boolean AM_Responder(event_t* ev); +void AM_Ticker(); +void AM_Drawer(); +void AM_Stop(); + #endif diff --git a/src/d_englsh.h b/src/d_englsh.h @@ -1,522 +0,0 @@ -#ifndef __D_ENGLSH__ -#define __D_ENGLSH__ -#define D_DEVSTR "Development mode ON.\n" -#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n" -#define PRESSKEY "press a key." -#define PRESSYN "press y or n." -#define QUITMSG "are you sure you want to\nquit this great game?" -#define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY -#define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY -#define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY -#define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY -#define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN -#define QLPROMPT "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN -#define NEWGAME \ -"you can't start a new game\n"\ -"while in a network game.\n\n"PRESSKEY -#define NIGHTMARE \ -"are you sure? this skill level\n"\ -"isn't even remotely fair.\n\n"PRESSYN -#define SWSTRING \ -"this is the shareware version of doom.\n\n"\ -"you need to order the entire trilogy.\n\n"PRESSKEY -#define MSGOFF "Messages OFF" -#define MSGON "Messages ON" -#define NETEND "you can't end a netgame!\n\n"PRESSKEY -#define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN -#define DOSY "(press y to quit)" -#define DETAILHI "High detail" -#define DETAILLO "Low detail" -#define GAMMALVL0 "Gamma correction OFF" -#define GAMMALVL1 "Gamma correction level 1" -#define GAMMALVL2 "Gamma correction level 2" -#define GAMMALVL3 "Gamma correction level 3" -#define GAMMALVL4 "Gamma correction level 4" -#define EMPTYSTRING "empty slot" -#define GOTARMOR "Picked up the armor." -#define GOTMEGA "Picked up the MegaArmor!" -#define GOTHTHBONUS "Picked up a health bonus." -#define GOTARMBONUS "Picked up an armor bonus." -#define GOTSTIM "Picked up a stimpack." -#define GOTMEDINEED "Picked up a medikit that you REALLY need!" -#define GOTMEDIKIT "Picked up a medikit." -#define GOTSUPER "Supercharge!" -#define GOTBLUECARD "Picked up a blue keycard." -#define GOTYELWCARD "Picked up a yellow keycard." -#define GOTREDCARD "Picked up a red keycard." -#define GOTBLUESKUL "Picked up a blue skull key." -#define GOTYELWSKUL "Picked up a yellow skull key." -#define GOTREDSKULL "Picked up a red skull key." -#define GOTINVUL "Invulnerability!" -#define GOTBERSERK "Berserk!" -#define GOTINVIS "Partial Invisibility" -#define GOTSUIT "Radiation Shielding Suit" -#define GOTMAP "Computer Area Map" -#define GOTVISOR "Light Amplification Visor" -#define GOTMSPHERE "MegaSphere!" -#define GOTCLIP "Picked up a clip." -#define GOTCLIPBOX "Picked up a box of bullets." -#define GOTROCKET "Picked up a rocket." -#define GOTROCKBOX "Picked up a box of rockets." -#define GOTCELL "Picked up an energy cell." -#define GOTCELLBOX "Picked up an energy cell pack." -#define GOTSHELLS "Picked up 4 shotgun shells." -#define GOTSHELLBOX "Picked up a box of shotgun shells." -#define GOTBACKPACK "Picked up a backpack full of ammo!" -#define GOTBFG9000 "You got the BFG9000! Oh, yes." -#define GOTCHAINGUN "You got the chaingun!" -#define GOTCHAINSAW "A chainsaw! Find some meat!" -#define GOTLAUNCHER "You got the rocket launcher!" -#define GOTPLASMA "You got the plasma gun!" -#define GOTSHOTGUN "You got the shotgun!" -#define GOTSHOTGUN2 "You got the super shotgun!" -#define PD_BLUEO "You need a blue key to activate this object" -#define PD_REDO "You need a red key to activate this object" -#define PD_YELLOWO "You need a yellow key to activate this object" -#define PD_BLUEK "You need a blue key to open this door" -#define PD_REDK "You need a red key to open this door" -#define PD_YELLOWK "You need a yellow key to open this door" -#define GGSAVED "game saved." -#define HUSTR_MSGU "[Message unsent]" -#define HUSTR_E1M1 "E1M1: Hangar" -#define HUSTR_E1M2 "E1M2: Nuclear Plant" -#define HUSTR_E1M3 "E1M3: Toxin Refinery" -#define HUSTR_E1M4 "E1M4: Command Control" -#define HUSTR_E1M5 "E1M5: Phobos Lab" -#define HUSTR_E1M6 "E1M6: Central Processing" -#define HUSTR_E1M7 "E1M7: Computer Station" -#define HUSTR_E1M8 "E1M8: Phobos Anomaly" -#define HUSTR_E1M9 "E1M9: Military Base" -#define HUSTR_E2M1 "E2M1: Deimos Anomaly" -#define HUSTR_E2M2 "E2M2: Containment Area" -#define HUSTR_E2M3 "E2M3: Refinery" -#define HUSTR_E2M4 "E2M4: Deimos Lab" -#define HUSTR_E2M5 "E2M5: Command Center" -#define HUSTR_E2M6 "E2M6: Halls of the Damned" -#define HUSTR_E2M7 "E2M7: Spawning Vats" -#define HUSTR_E2M8 "E2M8: Tower of Babel" -#define HUSTR_E2M9 "E2M9: Fortress of Mystery" -#define HUSTR_E3M1 "E3M1: Hell Keep" -#define HUSTR_E3M2 "E3M2: Slough of Despair" -#define HUSTR_E3M3 "E3M3: Pandemonium" -#define HUSTR_E3M4 "E3M4: House of Pain" -#define HUSTR_E3M5 "E3M5: Unholy Cathedral" -#define HUSTR_E3M6 "E3M6: Mt. Erebus" -#define HUSTR_E3M7 "E3M7: Limbo" -#define HUSTR_E3M8 "E3M8: Dis" -#define HUSTR_E3M9 "E3M9: Warrens" -#define HUSTR_E4M1 "E4M1: Hell Beneath" -#define HUSTR_E4M2 "E4M2: Perfect Hatred" -#define HUSTR_E4M3 "E4M3: Sever The Wicked" -#define HUSTR_E4M4 "E4M4: Unruly Evil" -#define HUSTR_E4M5 "E4M5: They Will Repent" -#define HUSTR_E4M6 "E4M6: Against Thee Wickedly" -#define HUSTR_E4M7 "E4M7: And Hell Followed" -#define HUSTR_E4M8 "E4M8: Unto The Cruel" -#define HUSTR_E4M9 "E4M9: Fear" -#define HUSTR_1 "level 1: entryway" -#define HUSTR_2 "level 2: underhalls" -#define HUSTR_3 "level 3: the gantlet" -#define HUSTR_4 "level 4: the focus" -#define HUSTR_5 "level 5: the waste tunnels" -#define HUSTR_6 "level 6: the crusher" -#define HUSTR_7 "level 7: dead simple" -#define HUSTR_8 "level 8: tricks and traps" -#define HUSTR_9 "level 9: the pit" -#define HUSTR_10 "level 10: refueling base" -#define HUSTR_11 "level 11: 'o' of destruction!" -#define HUSTR_12 "level 12: the factory" -#define HUSTR_13 "level 13: downtown" -#define HUSTR_14 "level 14: the inmost dens" -#define HUSTR_15 "level 15: industrial zone" -#define HUSTR_16 "level 16: suburbs" -#define HUSTR_17 "level 17: tenements" -#define HUSTR_18 "level 18: the courtyard" -#define HUSTR_19 "level 19: the citadel" -#define HUSTR_20 "level 20: gotcha!" -#define HUSTR_21 "level 21: nirvana" -#define HUSTR_22 "level 22: the catacombs" -#define HUSTR_23 "level 23: barrels o' fun" -#define HUSTR_24 "level 24: the chasm" -#define HUSTR_25 "level 25: bloodfalls" -#define HUSTR_26 "level 26: the abandoned mines" -#define HUSTR_27 "level 27: monster condo" -#define HUSTR_28 "level 28: the spirit world" -#define HUSTR_29 "level 29: the living end" -#define HUSTR_30 "level 30: icon of sin" -#define HUSTR_31 "level 31: wolfenstein" -#define HUSTR_32 "level 32: grosse" -#define PHUSTR_1 "level 1: congo" -#define PHUSTR_2 "level 2: well of souls" -#define PHUSTR_3 "level 3: aztec" -#define PHUSTR_4 "level 4: caged" -#define PHUSTR_5 "level 5: ghost town" -#define PHUSTR_6 "level 6: baron's lair" -#define PHUSTR_7 "level 7: caughtyard" -#define PHUSTR_8 "level 8: realm" -#define PHUSTR_9 "level 9: abattoire" -#define PHUSTR_10 "level 10: onslaught" -#define PHUSTR_11 "level 11: hunted" -#define PHUSTR_12 "level 12: speed" -#define PHUSTR_13 "level 13: the crypt" -#define PHUSTR_14 "level 14: genesis" -#define PHUSTR_15 "level 15: the twilight" -#define PHUSTR_16 "level 16: the omen" -#define PHUSTR_17 "level 17: compound" -#define PHUSTR_18 "level 18: neurosphere" -#define PHUSTR_19 "level 19: nme" -#define PHUSTR_20 "level 20: the death domain" -#define PHUSTR_21 "level 21: slayer" -#define PHUSTR_22 "level 22: impossible mission" -#define PHUSTR_23 "level 23: tombstone" -#define PHUSTR_24 "level 24: the final frontier" -#define PHUSTR_25 "level 25: the temple of darkness" -#define PHUSTR_26 "level 26: bunker" -#define PHUSTR_27 "level 27: anti-christ" -#define PHUSTR_28 "level 28: the sewers" -#define PHUSTR_29 "level 29: odyssey of noises" -#define PHUSTR_30 "level 30: the gateway of hell" -#define PHUSTR_31 "level 31: cyberden" -#define PHUSTR_32 "level 32: go 2 it" -#define THUSTR_1 "level 1: system control" -#define THUSTR_2 "level 2: human bbq" -#define THUSTR_3 "level 3: power control" -#define THUSTR_4 "level 4: wormhole" -#define THUSTR_5 "level 5: hanger" -#define THUSTR_6 "level 6: open season" -#define THUSTR_7 "level 7: prison" -#define THUSTR_8 "level 8: metal" -#define THUSTR_9 "level 9: stronghold" -#define THUSTR_10 "level 10: redemption" -#define THUSTR_11 "level 11: storage facility" -#define THUSTR_12 "level 12: crater" -#define THUSTR_13 "level 13: nukage processing" -#define THUSTR_14 "level 14: steel works" -#define THUSTR_15 "level 15: dead zone" -#define THUSTR_16 "level 16: deepest reaches" -#define THUSTR_17 "level 17: processing area" -#define THUSTR_18 "level 18: mill" -#define THUSTR_19 "level 19: shipping/respawning" -#define THUSTR_20 "level 20: central processing" -#define THUSTR_21 "level 21: administration center" -#define THUSTR_22 "level 22: habitat" -#define THUSTR_23 "level 23: lunar mining project" -#define THUSTR_24 "level 24: quarry" -#define THUSTR_25 "level 25: baron's den" -#define THUSTR_26 "level 26: ballistyx" -#define THUSTR_27 "level 27: mount pain" -#define THUSTR_28 "level 28: heck" -#define THUSTR_29 "level 29: river styx" -#define THUSTR_30 "level 30: last call" -#define THUSTR_31 "level 31: pharaoh" -#define THUSTR_32 "level 32: caribbean" -#define HUSTR_CHATMACRO1 "I'm ready to kick butt!" -#define HUSTR_CHATMACRO2 "I'm OK." -#define HUSTR_CHATMACRO3 "I'm not looking too good!" -#define HUSTR_CHATMACRO4 "Help!" -#define HUSTR_CHATMACRO5 "You suck!" -#define HUSTR_CHATMACRO6 "Next time, scumbag..." -#define HUSTR_CHATMACRO7 "Come here!" -#define HUSTR_CHATMACRO8 "I'll take care of it." -#define HUSTR_CHATMACRO9 "Yes" -#define HUSTR_CHATMACRO0 "No" -#define HUSTR_TALKTOSELF1 "You mumble to yourself" -#define HUSTR_TALKTOSELF2 "Who's there?" -#define HUSTR_TALKTOSELF3 "You scare yourself" -#define HUSTR_TALKTOSELF4 "You start to rave" -#define HUSTR_TALKTOSELF5 "You've lost it..." -#define HUSTR_MESSAGESENT "[Message Sent]" -#define HUSTR_PLRGREEN "Green: " -#define HUSTR_PLRINDIGO "Indigo: " -#define HUSTR_PLRBROWN "Brown: " -#define HUSTR_PLRRED "Red: " -#define HUSTR_KEYGREEN 'g' -#define HUSTR_KEYINDIGO 'i' -#define HUSTR_KEYBROWN 'b' -#define HUSTR_KEYRED 'r' -#define AMSTR_FOLLOWON "Follow Mode ON" -#define AMSTR_FOLLOWOFF "Follow Mode OFF" -#define AMSTR_GRIDON "Grid ON" -#define AMSTR_GRIDOFF "Grid OFF" -#define AMSTR_MARKEDSPOT "Marked Spot" -#define AMSTR_MARKSCLEARED "All Marks Cleared" -#define STSTR_MUS "Music Change" -#define STSTR_NOMUS "IMPOSSIBLE SELECTION" -#define STSTR_DQDON "Degreelessness Mode On" -#define STSTR_DQDOFF "Degreelessness Mode Off" -#define STSTR_KFAADDED "Very Happy Ammo Added" -#define STSTR_FAADDED "Ammo (no keys) Added" -#define STSTR_NCON "No Clipping Mode ON" -#define STSTR_NCOFF "No Clipping Mode OFF" -#define STSTR_BEHOLD "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp" -#define STSTR_BEHOLDX "Power-up Toggled" -#define STSTR_CHOPPERS "... doesn't suck - GM" -#define STSTR_CLEV "Changing Level..." -#define E1TEXT \ -"Once you beat the big badasses and\n"\ -"clean out the moon base you're supposed\n"\ -"to win, aren't you? Aren't you? Where's\n"\ -"your fat reward and ticket home? What\n"\ -"the hell is this? It's not supposed to\n"\ -"end this way!\n"\ -"\n" \ -"It stinks like rotten meat, but looks\n"\ -"like the lost Deimos base. Looks like\n"\ -"you're stuck on The Shores of Hell.\n"\ -"The only way out is through.\n"\ -"\n"\ -"To continue the DOOM experience, play\n"\ -"The Shores of Hell and its amazing\n"\ -"sequel, Inferno!\n" -#define E2TEXT \ -"You've done it! The hideous cyber-\n"\ -"demon lord that ruled the lost Deimos\n"\ -"moon base has been slain and you\n"\ -"are triumphant! But ... where are\n"\ -"you? You clamber to the edge of the\n"\ -"moon and look down to see the awful\n"\ -"truth.\n" \ -"\n"\ -"Deimos floats above Hell itself!\n"\ -"You've never heard of anyone escaping\n"\ -"from Hell, but you'll make the bastards\n"\ -"sorry they ever heard of you! Quickly,\n"\ -"you rappel down to the surface of\n"\ -"Hell.\n"\ -"\n" \ -"Now, it's on to the final chapter of\n"\ -"DOOM! -- Inferno." -#define E3TEXT \ -"The loathsome spiderdemon that\n"\ -"masterminded the invasion of the moon\n"\ -"bases and caused so much death has had\n"\ -"its ass kicked for all time.\n"\ -"\n"\ -"A hidden doorway opens and you enter.\n"\ -"You've proven too tough for Hell to\n"\ -"contain, and now Hell at last plays\n"\ -"fair -- for you emerge from the door\n"\ -"to see the green fields of Earth!\n"\ -"Home at last.\n" \ -"\n"\ -"You wonder what's been happening on\n"\ -"Earth while you were battling evil\n"\ -"unleashed. It's good that no Hell-\n"\ -"spawn could have come through that\n"\ -"door with you ..." -#define E4TEXT \ -"the spider mastermind must have sent forth\n"\ -"its legions of hellspawn before your\n"\ -"final confrontation with that terrible\n"\ -"beast from hell. but you stepped forward\n"\ -"and brought forth eternal damnation and\n"\ -"suffering upon the horde as a true hero\n"\ -"would in the face of something so evil.\n"\ -"\n"\ -"besides, someone was gonna pay for what\n"\ -"happened to daisy, your pet rabbit.\n"\ -"\n"\ -"but now, you see spread before you more\n"\ -"potential pain and gibbitude as a nation\n"\ -"of demons run amok among our cities.\n"\ -"\n"\ -"next stop, hell on earth!" -#define C1TEXT \ -"YOU HAVE ENTERED DEEPLY INTO THE INFESTED\n" \ -"STARPORT. BUT SOMETHING IS WRONG. THE\n" \ -"MONSTERS HAVE BROUGHT THEIR OWN REALITY\n" \ -"WITH THEM, AND THE STARPORT'S TECHNOLOGY\n" \ -"IS BEING SUBVERTED BY THEIR PRESENCE.\n" \ -"\n"\ -"AHEAD, YOU SEE AN OUTPOST OF HELL, A\n" \ -"FORTIFIED ZONE. IF YOU CAN GET PAST IT,\n" \ -"YOU CAN PENETRATE INTO THE HAUNTED HEART\n" \ -"OF THE STARBASE AND FIND THE CONTROLLING\n" \ -"SWITCH WHICH HOLDS EARTH'S POPULATION\n" \ -"HOSTAGE." -#define C2TEXT \ -"YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" \ -"HUMANKIND TO EVACUATE EARTH AND ESCAPE\n"\ -"THE NIGHTMARE. NOW YOU ARE THE ONLY\n"\ -"HUMAN LEFT ON THE FACE OF THE PLANET.\n"\ -"CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n"\ -"AND EVIL SPIRITS ARE YOUR ONLY NEIGHBORS.\n"\ -"YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n"\ -"THAT YOU HAVE SAVED YOUR SPECIES.\n"\ -"\n"\ -"BUT THEN, EARTH CONTROL BEAMS DOWN A\n"\ -"MESSAGE FROM SPACE: \"SENSORS HAVE LOCATED\n"\ -"THE SOURCE OF THE ALIEN INVASION. IF YOU\n"\ -"GO THERE, YOU MAY BE ABLE TO BLOCK THEIR\n"\ -"ENTRY. THE ALIEN BASE IS IN THE HEART OF\n"\ -"YOUR OWN HOME CITY, NOT FAR FROM THE\n"\ -"STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n"\ -"UP AND RETURN TO THE FRAY." -#define C3TEXT \ -"YOU ARE AT THE CORRUPT HEART OF THE CITY,\n"\ -"SURROUNDED BY THE CORPSES OF YOUR ENEMIES.\n"\ -"YOU SEE NO WAY TO DESTROY THE CREATURES'\n"\ -"ENTRYWAY ON THIS SIDE, SO YOU CLENCH YOUR\n"\ -"TEETH AND PLUNGE THROUGH IT.\n"\ -"\n"\ -"THERE MUST BE A WAY TO CLOSE IT ON THE\n"\ -"OTHER SIDE. WHAT DO YOU CARE IF YOU'VE\n"\ -"GOT TO GO THROUGH HELL TO GET TO IT?" -#define C4TEXT \ -"THE HORRENDOUS VISAGE OF THE BIGGEST\n"\ -"DEMON YOU'VE EVER SEEN CRUMBLES BEFORE\n"\ -"YOU, AFTER YOU PUMP YOUR ROCKETS INTO\n"\ -"HIS EXPOSED BRAIN. THE MONSTER SHRIVELS\n"\ -"UP AND DIES, ITS THRASHING LIMBS\n"\ -"DEVASTATING UNTOLD MILES OF HELL'S\n"\ -"SURFACE.\n"\ -"\n"\ -"YOU'VE DONE IT. THE INVASION IS OVER.\n"\ -"EARTH IS SAVED. HELL IS A WRECK. YOU\n"\ -"WONDER WHERE BAD FOLKS WILL GO WHEN THEY\n"\ -"DIE, NOW. WIPING THE SWEAT FROM YOUR\n"\ -"FOREHEAD YOU BEGIN THE LONG TREK BACK\n"\ -"HOME. REBUILDING EARTH OUGHT TO BE A\n"\ -"LOT MORE FUN THAN RUINING IT WAS.\n" -#define C5TEXT \ -"CONGRATULATIONS, YOU'VE FOUND THE SECRET\n"\ -"LEVEL! LOOKS LIKE IT'S BEEN BUILT BY\n"\ -"HUMANS, RATHER THAN DEMONS. YOU WONDER\n"\ -"WHO THE INMATES OF THIS CORNER OF HELL\n"\ -"WILL BE." -#define C6TEXT \ -"CONGRATULATIONS, YOU'VE FOUND THE\n"\ -"SUPER SECRET LEVEL! YOU'D BETTER\n"\ -"BLAZE THROUGH THIS ONE!\n" -#define P1TEXT \ -"You gloat over the steaming carcass of the\n"\ -"Guardian. With its death, you've wrested\n"\ -"the Accelerator from the stinking claws\n"\ -"of Hell. You relax and glance around the\n"\ -"room. Damn! There was supposed to be at\n"\ -"least one working prototype, but you can't\n"\ -"see it. The demons must have taken it.\n"\ -"\n"\ -"You must find the prototype, or all your\n"\ -"struggles will have been wasted. Keep\n"\ -"moving, keep fighting, keep killing.\n"\ -"Oh yes, keep living, too." -#define P2TEXT \ -"Even the deadly Arch-Vile labyrinth could\n"\ -"not stop you, and you've gotten to the\n"\ -"prototype Accelerator which is soon\n"\ -"efficiently and permanently deactivated.\n"\ -"\n"\ -"You're good at that kind of thing." -#define P3TEXT \ -"You've bashed and battered your way into\n"\ -"the heart of the devil-hive. Time for a\n"\ -"Search-and-Destroy mission, aimed at the\n"\ -"Gatekeeper, whose foul offspring is\n"\ -"cascading to Earth. Yeah, he's bad. But\n"\ -"you know who's worse!\n"\ -"\n"\ -"Grinning evilly, you check your gear, and\n"\ -"get ready to give the bastard a little Hell\n"\ -"of your own making!" -#define P4TEXT \ -"The Gatekeeper's evil face is splattered\n"\ -"all over the place. As its tattered corpse\n"\ -"collapses, an inverted Gate forms and\n"\ -"sucks down the shards of the last\n"\ -"prototype Accelerator, not to mention the\n"\ -"few remaining demons. You're done. Hell\n"\ -"has gone back to pounding bad dead folks \n"\ -"instead of good live ones. Remember to\n"\ -"tell your grandkids to put a rocket\n"\ -"launcher in your coffin. If you go to Hell\n"\ -"when you die, you'll need it for some\n"\ -"final cleaning-up ..." -#define P5TEXT \ -"You've found the second-hardest level we\n"\ -"got. Hope you have a saved game a level or\n"\ -"two previous. If not, be prepared to die\n"\ -"aplenty. For master marines only." -#define P6TEXT \ -"Betcha wondered just what WAS the hardest\n"\ -"level we had ready for ya? Now you know.\n"\ -"No one gets out alive." -#define T1TEXT \ -"You've fought your way out of the infested\n"\ -"experimental labs. It seems that UAC has\n"\ -"once again gulped it down. With their\n"\ -"high turnover, it must be hard for poor\n"\ -"old UAC to buy corporate health insurance\n"\ -"nowadays..\n"\ -"\n"\ -"Ahead lies the military complex, now\n"\ -"swarming with diseased horrors hot to get\n"\ -"their teeth into you. With luck, the\n"\ -"complex still has some warlike ordnance\n"\ -"laying around." -#define T2TEXT \ -"You hear the grinding of heavy machinery\n"\ -"ahead. You sure hope they're not stamping\n"\ -"out new hellspawn, but you're ready to\n"\ -"ream out a whole herd if you have to.\n"\ -"They might be planning a blood feast, but\n"\ -"you feel about as mean as two thousand\n"\ -"maniacs packed into one mad killer.\n"\ -"\n"\ -"You don't plan to go down easy." -#define T3TEXT \ -"The vista opening ahead looks real damn\n"\ -"familiar. Smells familiar, too -- like\n"\ -"fried excrement. You didn't like this\n"\ -"place before, and you sure as hell ain't\n"\ -"planning to like it now. The more you\n"\ -"brood on it, the madder you get.\n"\ -"Hefting your gun, an evil grin trickles\n"\ -"onto your face. Time to take some names." -#define T4TEXT \ -"Suddenly, all is silent, from one horizon\n"\ -"to the other. The agonizing echo of Hell\n"\ -"fades away, the nightmare sky turns to\n"\ -"blue, the heaps of monster corpses start \n"\ -"to evaporate along with the evil stench \n"\ -"that filled the air. Jeeze, maybe you've\n"\ -"done it. Have you really won?\n"\ -"\n"\ -"Something rumbles in the distance.\n"\ -"A blue light begins to glow inside the\n"\ -"ruined skull of the demon-spitter." -#define T5TEXT \ -"What now? Looks totally different. Kind\n"\ -"of like King Tut's condo. Well,\n"\ -"whatever's here can't be any worse\n"\ -"than usual. Can it? Or maybe it's best\n"\ -"to let sleeping gods lie.." -#define T6TEXT \ -"Time for a vacation. You've burst the\n"\ -"bowels of hell and by golly you're ready\n"\ -"for a break. You mutter to yourself,\n"\ -"Maybe someone else can kick Hell's ass\n"\ -"next time around. Ahead lies a quiet town,\n"\ -"with peaceful flowing water, quaint\n"\ -"buildings, and presumably no Hellspawn.\n"\ -"\n"\ -"As you step off the transport, you hear\n"\ -"the stomp of a cyberdemon's iron shoe." -#define CC_ZOMBIE "ZOMBIEMAN" -#define CC_SHOTGUN "SHOTGUN GUY" -#define CC_HEAVY "HEAVY WEAPON DUDE" -#define CC_IMP "IMP" -#define CC_DEMON "DEMON" -#define CC_LOST "LOST SOUL" -#define CC_CACO "CACODEMON" -#define CC_HELL "HELL KNIGHT" -#define CC_BARON "BARON OF HELL" -#define CC_ARACH "ARACHNOTRON" -#define CC_PAIN "PAIN ELEMENTAL" -#define CC_REVEN "REVENANT" -#define CC_MANCU "MANCUBUS" -#define CC_ARCH "ARCH-VILE" -#define CC_SPIDER "THE SPIDER MASTERMIND" -#define CC_CYBER "THE CYBERDEMON" -#define CC_HERO "OUR HERO" -#endif diff --git a/src/d_event.h b/src/d_event.h @@ -1,50 +1,55 @@ #ifndef __D_EVENT__ #define __D_EVENT__ -#include "doomtype.h" -typedef enum -{ - ev_keydown, - ev_keyup, - ev_mouse, - ev_joystick -} evtype_t; -typedef struct -{ - evtype_t type; - int data1; - int data2; - int data3; -} event_t; -typedef enum -{ - ga_nothing, - ga_loadlevel, - ga_newgame, - ga_loadgame, - ga_savegame, - ga_playdemo, - ga_completed, - ga_victory, - ga_worlddone, - ga_screenshot + +#include "doomdef.h" + +typedef enum { + ev_keydown, + ev_keyup, + ev_mouse, + ev_joystick +}evtype_t; + + +typedef struct { + evtype_t type; + int data1; + int data2; + int data3; +}event_t; + + +typedef enum { + ga_nothing, + ga_loadlevel, + ga_newgame, + ga_loadgame, + ga_savegame, + ga_playdemo, + ga_completed, + ga_victory, + ga_worlddone } gameaction_t; -typedef enum -{ - BT_ATTACK = 1, - BT_USE = 2, - BT_SPECIAL = 128, - BT_SPECIALMASK = 3, - BT_CHANGE = 4, - BT_WEAPONMASK = (8+16+32), - BT_WEAPONSHIFT = 3, - BTS_PAUSE = 1, - BTS_SAVEGAME = 2, - BTS_SAVEMASK = (4+8+16), - BTS_SAVESHIFT = 2 -} buttoncode_t; + +typedef enum { + BT_ATTACK = 1, + BT_USE = 2, + BT_SPECIAL = 128, + BT_SPECIALMASK = 3, + BT_CHANGE = 4, + BT_WEAPONMASK = (8+16+32), + BT_WEAPONSHIFT = 3, + BTS_PAUSE = 1, + BTS_SAVEGAME = 2, + BTS_SAVEMASK = (4+8+16), + BTS_SAVESHIFT = 2 +}buttoncode_t; + #define MAXEVENTS 64 -extern event_t events[MAXEVENTS]; -extern int eventhead; -extern int eventtail; -extern gameaction_t gameaction; + +extern event_t events[MAXEVENTS]; +extern int eventhead; +extern int eventtail; +extern gameaction_t gameaction; + #endif diff --git a/src/d_french.h b/src/d_french.h @@ -1,5 +1,6 @@ #ifndef __D_FRENCH__ #define __D_FRENCH__ + #define D_DEVSTR "MODE DEVELOPPEMENT ON.\n" #define D_CDROM "VERSION CD-ROM: DEFAULT.CFG DANS C:\\DOOMDATA\n" #define PRESSKEY "APPUYEZ SUR UNE TOUCHE." @@ -8,21 +9,15 @@ #define LOADNET "VOUS NE POUVEZ PAS CHARGER\nUN JEU EN RESEAU!\n\n"PRESSKEY #define QLOADNET "CHARGEMENT RAPIDE INTERDIT EN RESEAU!\n\n"PRESSKEY #define QSAVESPOT "VOUS N'AVEZ PAS CHOISI UN EMPLACEMENT!\n\n"PRESSKEY -#define SAVEDEAD "VOUS NE POUVEZ PAS SAUVER SI VOUS NE JOUEZ "\ -"PAS!\n\n"PRESSKEY +#define SAVEDEAD "VOUS NE POUVEZ PAS SAUVER SI VOUS NE JOUEZ PAS!\n\n"PRESSKEY #define QSPROMPT "SAUVEGARDE RAPIDE DANS LE FICHIER \n\n'%s'?\n\n"PRESSYN -#define QLPROMPT "VOULEZ-VOUS CHARGER LA SAUVEGARDE"\ -"\n\n'%s'?\n\n"PRESSYN -#define NEWGAME "VOUS NE POUVEZ PAS LANCER\n"\ -"UN NOUVEAU JEU SUR RESEAU.\n\n"PRESSKEY -#define NIGHTMARE "VOUS CONFIRMEZ? CE NIVEAU EST\n"\ -"VRAIMENT IMPITOYABLE!n"PRESSYN -#define SWSTRING "CECI EST UNE VERSION SHAREWARE DE DOOM.\n\n"\ -"VOUS DEVRIEZ COMMANDER LA TRILOGIE COMPLETE.\n\n"PRESSKEY +#define QLPROMPT "VOULEZ-VOUS CHARGER LA SAUVEGARDE\n\n'%s'?\n\n"PRESSYN +#define NEWGAME "VOUS NE POUVEZ PAS LANCER\nUN NOUVEAU JEU SUR RESEAU.\n\n"PRESSKEY +#define NIGHTMARE "VOUS CONFIRMEZ? CE NIVEAU EST\nVRAIMENT IMPITOYABLE!n"PRESSYN +#define SWSTRING "CECI EST UNE VERSION SHAREWARE DE DOOM.\n\nVOUS DEVRIEZ COMMANDER LA TRILOGIE COMPLETE.\n\n"PRESSKEY #define MSGOFF "MESSAGES OFF" #define MSGON "MESSAGES ON" -#define NETEND "VOUS NE POUVEZ PAS METTRE FIN A UN JEU SUR "\ -"RESEAU!\n\n"PRESSKEY +#define NETEND "VOUS NE POUVEZ PAS METTRE FIN A UN JEU SUR RESEAU!\n\n"PRESSKEY #define ENDGAME "VOUS VOULEZ VRAIMENT METTRE FIN AU JEU?\n\n"PRESSYN #define DOSY "(APPUYEZ SUR Y POUR REVENIR AU OS.)" #define DETAILHI "GRAPHISMES MAXIMUM " @@ -179,116 +174,15 @@ #define STSTR_BEHOLDX "AMELIORATION ACTIVEE" #define STSTR_CHOPPERS "... DOESN'T SUCK - GM" #define STSTR_CLEV "CHANGEMENT DE NIVEAU..." -#define E1TEXT "APRES AVOIR VAINCU LES GROS MECHANTS\n"\ -"ET NETTOYE LA BASE LUNAIRE, VOUS AVEZ\n"\ -"GAGNE, NON? PAS VRAI? OU EST DONC VOTRE\n"\ -" RECOMPENSE ET VOTRE BILLET DE\n"\ -"RETOUR? QU'EST-QUE CA VEUT DIRE?CE"\ -"N'EST PAS LA FIN ESPEREE!\n"\ -"\n" \ -"CA SENT LA VIANDE PUTREFIEE, MAIS\n"\ -"ON DIRAIT LA BASE DEIMOS. VOUS ETES\n"\ -"APPAREMMENT BLOQUE AUX PORTES DE L'ENFER.\n"\ -"LA SEULE ISSUE EST DE L'AUTRE COTE.\n"\ -"\n"\ -"POUR VIVRE LA SUITE DE DOOM, JOUEZ\n"\ -"A 'AUX PORTES DE L'ENFER' ET A\n"\ -"L'EPISODE SUIVANT, 'L'ENFER'!\n" -#define E2TEXT "VOUS AVEZ REUSSI. L'INFAME DEMON\n"\ -"QUI CONTROLAIT LA BASE LUNAIRE DE\n"\ -"DEIMOS EST MORT, ET VOUS AVEZ\n"\ -"TRIOMPHE! MAIS... OU ETES-VOUS?\n"\ -"VOUS GRIMPEZ JUSQU'AU BORD DE LA\n"\ -"LUNE ET VOUS DECOUVREZ L'ATROCE\n"\ -"VERITE.\n" \ -"\n"\ -"DEIMOS EST AU-DESSUS DE L'ENFER!\n"\ -"VOUS SAVEZ QUE PERSONNE NE S'EN\n"\ -"EST JAMAIS ECHAPPE, MAIS CES FUMIERS\n"\ -"VONT REGRETTER DE VOUS AVOIR CONNU!\n"\ -"VOUS REDESCENDEZ RAPIDEMENT VERS\n"\ -"LA SURFACE DE L'ENFER.\n"\ -"\n" \ -"VOICI MAINTENANT LE CHAPITRE FINAL DE\n"\ -"DOOM! -- L'ENFER." -#define E3TEXT "LE DEMON ARACHNEEN ET REPUGNANT\n"\ -"QUI A DIRIGE L'INVASION DES BASES\n"\ -"LUNAIRES ET SEME LA MORT VIENT DE SE\n"\ -"FAIRE PULVERISER UNE FOIS POUR TOUTES.\n"\ -"\n"\ -"UNE PORTE SECRETE S'OUVRE. VOUS ENTREZ.\n"\ -"VOUS AVEZ PROUVE QUE VOUS POUVIEZ\n"\ -"RESISTER AUX HORREURS DE L'ENFER.\n"\ -"IL SAIT ETRE BEAU JOUEUR, ET LORSQUE\n"\ -"VOUS SORTEZ, VOUS REVOYEZ LES VERTES\n"\ -"PRAIRIES DE LA TERRE, VOTRE PLANETE.\n"\ -"\n"\ -"VOUS VOUS DEMANDEZ CE QUI S'EST PASSE\n"\ -"SUR TERRE PENDANT QUE VOUS AVEZ\n"\ -"COMBATTU LE DEMON. HEUREUSEMENT,\n"\ -"AUCUN GERME DU MAL N'A FRANCHI\n"\ -"CETTE PORTE AVEC VOUS..." -#define C1TEXT "VOUS ETES AU PLUS PROFOND DE L'ASTROPORT\n" \ -"INFESTE DE MONSTRES, MAIS QUELQUE CHOSE\n" \ -"NE VA PAS. ILS ONT APPORTE LEUR PROPRE\n" \ -"REALITE, ET LA TECHNOLOGIE DE L'ASTROPORT\n" \ -"EST AFFECTEE PAR LEUR PRESENCE.\n" \ -"\n"\ -"DEVANT VOUS, VOUS VOYEZ UN POSTE AVANCE\n" \ -"DE L'ENFER, UNE ZONE FORTIFIEE. SI VOUS\n" \ -"POUVEZ PASSER, VOUS POURREZ PENETRER AU\n" \ -"COEUR DE LA BASE HANTEE ET TROUVER \n" \ -"L'INTERRUPTEUR DE CONTROLE QUI GARDE LA \n" \ -"POPULATION DE LA TERRE EN OTAGE." -#define C2TEXT "VOUS AVEZ GAGNE! VOTRE VICTOIRE A PERMIS\n" \ -"A L'HUMANITE D'EVACUER LA TERRE ET \n"\ -"D'ECHAPPER AU CAUCHEMAR. VOUS ETES \n"\ -"MAINTENANT LE DERNIER HUMAIN A LA SURFACE \n"\ -"DE LA PLANETE. VOUS ETES ENTOURE DE \n"\ -"MUTANTS CANNIBALES, D'EXTRATERRESTRES \n"\ -"CARNIVORES ET D'ESPRITS DU MAL. VOUS \n"\ -"ATTENDEZ CALMEMENT LA MORT, HEUREUX \n"\ -"D'AVOIR PU SAUVER VOTRE RACE.\n"\ -"MAIS UN MESSAGE VOUS PARVIENT SOUDAIN\n"\ -"DE L'ESPACE: \"NOS CAPTEURS ONT LOCALISE\n"\ -"LA SOURCE DE L'INVASION EXTRATERRESTRE.\n"\ -"SI VOUS Y ALLEZ, VOUS POURREZ PEUT-ETRE\n"\ -"LES ARRETER. LEUR BASE EST SITUEE AU COEUR\n"\ -"DE VOTRE VILLE NATALE, PRES DE L'ASTROPORT.\n"\ -"VOUS VOUS RELEVEZ LENTEMENT ET PENIBLEMENT\n"\ -"ET VOUS REPARTEZ POUR LE FRONT." -#define C3TEXT "VOUS ETES AU COEUR DE LA CITE CORROMPUE,\n"\ -"ENTOURE PAR LES CADAVRES DE VOS ENNEMIS.\n"\ -"VOUS NE VOYEZ PAS COMMENT DETRUIRE LA PORTE\n"\ -"DES CREATURES DE CE COTE. VOUS SERREZ\n"\ -"LES DENTS ET PLONGEZ DANS L'OUVERTURE.\n"\ -"\n"\ -"IL DOIT Y AVOIR UN MOYEN DE LA FERMER\n"\ -"DE L'AUTRE COTE. VOUS ACCEPTEZ DE\n"\ -"TRAVERSER L'ENFER POUR LE FAIRE?" -#define C4TEXT "LE VISAGE HORRIBLE D'UN DEMON D'UNE\n"\ -"TAILLE INCROYABLE S'EFFONDRE DEVANT\n"\ -"VOUS LORSQUE VOUS TIREZ UNE SALVE DE\n"\ -"ROQUETTES DANS SON CERVEAU. LE MONSTRE\n"\ -"SE RATATINE, SES MEMBRES DECHIQUETES\n"\ -"SE REPANDANT SUR DES CENTAINES DE\n"\ -"KILOMETRES A LA SURFACE DE L'ENFER.\n"\ -"\n"\ -"VOUS AVEZ REUSSI. L'INVASION N'AURA.\n"\ -"PAS LIEU. LA TERRE EST SAUVEE. L'ENFER\n"\ -"EST ANEANTI. EN VOUS DEMANDANT OU IRONT\n"\ -"MAINTENANT LES DAMNES, VOUS ESSUYEZ\n"\ -"VOTRE FRONT COUVERT DE SUEUR ET REPARTEZ\n"\ -"VERS LA TERRE. SA RECONSTRUCTION SERA\n"\ -"BEAUCOUP PLUS DROLE QUE SA DESTRUCTION.\n" -#define C5TEXT "FELICITATIONS! VOUS AVEZ TROUVE LE\n"\ -"NIVEAU SECRET! IL SEMBLE AVOIR ETE\n"\ -"CONSTRUIT PAR LES HUMAINS. VOUS VOUS\n"\ -"DEMANDEZ QUELS PEUVENT ETRE LES\n"\ -"HABITANTS DE CE COIN PERDU DE L'ENFER." -#define C6TEXT "FELICITATIONS! VOUS AVEZ DECOUVERT\n"\ -"LE NIVEAU SUPER SECRET! VOUS FERIEZ\n"\ -"MIEUX DE FONCER DANS CELUI-LA!\n" +#define E1TEXT "APRES AVOIR VAINCU LES GROS MECHANTS\nET NETTOYE LA BASE LUNAIRE, VOUS AVEZ\nGAGNE, NON? PAS VRAI? OU EST DONC VOTRE\n RECOMPENSE ET VOTRE BILLET DE\nRETOUR? QU'EST-QUE CA VEUT DIRE?CEN'EST PAS LA FIN ESPEREE!\n\nCA SENT LA VIANDE PUTREFIEE, MAIS\nON DIRAIT LA BASE DEIMOS. VOUS ETES\nAPPAREMMENT BLOQUE AUX PORTES DE L'ENFER.\nLA SEULE ISSUE EST DE L'AUTRE COTE.\n\nPOUR VIVRE LA SUITE DE DOOM, JOUEZ\nA 'AUX PORTES DE L'ENFER' ET A\nL'EPISODE SUIVANT, 'L'ENFER'!\n" +#define E2TEXT "VOUS AVEZ REUSSI. L'INFAME DEMON\nQUI CONTROLAIT LA BASE LUNAIRE DE\nDEIMOS EST MORT, ET VOUS AVEZ\nTRIOMPHE! MAIS... OU ETES-VOUS?\nVOUS GRIMPEZ JUSQU'AU BORD DE LA\nLUNE ET VOUS DECOUVREZ L'ATROCE\nVERITE.\n\nDEIMOS EST AU-DESSUS DE L'ENFER!\nVOUS SAVEZ QUE PERSONNE NE S'EN\nEST JAMAIS ECHAPPE, MAIS CES FUMIERS\nVONT REGRETTER DE VOUS AVOIR CONNU!\nVOUS REDESCENDEZ RAPIDEMENT VERS\nLA SURFACE DE L'ENFER.\n\nVOICI MAINTENANT LE CHAPITRE FINAL DE\nDOOM! -- L'ENFER." +#define E3TEXT "LE DEMON ARACHNEEN ET REPUGNANT\nQUI A DIRIGE L'INVASION DES BASES\nLUNAIRES ET SEME LA MORT VIENT DE SE\nFAIRE PULVERISER UNE FOIS POUR TOUTES.\n\nUNE PORTE SECRETE S'OUVRE. VOUS ENTREZ.\nVOUS AVEZ PROUVE QUE VOUS POUVIEZ\nRESISTER AUX HORREURS DE L'ENFER.\nIL SAIT ETRE BEAU JOUEUR, ET LORSQUE\nVOUS SORTEZ, VOUS REVOYEZ LES VERTES\nPRAIRIES DE LA TERRE, VOTRE PLANETE.\n\nVOUS VOUS DEMANDEZ CE QUI S'EST PASSE\nSUR TERRE PENDANT QUE VOUS AVEZ\nCOMBATTU LE DEMON. HEUREUSEMENT,\nAUCUN GERME DU MAL N'A FRANCHI\nCETTE PORTE AVEC VOUS..." +#define C1TEXT "VOUS ETES AU PLUS PROFOND DE L'ASTROPORT\nINFESTE DE MONSTRES, MAIS QUELQUE CHOSE\nNE VA PAS. ILS ONT APPORTE LEUR PROPRE\nREALITE, ET LA TECHNOLOGIE DE L'ASTROPORT\nEST AFFECTEE PAR LEUR PRESENCE.\n\nDEVANT VOUS, VOUS VOYEZ UN POSTE AVANCE\nDE L'ENFER, UNE ZONE FORTIFIEE. SI VOUS\nPOUVEZ PASSER, VOUS POURREZ PENETRER AU\nCOEUR DE LA BASE HANTEE ET TROUVER \nL'INTERRUPTEUR DE CONTROLE QUI GARDE LA \nPOPULATION DE LA TERRE EN OTAGE." +#define C2TEXT "VOUS AVEZ GAGNE! VOTRE VICTOIRE A PERMIS\nA L'HUMANITE D'EVACUER LA TERRE ET \nD'ECHAPPER AU CAUCHEMAR. VOUS ETES \nMAINTENANT LE DERNIER HUMAIN A LA SURFACE \nDE LA PLANETE. VOUS ETES ENTOURE DE \nMUTANTS CANNIBALES, D'EXTRATERRESTRES \nCARNIVORES ET D'ESPRITS DU MAL. VOUS \nATTENDEZ CALMEMENT LA MORT, HEUREUX \nD'AVOIR PU SAUVER VOTRE RACE.\nMAIS UN MESSAGE VOUS PARVIENT SOUDAIN\nDE L'ESPACE: \"NOS CAPTEURS ONT LOCALISE\nLA SOURCE DE L'INVASION EXTRATERRESTRE.\nSI VOUS Y ALLEZ, VOUS POURREZ PEUT-ETRE\nLES ARRETER. LEUR BASE EST SITUEE AU COEUR\nDE VOTRE VILLE NATALE, PRES DE L'ASTROPORT.\nVOUS VOUS RELEVEZ LENTEMENT ET PENIBLEMENT\nET VOUS REPARTEZ POUR LE FRONT." +#define C3TEXT "VOUS ETES AU COEUR DE LA CITE CORROMPUE,\nENTOURE PAR LES CADAVRES DE VOS ENNEMIS.\nVOUS NE VOYEZ PAS COMMENT DETRUIRE LA PORTE\nDES CREATURES DE CE COTE. VOUS SERREZ\nLES DENTS ET PLONGEZ DANS L'OUVERTURE.\n\nIL DOIT Y AVOIR UN MOYEN DE LA FERMER\nDE L'AUTRE COTE. VOUS ACCEPTEZ DE\nTRAVERSER L'ENFER POUR LE FAIRE?" +#define C4TEXT "LE VISAGE HORRIBLE D'UN DEMON D'UNE\nTAILLE INCROYABLE S'EFFONDRE DEVANT\nVOUS LORSQUE VOUS TIREZ UNE SALVE DE\nROQUETTES DANS SON CERVEAU. LE MONSTRE\nSE RATATINE, SES MEMBRES DECHIQUETES\nSE REPANDANT SUR DES CENTAINES DE\nKILOMETRES A LA SURFACE DE L'ENFER.\n\nVOUS AVEZ REUSSI. L'INVASION N'AURA.\nPAS LIEU. LA TERRE EST SAUVEE. L'ENFER\nEST ANEANTI. EN VOUS DEMANDANT OU IRONT\nMAINTENANT LES DAMNES, VOUS ESSUYEZ\nVOTRE FRONT COUVERT DE SUEUR ET REPARTEZ\nVERS LA TERRE. SA RECONSTRUCTION SERA\nBEAUCOUP PLUS DROLE QUE SA DESTRUCTION.\n" +#define C5TEXT "FELICITATIONS! VOUS AVEZ TROUVE LE\nNIVEAU SECRET! IL SEMBLE AVOIR ETE\nCONSTRUIT PAR LES HUMAINS. VOUS VOUS\nDEMANDEZ QUELS PEUVENT ETRE LES\nHABITANTS DE CE COIN PERDU DE L'ENFER." +#define C6TEXT "FELICITATIONS! VOUS AVEZ DECOUVERT\nLE NIVEAU SUPER SECRET! VOUS FERIEZ\nMIEUX DE FONCER DANS CELUI-LA!\n" #define CC_ZOMBIE "ZOMBIE" #define CC_SHOTGUN "TYPE AU FUSIL" #define CC_HEAVY "MEC SUPER-ARME" @@ -306,4 +200,5 @@ #define CC_SPIDER "L'ARAIGNEE CERVEAU" #define CC_CYBER "LE CYBERDEMON" #define CC_HERO "NOTRE HEROS" + #endif diff --git a/src/d_items.c b/src/d_items.c @@ -1,80 +1,15 @@ #include "info.h" -#ifdef __GNUG__ -#pragma implementation "d_items.h" -#endif + #include "d_items.h" -weaponinfo_t weaponinfo[NUMWEAPONS] = -{ - { - am_noammo, - S_PUNCHUP, - S_PUNCHDOWN, - S_PUNCH, - S_PUNCH1, - S_NULL - }, - { - am_clip, - S_PISTOLUP, - S_PISTOLDOWN, - S_PISTOL, - S_PISTOL1, - S_PISTOLFLASH - }, - { - am_shell, - S_SGUNUP, - S_SGUNDOWN, - S_SGUN, - S_SGUN1, - S_SGUNFLASH1 - }, - { - am_clip, - S_CHAINUP, - S_CHAINDOWN, - S_CHAIN, - S_CHAIN1, - S_CHAINFLASH1 - }, - { - am_misl, - S_MISSILEUP, - S_MISSILEDOWN, - S_MISSILE, - S_MISSILE1, - S_MISSILEFLASH1 - }, - { - am_cell, - S_PLASMAUP, - S_PLASMADOWN, - S_PLASMA, - S_PLASMA1, - S_PLASMAFLASH1 - }, - { - am_cell, - S_BFGUP, - S_BFGDOWN, - S_BFG, - S_BFG1, - S_BFGFLASH1 - }, - { - am_noammo, - S_SAWUP, - S_SAWDOWN, - S_SAW, - S_SAW1, - S_NULL - }, - { - am_shell, - S_DSGUNUP, - S_DSGUNDOWN, - S_DSGUN, - S_DSGUN1, - S_DSGUNFLASH1 - }, -}; + +weaponinfo_t weaponinfo[NUMWEAPONS] = { + { am_noammo, S_PUNCHUP, S_PUNCHDOWN, S_PUNCH, S_PUNCH1, S_NULL }, + { am_clip, S_PISTOLUP, S_PISTOLDOWN, S_PISTOL, S_PISTOL1, S_PISTOLFLASH }, + { am_shell, S_SGUNUP, S_SGUNDOWN, S_SGUN, S_SGUN1, S_SGUNFLASH1}, + { am_clip, S_CHAINUP, S_CHAINDOWN, S_CHAIN, S_CHAIN1, S_CHAINFLASH1 }, + { am_misl, S_MISSILEUP, S_MISSILEDOWN, S_MISSILE, S_MISSILE1, S_MISSILEFLASH1 }, + { am_cell, S_PLASMAUP, S_PLASMADOWN, S_PLASMA, S_PLASMA1, S_PLASMAFLASH1 }, + { am_cell, S_BFGUP, S_BFGDOWN, S_BFG, S_BFG1, S_BFGFLASH1 }, + { am_noammo, S_SAWUP, S_SAWDOWN, S_SAW, S_SAW1, S_NULL }, + { am_shell, S_DSGUNUP, S_DSGUNDOWN, S_DSGUN, S_DSGUN1, S_DSGUNFLASH1 }, +}; +\ No newline at end of file diff --git a/src/d_items.h b/src/d_items.h @@ -1,9 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_ITEMS__ #define __D_ITEMS__ + #include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + typedef struct { ammotype_t ammo; @@ -12,6 +39,14 @@ typedef struct int readystate; int atkstate; int flashstate; + } weaponinfo_t; + extern weaponinfo_t weaponinfo[NUMWEAPONS]; + #endif + + + + + diff --git a/src/d_main.c b/src/d_main.c @@ -1,11 +1,13 @@ #define BGCOLOR 7 #define FGCOLOR 8 + #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> + #include "doomdef.h" #include "doomstat.h" #include "dstrings.h" @@ -30,770 +32,282 @@ #include "p_setup.h" #include "r_local.h" #include "d_main.h" -void D_DoomLoop (void); -char* wadfiles[MAXWADFILES]; -boolean devparm; -boolean nomonsters; -boolean respawnparm; -boolean fastparm; -boolean drone; -boolean singletics = false; -extern boolean inhelpscreens; -skill_t startskill; -int startepisode; -int startmap; -boolean autostart; -FILE* debugfile; -boolean advancedemo; -char wadfile[1024]; -char mapdir[1024]; -char basedefault[1024]; -void D_CheckNetGame (void); -void D_ProcessEvents (void); -void G_BuildTiccmd (ticcmd_t* cmd); -void D_DoAdvanceDemo (void); -event_t events[MAXEVENTS]; -int eventhead; -int eventtail; + +void D_CheckNetGame(); +void D_ProcessEvents(); +void G_BuildTiccmd(ticcmd_t* cmd); +void D_DoAdvanceDemo(); + +extern boolean setsizeneeded; +extern int showMessages; +extern boolean inhelpscreens; +skill_t startskill; +FILE* debugfile; +char* wadfiles[MAXWADFILES]; +int startepisode; +int startmap; +boolean devparm; +boolean nomonsters; +boolean respawnparm; +boolean fastparm; +boolean drone; +boolean singletics = false; +boolean autostart; +boolean advancedemo; +char wadfile[1024]; +char mapdir[1024]; +char basedefault[1024]; +event_t events[MAXEVENTS]; +int eventhead; +int eventtail; +gamestate_t wipegamestate = GS_DEMOSCREEN; +void R_ExecuteSetViewSize(); void D_PostEvent(event_t* ev) { - events[eventhead] = *ev; - eventhead = (eventhead + 1)&(MAXEVENTS-1); -} -void D_ProcessEvents (void) -{ - event_t* ev; - if ( ( gamemode == commercial ) - && (W_CheckNumForName("map01")<0) ) - return; - for ( ; eventtail != eventhead ; eventtail = (eventtail + 1)&(MAXEVENTS-1) ) - { - ev = &events[eventtail]; - if (M_Responder (ev)) - continue; - G_Responder (ev); - } + events[eventhead] = *ev; + eventhead =(eventhead + 1)&(MAXEVENTS-1); } -gamestate_t wipegamestate = GS_DEMOSCREEN; -extern boolean setsizeneeded; -extern int showMessages; -void R_ExecuteSetViewSize (void); -void D_Display (void) + +void +D_ProcessEvents() { - static boolean viewactivestate = false; - static boolean menuactivestate = false; - static boolean inhelpscreensstate = false; - static boolean fullscreen = false; - static gamestate_t oldgamestate = -1; - static int borderdrawcount; - int nowtime; - int tics; - int wipestart; - int y; - boolean done; - boolean wipe; - boolean redrawsbar; - if (nodrawers) - return; - redrawsbar = false; - if (setsizeneeded) - { - R_ExecuteSetViewSize (); - oldgamestate = -1; - borderdrawcount = 3; - } - if (gamestate != wipegamestate) - { - wipe = true; - wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - wipe = false; - if (gamestate == GS_LEVEL && gametic) - HU_Erase(); - switch (gamestate) - { - case GS_LEVEL: - if (!gametic) - break; - if (automapactive) - AM_Drawer (); - if (wipe || (viewheight != 200 && fullscreen) ) - redrawsbar = true; - if (inhelpscreensstate && !inhelpscreens) - redrawsbar = true; - ST_Drawer (viewheight == 200, redrawsbar ); - fullscreen = viewheight == 200; - break; - case GS_INTERMISSION: - WI_Drawer (); - break; - case GS_FINALE: - F_Drawer (); - break; - case GS_DEMOSCREEN: - D_PageDrawer (); - break; - } - I_UpdateNoBlit (); - if (gamestate == GS_LEVEL && !automapactive && gametic) - R_RenderPlayerView (&players[displayplayer]); - if (gamestate == GS_LEVEL && gametic) - HU_Drawer (); - if (gamestate != oldgamestate && gamestate != GS_LEVEL) - I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); - if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) - { - viewactivestate = false; - R_FillBackScreen (); - } - if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320) - { - if (menuactive || menuactivestate || !viewactivestate) - borderdrawcount = 3; - if (borderdrawcount) - { - R_DrawViewBorder (); - borderdrawcount--; + event_t* ev; + + for (; eventtail != eventhead; eventtail =(eventtail + 1)&(MAXEVENTS-1)) { + ev = &events[eventtail]; + if (M_Responder(ev)) continue; + G_Responder(ev); } - } - menuactivestate = menuactive; - viewactivestate = viewactive; - inhelpscreensstate = inhelpscreens; - oldgamestate = wipegamestate = gamestate; - if (paused) - { - if (automapactive) - y = 4; - else - y = viewwindowy+4; - V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2, - y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE)); - } - M_Drawer (); - NetUpdate (); - if (!wipe) - { - I_FinishUpdate (); - return; - } - wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); - wipestart = I_GetTime () - 1; - do - { - do - { - nowtime = I_GetTime (); - tics = nowtime - wipestart; - } while (!tics); - wipestart = nowtime; - done = wipe_ScreenWipe(wipe_Melt - , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics); - I_UpdateNoBlit (); - M_Drawer (); - I_FinishUpdate (); - } while (!done); } -extern boolean demorecording; -void D_DoomLoop (void) + +void +D_Display() { - if (demorecording) - G_BeginRecording (); - if (M_CheckParm ("-debugfile")) - { - char filename[20]; - sprintf (filename,"debug%i.txt",consoleplayer); - printf ("debug output to: %s\n",filename); - debugfile = fopen (filename,"w"); - } - I_InitGraphics (); - while (1) - { - if (singletics) - { - I_StartTic (); - D_ProcessEvents (); - G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); - if (advancedemo) - D_DoAdvanceDemo (); - M_Ticker (); - G_Ticker (); - gametic++; - maketic++; + static boolean viewactivestate = false; + static boolean menuactivestate = false; + static boolean inhelpscreensstate = false; + static boolean fullscreen = false; + static gamestate_t oldgamestate = -1; + static int borderdrawcount; + int nowtime, tics, wipestart, y; + boolean done, wipe, redrawsbar; + + if (nodrawers) + return; + redrawsbar = false; + if (setsizeneeded) { + R_ExecuteSetViewSize(); + oldgamestate = -1; + borderdrawcount = 3; + } + if (gamestate != wipegamestate) { + wipe = true; + wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } else - { - TryRunTics (); + wipe = false; + if (gamestate == GS_LEVEL && gametic) + HU_Erase(); + switch (gamestate) { + case GS_LEVEL: + if (!gametic) + break; + if (automapactive) + AM_Drawer(); + if (wipe ||(viewheight != 200 && fullscreen)) + redrawsbar = true; + if (inhelpscreensstate && !inhelpscreens) + redrawsbar = true; + ST_Drawer(viewheight == 200, redrawsbar); + fullscreen = viewheight == 200; + break; + case GS_INTERMISSION: + WI_Drawer(); + break; + case GS_FINALE: + F_Drawer(); + break; + case GS_DEMOSCREEN: + D_PageDrawer(); + break; + } + I_UpdateNoBlit(); + if (gamestate == GS_LEVEL && gametic && !automapactive) + R_RenderPlayerView(&players[displayplayer]); + if (gamestate == GS_LEVEL && gametic) + HU_Drawer(); + if (gamestate != oldgamestate && gamestate != GS_LEVEL) + I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); + if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) { + viewactivestate = false; + R_FillBackScreen(); + } + if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320) { + if (menuactive || menuactivestate || !viewactivestate) borderdrawcount = 3; + if (borderdrawcount) { + R_DrawViewBorder(); + borderdrawcount--; + } + } + menuactivestate = menuactive; + viewactivestate = viewactive; + inhelpscreensstate = inhelpscreens; + oldgamestate = wipegamestate = gamestate; + if (paused) { + if (automapactive) y = 4; + else y = viewwindowy + 4; + V_DrawPatch(viewwindowx+(scaledviewwidth-68)/2, y, 0, W_CacheLumpName("M_PAUSE", PU_CACHE)); + } + M_Drawer(); + NetUpdate(); + if (!wipe) { + I_FinishUpdate(); + return; } - S_UpdateSounds (players[consoleplayer].mo); - D_Display (); -#ifndef SNDSERV - I_UpdateSound(); -#endif -#ifndef SNDINTR - I_SubmitSound(); -#endif - } + wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); + wipestart = I_GetTime() - 1; + do { + do { + nowtime = I_GetTime(); + tics = nowtime - wipestart; + } while(!tics); + wipestart = nowtime; + done = wipe_ScreenWipe(wipe_Melt, 0, 0, SCREENWIDTH, SCREENHEIGHT, tics); + I_UpdateNoBlit(); + M_Drawer(); + I_FinishUpdate(); + } while(!done); } -int demosequence; -int pagetic; -char *pagename; -void D_PageTicker (void) + +int demosequence; +int pagetic; +char* pagename; + +void +D_PageTicker() { - if (--pagetic < 0) - D_AdvanceDemo (); + if (--pagetic < 0) + D_AdvanceDemo(); } -void D_PageDrawer (void) + +void +D_PageDrawer() { - V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE)); + V_DrawPatch(0, 0, 0, W_CacheLumpName(pagename, PU_CACHE)); } -void D_AdvanceDemo (void) + +void +D_AdvanceDemo() { - advancedemo = true; + advancedemo = true; } - void D_DoAdvanceDemo (void) + +void +D_DoAdvanceDemo() { - players[consoleplayer].playerstate = PST_LIVE; - advancedemo = false; - usergame = false; - paused = false; - gameaction = ga_nothing; - if ( gamemode == retail ) - demosequence = (demosequence+1)%7; - else - demosequence = (demosequence+1)%6; - switch (demosequence) - { - case 0: - if ( gamemode == commercial ) - pagetic = 35 * 11; - else - pagetic = 170; - gamestate = GS_DEMOSCREEN; - pagename = "TITLEPIC"; - if ( gamemode == commercial ) - S_StartMusic(mus_dm2ttl); - else - S_StartMusic (mus_intro); - break; - case 1: - G_DeferedPlayDemo ("demo1"); - break; - case 2: - pagetic = 200; - gamestate = GS_DEMOSCREEN; - pagename = "CREDIT"; - break; - case 3: - G_DeferedPlayDemo ("demo2"); - break; - case 4: - gamestate = GS_DEMOSCREEN; - if ( gamemode == commercial) - { - pagetic = 35 * 11; - pagename = "TITLEPIC"; - S_StartMusic(mus_dm2ttl); - } - else - { - pagetic = 200; - if ( gamemode == retail ) - pagename = "CREDIT"; - else - pagename = "HELP2"; + players[consoleplayer].playerstate = PST_LIVE; + advancedemo = false; + usergame = false; + paused = false; + gameaction = ga_nothing; + demosequence =(demosequence+1)%6; + switch (demosequence) { + case 0: + pagetic = 170; + gamestate = GS_DEMOSCREEN; + pagename = "TITLEPIC"; + S_StartMusic(mus_intro); + break; + case 1: + G_DeferedPlayDemo("DEMO1"); + break; + case 2: + pagetic = 200; + gamestate = GS_DEMOSCREEN; + pagename = "CREDIT"; + break; + case 3: + G_DeferedPlayDemo("DEMO2"); + break; + case 4: + gamestate = GS_DEMOSCREEN; + pagetic = 200; + pagename = "HELP2"; + break; + case 5: + G_DeferedPlayDemo("DEMO3"); + break; + case 6: + G_DeferedPlayDemo("DEMO4"); + break; } - break; - case 5: - G_DeferedPlayDemo ("demo3"); - break; - case 6: - G_DeferedPlayDemo ("demo4"); - break; - } -} -void D_StartTitle (void) -{ - gameaction = ga_nothing; - demosequence = -1; - D_AdvanceDemo (); } -char title[128]; -void D_AddFile (char *file) + +void +D_StartTitle() { - int numwadfiles; - char *newfile; - for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++); - newfile = malloc(strlen(file)+1); - strcpy (newfile, file); - wadfiles[numwadfiles] = newfile; + gameaction = ga_nothing; + demosequence = -1; + D_AdvanceDemo(); } -void IdentifyVersion (void) + +void +D_AddFile(char* file) { - char* doom1wad; - char* doomwad; - char* doomuwad; - char* doom2wad; - char* doom2fwad; - char* plutoniawad; - char* tntwad; - char *home; - char *doomwaddir; + char* newfile; + int numwadfiles; - doomwaddir = getenv("DOOMWADDIR"); - if (!doomwaddir) - doomwaddir = "."; - doom2wad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(doom2wad, "%s/doom2.wad", doomwaddir); - doomuwad = malloc(strlen(doomwaddir)+1+8+1); - sprintf(doomuwad, "%s/doomu.wad", doomwaddir); - doomwad = malloc(strlen(doomwaddir)+1+8+1); - sprintf(doomwad, "%s/doom.wad", doomwaddir); - doom1wad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(doom1wad, "%s/doom1.wad", doomwaddir); - plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1); - sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir); - tntwad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(tntwad, "%s/tnt.wad", doomwaddir); - doom2fwad = malloc(strlen(doomwaddir)+1+10+1); - sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - home = getenv("HOME"); - if (!home) - I_Error("Please set $HOME to your home directory"); - sprintf(basedefault, "%s/.doomrc", home); - if (M_CheckParm ("-shdev")) - { - gamemode = shareware; - devparm = true; - D_AddFile (DEVDATA"doom1.wad"); - D_AddFile (DEVMAPS"data_se/texture1.lmp"); - D_AddFile (DEVMAPS"data_se/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if (M_CheckParm ("-regdev")) - { - gamemode = registered; - devparm = true; - D_AddFile (DEVDATA"doom.wad"); - D_AddFile (DEVMAPS"data_se/texture1.lmp"); - D_AddFile (DEVMAPS"data_se/texture2.lmp"); - D_AddFile (DEVMAPS"data_se/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if (M_CheckParm ("-comdev")) - { - gamemode = commercial; - devparm = true; - /* I don't bother - if(plutonia) - D_AddFile (DEVDATA"plutonia.wad"); - else if(tnt) - D_AddFile (DEVDATA"tnt.wad"); - else*/ - D_AddFile (DEVDATA"doom2.wad"); - D_AddFile (DEVMAPS"cdata/texture1.lmp"); - D_AddFile (DEVMAPS"cdata/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if ( !access (doom2fwad,R_OK) ) - { - gamemode = commercial; - language = french; - printf("French version\n"); - D_AddFile (doom2fwad); - return; - } - if ( !access (doom2wad,R_OK) ) - { - gamemode = commercial; - D_AddFile (doom2wad); - return; - } - if ( !access (plutoniawad, R_OK ) ) - { - gamemode = commercial; - D_AddFile (plutoniawad); - return; - } - if ( !access ( tntwad, R_OK ) ) - { - gamemode = commercial; - D_AddFile (tntwad); - return; - } - if ( !access (doomuwad,R_OK) ) - { - gamemode = retail; - D_AddFile (doomuwad); - return; - } - if ( !access (doomwad,R_OK) ) - { - gamemode = registered; - D_AddFile (doomwad); - return; - } - if ( !access (doom1wad,R_OK) ) - { - gamemode = shareware; - D_AddFile (doom1wad); - return; - } - printf("Game mode indeterminate.\n"); - gamemode = indetermined; + if (access("doom1.wad", R_OK)) + I_Error("D_AddFile: no wad mmmbud"); + for (numwadfiles = 0; wadfiles[numwadfiles]; ++numwadfiles); + newfile = malloc(strlen(file)+1); + strcpy(newfile, file); + wadfiles[numwadfiles] = newfile; } -void FindResponseFile (void) + +void +init() { - int i; -#define MAXARGVS 100 - for (i = 1;i < myargc;i++) - if (myargv[i][0] == '@') - { - FILE * handle; - int size; - int k; - int index; - int indexinfile; - char *infile; - char *file; - char *moreargs[20]; - char *firstargv; - handle = fopen (&myargv[i][1],"rb"); - if (!handle) - { - printf ("\nNo such response file!"); - exit(1); - } - printf("Found response file %s!\n",&myargv[i][1]); - fseek (handle,0,SEEK_END); - size = ftell(handle); - fseek (handle,0,SEEK_SET); - file = malloc (size); - fread (file,size,1,handle); - fclose (handle); - for (index = 0,k = i+1; k < myargc; k++) - moreargs[index++] = myargv[k]; - firstargv = myargv[0]; - myargv = malloc(sizeof(char *)*MAXARGVS); - memset(myargv,0,sizeof(char *)*MAXARGVS); - myargv[0] = firstargv; - infile = file; - indexinfile = k = 0; - indexinfile++; - do - { - myargv[indexinfile++] = infile+k; - while(k < size && - ((*(infile+k)>= ' '+1) && (*(infile+k)<='z'))) - k++; - *(infile+k) = 0; - while(k < size && - ((*(infile+k)<= ' ') || (*(infile+k)>'z'))) - k++; - } while(k < size); - for (k = 0;k < index;k++) - myargv[indexinfile++] = moreargs[k]; - myargc = indexinfile; - printf("%d command-line args:\n",myargc); - for (k=1;k<myargc;k++) - printf("%s\n",myargv[k]); - break; - } } -void D_DoomMain (void) + +void +D_DoomMain() { - int p; - char file[256]; - FindResponseFile (); - IdentifyVersion (); - setbuf (stdout, NULL); - modifiedgame = false; - nomonsters = M_CheckParm ("-nomonsters"); - respawnparm = M_CheckParm ("-respawn"); - fastparm = M_CheckParm ("-fast"); - devparm = M_CheckParm ("-devparm"); - if (M_CheckParm ("-altdeath")) - deathmatch = 2; - else if (M_CheckParm ("-deathmatch")) - deathmatch = 1; - switch ( gamemode ) - { - case retail: - sprintf (title, - " " - "The Ultimate DOOM Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case shareware: - sprintf (title, - " " - "DOOM Shareware Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case registered: - sprintf (title, - " " - "DOOM Registered Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case commercial: - sprintf (title, - " " - "DOOM 2: Hell on Earth v%i.%i" - " ", - VERSION/100,VERSION%100); - break; -/*FIXME - case pack_plut: - sprintf (title, - " " - "DOOM 2: Plutonia Experiment v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case pack_tnt: - sprintf (title, - " " - "DOOM 2: TNT - Evilution v%i.%i" - " ", - VERSION/100,VERSION%100); - break; -*/ - default: - sprintf (title, - " " - "Public DOOM - v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - } - printf ("%s\n",title); - if (devparm) - printf(D_DEVSTR); - if (M_CheckParm("-cdrom")) - { - printf(D_CDROM); - mkdir("c:\\doomdata",0); - strcpy (basedefault,"c:/doomdata/default.cfg"); - } - if ( (p=M_CheckParm ("-turbo")) ) - { - int scale = 200; - extern int forwardmove[2]; - extern int sidemove[2]; - if (p<myargc-1) - scale = atoi (myargv[p+1]); - if (scale < 10) - scale = 10; - if (scale > 400) - scale = 400; - printf ("turbo scale: %i%%\n",scale); - forwardmove[0] = forwardmove[0]*scale/100; - forwardmove[1] = forwardmove[1]*scale/100; - sidemove[0] = sidemove[0]*scale/100; - sidemove[1] = sidemove[1]*scale/100; - } - p = M_CheckParm ("-wart"); - if (p) - { - myargv[p][4] = 'p'; - switch (gamemode ) - { - case shareware: - case retail: - case registered: - sprintf (file,"~"DEVMAPS"E%cM%c.wad", - myargv[p+1][0], myargv[p+2][0]); - printf("Warping to Episode %s, Map %s.\n", - myargv[p+1],myargv[p+2]); - break; - case commercial: - default: - p = atoi (myargv[p+1]); - if (p<10) - sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p); - else - sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p); - break; - } - D_AddFile (file); - } - p = M_CheckParm ("-file"); - if (p) - { - modifiedgame = true; - while (++p != myargc && myargv[p][0] != '-') - D_AddFile (myargv[p]); - } - p = M_CheckParm ("-playdemo"); - if (!p) - p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) - { - sprintf (file,"%s.lmp", myargv[p+1]); - D_AddFile (file); - printf("Playing demo %s.lmp.\n",myargv[p+1]); - } - startskill = sk_medium; - startepisode = 1; - startmap = 1; - autostart = false; - p = M_CheckParm ("-skill"); - if (p && p < myargc-1) - { - startskill = myargv[p+1][0]-'1'; - autostart = true; - } - p = M_CheckParm ("-episode"); - if (p && p < myargc-1) - { - startepisode = myargv[p+1][0]-'0'; + D_AddFile("doom1.wad"); + setbuf(stdout, NULL); + modifiedgame = false; + startskill = sk_medium; + startepisode = 1; startmap = 1; - autostart = true; - } - p = M_CheckParm ("-timer"); - if (p && p < myargc-1 && deathmatch) - { - int time; - time = atoi(myargv[p+1]); - printf("Levels will end after %d minute",time); - if (time>1) - printf("s"); - printf(".\n"); - } - p = M_CheckParm ("-avg"); - if (p && p < myargc-1 && deathmatch) - printf("Austin Virtual Gaming: Levels will end after 20 minutes\n"); - p = M_CheckParm ("-warp"); - if (p && p < myargc-1) - { - if (gamemode == commercial) - startmap = atoi (myargv[p+1]); - else - { - startepisode = myargv[p+1][0]-'0'; - startmap = myargv[p+2][0]-'0'; + autostart = false; + /*everything should be one big init function...*/ + V_Init(); + M_LoadDefaults(); + Z_Init(); + W_InitMultipleFiles(wadfiles); + M_Init(); + R_Init(); + P_Init(); + I_Init(); + D_CheckNetGame(); + S_Init(snd_SfxVolume, snd_MusicVolume); + HU_Init(); + ST_Init(); + if (gameaction != ga_loadgame) { + if (autostart || netgame) + G_InitNew(startskill, startepisode, startmap); + else + D_StartTitle(); + } + I_InitGraphics(); + /*...everything*/ + for (;;) { + TryRunTics(); + S_UpdateSounds(players[consoleplayer].mo); + D_Display(); + I_UpdateSound(); + I_SubmitSound(); } - autostart = true; - } - printf ("V_Init: allocate screens.\n"); - V_Init (); - printf ("M_LoadDefaults: Load system defaults.\n"); - M_LoadDefaults (); - printf ("Z_Init: Init zone memory allocation daemon. \n"); - Z_Init (); - printf ("W_Init: Init WADfiles.\n"); - W_InitMultipleFiles (wadfiles); - if (modifiedgame) - { - char name[23][8]= - { - "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9", - "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9", - "dphoof","bfgga0","heada1","cybra1","spida1d1" - }; - int i; - if ( gamemode == shareware) - I_Error("\nYou cannot -file with the shareware " - "version. Register!"); - if (gamemode == registered) - for (i = 0;i < 23; i++) - if (W_CheckNumForName(name[i])<0) - I_Error("\nThis is not the registered version."); - } - if (modifiedgame) - { - /*m*/printf ( - "===========================================================================\n" - "ATTENTION: This version of DOOM has been modified. If you would like to\n" - "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n" - " You will not receive technical support for modified games.\n" - " press enter to continue\n" - "===========================================================================\n" - ); - getchar (); - } - switch ( gamemode ) - { - case shareware: - case indetermined: - printf ( - "===========================================================================\n" - " Shareware!\n" - "===========================================================================\n" - ); - break; - case registered: - case retail: - case commercial: - printf ( - "===========================================================================\n" - " Commercial product - do not distribute!\n" - " Please report software piracy to the SPA: 1-800-388-PIR8\n" - "===========================================================================\n" - ); - break; - default: - break; - } - printf ("M_Init: Init miscellaneous info.\n"); - M_Init (); - printf ("R_Init: Init DOOM refresh daemon - "); - R_Init (); - printf ("\nP_Init: Init Playloop state.\n"); - P_Init (); - printf ("I_Init: Setting up machine state.\n"); - I_Init (); - printf ("D_CheckNetGame: Checking network game status.\n"); - D_CheckNetGame (); - printf ("S_Init: Setting up sound.\n"); - S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); - printf ("HU_Init: Setting up heads up display.\n"); - HU_Init (); - printf ("ST_Init: Init status bar.\n"); - ST_Init (); - p = M_CheckParm ("-record"); - if (p && p < myargc-1) - { - G_RecordDemo (myargv[p+1]); - autostart = true; - } - p = M_CheckParm ("-playdemo"); - if (p && p < myargc-1) - { - singledemo = true; - G_DeferedPlayDemo (myargv[p+1]); - D_DoomLoop (); - } - p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) - { - G_TimeDemo (myargv[p+1]); - D_DoomLoop (); - } - p = M_CheckParm ("-loadgame"); - if (p && p < myargc-1) - { - if (M_CheckParm("-cdrom")) - sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]); - else - sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]); - G_LoadGame (file); - } - if ( gameaction != ga_loadgame ) - { - if (autostart || netgame) - G_InitNew (startskill, startepisode, startmap); - else - D_StartTitle (); - } - D_DoomLoop (); } diff --git a/src/d_main.h b/src/d_main.h @@ -1,16 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_MAIN__ #define __D_MAIN__ + #include "d_event.h" + #ifdef __GNUG__ #pragma interface #endif + + + #define MAXWADFILES 20 extern char* wadfiles[MAXWADFILES]; + void D_AddFile (char *file); + + + + + + + + + void D_DoomMain (void); + + void D_PostEvent (event_t* ev); + + + + + + void D_PageTicker (void); void D_PageDrawer (void); void D_AdvanceDemo (void); void D_StartTitle (void); + #endif diff --git a/src/d_net.c b/src/d_net.c @@ -1,3 +1,5 @@ +#include <limits.h> + #include "m_menu.h" #include "i_system.h" #include "i_video.h" @@ -5,521 +7,470 @@ #include "g_game.h" #include "doomdef.h" #include "doomstat.h" + #define NCMD_EXIT 0x80000000 #define NCMD_RETRANSMIT 0x40000000 #define NCMD_SETUP 0x20000000 -#define NCMD_KILL 0x10000000 +#define NCMD_KILL 0x10000000 #define NCMD_CHECKSUM 0x0fffffff -doomcom_t* doomcom; -doomdata_t* netbuffer; #define RESENDCOUNT 10 -#define PL_DRONE 0x80 +#define PL_DRONE 0x80 + +doomcom_t* doomcom; +doomdata_t* netbuffer; ticcmd_t localcmds[BACKUPTICS]; -ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; -int nettics[MAXNETNODES]; -boolean nodeingame[MAXNETNODES]; -boolean remoteresend[MAXNETNODES]; -int resendto[MAXNETNODES]; +ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; +int nettics[MAXNETNODES]; +boolean nodeingame[MAXNETNODES]; +boolean remoteresend[MAXNETNODES]; +int resendto[MAXNETNODES]; int resendcount[MAXNETNODES]; int nodeforplayer[MAXPLAYERS]; -int maketic; +int maketic; int lastnettic; int skiptics; -int ticdup; -int maxsend; -void D_ProcessEvents (void); -void G_BuildTiccmd (ticcmd_t *cmd); -void D_DoAdvanceDemo (void); +int ticdup; +int maxsend; + +void D_ProcessEvents (); +void G_BuildTiccmd (ticcmd_t *cmd); +void D_DoAdvanceDemo (); + boolean reboundpacket; doomdata_t reboundstore; -int +long NetbufferSize() { - return (long)&(((doomdata_t *)0)->cmds[netbuffer->numtics]); + return (long)&(((doomdata_t*)0)->cmds[netbuffer->numtics]); } -unsigned +uint NetbufferChecksum() { - return 0; + long i, l; + uint c; + + c = 0x1234567; + return 0; /*Linux, fixme. Endianess?*/ + l = (NetbufferSize() - (long)&(((doomdata_t *)0)->retransmitfrom))/4; + for (i = 0; i < l; ++i) + c += ((unsigned *)&netbuffer->retransmitfrom)[i] * (i+1); + return c & NCMD_CHECKSUM; } -int ExpandTics (int low) +int +ExpandTics(int low) { - int delta; - delta = low - (maketic&0xff); - if (delta >= -64 && delta <= 64) - return (maketic&~0xff) + low; - if (delta > 64) - return (maketic&~0xff) - 256 + low; - if (delta < -64) - return (maketic&~0xff) + 256 + low; - I_Error ("ExpandTics: strange value %i at maketic %i",low,maketic); - return 0; + int delta; + + delta = low - (maketic & 0xff); + if (delta >= -64 && delta <= 64) + return (maketic&~0xff) + low; + if (delta > 64) + return (maketic&~0xff) - 256 + low; + if (delta < -64) + return (maketic&~0xff) + 256 + low; + I_Error("ExpandTics: strange value %i at maketic %i",low,maketic); + return 0; } + void -HSendPacket - (int node, - int flags ) +HSendPacket(int node, int flags) { - netbuffer->checksum = NetbufferChecksum () | flags; - if (!node) - { - reboundstore = *netbuffer; - reboundpacket = true; - return; - } - if (demoplayback) - return; - if (!netgame) - I_Error ("Tried to transmit to another node"); - doomcom->command = CMD_SEND; - doomcom->remotenode = node; - doomcom->datalength = NetbufferSize (); - if (debugfile) - { - int i; - int realretrans; - if (netbuffer->checksum & NCMD_RETRANSMIT) - realretrans = ExpandTics (netbuffer->retransmitfrom); - else - realretrans = -1; - fprintf (debugfile,"send (%i + %i, R %i) [%i] ", - ExpandTics(netbuffer->starttic), - netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); - } - I_NetCmd (); -} -boolean HGetPacket (void) -{ - if (reboundpacket) - { - *netbuffer = reboundstore; - doomcom->remotenode = 0; - reboundpacket = false; - return true; - } - if (!netgame) - return false; - if (demoplayback) - return false; - doomcom->command = CMD_GET; - I_NetCmd (); - if (doomcom->remotenode == -1) - return false; - if (doomcom->datalength != NetbufferSize ()) - { - if (debugfile) - fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); - return false; - } - if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) ) - { - if (debugfile) - fprintf (debugfile,"bad packet checksum\n"); - return false; - } - if (debugfile) - { - int realretrans; - int i; - if (netbuffer->checksum & NCMD_SETUP) - fprintf (debugfile,"setup packet\n"); - else - { - if (netbuffer->checksum & NCMD_RETRANSMIT) - realretrans = ExpandTics (netbuffer->retransmitfrom); - else - realretrans = -1; - fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ", - doomcom->remotenode, - ExpandTics(netbuffer->starttic), - netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); + int i, realretrans; + + netbuffer->checksum = NetbufferChecksum() | flags; + if (!node) { + reboundstore = *netbuffer; + reboundpacket = true; + return; } - } - return true; + if (demoplayback) + return; + if (!netgame) + I_Error("Tried to transmit to another node"); + doomcom->command = CMD_SEND; + doomcom->remotenode = node; + doomcom->datalength = NetbufferSize (); + if (debugfile) { + if (netbuffer->checksum & NCMD_RETRANSMIT) + realretrans = ExpandTics(netbuffer->retransmitfrom); + else + realretrans = -1; + fprintf (debugfile,"send (%i + %i, R %i) [%i] ", ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); + for (i = 0; i < doomcom->datalength; ++i) + fprintf(debugfile,"%i ",((byte *)netbuffer)[i]); + fprintf(debugfile,"\n"); + } + I_NetCmd(); } -char exitmsg[80]; -void GetPackets (void) + +boolean +HGetPacket() { - int netconsole; - int netnode; - ticcmd_t *src, *dest; - int realend; - int realstart; - while ( HGetPacket() ) - { - if (netbuffer->checksum & NCMD_SETUP) - continue; - netconsole = netbuffer->player & ~PL_DRONE; - netnode = doomcom->remotenode; - realstart = ExpandTics (netbuffer->starttic); - realend = (realstart+netbuffer->numtics); - if (netbuffer->checksum & NCMD_EXIT) - { - if (!nodeingame[netnode]) - continue; - nodeingame[netnode] = false; - playeringame[netconsole] = false; - strcpy (exitmsg, "Player 1 left the game"); - exitmsg[7] += netconsole; - players[consoleplayer].message = exitmsg; - if (demorecording) - G_CheckDemoStatus (); - continue; + int i, realretrans; + + if (reboundpacket) { + *netbuffer = reboundstore; + doomcom->remotenode = 0; + reboundpacket = false; + return true; } - if (netbuffer->checksum & NCMD_KILL) - I_Error ("Killed by network driver"); - nodeforplayer[netconsole] = netnode; - if ( resendcount[netnode] <= 0 - && (netbuffer->checksum & NCMD_RETRANSMIT) ) - { - resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); - if (debugfile) - fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); - resendcount[netnode] = RESENDCOUNT; + if (!netgame) + return false; + if (demoplayback) + return false; + doomcom->command = CMD_GET; + I_NetCmd(); + if (doomcom->remotenode == -1) + return false; + if (doomcom->datalength != NetbufferSize ()) { + if (debugfile) + fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); + return false; } - else - resendcount[netnode]--; - if (realend == nettics[netnode]) - continue; - if (realend < nettics[netnode]) - { - if (debugfile) - fprintf (debugfile, - "out of order packet (%i + %i)\n" , - realstart,netbuffer->numtics); - continue; + if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM)) { + if (debugfile) + fprintf (debugfile,"bad packet checksum\n"); + return false; } - if (realstart > nettics[netnode]) - { - if (debugfile) - fprintf (debugfile, - "missed tics from %i (%i - %i)\n", - netnode, realstart, nettics[netnode]); - remoteresend[netnode] = true; - continue; + if (debugfile) { + if (netbuffer->checksum & NCMD_SETUP) + fprintf (debugfile,"setup packet\n"); + else { + if (netbuffer->checksum & NCMD_RETRANSMIT) + realretrans = ExpandTics (netbuffer->retransmitfrom); + else + realretrans = -1; + fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ", doomcom->remotenode, ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); + for (i = 0; i < doomcom->datalength; ++i) + fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); + fprintf (debugfile,"\n"); + } } - { - int start; - remoteresend[netnode] = false; - start = nettics[netnode] - realstart; - src = &netbuffer->cmds[start]; - while (nettics[netnode] < realend) - { - dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; - nettics[netnode]++; - *dest = *src; - src++; - } + return true; +} + +char exitmsg[80]; + +void +GetPackets() +{ + ticcmd_t *src, *dest; + int realend, realstart, netconsole, netnode, start; + + while (HGetPacket()) { + if (netbuffer->checksum & NCMD_SETUP) + continue; + netconsole = netbuffer->player & ~PL_DRONE; + netnode = doomcom->remotenode; + realstart = ExpandTics (netbuffer->starttic); + realend = (realstart+netbuffer->numtics); + if (netbuffer->checksum & NCMD_EXIT) { + if (!nodeingame[netnode]) + continue; + nodeingame[netnode] = false; + playeringame[netconsole] = false; + strcpy(exitmsg, "Player 1 left the game"); + exitmsg[7] += netconsole; + players[consoleplayer].message = exitmsg; + if (demorecording) + G_CheckDemoStatus(); + continue; + } + if (netbuffer->checksum & NCMD_KILL) + I_Error("Killed by network driver"); + nodeforplayer[netconsole] = netnode; + if (resendcount[netnode] <= 0 && (netbuffer->checksum & NCMD_RETRANSMIT)) { + resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); + if (debugfile) + fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); + resendcount[netnode] = RESENDCOUNT; + } else + --resendcount[netnode]; + if (realend == nettics[netnode]) + continue; + if (realend < nettics[netnode]) { + if (debugfile) + fprintf (debugfile, "out of order packet (%i + %i)\n", realstart, netbuffer->numtics); + continue; + } + if (realstart > nettics[netnode]) { + if (debugfile) + fprintf (debugfile, "missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); + remoteresend[netnode] = true; + continue; + } + + remoteresend[netnode] = false; + start = nettics[netnode] - realstart; + src = &netbuffer->cmds[start]; + while (nettics[netnode] < realend) { + dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; + ++nettics[netnode]; + *dest = *src; + ++src; + } } - } } -int gametime; -void NetUpdate (void) + +int gametime; + +void +NetUpdate() { - int nowtime; - int newtics; - int i,j; - int realstart; - int gameticdiv; - nowtime = I_GetTime ()/ticdup; - newtics = nowtime - gametime; - gametime = nowtime; - if (newtics <= 0) - goto listen; - if (skiptics <= newtics) - { - newtics -= skiptics; - skiptics = 0; - } - else - { - skiptics -= newtics; - newtics = 0; - } - netbuffer->player = consoleplayer; - gameticdiv = gametic/ticdup; - for (i=0 ; i<newtics ; i++) - { - I_StartTic (); - D_ProcessEvents (); - if (maketic - gameticdiv >= BACKUPTICS/2-1) - break; - G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]); - maketic++; - } - if (singletics) - return; - for (i=0 ; i<doomcom->numnodes ; i++) - if (nodeingame[i]) - { - netbuffer->starttic = realstart = resendto[i]; - netbuffer->numtics = maketic - realstart; - if (netbuffer->numtics > BACKUPTICS) - I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); - resendto[i] = maketic - doomcom->extratics; - for (j=0 ; j< netbuffer->numtics ; j++) - netbuffer->cmds[j] = - localcmds[(realstart+j)%BACKUPTICS]; - if (remoteresend[i]) - { - netbuffer->retransmitfrom = nettics[i]; - HSendPacket (i, NCMD_RETRANSMIT); - } - else - { - netbuffer->retransmitfrom = 0; - HSendPacket (i, 0); - } + int nowtime, newtics, i, j, realstart, gameticdiv; + + nowtime = I_GetTime()/ticdup; + newtics = nowtime - gametime; + gametime = nowtime; + if (newtics <= 0) + goto listen; + if (skiptics <= newtics) { + newtics -= skiptics; + skiptics = 0; + } else { + skiptics -= newtics; + newtics = 0; } - listen: - GetPackets (); + netbuffer->player = consoleplayer; + gameticdiv = gametic/ticdup; + for (i = 0; i < newtics; ++i) { + I_StartTic(); + D_ProcessEvents(); + if (maketic - gameticdiv >= BACKUPTICS/2-1) + break; + G_BuildTiccmd(&localcmds[maketic%BACKUPTICS]); + ++maketic; + } + if (singletics) + return; + for (i = 0; i < doomcom->numnodes; ++i) + if (nodeingame[i]) { + netbuffer->starttic = realstart = resendto[i]; + netbuffer->numtics = maketic - realstart; + if (netbuffer->numtics > BACKUPTICS) + I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); + resendto[i] = maketic - doomcom->extratics; + for (j = 0; j < netbuffer->numtics; ++j) + netbuffer->cmds[j] = localcmds[(realstart+j)%BACKUPTICS]; + if (remoteresend[i]) { + netbuffer->retransmitfrom = nettics[i]; + HSendPacket (i, NCMD_RETRANSMIT); + } else { + netbuffer->retransmitfrom = 0; + HSendPacket (i, 0); + } + } +listen: + GetPackets(); } -void CheckAbort (void) + +void +CheckAbort() { - event_t *ev; - int stoptic; - stoptic = I_GetTime () + 2; - while (I_GetTime() < stoptic) - I_StartTic (); - I_StartTic (); - for ( ; eventtail != eventhead - ; eventtail = (eventtail + 1)&(MAXEVENTS-1) ) - { - ev = &events[eventtail]; - if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) - I_Error ("Network game synchronization aborted."); - } + event_t *ev; + int stoptic; + + stoptic = I_GetTime() + 2; + while (I_GetTime() < stoptic) + I_StartTic(); + I_StartTic(); + for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1)) { + ev = &events[eventtail]; + if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) + I_Error("Network game synchronization aborted."); + } } -void D_ArbitrateNetStart (void) + +void +D_ArbitrateNetStart() { - int i; - boolean gotinfo[MAXNETNODES]; - autostart = true; - memset (gotinfo,0,sizeof(gotinfo)); - if (doomcom->consoleplayer) - { - printf ("listening for network start info...\n"); - while (1) - { - CheckAbort (); - if (!HGetPacket ()) - continue; - if (netbuffer->checksum & NCMD_SETUP) - { - if (netbuffer->player != VERSION) - I_Error ("Different DOOM versions cannot play a net game!"); - startskill = netbuffer->retransmitfrom & 15; - deathmatch = (netbuffer->retransmitfrom & 0xc0) >> 6; - nomonsters = (netbuffer->retransmitfrom & 0x20) > 0; - respawnparm = (netbuffer->retransmitfrom & 0x10) > 0; - startmap = netbuffer->starttic & 0x3f; - startepisode = netbuffer->starttic >> 6; - return; - } + int i; + uchar gotinfo[MAXNETNODES]; + + autostart = true; + memset(gotinfo, 0, sizeof(gotinfo)); + if (doomcom->consoleplayer) { + printf ("listening for network start info...\n"); + for (;;) { + CheckAbort(); + if (!HGetPacket()) + continue; + if (netbuffer->checksum & NCMD_SETUP) { + if (netbuffer->player != VERSION) + I_Error("Different DOOM versions cannot play a net game!"); + startskill = netbuffer->retransmitfrom & 15; + deathmatch = (netbuffer->retransmitfrom & 0xc0) >> 6; + nomonsters = (netbuffer->retransmitfrom & 0x20) > 0; + respawnparm = (netbuffer->retransmitfrom & 0x10) > 0; + startmap = netbuffer->starttic & 0x3f; + startepisode = netbuffer->starttic >> 6; + return; + } + } + } else { + printf("sending network start info...\n"); + do { + CheckAbort(); + for (i = 0; i < doomcom->numnodes; ++i) { + netbuffer->retransmitfrom = startskill; + if (deathmatch) + netbuffer->retransmitfrom |= (deathmatch<<6); + if (nomonsters) + netbuffer->retransmitfrom |= 0x20; + if (respawnparm) + netbuffer->retransmitfrom |= 0x10; + netbuffer->starttic = startepisode * 64 + startmap; + netbuffer->player = VERSION; + netbuffer->numtics = 0; + HSendPacket(i, NCMD_SETUP); + } + for(i = 10; i && HGetPacket(); --i) + if((netbuffer->player&0x7f) < MAXNETNODES) + gotinfo[netbuffer->player&0x7f] = true; + for (i = 1; i < doomcom->numnodes; ++i) + if (!gotinfo[i]) + break; + } while (i < doomcom->numnodes); } - } - else - { - printf ("sending network start info...\n"); - do - { - CheckAbort (); - for (i=0 ; i<doomcom->numnodes ; i++) - { - netbuffer->retransmitfrom = startskill; - if (deathmatch) - netbuffer->retransmitfrom |= (deathmatch<<6); - if (nomonsters) - netbuffer->retransmitfrom |= 0x20; - if (respawnparm) - netbuffer->retransmitfrom |= 0x10; - netbuffer->starttic = startepisode * 64 + startmap; - netbuffer->player = VERSION; - netbuffer->numtics = 0; - HSendPacket (i, NCMD_SETUP); - } -#if 1 - for(i = 10 ; i && HGetPacket(); --i) - { - if((netbuffer->player&0x7f) < MAXNETNODES) - gotinfo[netbuffer->player&0x7f] = true; - } -#else - while (HGetPacket ()) - { - gotinfo[netbuffer->player&0x7f] = true; - } -#endif - for (i=1 ; i<doomcom->numnodes ; i++) - if (!gotinfo[i]) - break; - } while (i < doomcom->numnodes); - } } -extern int viewangleoffset; -void D_CheckNetGame (void) + +extern int viewangleoffset; + +void +D_CheckNetGame() { - int i; - for (i=0 ; i<MAXNETNODES ; i++) - { - nodeingame[i] = false; - nettics[i] = 0; - remoteresend[i] = false; - resendto[i] = 0; - } - I_InitNetwork (); - if (doomcom->id != DOOMCOM_ID) - I_Error ("Doomcom buffer invalid!"); - netbuffer = &doomcom->data; - consoleplayer = displayplayer = doomcom->consoleplayer; - if (netgame) - D_ArbitrateNetStart (); - printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", - startskill, deathmatch, startmap, startepisode); - ticdup = doomcom->ticdup; - maxsend = BACKUPTICS/(2*ticdup)-1; - if (maxsend<1) - maxsend = 1; - for (i=0 ; i<doomcom->numplayers ; i++) - playeringame[i] = true; - for (i=0 ; i<doomcom->numnodes ; i++) - nodeingame[i] = true; - printf ("player %i of %i (%i nodes)\n", - consoleplayer+1, doomcom->numplayers, doomcom->numnodes); + int i; + + for (i = 0; i < MAXNETNODES; ++i) { + nodeingame[i] = false; + nettics[i] = 0; + remoteresend[i] = false; + resendto[i] = 0; + } + I_InitNetwork(); + if (doomcom->id != DOOMCOM_ID) + I_Error ("Doomcom buffer invalid!"); + netbuffer = &doomcom->data; + consoleplayer = displayplayer = doomcom->consoleplayer; + if (netgame) + D_ArbitrateNetStart(); + printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", startskill, deathmatch, startmap, startepisode); + ticdup = doomcom->ticdup; + maxsend = BACKUPTICS/(2 * ticdup) - 1; + if (maxsend < 1) + maxsend = 1; + for (i = 0; i < doomcom->numplayers; ++i) + playeringame[i] = true; + for (i = 0; i < doomcom->numnodes; ++i) + nodeingame[i] = true; + printf("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom->numplayers, doomcom->numnodes); } -void D_QuitNetGame (void) + +void +D_QuitNetGame() { - int i, j; - if (debugfile) - fclose (debugfile); - if (!netgame || !usergame || consoleplayer == -1 || demoplayback) - return; - netbuffer->player = consoleplayer; - netbuffer->numtics = 0; - for (i=0 ; i<4 ; i++) - { - for (j=1 ; j<doomcom->numnodes ; j++) - if (nodeingame[j]) - HSendPacket (j, NCMD_EXIT); - I_WaitVBL (1); - } + int i, j; + + if (debugfile) + fclose(debugfile); + if (!netgame || !usergame || consoleplayer == -1 || demoplayback) + return; + netbuffer->player = consoleplayer; + netbuffer->numtics = 0; + for (i = 0; i < 4; ++i) { + for (j = 1; j < doomcom->numnodes; ++j) + if (nodeingame[j]) + HSendPacket(j, NCMD_EXIT); + I_WaitVBL(1); + } } + int frametics[4]; int frameon; int frameskip[4]; int oldnettics; extern boolean advancedemo; -void TryRunTics (void) + +void +TryRunTics() { - int i; - int lowtic; - int entertic; - static int oldentertics; - int realtics; - int availabletics; - int counts; - int numplaying; - entertic = I_GetTime ()/ticdup; - realtics = entertic - oldentertics; - oldentertics = entertic; - NetUpdate (); - lowtic = MAXINT; - numplaying = 0; - for (i=0 ; i<doomcom->numnodes ; i++) - { - if (nodeingame[i]) - { - numplaying++; - if (nettics[i] < lowtic) - lowtic = nettics[i]; - } - } - availabletics = lowtic - gametic/ticdup; - if (realtics < availabletics-1) - counts = realtics+1; - else if (realtics < availabletics) - counts = realtics; - else - counts = availabletics; - if (counts < 1) - counts = 1; - frameon++; - if (debugfile) - fprintf (debugfile, - "=======real: %i avail: %i game: %i\n", - realtics, availabletics,counts); - if (!demoplayback) - { - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i]) - break; - if (consoleplayer == i) - { + static int oldentertics; + ticcmd_t *cmd; + int i, j, lowtic, entertic, realtics, availabletics, counts, numplaying, buf; + + entertic = I_GetTime() / ticdup; + realtics = entertic - oldentertics; + oldentertics = entertic; + NetUpdate(); + lowtic = INT_MAX; + numplaying = 0; + for (i = 0; i < doomcom->numnodes; ++i) { + if (nodeingame[i]) { + ++numplaying; + if (nettics[i] < lowtic) + lowtic = nettics[i]; + } } + availabletics = lowtic - gametic/ticdup; + if (realtics < availabletics-1) + counts = realtics+1; + else if (realtics < availabletics) + counts = realtics; else - { - if (nettics[0] <= nettics[nodeforplayer[i]]) - { - gametime--; - } - frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]); - oldnettics = nettics[0]; - if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) - { - skiptics = 1; - } + counts = availabletics; + if (counts < 1) + counts = 1; + ++frameon; + if (debugfile) + fprintf (debugfile, "=======real: %i avail: %i game: %i\n", realtics, availabletics,counts); + if (!demoplayback) { + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + break; + if (consoleplayer != i) { + if (nettics[0] <= nettics[nodeforplayer[i]]) + --gametime; + frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]); + oldnettics = nettics[0]; + if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) + skiptics = 1; + } + } + while (lowtic < gametic/ticdup + counts) { + NetUpdate(); + lowtic = INT_MAX; + for (i = 0; i < doomcom->numnodes; ++i) + if (nodeingame[i] && nettics[i] < lowtic) + lowtic = nettics[i]; + if (lowtic < gametic/ticdup) + I_Error("TryRunTics: lowtic < gametic"); + if (I_GetTime ()/ticdup - entertic >= 20) { + M_Ticker(); + return; + } } - } - while (lowtic < gametic/ticdup + counts) - { - NetUpdate (); - lowtic = MAXINT; - for (i=0 ; i<doomcom->numnodes ; i++) - if (nodeingame[i] && nettics[i] < lowtic) - lowtic = nettics[i]; - if (lowtic < gametic/ticdup) - I_Error ("TryRunTics: lowtic < gametic"); - if (I_GetTime ()/ticdup - entertic >= 20) - { - M_Ticker (); - return; - } - } - while (counts--) - { - for (i=0 ; i<ticdup ; i++) - { - if (gametic/ticdup > lowtic) - I_Error ("gametic>lowtic"); - if (advancedemo) - D_DoAdvanceDemo (); - M_Ticker (); - G_Ticker (); - gametic++; - if (i != ticdup-1) - { - ticcmd_t *cmd; - int buf; - int j; - buf = (gametic/ticdup)%BACKUPTICS; - for (j=0 ; j<MAXPLAYERS ; j++) - { - cmd = &netcmds[j][buf]; - cmd->chatchar = 0; - if (cmd->buttons & BT_SPECIAL) - cmd->buttons = 0; + while (--counts) { + for (i = 0; i < ticdup; ++i) { + if (gametic/ticdup > lowtic) + I_Error("gametic>lowtic"); + if (advancedemo) + D_DoAdvanceDemo(); + M_Ticker(); + G_Ticker(); + ++gametic; + if (i != ticdup-1) { + buf = (gametic/ticdup) % BACKUPTICS; + for (j = 0; j < MAXPLAYERS; ++j) { + cmd = &netcmds[j][buf]; + cmd->chatchar = 0; + if (cmd->buttons & BT_SPECIAL) + cmd->buttons = 0; + } + } } - } + NetUpdate(); } - NetUpdate (); - } } diff --git a/src/d_net.h b/src/d_net.h @@ -1,48 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_NET__ #define __D_NET__ + #include "d_player.h" + + #ifdef __GNUG__ #pragma interface #endif + + + + + + + + + + #define DOOMCOM_ID 0x12345678l + + #define MAXNETNODES 8 + + + #define BACKUPTICS 12 + typedef enum { CMD_SEND = 1, CMD_GET = 2 + } command_t; + + + + + typedef struct { + unsigned checksum; + byte retransmitfrom; + byte starttic; byte player; byte numtics; ticcmd_t cmds[BACKUPTICS]; + } doomdata_t; + + + + typedef struct { + long id; + + short intnum; + + short command; + short remotenode; + + short datalength; + + + short numnodes; + short ticdup; + short extratics; + short deathmatch; + short savegame; short episode; short map; short skill; + + short consoleplayer; short numplayers; + + + + + + + short angleoffset; + short drone; + + doomdata_t data; + } doomcom_t; + + + + void NetUpdate (void); + + + void D_QuitNetGame (void); + + void TryRunTics (void); + + #endif + + + + + + + diff --git a/src/d_player.h b/src/d_player.h @@ -1,84 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_PLAYER__ #define __D_PLAYER__ + + + + + + #include "d_items.h" #include "p_pspr.h" + + + #include "p_mobj.h" + + + + #include "d_ticcmd.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + + + typedef enum { + PST_LIVE, + PST_DEAD, + PST_REBORN + } playerstate_t; + + + + + typedef enum { + CF_NOCLIP = 1, + CF_GODMODE = 2, + CF_NOMOMENTUM = 4 + } cheat_t; + + + + + typedef struct player_s { mobj_t* mo; playerstate_t playerstate; ticcmd_t cmd; + + + + fixed_t viewz; + fixed_t viewheight; + fixed_t deltaviewheight; + fixed_t bob; + + + int health; int armorpoints; + int armortype; + + int powers[NUMPOWERS]; boolean cards[NUMCARDS]; boolean backpack; + + int frags[MAXPLAYERS]; weapontype_t readyweapon; + + weapontype_t pendingweapon; + boolean weaponowned[NUMWEAPONS]; int ammo[NUMAMMO]; int maxammo[NUMAMMO]; + + int attackdown; int usedown; + + + int cheats; + + int refire; + + int killcount; int itemcount; int secretcount; + + char* message; + + int damagecount; int bonuscount; + + mobj_t* attacker; + + int extralight; + + + int fixedcolormap; + + + int colormap; + + pspdef_t psprites[NUMPSPRITES]; + + boolean didsecret; + } player_t; + + + + + + typedef struct { boolean in; + + int skills; int sitems; int ssecret; int stime; int frags[4]; int score; + } wbplayerstruct_t; + typedef struct { int epsd; + + boolean didsecret; + + int last; int next; + int maxkills; int maxitems; int maxsecret; int maxfrags; + + int partime; + + int pnum; + wbplayerstruct_t plyr[MAXPLAYERS]; + } wbstartstruct_t; + + #endif + + + + + diff --git a/src/d_textur.h b/src/d_textur.h @@ -1,10 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_TEXTUR__ #define __D_TEXTUR__ -#include "doomtype.h" + +#include "doomdef.h" + + + + + + + + typedef struct { byte width; byte height; byte data; } pic_t; + + + + #endif + + + + + diff --git a/src/d_think.h b/src/d_think.h @@ -1,22 +1,27 @@ #ifndef __D_THINK__ #define __D_THINK__ -#ifdef __GNUG__ -#pragma interface -#endif -typedef void (*actionf_v)(); -typedef void (*actionf_p1)( void* ); -typedef void (*actionf_p2)( void*, void* ); -typedef union -{ - actionf_p1 acp1; - actionf_v acv; - actionf_p2 acp2; + +typedef void (*actionf_v)(); +typedef void (*actionf_p1)(void*); +typedef void (*actionf_p2)(void*, void*); + +typedef union { + actionf_p1 acp1; + actionf_v acv; + actionf_p2 acp2; } actionf_t; + typedef actionf_t think_t; -typedef struct thinker_s -{ + +typedef struct thinker_s { struct thinker_s* prev; struct thinker_s* next; think_t function; } thinker_t; + #endif + + + + + diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h @@ -1,9 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_TICCMD__ #define __D_TICCMD__ -#include "doomtype.h" + +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + typedef struct { char forwardmove; @@ -13,4 +42,12 @@ typedef struct byte chatchar; byte buttons; } ticcmd_t; + + + #endif + + + + + diff --git a/src/doom1.wad b/src/doom1.wad Binary files differ. diff --git a/src/doomdata.h b/src/doomdata.h @@ -1,7 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + #ifndef __DOOMDATA__ #define __DOOMDATA__ -#include "doomtype.h" + + #include "doomdef.h" + + +#include "doomdef.h" + + + + + + + + + + + enum { ML_LABEL, @@ -16,11 +54,18 @@ enum ML_REJECT, ML_BLOCKMAP }; + + + typedef struct { short x; short y; } mapvertex_t; + + + + typedef struct { short textureoffset; @@ -28,8 +73,14 @@ typedef struct char toptexture[8]; char bottomtexture[8]; char midtexture[8]; + short sector; } mapsidedef_t; + + + + + typedef struct { short v1; @@ -37,17 +88,56 @@ typedef struct short flags; short special; short tag; + short sidenum[2]; } maplinedef_t; + + + + + + + #define ML_BLOCKING 1 + + #define ML_BLOCKMONSTERS 2 + + + #define ML_TWOSIDED 4 + + + + + + + + + + + #define ML_DONTPEGTOP 8 + + #define ML_DONTPEGBOTTOM 16 + + #define ML_SECRET 32 + + #define ML_SOUNDBLOCK 64 + + #define ML_DONTDRAW 128 + + #define ML_MAPPED 256 + + + + + typedef struct { short floorheight; @@ -58,11 +148,18 @@ typedef struct short special; short tag; } mapsector_t; + + typedef struct { short numsegs; + short firstseg; } mapsubsector_t; + + + + typedef struct { short v1; @@ -72,16 +169,37 @@ typedef struct short side; short offset; } mapseg_t; + + + + + + #define NF_SUBSECTOR 0x8000 + typedef struct { + short x; short y; short dx; short dy; + + + short bbox[2][4]; + + + unsigned short children[2]; + } mapnode_t; + + + + + + typedef struct { short x; @@ -90,4 +208,15 @@ typedef struct short type; short options; } mapthing_t; + + + + + #endif + + + + + + diff --git a/src/doomdef.h b/src/doomdef.h @@ -1,37 +1,38 @@ #ifndef __DOOMDEF__ #define __DOOMDEF__ + #include <stdio.h> #include <string.h> -enum { VERSION = 110 }; - -typedef unsigned char uchar; - -typedef enum -{ - shareware, - registered, - commercial, - retail, - indetermined -} GameMode_t; -typedef enum -{ - doom, - doom2, - pack_tnt, - pack_plut, - none -} GameMission_t; - -typedef enum -{ - english, - french, - german, - unknown -} Language_t; +#include <limits.h> #define RANGECHECK +#define KEY_RIGHTARROW 0xae +#define KEY_LEFTARROW 0xac +#define KEY_UPARROW 0xad +#define KEY_DOWNARROW 0xaf +#define KEY_ESCAPE 27 +#define KEY_ENTER 13 +#define KEY_TAB 9 +#define KEY_F1 (0x80+0x3b) +#define KEY_F2 (0x80+0x3c) +#define KEY_F3 (0x80+0x3d) +#define KEY_F4 (0x80+0x3e) +#define KEY_F5 (0x80+0x3f) +#define KEY_F6 (0x80+0x40) +#define KEY_F7 (0x80+0x41) +#define KEY_F8 (0x80+0x42) +#define KEY_F9 (0x80+0x43) +#define KEY_F10 (0x80+0x44) +#define KEY_F11 (0x80+0x57) +#define KEY_F12 (0x80+0x58) +#define KEY_BACKSPACE 127 +#define KEY_PAUSE 0xff +#define KEY_EQUALS 0x3d +#define KEY_MINUS 0x2d +#define KEY_RSHIFT (0x80+0x36) +#define KEY_RCTRL (0x80+0x1d) +#define KEY_RALT (0x80+0x38) +#define KEY_LALT KEY_RALT #define SNDSERV 1 #define BASE_WIDTH 320 #define SCREEN_MUL 1 @@ -40,30 +41,40 @@ typedef enum #define SCREENHEIGHT 200 #define MAXPLAYERS 4 #define TICRATE 35 +#define MTF_EASY 1 +#define MTF_NORMAL 2 +#define MTF_HARD 4 +#define MTF_AMBUSH 8 +#define LENGTH(a) (sizeof(a)/sizeof(a[0])) +#define SKYFLATNAME "F_SKY1" +#define ANGLETOSKYSHIFT 22 + +typedef unsigned char byte; +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; -typedef enum -{ +typedef enum {false, true} boolean; + +enum { VERSION = 110 }; + +typedef enum { GS_LEVEL, GS_INTERMISSION, GS_FINALE, GS_DEMOSCREEN } gamestate_t; -#define MTF_EASY 1 -#define MTF_NORMAL 2 -#define MTF_HARD 4 -#define MTF_AMBUSH 8 - -typedef enum -{ +typedef enum { sk_baby, sk_easy, sk_medium, sk_hard, sk_nightmare } skill_t; -typedef enum -{ + +typedef enum { it_bluecard, it_yellowcard, it_redcard, @@ -72,8 +83,8 @@ typedef enum it_redskull, NUMCARDS } card_t; -typedef enum -{ + +typedef enum { wp_fist, wp_pistol, wp_shotgun, @@ -86,8 +97,8 @@ typedef enum NUMWEAPONS, wp_nochange } weapontype_t; -typedef enum -{ + +typedef enum { am_clip, am_shell, am_cell, @@ -95,8 +106,8 @@ typedef enum NUMAMMO, am_noammo } ammotype_t; -typedef enum -{ + +typedef enum { pw_invulnerability, pw_strength, pw_invisibility, @@ -105,38 +116,329 @@ typedef enum pw_infrared, NUMPOWERS } powertype_t; -typedef enum -{ - INVULNTICS = (30*TICRATE), - INVISTICS = (60*TICRATE), - INFRATICS = (120*TICRATE), - IRONTICS = (60*TICRATE) + +typedef enum { + INVULNTICS = (30*TICRATE), + INVISTICS = (60*TICRATE), + INFRATICS = (120*TICRATE), + IRONTICS = (60*TICRATE) } powerduration_t; -#define KEY_RIGHTARROW 0xae -#define KEY_LEFTARROW 0xac -#define KEY_UPARROW 0xad -#define KEY_DOWNARROW 0xaf -#define KEY_ESCAPE 27 -#define KEY_ENTER 13 -#define KEY_TAB 9 -#define KEY_F1 (0x80+0x3b) -#define KEY_F2 (0x80+0x3c) -#define KEY_F3 (0x80+0x3d) -#define KEY_F4 (0x80+0x3e) -#define KEY_F5 (0x80+0x3f) -#define KEY_F6 (0x80+0x40) -#define KEY_F7 (0x80+0x41) -#define KEY_F8 (0x80+0x42) -#define KEY_F9 (0x80+0x43) -#define KEY_F10 (0x80+0x44) -#define KEY_F11 (0x80+0x57) -#define KEY_F12 (0x80+0x58) -#define KEY_BACKSPACE 127 -#define KEY_PAUSE 0xff -#define KEY_EQUALS 0x3d -#define KEY_MINUS 0x2d -#define KEY_RSHIFT (0x80+0x36) -#define KEY_RCTRL (0x80+0x1d) -#define KEY_RALT (0x80+0x38) -#define KEY_LALT KEY_RALT -#endif + +enum { + NEWLEVEL, + PRESSKEY, + PRESSYN, + D_DEVSTR, + D_CDROM, + LOADNET, + QLOADNET, + QSAVESPOT, + SAVEDEAD, + QSPROMPT, + QLPROMPT, + NEWGAME, + NIGHTMARE, + SWSTRING, + MSGOFF, + MSGON, + NETEND, + ENDGAME, + DOSY, + DETAILHI, + DETAILLO, + GAMMALVL0, + GAMMALVL1, + GAMMALVL2, + GAMMALVL3, + GAMMALVL4, + EMPTYSTRING, + GOTARMOR, + GOTMEGA, + GOTHTHBONUS, + GOTARMBONUS, + GOTSTIM, + GOTMEDINEED, + GOTMEDIKIT, + GOTSUPER, + GOTBLUECARD, + GOTYELWCARD, + GOTREDCARD, + GOTBLUESKUL, + GOTYELWSKUL, + GOTREDSKULL, + GOTINVUL, + GOTBERSERK, + GOTINVIS, + GOTSUIT, + GOTMAP, + GOTVISOR, + GOTMSPHERE, + GOTCLIP, + GOTCLIPBOX, + GOTROCKET, + GOTROCKBOX, + GOTCELL, + GOTCELLBOX, + GOTSHELLS, + GOTSHELLBOX, + GOTBACKPACK, + GOTBFG9000, + GOTCHAINGUN, + GOTCHAINSAW, + GOTLAUNCHER, + GOTPLASMA, + GOTSHOTGUN, + GOTSHOTGUN2, + PD_BLUEO, + PD_REDO, + PD_YELLOWO, + PD_BLUEK, + PD_REDK, + PD_YELLOWK, + GGSAVED, + HUSTR_MSGU, + HUSTR_E1M1, + HUSTR_E1M2, + HUSTR_E1M3, + HUSTR_E1M4, + HUSTR_E1M5, + HUSTR_E1M6, + HUSTR_E1M7, + HUSTR_E1M8, + HUSTR_E1M9, + HUSTR_E2M1, + HUSTR_E2M2, + HUSTR_E2M3, + HUSTR_E2M4, + HUSTR_E2M5, + HUSTR_E2M6, + HUSTR_E2M7, + HUSTR_E2M8, + HUSTR_E2M9, + HUSTR_E3M1, + HUSTR_E3M2, + HUSTR_E3M3, + HUSTR_E3M4, + HUSTR_E3M5, + HUSTR_E3M6, + HUSTR_E3M7, + HUSTR_E3M8, + HUSTR_E3M9, + HUSTR_E4M1, + HUSTR_E4M2, + HUSTR_E4M3, + HUSTR_E4M4, + HUSTR_E4M5, + HUSTR_E4M6, + HUSTR_E4M7, + HUSTR_E4M8, + HUSTR_E4M9, + HUSTR_1, + HUSTR_2, + HUSTR_3, + HUSTR_4, + HUSTR_5, + HUSTR_6, + HUSTR_7, + HUSTR_8, + HUSTR_9, + HUSTR_10, + HUSTR_11, + HUSTR_12, + HUSTR_13, + HUSTR_14, + HUSTR_15, + HUSTR_16, + HUSTR_17, + HUSTR_18, + HUSTR_19, + HUSTR_20, + HUSTR_21, + HUSTR_22, + HUSTR_23, + HUSTR_24, + HUSTR_25, + HUSTR_26, + HUSTR_27, + HUSTR_28, + HUSTR_29, + HUSTR_30, + HUSTR_31, + HUSTR_32, + PHUSTR_1, + PHUSTR_2, + PHUSTR_3, + PHUSTR_4, + PHUSTR_5, + PHUSTR_6, + PHUSTR_7, + PHUSTR_8, + PHUSTR_9, + PHUSTR_10, + PHUSTR_11, + PHUSTR_12, + PHUSTR_13, + PHUSTR_14, + PHUSTR_15, + PHUSTR_16, + PHUSTR_17, + PHUSTR_18, + PHUSTR_19, + PHUSTR_20, + PHUSTR_21, + PHUSTR_22, + PHUSTR_23, + PHUSTR_24, + PHUSTR_25, + PHUSTR_26, + PHUSTR_27, + PHUSTR_28, + PHUSTR_29, + PHUSTR_30, + PHUSTR_31, + PHUSTR_32, + THUSTR_1, + THUSTR_2, + THUSTR_3, + THUSTR_4, + THUSTR_5, + THUSTR_6, + THUSTR_7, + THUSTR_8, + THUSTR_9, + THUSTR_10, + THUSTR_11, + THUSTR_12, + THUSTR_13, + THUSTR_14, + THUSTR_15, + THUSTR_16, + THUSTR_17, + THUSTR_18, + THUSTR_19, + THUSTR_20, + THUSTR_21, + THUSTR_22, + THUSTR_23, + THUSTR_24, + THUSTR_25, + THUSTR_26, + THUSTR_27, + THUSTR_28, + THUSTR_29, + THUSTR_30, + THUSTR_31, + THUSTR_32, + HUSTR_CHATMACRO1, + HUSTR_CHATMACRO2, + HUSTR_CHATMACRO3, + HUSTR_CHATMACRO4, + HUSTR_CHATMACRO5, + HUSTR_CHATMACRO6, + HUSTR_CHATMACRO7, + HUSTR_CHATMACRO8, + HUSTR_CHATMACRO9, + HUSTR_CHATMACRO0, + HUSTR_TALKTOSELF1, + HUSTR_TALKTOSELF2, + HUSTR_TALKTOSELF3, + HUSTR_TALKTOSELF4, + HUSTR_TALKTOSELF5, + HUSTR_MESSAGESENT, + HUSTR_PLRGREEN, + HUSTR_PLRINDIGO, + HUSTR_PLRBROWN, + HUSTR_PLRRED, + HUSTR_KEYGREEN, + HUSTR_KEYINDIGO, + HUSTR_KEYBROWN, + HUSTR_KEYRED, + AMSTR_FOLLOWON, + AMSTR_FOLLOWOFF, + AMSTR_GRIDON, + AMSTR_GRIDOFF, + AMSTR_MARKEDSPOT, + AMSTR_MARKSCLEARED, + STSTR_MUS, + STSTR_NOMUS, + STSTR_DQDON, + STSTR_DQDOFF, + STSTR_KFAADDED, + STSTR_FAADDED, + STSTR_NCON, + STSTR_NCOFF, + STSTR_BEHOLD, + STSTR_BEHOLDX, + STSTR_CHOPPERS, + STSTR_CLEV, + E1TEXT, + E2TEXT, + E3TEXT, + E4TEXT, + C1TEXT, + C2TEXT, + C3TEXT, + C4TEXT, + C5TEXT, + C6TEXT, + P1TEXT, + P2TEXT, + P3TEXT, + P4TEXT, + P5TEXT, + P6TEXT, + T1TEXT, + T2TEXT, + T3TEXT, + T4TEXT, + T5TEXT, + T6TEXT, + CC_ZOMBIE, + CC_SHOTGUN, + CC_HEAVY, + CC_IMP, + CC_DEMON, + CC_LOST, + CC_CACO, + CC_HELL, + CC_BARON, + CC_ARACH, + CC_PAIN, + CC_REVEN, + CC_MANCU, + CC_ARCH, + CC_SPIDER, + CC_CYBER, + CC_HERO, + SAVEGAMENAME, + DEVMAPS, + DEVDATA, + QUITMSG0, + QUITMSG1, + QUITMSG2, + QUITMSG3, + QUITMSG4, + QUITMSG5, + QUITMSG6, + QUITMSG7, + QUITMSG8, + QUITMSG9, + QUITMSG10, + QUITMSG11, + QUITMSG12, + QUITMSG13, + QUITMSG14, + QUITMSG15, + QUITMSG16, + QUITMSG17, + QUITMSG18, + QUITMSG19, + QUITMSG20, + QUITMSG21 +}; + +extern char** lang; + +char* str_cat(char* p, char* q); + +#endif diff --git a/src/doomstat.c b/src/doomstat.c @@ -1,5 +1,3 @@ #include "doomstat.h" -GameMode_t gamemode = indetermined; -GameMission_t gamemission = doom; -Language_t language = english; -boolean modifiedgame; + +boolean modifiedgame; diff --git a/src/doomstat.h b/src/doomstat.h @@ -1,83 +1,81 @@ #ifndef __D_STATE__ #define __D_STATE__ + #include "doomdata.h" #include "d_net.h" #include "d_player.h" -#ifdef __GNUG__ -#pragma interface -#endif -extern boolean nomonsters; -extern boolean respawnparm; -extern boolean fastparm; -extern boolean devparm; -extern GameMode_t gamemode; -extern GameMission_t gamemission; -extern boolean modifiedgame; -extern Language_t language; -extern skill_t startskill; -extern int startepisode; -extern int startmap; -extern boolean autostart; -extern skill_t gameskill; -extern int gameepisode; -extern int gamemap; -extern boolean respawnmonsters; -extern boolean netgame; -extern boolean deathmatch; -extern int snd_SfxVolume; -extern int snd_MusicVolume; -extern int snd_MusicDevice; -extern int snd_SfxDevice; -extern int snd_DesiredMusicDevice; -extern int snd_DesiredSfxDevice; -extern boolean statusbaractive; -extern boolean automapactive; -extern boolean menuactive; -extern boolean paused; -extern boolean viewactive; -extern boolean nodrawers; -extern boolean noblit; -extern int viewwindowx; -extern int viewwindowy; -extern int viewheight; -extern int viewwidth; -extern int scaledviewwidth; -extern int viewangleoffset; -extern int consoleplayer; -extern int displayplayer; -extern int totalkills; -extern int totalitems; -extern int totalsecret; -extern int levelstarttic; -extern int leveltime; -extern boolean usergame; -extern boolean demoplayback; -extern boolean demorecording; -extern boolean singledemo; -extern gamestate_t gamestate; -extern int gametic; -extern player_t players[MAXPLAYERS]; -extern boolean playeringame[MAXPLAYERS]; -#define MAX_DM_STARTS 10 -extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; -extern mapthing_t* deathmatch_p; -extern mapthing_t playerstarts[MAXPLAYERS]; -extern wbstartstruct_t wminfo; -extern int maxammo[NUMAMMO]; -extern char basedefault[1024]; -extern FILE* debugfile; -extern boolean precache; -extern gamestate_t wipegamestate; -extern int mouseSensitivity; -extern boolean singletics; -extern int bodyqueslot; -extern int skyflatnum; -extern doomcom_t* doomcom; -extern doomdata_t* netbuffer; -extern ticcmd_t localcmds[BACKUPTICS]; -extern int rndindex; -extern int maketic; -extern int nettics[MAXNETNODES]; -extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; -extern int ticdup; + +#define MAX_DM_STARTS 10 + +extern FILE* debugfile; +extern doomcom_t* doomcom; +extern doomdata_t* netbuffer; +extern boolean nomonsters; +extern boolean respawnparm; +extern boolean fastparm; +extern boolean devparm; +extern boolean modifiedgame; +extern boolean autostart; +extern boolean respawnmonsters; +extern boolean netgame; +extern boolean deathmatch; +extern boolean statusbaractive; +extern boolean automapactive; +extern boolean menuactive; +extern boolean paused; +extern boolean viewactive; +extern boolean nodrawers; +extern boolean noblit; +extern boolean usergame; +extern boolean demoplayback; +extern boolean demorecording; +extern boolean singledemo; +extern boolean playeringame[MAXPLAYERS]; +extern boolean precache; +extern boolean singletics; +extern int startepisode; +extern int startmap; +extern int gameepisode; +extern int gamemap; +extern int snd_SfxVolume; +extern int snd_MusicVolume; +extern int snd_MusicDevice; +extern int snd_SfxDevice; +extern int snd_DesiredMusicDevice; +extern int snd_DesiredSfxDevice; +extern int viewwindowx; +extern int viewwindowy; +extern int viewheight; +extern int viewwidth; +extern int scaledviewwidth; +extern int viewangleoffset; +extern int consoleplayer; +extern int displayplayer; +extern int totalkills; +extern int totalitems; +extern int totalsecret; +extern int levelstarttic; +extern int leveltime; +extern int gametic; +extern int maxammo[NUMAMMO]; +extern int mouseSensitivity; +extern int bodyqueslot; +extern int skyflatnum; +extern int rndindex; +extern int maketic; +extern int nettics[MAXNETNODES]; +extern int ticdup; +extern mapthing_t* deathmatch_p; +extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; +extern mapthing_t playerstarts[MAXPLAYERS]; +extern skill_t startskill; +extern skill_t gameskill; +extern ticcmd_t localcmds[BACKUPTICS]; +extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; +extern gamestate_t gamestate; +extern gamestate_t wipegamestate; +extern player_t players[MAXPLAYERS]; +extern wbstartstruct_t wminfo; +extern char basedefault[1024]; + #endif diff --git a/src/doomtype.h b/src/doomtype.h @@ -1,9 +0,0 @@ -#ifndef __DOOMTYPE__ -#define __DOOMTYPE__ -#ifndef __BYTEBOOL__ -#define __BYTEBOOL__ -typedef enum {false, true} boolean; -typedef unsigned char byte; -#endif -#include <values.h> -#endif diff --git a/src/dstrings.c b/src/dstrings.c @@ -1,26 +0,0 @@ -#include "dstrings.h" -char* endmsg[NUM_QUITMESSAGES+1] = { - QUITMSG, - "please don't leave, there's more\ndemons to toast!", - "let's beat it -- this is turning\ninto a bloodbath!", - "i wouldn't leave if i were you.\ndos is much worse.", - "you're trying to say you like dos\nbetter than me, right?", - "don't leave yet -- there's a\ndemon around that corner!", - "ya know, next time you come in here\ni'm gonna toast ya.", - "go ahead and leave. see if i care." - "you want to quit?\nthen, thou hast lost an eighth!", - "don't go now, there's a \ndimensional shambler waiting\nat the dos prompt!", - "get outta here and go back\nto your boring programs.", - "if i were your boss, i'd \n deathmatch ya in a minute!", - "look, bud. you leave now\nand you forfeit your body count!", - "just leave. when you come\nback, i'll be waiting with a bat.", - "you're lucky i don't smack\nyou for thinking about leaving." - "fuck you, pussy!\nget the fuck out!", - "you quit and i'll jizz\nin your cystholes!", - "if you leave, i'll make\nthe lord drink my jizz.", - "hey, ron! can we say\n'fuck' in the game?", - "i'd leave: this is just\nmore monsters and levels.\nwhat a load.", - "suck it down, asshole!\nyou're a fucking wimp!", - "don't quit now! we're \nstill spending your money!", - "THIS IS NO MESSAGE!\nPage intentionally left blank." -}; diff --git a/src/dstrings.h b/src/dstrings.h @@ -1,13 +1,11 @@ #ifndef __DSTRINGS__ #define __DSTRINGS__ -#ifdef FRENCH -#include "d_french.h" -#else -#include "d_englsh.h" -#endif -#define SAVEGAMENAME "doomsav" + +#define SAVEGAMENAME "doomsav" #define DEVMAPS "devmaps" #define DEVDATA "devdata" -#define NUM_QUITMESSAGES 22 +#define NUM_QUITMESSAGES 22 + extern char* endmsg[]; + #endif diff --git a/src/f_finale.c b/src/f_finale.c @@ -1,537 +1,384 @@ #include <ctype.h> + +#include "doomdef.h" #include "i_system.h" -#include "m_swap.h" #include "z_zone.h" #include "v_video.h" #include "w_wad.h" #include "s_sound.h" -#include "dstrings.h" #include "sounds.h" #include "doomstat.h" #include "r_state.h" -int finalestage; -int finalecount; +#include "hu_stuff.h" + #define TEXTSPEED 3 #define TEXTWAIT 250 -char* e1text = E1TEXT; -char* e2text = E2TEXT; -char* e3text = E3TEXT; -char* e4text = E4TEXT; -char* c1text = C1TEXT; -char* c2text = C2TEXT; -char* c3text = C3TEXT; -char* c4text = C4TEXT; -char* c5text = C5TEXT; -char* c6text = C6TEXT; -char* p1text = P1TEXT; -char* p2text = P2TEXT; -char* p3text = P3TEXT; -char* p4text = P4TEXT; -char* p5text = P5TEXT; -char* p6text = P6TEXT; -char* t1text = T1TEXT; -char* t2text = T2TEXT; -char* t3text = T3TEXT; -char* t4text = T4TEXT; -char* t5text = T5TEXT; -char* t6text = T6TEXT; + +typedef struct { + int name; + mobjtype_t type; +} castinfo_t; + +void F_CastTicker (); +boolean F_CastResponder (event_t *ev); +void F_CastDrawer (); +void V_DrawPatchFlipped(int x, int y, int scrn, patch_t *patch); + +extern patch_t *hu_font[HU_FONTSIZE]; +int finalestage; +int finalecount; char* finaletext; char* finaleflat; -void F_StartCast (void); -void F_CastTicker (void); -boolean F_CastResponder (event_t *ev); -void F_CastDrawer (void); -void F_StartFinale (void) +int castnum; +int casttics; +state_t* caststate; +boolean castdeath; +int castframes; +int castonmelee; +boolean castattacking; +extern gamestate_t wipegamestate; + +castinfo_t castorder[] = { + {CC_ZOMBIE, MT_POSSESSED}, + {CC_SHOTGUN, MT_SHOTGUY}, + {CC_HEAVY, MT_CHAINGUY}, + {CC_IMP, MT_TROOP}, + {CC_DEMON, MT_SERGEANT}, + {CC_LOST, MT_SKULL}, + {CC_CACO, MT_HEAD}, + {CC_HELL, MT_KNIGHT}, + {CC_BARON, MT_BRUISER}, + {CC_ARACH, MT_BABY}, + {CC_PAIN, MT_PAIN}, + {CC_REVEN, MT_UNDEAD}, + {CC_MANCU, MT_FATSO}, + {CC_ARCH, MT_VILE}, + {CC_SPIDER, MT_SPIDER}, + {CC_CYBER, MT_CYBORG}, + {CC_HERO, MT_PLAYER}, + {0, 0} +}; + +void +F_StartFinale() { - gameaction = ga_nothing; - gamestate = GS_FINALE; - viewactive = false; - automapactive = false; - switch ( gamemode ) - { - case shareware: - case registered: - case retail: - { + gameaction = ga_nothing; + gamestate = GS_FINALE; + viewactive = false; + automapactive = false; S_ChangeMusic(mus_victor, true); - switch (gameepisode) - { - case 1: - finaleflat = "FLOOR4_8"; - finaletext = e1text; - break; - case 2: - finaleflat = "SFLR6_1"; - finaletext = e2text; - break; - case 3: - finaleflat = "MFLR8_4"; - finaletext = e3text; - break; - case 4: - finaleflat = "MFLR8_3"; - finaletext = e4text; - break; - default: - break; + switch (gameepisode) { + case 1: + finaleflat = "FLOOR4_8"; + finaletext = lang[E1TEXT]; + break; + case 2: + finaleflat = "SFLR6_1"; + finaletext = lang[E2TEXT]; + break; + case 3: + finaleflat = "MFLR8_4"; + finaletext = lang[E3TEXT]; + break; + case 4: + finaleflat = "MFLR8_3"; + finaletext = lang[E4TEXT]; + break; } - break; - } - case commercial: - { - S_ChangeMusic(mus_read_m, true); - switch (gamemap) - { - case 6: - finaleflat = "SLIME16"; - finaletext = c1text; - break; - case 11: - finaleflat = "RROCK14"; - finaletext = c2text; - break; - case 20: - finaleflat = "RROCK07"; - finaletext = c3text; - break; - case 30: - finaleflat = "RROCK17"; - finaletext = c4text; - break; - case 15: - finaleflat = "RROCK13"; - finaletext = c5text; - break; - case 31: - finaleflat = "RROCK19"; - finaletext = c6text; - break; - default: - break; - } - break; - } - default: - S_ChangeMusic(mus_read_m, true); - finaleflat = "F_SKY1"; - finaletext = c1text; - break; - } - finalestage = 0; - finalecount = 0; -} -boolean F_Responder (event_t *event) -{ - if (finalestage == 2) - return F_CastResponder (event); - return false; + finalestage = 0; + finalecount = 0; } -void F_Ticker (void) + +boolean +F_Responder(event_t* event) { - int i; - if ( (gamemode == commercial) - && ( finalecount > 50) ) - { - for (i=0 ; i<MAXPLAYERS ; i++) - if (players[i].cmd.buttons) - break; - if (i < MAXPLAYERS) - { - if (gamemap == 30) - F_StartCast (); - else - gameaction = ga_worlddone; - } - } - finalecount++; - if (finalestage == 2) - { - F_CastTicker (); - return; - } - if ( gamemode == commercial) - return; - if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) - { - finalecount = 0; - finalestage = 1; - wipegamestate = -1; - if (gameepisode == 3) - S_StartMusic (mus_bunny); - } + if (finalestage == 2) return F_CastResponder(event); + return false; } -#include "hu_stuff.h" -extern patch_t *hu_font[HU_FONTSIZE]; -void F_TextWrite (void) + +void +F_Ticker() { - byte* src; - byte* dest; - int x,y,w; - int count; - char* ch; - int c; - int cx; - int cy; - src = W_CacheLumpName ( finaleflat , PU_CACHE); - dest = screens[0]; - for (y=0 ; y<SCREENHEIGHT ; y++) - { - for (x=0 ; x<SCREENWIDTH/64 ; x++) - { - memcpy (dest, src+((y&63)<<6), 64); - dest += 64; - } - if (SCREENWIDTH&63) - { - memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); - dest += (SCREENWIDTH&63); + finalecount++; + if (finalestage == 2) { + F_CastTicker (); + return; } - } - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - cx = 10; - cy = 10; - ch = finaletext; - count = (finalecount - 10)/TEXTSPEED; - if (count < 0) - count = 0; - for ( ; count ; count-- ) - { - c = *ch++; - if (!c) - break; - if (c == '\n') - { - cx = 10; - cy += 11; - continue; + if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) { + finalecount = 0; + finalestage = 1; + wipegamestate = -1; + if (gameepisode == 3) S_StartMusic(mus_bunny); } - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - cx += 4; - continue; - } - w = SHORT (hu_font[c]->width); - if (cx+w > SCREENWIDTH) - break; - V_DrawPatch(cx, cy, 0, hu_font[c]); - cx+=w; - } } -typedef struct -{ - char *name; - mobjtype_t type; -} castinfo_t; -castinfo_t castorder[] = { - {CC_ZOMBIE, MT_POSSESSED}, - {CC_SHOTGUN, MT_SHOTGUY}, - {CC_HEAVY, MT_CHAINGUY}, - {CC_IMP, MT_TROOP}, - {CC_DEMON, MT_SERGEANT}, - {CC_LOST, MT_SKULL}, - {CC_CACO, MT_HEAD}, - {CC_HELL, MT_KNIGHT}, - {CC_BARON, MT_BRUISER}, - {CC_ARACH, MT_BABY}, - {CC_PAIN, MT_PAIN}, - {CC_REVEN, MT_UNDEAD}, - {CC_MANCU, MT_FATSO}, - {CC_ARCH, MT_VILE}, - {CC_SPIDER, MT_SPIDER}, - {CC_CYBER, MT_CYBORG}, - {CC_HERO, MT_PLAYER}, - {NULL,0} -}; -int castnum; -int casttics; -state_t* caststate; -boolean castdeath; -int castframes; -int castonmelee; -boolean castattacking; -extern gamestate_t wipegamestate; -void F_StartCast (void) + +void +F_TextWrite() { - wipegamestate = -1; - castnum = 0; - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; - casttics = caststate->tics; - castdeath = false; - finalestage = 2; - castframes = 0; - castonmelee = 0; - castattacking = false; - S_ChangeMusic(mus_evil, true); + byte* src, *dest; + char* ch; + int x, y, w, count, c, cx, cy; + + src = W_CacheLumpName(finaleflat, PU_CACHE); + dest = screens[0]; + for (y = 0; y < SCREENHEIGHT; ++y) { + for (x = 0; x < SCREENWIDTH/64; ++x) { + memcpy (dest, src+((y&63)<<6), 64); + dest += 64; + } + if (SCREENWIDTH&63) { + memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); + dest += (SCREENWIDTH&63); + } + } + V_MarkRect(0, 0, SCREENWIDTH, SCREENHEIGHT); + cx = cy = 10; + ch = finaletext; + count = (finalecount - 10)/TEXTSPEED; + if (count < 0) count = 0; + for (; count; --count) { + c = *ch++; + if (!c) break; + if (c == '\n') { + cx = 10; + cy += 11; + continue; + } + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c> HU_FONTSIZE) { + cx += 4; + continue; + } + w = hu_font[c]->width; + if (cx+w > SCREENWIDTH) break; + V_DrawPatch(cx, cy, 0, hu_font[c]); + cx+=w; + } } -void F_CastTicker (void) + + +void +F_CastTicker() { - int st; - int sfx; - if (--casttics > 0) - return; - if (caststate->tics == -1 || caststate->nextstate == S_NULL) - { - castnum++; - castdeath = false; - if (castorder[castnum].name == NULL) - castnum = 0; - if (mobjinfo[castorder[castnum].type].seesound) - S_StartSound (NULL, mobjinfo[castorder[castnum].type].seesound); - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; - castframes = 0; - } - else - { - if (caststate == &states[S_PLAY_ATK1]) - goto stopattack; - st = caststate->nextstate; - caststate = &states[st]; - castframes++; - switch (st) - { - case S_PLAY_ATK1: sfx = sfx_dshtgn; break; - case S_POSS_ATK2: sfx = sfx_pistol; break; - case S_SPOS_ATK2: sfx = sfx_shotgn; break; - case S_VILE_ATK2: sfx = sfx_vilatk; break; - case S_SKEL_FIST2: sfx = sfx_skeswg; break; - case S_SKEL_FIST4: sfx = sfx_skepch; break; - case S_SKEL_MISS2: sfx = sfx_skeatk; break; - case S_FATT_ATK8: - case S_FATT_ATK5: - case S_FATT_ATK2: sfx = sfx_firsht; break; - case S_CPOS_ATK2: - case S_CPOS_ATK3: - case S_CPOS_ATK4: sfx = sfx_shotgn; break; - case S_TROO_ATK3: sfx = sfx_claw; break; - case S_SARG_ATK2: sfx = sfx_sgtatk; break; - case S_BOSS_ATK2: - case S_BOS2_ATK2: - case S_HEAD_ATK2: sfx = sfx_firsht; break; - case S_SKULL_ATK2: sfx = sfx_sklatk; break; - case S_SPID_ATK2: - case S_SPID_ATK3: sfx = sfx_shotgn; break; - case S_BSPI_ATK2: sfx = sfx_plasma; break; - case S_CYBER_ATK2: - case S_CYBER_ATK4: - case S_CYBER_ATK6: sfx = sfx_rlaunc; break; - case S_PAIN_ATK3: sfx = sfx_sklatk; break; - default: sfx = 0; break; + int st, sfx; + + if (--casttics > 0) return; + if (caststate->tics == -1 || caststate->nextstate == S_NULL) { + castnum++; + castdeath = false; + if (lang[castorder[castnum].name] == NULL) + castnum = 0; + if (mobjinfo[castorder[castnum].type].seesound) + S_StartSound(NULL, mobjinfo[castorder[castnum].type].seesound); + caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + castframes = 0; + } else { + if (caststate == &states[S_PLAY_ATK1]) goto stopattack; + st = caststate->nextstate; + caststate = &states[st]; + castframes++; + switch (st) { + case S_PLAY_ATK1: sfx = sfx_dshtgn; break; + case S_POSS_ATK2: sfx = sfx_pistol; break; + case S_SPOS_ATK2: sfx = sfx_shotgn; break; + case S_VILE_ATK2: sfx = sfx_vilatk; break; + case S_SKEL_FIST2: sfx = sfx_skeswg; break; + case S_SKEL_FIST4: sfx = sfx_skepch; break; + case S_SKEL_MISS2: sfx = sfx_skeatk; break; + case S_FATT_ATK8: + case S_FATT_ATK5: + case S_FATT_ATK2: sfx = sfx_firsht; break; + case S_CPOS_ATK2: + case S_CPOS_ATK3: + case S_CPOS_ATK4: sfx = sfx_shotgn; break; + case S_TROO_ATK3: sfx = sfx_claw; break; + case S_SARG_ATK2: sfx = sfx_sgtatk; break; + case S_BOSS_ATK2: + case S_BOS2_ATK2: + case S_HEAD_ATK2: sfx = sfx_firsht; break; + case S_SKULL_ATK2: sfx = sfx_sklatk; break; + case S_SPID_ATK2: + case S_SPID_ATK3: sfx = sfx_shotgn; break; + case S_BSPI_ATK2: sfx = sfx_plasma; break; + case S_CYBER_ATK2: + case S_CYBER_ATK4: + case S_CYBER_ATK6: sfx = sfx_rlaunc; break; + case S_PAIN_ATK3: sfx = sfx_sklatk; break; + default: sfx = 0; break; + } + if (sfx) S_StartSound(NULL, sfx); } - if (sfx) - S_StartSound (NULL, sfx); - } - if (castframes == 12) - { - castattacking = true; - if (castonmelee) - caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; - else - caststate=&states[mobjinfo[castorder[castnum].type].missilestate]; - castonmelee ^= 1; - if (caststate == &states[S_NULL]) - { - if (castonmelee) - caststate= - &states[mobjinfo[castorder[castnum].type].meleestate]; - else - caststate= - &states[mobjinfo[castorder[castnum].type].missilestate]; + if (castframes == 12) { + castattacking = true; + if (castonmelee) caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; + else caststate=&states[mobjinfo[castorder[castnum].type].missilestate]; + castonmelee ^= 1; + if (caststate == &states[S_NULL]) { + if (castonmelee) caststate = &states[mobjinfo[castorder[castnum].type].meleestate]; + else caststate = &states[mobjinfo[castorder[castnum].type].missilestate]; + } } - } - if (castattacking) - { - if (castframes == 24 - || caststate == &states[mobjinfo[castorder[castnum].type].seestate] ) - { - stopattack: - castattacking = false; - castframes = 0; - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + if (castattacking) { + if (castframes == 24 || caststate == &states[mobjinfo[castorder[castnum].type].seestate] ) { + stopattack: + castattacking = false; + castframes = 0; + caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + } } - } - casttics = caststate->tics; - if (casttics == -1) - casttics = 15; + casttics = caststate->tics; + if (casttics == -1) casttics = 15; } -boolean F_CastResponder (event_t* ev) + +boolean +F_CastResponder(event_t* ev) { - if (ev->type != ev_keydown) - return false; - if (castdeath) - return true; - castdeath = true; - caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; - casttics = caststate->tics; - castframes = 0; - castattacking = false; - if (mobjinfo[castorder[castnum].type].deathsound) - S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound); - return true; + if (ev->type != ev_keydown) return false; + if (castdeath) return true; + castdeath = true; + caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; + casttics = caststate->tics; + castframes = 0; + castattacking = false; + if (mobjinfo[castorder[castnum].type].deathsound) S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound); + return true; } -void F_CastPrint (char* text) + +void +F_CastPrint(char* text) { - char* ch; - int c; - int cx; - int w; - int width; - ch = text; - width = 0; - while (ch) - { - c = *ch++; - if (!c) - break; - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - width += 4; - continue; + char* ch; + int c, cx, w, width; + + width = 0; + ch = text; + while (ch) { + c = *ch++; + if (!c) break; + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c> HU_FONTSIZE) { + width += 4; + continue; + } + w = (hu_font[c]->width); + width += w; } - w = SHORT (hu_font[c]->width); - width += w; - } - cx = 160-width/2; - ch = text; - while (ch) - { - c = *ch++; - if (!c) - break; - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - cx += 4; - continue; + cx = 160-width/2; + ch = text; + while (ch) { + c = *ch++; + if (!c) break; + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c > HU_FONTSIZE) { + cx += 4; + continue; + } + w = (hu_font[c]->width); + V_DrawPatch(cx, 180, 0, hu_font[c]); + cx += w; } - w = SHORT (hu_font[c]->width); - V_DrawPatch(cx, 180, 0, hu_font[c]); - cx+=w; - } } -void V_DrawPatchFlipped (int x, int y, int scrn, patch_t *patch); -void F_CastDrawer (void) + + +void +F_CastDrawer() { - spritedef_t* sprdef; - spriteframe_t* sprframe; - int lump; - boolean flip; - patch_t* patch; - V_DrawPatch (0,0,0, W_CacheLumpName ("BOSSBACK", PU_CACHE)); - F_CastPrint (castorder[castnum].name); - sprdef = &sprites[caststate->sprite]; - sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; - lump = sprframe->lump[0]; - flip = (boolean)sprframe->flip[0]; - patch = W_CacheLumpNum (lump+firstspritelump, PU_CACHE); - if (flip) - V_DrawPatchFlipped (160,170,0,patch); - else - V_DrawPatch (160,170,0,patch); + spriteframe_t* sprframe; + spritedef_t* sprdef; + patch_t* patch; + int lump; + boolean flip; + + V_DrawPatch (0, 0, 0, W_CacheLumpName ("BOSSBACK", PU_CACHE)); + F_CastPrint(lang[castorder[castnum].name]); + sprdef = &sprites[caststate->sprite]; + sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; + lump = sprframe->lump[0]; + flip = (boolean)sprframe->flip[0]; + patch = W_CacheLumpNum (lump+firstspritelump, PU_CACHE); + if (flip) V_DrawPatchFlipped(160, 170, 0, patch); + else V_DrawPatch (160, 170, 0, patch); } + void -F_DrawPatchCol -( int x, - patch_t* patch, - int col ) +F_DrawPatchCol(int x, patch_t* patch, int col) { - column_t* column; - byte* source; - byte* dest; - byte* desttop; - int count; - column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - desttop = screens[0]+x; - while (column->topdelta != 0xff ) - { - source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; - count = column->length; - while (count--) - { - *dest = *source++; - dest += SCREENWIDTH; + column_t* column; + byte* source, *dest , *desttop; + int count; + + column = (column_t *)((byte *)patch + patch->columnofs[col]); + desttop = screens[0] + x; + while (column->topdelta != 0xff ) { + source = (byte *)column + 3; + dest = desttop + column->topdelta*SCREENWIDTH; + for (count = column->length; count; --count) { + *dest = *source++; + dest += SCREENWIDTH; + } + column = (column_t*)((byte*)column + column->length + 4); } - column = (column_t *)( (byte *)column + column->length + 4 ); - } } -void F_BunnyScroll (void) + +void +F_BunnyScroll() { - int scrolled; - int x; - patch_t* p1; - patch_t* p2; - char name[10]; - int stage; - static int laststage; - p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); - p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - scrolled = 320 - (finalecount-230)/2; - if (scrolled > 320) - scrolled = 320; - if (scrolled < 0) - scrolled = 0; - for ( x=0 ; x<SCREENWIDTH ; x++) - { - if (x+scrolled < 320) - F_DrawPatchCol (x, p1, x+scrolled); - else - F_DrawPatchCol (x, p2, x+scrolled - 320); - } - if (finalecount < 1130) - return; - if (finalecount < 1180) - { - V_DrawPatch ((SCREENWIDTH-13*8)/2, - (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName ("END0",PU_CACHE)); - laststage = 0; - return; - } - stage = (finalecount-1180) / 5; - if (stage > 6) - stage = 6; - if (stage > laststage) - { - S_StartSound (NULL, sfx_pistol); - laststage = stage; - } - sprintf (name,"END%i",stage); - V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName (name,PU_CACHE)); + static int laststage; + patch_t* p1; + patch_t* p2; + int scrolled; + int x; + int stage; + char name[10]; + + p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); + p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); + V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); + scrolled = 320 - (finalecount-230)/2; + if (scrolled > 320) scrolled = 320; + if (scrolled < 0) scrolled = 0; + for (x = 0; x < SCREENWIDTH; ++x) { + if (x+scrolled < 320) F_DrawPatchCol(x, p1, x+scrolled); + else F_DrawPatchCol(x, p2, x+scrolled - 320); + } + if (finalecount < 1130) return; + if (finalecount < 1180) { + V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2, 0, W_CacheLumpName("END0", PU_CACHE)); + laststage = 0; + return; + } + stage = (finalecount-1180) / 5; + if (stage > 6) stage = 6; + if (stage > laststage) { + S_StartSound (NULL, sfx_pistol); + laststage = stage; + } + sprintf (name, "END%i", stage); + V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2, 0, W_CacheLumpName(name, PU_CACHE)); } -void F_Drawer (void) + +void +F_Drawer() { - if (finalestage == 2) - { - F_CastDrawer (); - return; - } - if (!finalestage) - F_TextWrite (); - else - { - switch (gameepisode) - { - case 1: - if ( gamemode == retail ) - V_DrawPatch (0,0,0, - W_CacheLumpName("CREDIT",PU_CACHE)); - else - V_DrawPatch (0,0,0, - W_CacheLumpName("HELP2",PU_CACHE)); - break; - case 2: - V_DrawPatch(0,0,0, - W_CacheLumpName("VICTORY2",PU_CACHE)); - break; - case 3: - F_BunnyScroll (); - break; - case 4: - V_DrawPatch (0,0,0, - W_CacheLumpName("ENDPIC",PU_CACHE)); - break; + if (finalestage == 2) { + F_CastDrawer (); + return; + } + if (!finalestage) F_TextWrite(); + else { + switch (gameepisode) { + case 1: + V_DrawPatch (0, 0, 0, W_CacheLumpName("HELP2", PU_CACHE)); + break; + case 2: + V_DrawPatch(0, 0, 0, W_CacheLumpName("VICTORY2", PU_CACHE)); + break; + case 3: + F_BunnyScroll(); + break; + case 4: + V_DrawPatch (0, 0, 0, W_CacheLumpName("ENDPIC", PU_CACHE)); + break; + } } - } } diff --git a/src/f_finale.h b/src/f_finale.h @@ -1,9 +1,12 @@ #ifndef __F_FINALE__ #define __F_FINALE__ -#include "doomtype.h" + +#include "doomdef.h" #include "d_event.h" + boolean F_Responder (event_t* ev); void F_Ticker (void); void F_Drawer (void); void F_StartFinale (void); + #endif diff --git a/src/f_wipe.c b/src/f_wipe.c @@ -2,54 +2,58 @@ #include "i_video.h" #include "v_video.h" #include "m_random.h" + #include "doomdef.h" #include "f_wipe.h" + static boolean go = 0; static byte* wipe_scr_start; static byte* wipe_scr_end; static byte* wipe_scr; + void -wipe_shittyColMajorXform -( short* array, - int width, - int height ) +wipe_shittyColMajorXform(short* array, int width, int height) { int x; int y; short* dest; + dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); + for(y=0;y<height;y++) for(x=0;x<width;x++) dest[x*height+y] = array[y*width+x]; + memcpy(array, dest, width*height*2); + Z_Free(dest); + } + int -wipe_initColorXForm -( int width, - int height, - int ticks ) +wipe_initColorXForm(int width, int height, int ticks) { memcpy(wipe_scr, wipe_scr_start, width*height); return 0; } + int -wipe_doColorXForm -( int width, +wipe_doColorXForm( int width, int height, int ticks ) { - boolean changed; byte* w; byte* e; - int newval; + boolean changed; + int newval; + changed = false; w = wipe_scr; e = wipe_scr_end; + while (w!=wipe_scr+width*height) { - if (*w != *e) - { + if (*w != *e) { if (*w > *e) { newval = *w - ticks; @@ -72,8 +76,11 @@ wipe_doColorXForm w++; e++; } + return !changed; + } + int wipe_exitColorXForm ( int width, @@ -82,7 +89,10 @@ wipe_exitColorXForm { return 0; } + + static int* y; + int wipe_initMelt ( int width, @@ -90,9 +100,17 @@ wipe_initMelt int ticks ) { int i, r; + + memcpy(wipe_scr, wipe_scr_start, width*height); + + + wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); + + + y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0); y[0] = -(M_Random()%16); for (i=1;i<width;i++) @@ -102,8 +120,10 @@ wipe_initMelt if (y[i] > 0) y[i] = 0; else if (y[i] == -16) y[i] = -15; } + return 0; } + int wipe_doMelt ( int width, @@ -114,10 +134,13 @@ wipe_doMelt int j; int dy; int idx; + short* s; short* d; boolean done = true; + width/=2; + while (ticks--) { for (i=0;i<width;i++) @@ -151,8 +174,11 @@ wipe_doMelt } } } + return done; + } + int wipe_exitMelt ( int width, @@ -162,6 +188,7 @@ wipe_exitMelt Z_Free(y); return 0; } + int wipe_StartScreen ( int x, @@ -173,6 +200,7 @@ wipe_StartScreen I_ReadScreen(wipe_scr_start); return 0; } + int wipe_EndScreen ( int x, @@ -185,6 +213,7 @@ wipe_EndScreen V_DrawBlock(x, y, 0, width, height, wipe_scr_start); return 0; } + int wipe_ScreenWipe ( int wipeno, @@ -200,19 +229,30 @@ wipe_ScreenWipe wipe_initColorXForm, wipe_doColorXForm, wipe_exitColorXForm, wipe_initMelt, wipe_doMelt, wipe_exitMelt }; + void V_MarkRect(int, int, int, int); + + if (!go) { go = 1; + wipe_scr = screens[0]; (*wipes[wipeno*3])(width, height, ticks); } + + V_MarkRect(0, 0, width, height); rc = (*wipes[wipeno*3+1])(width, height, ticks); + + + if (rc) { go = 0; (*wipes[wipeno*3+2])(width, height, ticks); } + return !go; + } diff --git a/src/f_wipe.h b/src/f_wipe.h @@ -1,23 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __F_WIPE_H__ #define __F_WIPE_H__ + + + + + enum { + wipe_ColorXForm, + + wipe_Melt, + wipe_NUMWIPES }; + int wipe_StartScreen ( int x, int y, int width, int height ); + + int wipe_EndScreen ( int x, int y, int width, int height ); + + int wipe_ScreenWipe ( int wipeno, @@ -26,4 +62,10 @@ wipe_ScreenWipe int width, int height, int ticks ); + #endif + + + + + diff --git a/src/g_game.c b/src/g_game.c @@ -1,6 +1,7 @@ #include <string.h> #include <stdlib.h> -#include "doomdef.h" + +#include "doomdef.h" #include "doomstat.h" #include "z_zone.h" #include "f_finale.h" @@ -19,1169 +20,734 @@ #include "am_map.h" #include "v_video.h" #include "w_wad.h" -#include "p_local.h" +#include "p_local.h" #include "s_sound.h" -#include "dstrings.h" #include "sounds.h" #include "r_data.h" -#include "r_sky.h" #include "g_game.h" + #define SAVEGAMESIZE 0x2c000 #define SAVESTRINGSIZE 24 -boolean G_CheckDemoStatus (void); -void G_ReadDemoTiccmd (ticcmd_t* cmd); -void G_WriteDemoTiccmd (ticcmd_t* cmd); -void G_PlayerReborn (int player); -void G_InitNew (skill_t skill, int episode, int map); -void G_DoReborn (int playernum); -void G_DoLoadLevel (void); -void G_DoNewGame (void); -void G_DoLoadGame (void); -void G_DoPlayDemo (void); -void G_DoCompleted (void); -void G_DoVictory (void); -void G_DoWorldDone (void); -void G_DoSaveGame (void); -gameaction_t gameaction; -gamestate_t gamestate; -skill_t gameskill; +#define MAXPLMOVE (forwardmove[1]) +#define TURBOTHRESHOLD 0x32 +#define SLOWTURNTICS 6 +#define NUMKEYS 256 +#define BODYQUESIZE 32 +#define VERSIONSIZE 16 +#define DEMOMARKER 0x80 + +boolean G_CheckDemoStatus (); +void G_ReadDemoTiccmd (ticcmd_t* cmd); +void G_WriteDemoTiccmd (ticcmd_t* cmd); +void G_PlayerReborn (int player); +void G_InitNew (skill_t skill, int episode, int map); +void G_DoReborn (int playernum); +void G_DoLoadLevel (); +void G_DoNewGame (); +void G_DoLoadGame (); +void G_DoPlayDemo (); +void G_DoCompleted (); +void G_DoVictory (); +void G_DoWorldDone (); +void G_DoSaveGame (); +void R_ExecuteSetViewSize (); + +extern gamestate_t wipegamestate; +extern boolean setsizeneeded; +extern char* pagename; +extern int skytexture; +skill_t d_skill; +int d_episode; +int d_map; +boolean secretexit; +gameaction_t gameaction; +gamestate_t gamestate; +skill_t gameskill; boolean respawnmonsters; -int gameepisode; -int gamemap; -boolean paused; -boolean sendpause; -boolean sendsave; -boolean usergame; -boolean timingdemo; -boolean nodrawers; -boolean noblit; -int starttime; -boolean viewactive; -boolean deathmatch; -boolean netgame; -boolean playeringame[MAXPLAYERS]; -player_t players[MAXPLAYERS]; -int consoleplayer; -int displayplayer; -int gametic; -int levelstarttic; -int totalkills, totalitems, totalsecret; -char demoname[32]; -boolean demorecording; -boolean demoplayback; -boolean netdemo; +int gameepisode; +int gamemap; +boolean paused; +boolean sendpause; +boolean sendsave; +boolean usergame; +boolean timingdemo; +boolean nodrawers; +boolean noblit; +int starttime; +boolean viewactive; +boolean deathmatch; +boolean netgame; +boolean playeringame[MAXPLAYERS]; +player_t players[MAXPLAYERS]; +int consoleplayer; +int displayplayer; +int gametic; +int levelstarttic; +int totalkills, totalitems, totalsecret; +char demoname[32]; +boolean demorecording; +boolean demoplayback; +boolean netdemo; byte* demobuffer; byte* demo_p; -byte* demoend; -boolean singledemo; -boolean precache = true; -wbstartstruct_t wminfo; -short consistancy[MAXPLAYERS][BACKUPTICS]; +byte* demoend; +boolean singledemo; +boolean precache = true; +wbstartstruct_t wminfo; +short consistancy[MAXPLAYERS][BACKUPTICS]; byte* savebuffer; -int key_right; +int key_right; int key_left; int key_up; -int key_down; -int key_strafeleft; -int key_straferight; -int key_fire; +int key_down; +int key_strafeleft; +int key_straferight; +int key_fire; int key_use; int key_strafe; -int key_speed; -int mousebfire; -int mousebstrafe; -int mousebforward; -int joybfire; -int joybstrafe; -int joybuse; -int joybspeed; -#define MAXPLMOVE (forwardmove[1]) -#define TURBOTHRESHOLD 0x32 -fixed_t forwardmove[2] = {0x19, 0x32}; -fixed_t sidemove[2] = {0x18, 0x28}; -fixed_t angleturn[3] = {640, 1280, 320}; -#define SLOWTURNTICS 6 -#define NUMKEYS 256 -boolean gamekeydown[NUMKEYS]; -int turnheld; -boolean mousearray[4]; -boolean* mousebuttons = &mousearray[1]; -int mousex; -int mousey; -int dclicktime; +int key_speed; +int mousebfire; +int mousebstrafe; +int mousebforward; +int joybfire; +int joybstrafe; +int joybuse; +int joybspeed; +fixed_t forwardmove[2] = {0x19, 0x32}; +fixed_t sidemove[2] = {0x18, 0x28}; +fixed_t angleturn[3] = {640, 1280, 320}; +boolean gamekeydown[NUMKEYS]; +int turnheld; +boolean mousearray[4]; +boolean* mousebuttons = &mousearray[1]; +int mousex; +int mousey; +int dclicktime; int dclickstate; -int dclicks; -int dclicktime2; +int dclicks; +int dclicktime2; int dclickstate2; int dclicks2; -int joyxmove; +int joyxmove; int joyymove; -boolean joyarray[5]; -boolean* joybuttons = &joyarray[1]; -int savegameslot; -char savedescription[32]; -#define BODYQUESIZE 32 -mobj_t* bodyque[BODYQUESIZE]; -int bodyqueslot; -void* statcopy; -int G_CmdChecksum (ticcmd_t* cmd) -{ - int i; - int sum = 0; - for (i=0 ; i< sizeof(*cmd)/4 - 1 ; i++) - sum += ((int *)cmd)[i]; - return sum; -} -void G_BuildTiccmd (ticcmd_t* cmd) -{ - int i; - boolean strafe; - boolean bstrafe; - int speed; - int tspeed; - int forward; - int side; - ticcmd_t* base; - base = I_BaseTiccmd (); - memcpy (cmd,base,sizeof(*cmd)); - cmd->consistancy = - consistancy[consoleplayer][maketic%BACKUPTICS]; - strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] - || joybuttons[joybstrafe]; - speed = gamekeydown[key_speed] || joybuttons[joybspeed]; - forward = side = 0; - if (joyxmove < 0 - || joyxmove > 0 - || gamekeydown[key_right] - || gamekeydown[key_left]) - turnheld += ticdup; - else - turnheld = 0; - if (turnheld < SLOWTURNTICS) - tspeed = 2; - else - tspeed = speed; - if (strafe) - { - if (gamekeydown[key_right]) - { - side += sidemove[speed]; +boolean joyarray[5]; +boolean* joybuttons = &joyarray[1]; +int savegameslot; +char savedescription[32]; +mobj_t* bodyque[BODYQUESIZE]; +int bodyqueslot; +void* statcopy; +char* defdemoname; + +int pars[4][10] = { + {0}, + {0,30,75,120,90,165,180,180,30,165}, + {0,90,90,90,120,90,360,240,30,170}, + {0,90,45,90,150,90,90,165,30,135} +}; + +int cpars[32] = { + 30,90,120,120,90,150,120,120,270,90, + 210,150,150,150,210,150,420,150,210,150, + 240,150,180,150,150,300,330,420,300,180, + 120,30 +}; + +int +G_CmdChecksum(ticcmd_t* cmd) +{ + int i, sum; + + for (sum = i = 0; i < sizeof(*cmd)/4 - 1; ++i) sum += ((int*)cmd)[i]; + return sum; +} + +void +G_BuildTiccmd(ticcmd_t* cmd) +{ + static ticcmd_t base; + int i, speed, tspeed, forward, side; + boolean strafe, bstrafe; + + memcpy(cmd, &base, sizeof(*cmd)); + cmd->consistancy = consistancy[consoleplayer][maketic%BACKUPTICS]; + strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; + speed = gamekeydown[key_speed] || joybuttons[joybspeed]; + forward = side = 0; + if (joyxmove < 0 || joyxmove > 0 || gamekeydown[key_right] || gamekeydown[key_left]) turnheld += ticdup; + else turnheld = 0; + if (turnheld < SLOWTURNTICS) tspeed = 2; + else tspeed = speed; + if (strafe) { + if (gamekeydown[key_right]) side += sidemove[speed]; + if (gamekeydown[key_left]) side -= sidemove[speed]; + if (joyxmove > 0) side += sidemove[speed]; + if (joyxmove < 0) side -= sidemove[speed]; } - if (gamekeydown[key_left]) - { - side -= sidemove[speed]; + else { + if (gamekeydown[key_right]) cmd->angleturn -= angleturn[tspeed]; + if (gamekeydown[key_left]) cmd->angleturn += angleturn[tspeed]; + if (joyxmove > 0) cmd->angleturn -= angleturn[tspeed]; + if (joyxmove < 0) cmd->angleturn += angleturn[tspeed]; } - if (joyxmove > 0) - side += sidemove[speed]; - if (joyxmove < 0) - side -= sidemove[speed]; - } - else - { - if (gamekeydown[key_right]) - cmd->angleturn -= angleturn[tspeed]; - if (gamekeydown[key_left]) - cmd->angleturn += angleturn[tspeed]; - if (joyxmove > 0) - cmd->angleturn -= angleturn[tspeed]; - if (joyxmove < 0) - cmd->angleturn += angleturn[tspeed]; - } - if (gamekeydown[key_up]) - { - forward += forwardmove[speed]; - } - if (gamekeydown[key_down]) - { - forward -= forwardmove[speed]; - } - if (joyymove < 0) - forward += forwardmove[speed]; - if (joyymove > 0) - forward -= forwardmove[speed]; - if (gamekeydown[key_straferight]) - side += sidemove[speed]; - if (gamekeydown[key_strafeleft]) - side -= sidemove[speed]; - cmd->chatchar = HU_dequeueChatChar(); - if (gamekeydown[key_fire] || mousebuttons[mousebfire] - || joybuttons[joybfire]) - cmd->buttons |= BT_ATTACK; - if (gamekeydown[key_use] || joybuttons[joybuse] ) - { - cmd->buttons |= BT_USE; - dclicks = 0; - } - for (i=0 ; i<NUMWEAPONS-1 ; i++) - if (gamekeydown['1'+i]) - { - cmd->buttons |= BT_CHANGE; - cmd->buttons |= i<<BT_WEAPONSHIFT; - break; + if (gamekeydown[key_up]) forward += forwardmove[speed]; + if (gamekeydown[key_down]) forward -= forwardmove[speed]; + if (joyymove < 0) forward += forwardmove[speed]; + if (joyymove > 0) forward -= forwardmove[speed]; + if (gamekeydown[key_straferight]) side += sidemove[speed]; + if (gamekeydown[key_strafeleft]) side -= sidemove[speed]; + cmd->chatchar = HU_dequeueChatChar(); + if (gamekeydown[key_fire] || mousebuttons[mousebfire] || joybuttons[joybfire]) + cmd->buttons |= BT_ATTACK; + if (gamekeydown[key_use] || joybuttons[joybuse]) { + cmd->buttons |= BT_USE; + dclicks = 0; } - if (mousebuttons[mousebforward]) - forward += forwardmove[speed]; - if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) - { - dclickstate = mousebuttons[mousebforward]; - if (dclickstate) - dclicks++; - if (dclicks == 2) - { - cmd->buttons |= BT_USE; - dclicks = 0; - } - else - dclicktime = 0; - } - else - { - dclicktime += ticdup; - if (dclicktime > 20) - { - dclicks = 0; - dclickstate = 0; - } - } - bstrafe = - mousebuttons[mousebstrafe] - || joybuttons[joybstrafe]; - if (bstrafe != dclickstate2 && dclicktime2 > 1 ) - { - dclickstate2 = bstrafe; - if (dclickstate2) - dclicks2++; - if (dclicks2 == 2) - { - cmd->buttons |= BT_USE; - dclicks2 = 0; - } - else - dclicktime2 = 0; - } - else - { - dclicktime2 += ticdup; - if (dclicktime2 > 20) - { - dclicks2 = 0; - dclickstate2 = 0; - } - } - forward += mousey; - if (strafe) - side += mousex*2; - else - cmd->angleturn -= mousex*0x8; - mousex = mousey = 0; - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - cmd->forwardmove += forward; - cmd->sidemove += side; - if (sendpause) - { - sendpause = false; - cmd->buttons = BT_SPECIAL | BTS_PAUSE; - } - if (sendsave) - { - sendsave = false; - cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT); - } -} -extern gamestate_t wipegamestate; -void G_DoLoadLevel (void) -{ - int i; - skyflatnum = R_FlatNumForName ( SKYFLATNAME ); - if ( (gamemode == commercial) || (gamemode == retail)) { - skytexture = R_TextureNumForName ("SKY3"); - if (gamemap < 12) - skytexture = R_TextureNumForName ("SKY1"); - else - if (gamemap < 21) - skytexture = R_TextureNumForName ("SKY2"); - } - levelstarttic = gametic; - if (wipegamestate == GS_LEVEL) - wipegamestate = -1; - gamestate = GS_LEVEL; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i] && players[i].playerstate == PST_DEAD) - players[i].playerstate = PST_REBORN; - memset (players[i].frags,0,sizeof(players[i].frags)); - } - P_SetupLevel (gameepisode, gamemap, 0, gameskill); - displayplayer = consoleplayer; - starttime = I_GetTime (); - gameaction = ga_nothing; - Z_CheckHeap (); - memset (gamekeydown, 0, sizeof(gamekeydown)); - joyxmove = joyymove = 0; - mousex = mousey = 0; - sendpause = sendsave = paused = false; - memset(mousebuttons, 0, sizeof(*mousebuttons)); - memset(joybuttons, 0, sizeof(*joybuttons)); -} -boolean G_Responder (event_t* ev) -{ - if (gamestate == GS_LEVEL && ev->type == ev_keydown - && ev->data1 == KEY_F12 && (singledemo || !deathmatch) ) - { - do - { - displayplayer++; - if (displayplayer == MAXPLAYERS) - displayplayer = 0; - } while (!playeringame[displayplayer] && displayplayer != consoleplayer); - return true; - } - if (gameaction == ga_nothing && !singledemo && - (demoplayback || gamestate == GS_DEMOSCREEN) - ) - { - if (ev->type == ev_keydown || - (ev->type == ev_mouse && ev->data1) || - (ev->type == ev_joystick && ev->data1) ) - { - M_StartControlPanel (); - return true; - } - return false; - } - if (gamestate == GS_LEVEL) - { -#if 0 - if (devparm && ev->type == ev_keydown && ev->data1 == ';') - { - G_DeathMatchSpawnPlayer (0); - return true; - } -#endif - if (HU_Responder (ev)) - return true; - if (ST_Responder (ev)) - return true; - if (AM_Responder (ev)) - return true; - } - if (gamestate == GS_FINALE) - { - if (F_Responder (ev)) - return true; - } - switch (ev->type) - { - case ev_keydown: - if (ev->data1 == KEY_PAUSE) - { - sendpause = true; - return true; - } - if (ev->data1 <NUMKEYS) - gamekeydown[ev->data1] = true; - return true; - case ev_keyup: - if (ev->data1 <NUMKEYS) - gamekeydown[ev->data1] = false; - return false; - case ev_mouse: - mousebuttons[0] = ev->data1 & 1; - mousebuttons[1] = ev->data1 & 2; - mousebuttons[2] = ev->data1 & 4; - mousex = ev->data2*(mouseSensitivity+5)/10; - mousey = ev->data3*(mouseSensitivity+5)/10; - return true; - case ev_joystick: - joybuttons[0] = ev->data1 & 1; - joybuttons[1] = ev->data1 & 2; - joybuttons[2] = ev->data1 & 4; - joybuttons[3] = ev->data1 & 8; - joyxmove = ev->data2; - joyymove = ev->data3; - return true; - default: - break; - } - return false; -} -void G_Ticker (void) -{ - int i; - int buf; - ticcmd_t* cmd; - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i] && players[i].playerstate == PST_REBORN) - G_DoReborn (i); - while (gameaction != ga_nothing) - { - switch (gameaction) - { - case ga_loadlevel: - G_DoLoadLevel (); - break; - case ga_newgame: - G_DoNewGame (); - break; - case ga_loadgame: - G_DoLoadGame (); - break; - case ga_savegame: - G_DoSaveGame (); - break; - case ga_playdemo: - G_DoPlayDemo (); - break; - case ga_completed: - G_DoCompleted (); - break; - case ga_victory: - F_StartFinale (); - break; - case ga_worlddone: - G_DoWorldDone (); - break; - case ga_screenshot: - M_ScreenShot (); - gameaction = ga_nothing; - break; - case ga_nothing: - break; - } - } - buf = (gametic/ticdup)%BACKUPTICS; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - cmd = &players[i].cmd; - memcpy (cmd, &netcmds[i][buf], sizeof(ticcmd_t)); - if (demoplayback) - G_ReadDemoTiccmd (cmd); - if (demorecording) - G_WriteDemoTiccmd (cmd); - if (cmd->forwardmove > TURBOTHRESHOLD - && !(gametic&31) && ((gametic>>5)&3) == i ) - { - static char turbomessage[80]; - extern char *player_names[4]; - sprintf (turbomessage, "%s is turbo!",player_names[i]); - players[consoleplayer].message = turbomessage; - } - if (netgame && !netdemo && !(gametic%ticdup) ) - { - if (gametic > BACKUPTICS - && consistancy[i][buf] != cmd->consistancy) - { - I_Error ("consistency failure (%i should be %i)", - cmd->consistancy, consistancy[i][buf]); - } - if (players[i].mo) - consistancy[i][buf] = players[i].mo->x; - else - consistancy[i][buf] = rndindex; - } + for (i = 0; i < NUMWEAPONS - 1; ++i) + if (gamekeydown['1'+i]) { + cmd->buttons |= BT_CHANGE; + cmd->buttons |= i<<BT_WEAPONSHIFT; + break; + } + if (mousebuttons[mousebforward]) forward += forwardmove[speed]; + if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) { + dclickstate = mousebuttons[mousebforward]; + if (dclickstate) dclicks++; + if (dclicks == 2) { + cmd->buttons |= BT_USE; + dclicks = 0; + } else dclicktime = 0; + } else { + dclicktime += ticdup; + if (dclicktime > 20) { + dclicks = 0; + dclickstate = 0; + } + } + bstrafe = mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; + if (bstrafe != dclickstate2 && dclicktime2 > 1 ) { + dclickstate2 = bstrafe; + if (dclickstate2) dclicks2++; + if (dclicks2 == 2) { + cmd->buttons |= BT_USE; + dclicks2 = 0; + } else dclicktime2 = 0; + } else { + dclicktime2 += ticdup; + if (dclicktime2 > 20) { + dclicks2 = 0; + dclickstate2 = 0; + } + } + forward += mousey; + if (strafe) side += mousex * 2; + else cmd->angleturn -= mousex*0x8; + mousex = mousey = 0; + if (forward > MAXPLMOVE) forward = MAXPLMOVE; + if (forward < -MAXPLMOVE) forward = -MAXPLMOVE; + if (side > MAXPLMOVE) side = MAXPLMOVE; + if (side < -MAXPLMOVE) side = -MAXPLMOVE; + cmd->forwardmove += forward; + cmd->sidemove += side; + if (sendpause) { + sendpause = false; + cmd->buttons = BT_SPECIAL | BTS_PAUSE; } - } - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - if (players[i].cmd.buttons & BT_SPECIAL) - { - switch (players[i].cmd.buttons & BT_SPECIALMASK) - { - case BTS_PAUSE: - paused ^= 1; - if (paused) - S_PauseSound (); - else - S_ResumeSound (); - break; - case BTS_SAVEGAME: - if (!savedescription[0]) - strcpy (savedescription, "NET GAME"); - savegameslot = - (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT; - gameaction = ga_savegame; - break; - } - } + if (sendsave) { + sendsave = false; + cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT); } - } - switch (gamestate) - { - case GS_LEVEL: - P_Ticker (); - ST_Ticker (); - AM_Ticker (); - HU_Ticker (); - break; - case GS_INTERMISSION: - WI_Ticker (); - break; - case GS_FINALE: - F_Ticker (); - break; - case GS_DEMOSCREEN: - D_PageTicker (); - break; - } -} -void G_InitPlayer (int player) -{ - G_PlayerReborn (player); -} -void G_PlayerFinishLevel (int player) -{ - player_t* p; - p = &players[player]; - memset (p->powers, 0, sizeof (p->powers)); - memset (p->cards, 0, sizeof (p->cards)); - p->mo->flags &= ~MF_SHADOW; - p->extralight = 0; - p->fixedcolormap = 0; - p->damagecount = 0; - p->bonuscount = 0; -} -void G_PlayerReborn (int player) -{ - player_t* p; - int i; - int frags[MAXPLAYERS]; - int killcount; - int itemcount; - int secretcount; - memcpy (frags,players[player].frags,sizeof(frags)); - killcount = players[player].killcount; - itemcount = players[player].itemcount; - secretcount = players[player].secretcount; - p = &players[player]; - memset (p, 0, sizeof(*p)); - memcpy (players[player].frags, frags, sizeof(players[player].frags)); - players[player].killcount = killcount; - players[player].itemcount = itemcount; - players[player].secretcount = secretcount; - p->usedown = p->attackdown = true; - p->playerstate = PST_LIVE; - p->health = MAXHEALTH; - p->readyweapon = p->pendingweapon = wp_pistol; - p->weaponowned[wp_fist] = true; - p->weaponowned[wp_pistol] = true; - p->ammo[am_clip] = 50; - for (i=0 ; i<NUMAMMO ; i++) - p->maxammo[i] = maxammo[i]; } -void P_SpawnPlayer (mapthing_t* mthing); + +void +G_DoLoadLevel() +{ + int i; + + skyflatnum = R_FlatNumForName(SKYFLATNAME); + levelstarttic = gametic; + if (wipegamestate == GS_LEVEL) wipegamestate = -1; + gamestate = GS_LEVEL; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; + memset(players[i].frags,0,sizeof(players[i].frags)); + } + P_SetupLevel(gameepisode, gamemap, 0, gameskill); + displayplayer = consoleplayer; + starttime = I_GetTime(); + gameaction = ga_nothing; + Z_CheckHeap(); + memset(gamekeydown, 0, sizeof(gamekeydown)); + joyxmove = joyymove = 0; + mousex = mousey = 0; + sendpause = sendsave = paused = false; + memset(mousebuttons, 0, sizeof(*mousebuttons)); + memset(joybuttons, 0, sizeof(*joybuttons)); +} + boolean -G_CheckSpot -( int playernum, - mapthing_t* mthing ) -{ - fixed_t x; - fixed_t y; - subsector_t* ss; - unsigned an; - mobj_t* mo; - int i; - if (!players[playernum].mo) - { - for (i=0 ; i<playernum ; i++) - if (players[i].mo->x == mthing->x << FRACBITS - && players[i].mo->y == mthing->y << FRACBITS) - return false; +G_Responder(event_t* ev) +{ + if (gamestate == GS_LEVEL && ev->type == ev_keydown && ev->data1 == KEY_F12 && (singledemo || !deathmatch)) { + do { + displayplayer++; + if (displayplayer == MAXPLAYERS) displayplayer = 0; + } while (!playeringame[displayplayer] && displayplayer != consoleplayer); + return true; + } + if (gameaction == ga_nothing && !singledemo && (demoplayback || gamestate == GS_DEMOSCREEN)) { + if (ev->type == ev_keydown || (ev->type == ev_mouse && ev->data1) || (ev->type == ev_joystick && ev->data1)) { + M_StartControlPanel(); + return true; + } + return false; + } + if (gamestate == GS_LEVEL) { + if (HU_Responder(ev)) + return true; + if (ST_Responder(ev)) + return true; + if (AM_Responder(ev)) + return true; + } + if (gamestate == GS_FINALE) + if (F_Responder(ev)) return true; + + switch (ev->type) { + case ev_keydown: + if (ev->data1 == KEY_PAUSE) { + sendpause = true; + return true; + } + if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = true; + return true; + case ev_keyup: + if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = false; + return false; + case ev_mouse: + mousebuttons[0] = ev->data1 & 1; + mousebuttons[1] = ev->data1 & 2; + mousebuttons[2] = ev->data1 & 4; + mousex = ev->data2*(mouseSensitivity+5)/10; + mousey = ev->data3*(mouseSensitivity+5)/10; + return true; + case ev_joystick: + joybuttons[0] = ev->data1 & 1; + joybuttons[1] = ev->data1 & 2; + joybuttons[2] = ev->data1 & 4; + joybuttons[3] = ev->data1 & 8; + joyxmove = ev->data2; + joyymove = ev->data3; + return true; + default: + return false; + } +} + +void +G_Ticker() +{ + int i, buf; + ticcmd_t* cmd; + + + for (i = 0; i < MAXPLAYERS; ++i) if(playeringame[i] && players[i].playerstate == PST_REBORN) G_DoReborn (i); + while (gameaction != ga_nothing) { + switch (gameaction) { + case ga_loadlevel: + G_DoLoadLevel(); + break; + case ga_newgame: + G_DoNewGame(); + break; + case ga_loadgame: + G_DoLoadGame(); + break; + case ga_savegame: + G_DoSaveGame(); + break; + case ga_playdemo: + G_DoPlayDemo(); + break; + case ga_completed: + G_DoCompleted(); + break; + case ga_victory: + F_StartFinale(); + break; + case ga_worlddone: + G_DoWorldDone(); + break; + case ga_nothing: + break; + } + } + buf = (gametic/ticdup)%BACKUPTICS; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + cmd = &players[i].cmd; + memcpy (cmd, &netcmds[i][buf], sizeof(ticcmd_t)); + if (demoplayback) G_ReadDemoTiccmd (cmd); + if (demorecording) G_WriteDemoTiccmd (cmd); + if (cmd->forwardmove > TURBOTHRESHOLD && !(gametic&31) && ((gametic>>5)&3) == i) { + static char turbomessage[80]; + extern char *player_names[4]; + sprintf (turbomessage, "%s is turbo!",player_names[i]); + players[consoleplayer].message = turbomessage; + } + if (netgame && !netdemo && !(gametic%ticdup) ) { + if (gametic > BACKUPTICS && consistancy[i][buf] != cmd->consistancy) I_Error("consistency failure (%i should be %i)", cmd->consistancy, consistancy[i][buf]); + if (players[i].mo) consistancy[i][buf] = players[i].mo->x; + else consistancy[i][buf] = rndindex; + } + } + } + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + if (players[i].cmd.buttons & BT_SPECIAL){ + switch (players[i].cmd.buttons & BT_SPECIALMASK) { + case BTS_PAUSE: + paused ^= 1; + if (paused) S_PauseSound (); + else S_ResumeSound (); + break; + case BTS_SAVEGAME: + if (!savedescription[0]) strcpy(savedescription, "NET GAME"); + savegameslot = (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT; + gameaction = ga_savegame; + break; + } + } + } + } + switch (gamestate) { + case GS_LEVEL: + P_Ticker(); + ST_Ticker(); + AM_Ticker(); + HU_Ticker(); + break; + case GS_INTERMISSION: + WI_Ticker(); + break; + case GS_FINALE: + F_Ticker(); + break; + case GS_DEMOSCREEN: + D_PageTicker(); + break; + } +} + +void +G_InitPlayer(int player) +{ + G_PlayerReborn(player); +} + +void +G_PlayerFinishLevel(int player) +{ + player_t* p; + + p = &players[player]; + memset (p->powers, 0, sizeof (p->powers)); + memset (p->cards, 0, sizeof (p->cards)); + p->mo->flags &= ~MF_SHADOW; + p->extralight = 0; + p->fixedcolormap = 0; + p->damagecount = 0; + p->bonuscount = 0; +} + +void +G_PlayerReborn(int player) +{ + player_t* p; + int i, killcount, itemcount, secretcount, frags[MAXPLAYERS]; + + memcpy(frags,players[player].frags,sizeof(frags)); + killcount = players[player].killcount; + itemcount = players[player].itemcount; + secretcount = players[player].secretcount; + p = &players[player]; + memset(p, 0, sizeof(*p)); + memcpy(players[player].frags, frags, sizeof(players[player].frags)); + players[player].killcount = killcount; + players[player].itemcount = itemcount; + players[player].secretcount = secretcount; + p->usedown = p->attackdown = true; + p->playerstate = PST_LIVE; + p->health = MAXHEALTH; + p->readyweapon = p->pendingweapon = wp_pistol; + p->weaponowned[wp_fist] = true; + p->weaponowned[wp_pistol] = true; + p->ammo[am_clip] = 50; + for (i = 0; i < NUMAMMO; ++i) p->maxammo[i] = maxammo[i]; +} + +void P_SpawnPlayer(mapthing_t* mthing); + +boolean +G_CheckSpot(int playernum, mapthing_t* mthing) +{ + subsector_t* ss; + mobj_t* mo; + fixed_t x, y; + unsigned an; + int i; + + if (!players[playernum].mo) { + for (i = 0; i < playernum; ++i) + if (players[i].mo->x == mthing->x << FRACBITS && players[i].mo->y == mthing->y << FRACBITS) + return false; + return true; + } + x = mthing->x << FRACBITS; + y = mthing->y << FRACBITS; + if (!P_CheckPosition (players[playernum].mo, x, y)) return false; + if (bodyqueslot >= BODYQUESIZE) P_RemoveMobj (bodyque[bodyqueslot%BODYQUESIZE]); + bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo; + bodyqueslot++; + ss = R_PointInSubsector(x,y); + an = (ANG45 * (mthing->angle/45)) >> ANGLETOFINESHIFT; + mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an], ss->sector->floorheight, MT_TFOG); + if (players[consoleplayer].viewz != 1) S_StartSound (mo, sfx_telept); return true; - } - x = mthing->x << FRACBITS; - y = mthing->y << FRACBITS; - if (!P_CheckPosition (players[playernum].mo, x, y) ) - return false; - if (bodyqueslot >= BODYQUESIZE) - P_RemoveMobj (bodyque[bodyqueslot%BODYQUESIZE]); - bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo; - bodyqueslot++; - ss = R_PointInSubsector (x,y); - an = ( ANG45 * (mthing->angle/45) ) >> ANGLETOFINESHIFT; - mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an] - , ss->sector->floorheight - , MT_TFOG); - if (players[consoleplayer].viewz != 1) - S_StartSound (mo, sfx_telept); - return true; -} -void G_DeathMatchSpawnPlayer (int playernum) -{ - int i,j; - int selections; - selections = deathmatch_p - deathmatchstarts; - if (selections < 4) - I_Error ("Only %i deathmatch spots, 4 required", selections); - for (j=0 ; j<20 ; j++) - { - i = P_Random() % selections; - if (G_CheckSpot (playernum, &deathmatchstarts[i]) ) - { - deathmatchstarts[i].type = playernum+1; - P_SpawnPlayer (&deathmatchstarts[i]); - return; - } - } - P_SpawnPlayer (&playerstarts[playernum]); -} -void G_DoReborn (int playernum) -{ - int i; - if (!netgame) - { - gameaction = ga_loadlevel; - } - else - { - players[playernum].mo->player = NULL; - if (deathmatch) - { - G_DeathMatchSpawnPlayer (playernum); - return; - } - if (G_CheckSpot (playernum, &playerstarts[playernum]) ) - { - P_SpawnPlayer (&playerstarts[playernum]); - return; +} + +void +G_DeathMatchSpawnPlayer(int playernum) +{ + int i, j, selections; + + selections = deathmatch_p - deathmatchstarts; + if (selections < 4) I_Error ("Only %i deathmatch spots, 4 required", selections); + for (j = 0; j < 20; ++j) { + i = P_Random() % selections; + if (G_CheckSpot (playernum, &deathmatchstarts[i])) { + deathmatchstarts[i].type = playernum+1; + P_SpawnPlayer (&deathmatchstarts[i]); + return; + } } - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (G_CheckSpot (playernum, &playerstarts[i]) ) - { - playerstarts[i].type = playernum+1; - P_SpawnPlayer (&playerstarts[i]); - playerstarts[i].type = i+1; - return; - } + P_SpawnPlayer(&playerstarts[playernum]); +} + +void +G_DoReborn(int playernum) +{ + int i; + + if (!netgame) gameaction = ga_loadlevel; + else { + players[playernum].mo->player = NULL; + if (deathmatch) { + G_DeathMatchSpawnPlayer (playernum); + return; + } + if (G_CheckSpot(playernum, &playerstarts[playernum])) { + P_SpawnPlayer (&playerstarts[playernum]); + return; + } + for (i = 0; i < MAXPLAYERS; ++i) { + if (G_CheckSpot (playernum, &playerstarts[i])) { + playerstarts[i].type = playernum+1; + P_SpawnPlayer (&playerstarts[i]); + playerstarts[i].type = i+1; + return; + } + } + P_SpawnPlayer(&playerstarts[playernum]); } - P_SpawnPlayer (&playerstarts[playernum]); - } -} -void G_ScreenShot (void) -{ - gameaction = ga_screenshot; -} -int pars[4][10] = -{ - {0}, - {0,30,75,120,90,165,180,180,30,165}, - {0,90,90,90,120,90,360,240,30,170}, - {0,90,45,90,150,90,90,165,30,135} -}; -int cpars[32] = +} + +void +G_ExitLevel() { - 30,90,120,120,90,150,120,120,270,90, - 210,150,150,150,210,150,420,150,210,150, - 240,150,180,150,150,300,330,420,300,180, - 120,30 -}; -boolean secretexit; -extern char* pagename; -void G_ExitLevel (void) -{ - secretexit = false; - gameaction = ga_completed; -} -void G_SecretExitLevel (void) -{ - if ( (gamemode == commercial) - && (W_CheckNumForName("map31")<0)) secretexit = false; - else - secretexit = true; - gameaction = ga_completed; -} -void G_DoCompleted (void) -{ - int i; - gameaction = ga_nothing; - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i]) - G_PlayerFinishLevel (i); - if (automapactive) - AM_Stop (); - if ( gamemode != commercial) - switch(gamemap) - { - case 8: - gameaction = ga_victory; - return; - case 9: - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].didsecret = true; - break; - } - if ( (gamemap == 8) - && (gamemode != commercial) ) - { - gameaction = ga_victory; - return; - } - if ( (gamemap == 9) - && (gamemode != commercial) ) - { - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].didsecret = true; - } - wminfo.didsecret = players[consoleplayer].didsecret; - wminfo.epsd = gameepisode -1; - wminfo.last = gamemap -1; - if ( gamemode == commercial) - { - if (secretexit) - switch(gamemap) - { - case 15: wminfo.next = 30; break; - case 31: wminfo.next = 31; break; - } - else - switch(gamemap) - { - case 31: - case 32: wminfo.next = 15; break; - default: wminfo.next = gamemap; - } - } - else - { - if (secretexit) - wminfo.next = 8; - else if (gamemap == 9) - { - switch (gameepisode) - { - case 1: - wminfo.next = 3; - break; - case 2: - wminfo.next = 5; - break; - case 3: - wminfo.next = 6; - break; - case 4: - wminfo.next = 2; - break; - } - } - else - wminfo.next = gamemap; - } - wminfo.maxkills = totalkills; - wminfo.maxitems = totalitems; - wminfo.maxsecret = totalsecret; - wminfo.maxfrags = 0; - if ( gamemode == commercial ) - wminfo.partime = 35*cpars[gamemap-1]; - else - wminfo.partime = 35*pars[gameepisode][gamemap]; - wminfo.pnum = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) - { - wminfo.plyr[i].in = playeringame[i]; - wminfo.plyr[i].skills = players[i].killcount; - wminfo.plyr[i].sitems = players[i].itemcount; - wminfo.plyr[i].ssecret = players[i].secretcount; - wminfo.plyr[i].stime = leveltime; - memcpy (wminfo.plyr[i].frags, players[i].frags - , sizeof(wminfo.plyr[i].frags)); - } - gamestate = GS_INTERMISSION; - viewactive = false; - automapactive = false; - if (statcopy) - memcpy (statcopy, &wminfo, sizeof(wminfo)); - WI_Start (&wminfo); -} -void G_WorldDone (void) -{ - gameaction = ga_worlddone; - if (secretexit) - players[consoleplayer].didsecret = true; - if ( gamemode == commercial ) - { - switch (gamemap) - { - case 15: - case 31: - if (!secretexit) - break; - case 6: - case 11: - case 20: - case 30: - F_StartFinale (); - break; + gameaction = ga_completed; +} + +void +G_SecretExitLevel() +{ + secretexit = true; + gameaction = ga_completed; +} + +void +G_DoCompleted() +{ + int i; + + gameaction = ga_nothing; + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + G_PlayerFinishLevel (i); + if (automapactive) AM_Stop(); + if (gamemap == 9) + for (i = 0; i < MAXPLAYERS; ++i) players[i].didsecret = true; + wminfo.didsecret = players[consoleplayer].didsecret; + wminfo.epsd = gameepisode -1; + wminfo.last = gamemap -1; + if (secretexit) wminfo.next = 8; + else if (gamemap == 9) { + switch (gameepisode) { + case 1: + wminfo.next = 3; + break; + case 2: + wminfo.next = 5; + break; + case 3: + wminfo.next = 6; + break; + case 4: + wminfo.next = 2; + break; + } + } else wminfo.next = gamemap; + wminfo.maxkills = totalkills; + wminfo.maxitems = totalitems; + wminfo.maxsecret = totalsecret; + wminfo.maxfrags = 0; + wminfo.partime = 35*pars[gameepisode][gamemap]; + wminfo.pnum = consoleplayer; + for (i = 0; i < MAXPLAYERS; ++i) { + wminfo.plyr[i].in = playeringame[i]; + wminfo.plyr[i].skills = players[i].killcount; + wminfo.plyr[i].sitems = players[i].itemcount; + wminfo.plyr[i].ssecret = players[i].secretcount; + wminfo.plyr[i].stime = leveltime; memcpy(wminfo.plyr[i].frags, players[i].frags, sizeof(wminfo.plyr[i].frags)); } - } -} -void G_DoWorldDone (void) -{ - gamestate = GS_LEVEL; - gamemap = wminfo.next+1; - G_DoLoadLevel (); - gameaction = ga_nothing; - viewactive = true; -} -extern boolean setsizeneeded; -void R_ExecuteSetViewSize (void); + gamestate = GS_INTERMISSION; + viewactive = false; + automapactive = false; + if (statcopy) memcpy(statcopy, &wminfo, sizeof(wminfo)); + WI_Start (&wminfo); +} + +void +G_WorldDone() +{ + gameaction = ga_worlddone; + if (secretexit) players[consoleplayer].didsecret = true; +} + +void +G_DoWorldDone() +{ + gamestate = GS_LEVEL; + gamemap = wminfo.next+1; + G_DoLoadLevel(); + gameaction = ga_nothing; + viewactive = true; +} + char savename[256]; -void G_LoadGame (char* name) -{ - strcpy (savename, name); - gameaction = ga_loadgame; -} -#define VERSIONSIZE 16 -void G_DoLoadGame (void) -{ - int i; - int a,b,c; - char vcheck[VERSIONSIZE]; - gameaction = ga_nothing; - save_p = savebuffer + SAVESTRINGSIZE; - memset (vcheck,0,sizeof(vcheck)); - sprintf (vcheck,"version %i",VERSION); - if (strcmp((char*)save_p, vcheck)) - return; - save_p += VERSIONSIZE; - gameskill = *save_p++; - gameepisode = *save_p++; - gamemap = *save_p++; - for (i=0 ; i<MAXPLAYERS ; i++) - playeringame[i] = *save_p++; - G_InitNew (gameskill, gameepisode, gamemap); - a = *save_p++; - b = *save_p++; - c = *save_p++; - leveltime = (a<<16) + (b<<8) + c; - P_UnArchivePlayers (); - P_UnArchiveWorld (); - P_UnArchiveThinkers (); - P_UnArchiveSpecials (); - if (*save_p != 0x1d) - I_Error ("Bad savegame"); - Z_Free (savebuffer); - if (setsizeneeded) - R_ExecuteSetViewSize (); - R_FillBackScreen (); -} + +void G_LoadGame (char* name) +{ + strcpy (savename, name); + gameaction = ga_loadgame; +} + void -G_SaveGame -( int slot, - char* description ) -{ - savegameslot = slot; - strcpy (savedescription, description); - sendsave = true; -} -void G_DoSaveGame (void) -{ - char name[100]; - char name2[VERSIONSIZE]; - char* description; - int length; - int i; - if (M_CheckParm("-cdrom")) - sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot); - else - sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot); - description = savedescription; - save_p = savebuffer = screens[1]+0x4000; - memcpy (save_p, description, SAVESTRINGSIZE); - save_p += SAVESTRINGSIZE; - memset (name2,0,sizeof(name2)); - sprintf (name2,"version %i",VERSION); - memcpy (save_p, name2, VERSIONSIZE); - save_p += VERSIONSIZE; - *save_p++ = gameskill; - *save_p++ = gameepisode; - *save_p++ = gamemap; - for (i=0 ; i<MAXPLAYERS ; i++) - *save_p++ = playeringame[i]; - *save_p++ = leveltime>>16; - *save_p++ = leveltime>>8; - *save_p++ = leveltime; - P_ArchivePlayers (); - P_ArchiveWorld (); - P_ArchiveThinkers (); - P_ArchiveSpecials (); - *save_p++ = 0x1d; - length = save_p - savebuffer; - if (length > SAVEGAMESIZE) - I_Error ("Savegame buffer overrun"); - M_WriteFile (name, savebuffer, length); - gameaction = ga_nothing; - savedescription[0] = 0; - players[consoleplayer].message = GGSAVED; - R_FillBackScreen (); -} -skill_t d_skill; -int d_episode; -int d_map; +G_DoLoadGame() +{ + int i, a, b, c; + char vcheck[VERSIONSIZE]; + + gameaction = ga_nothing; + M_ReadFile(savename, &savebuffer); + save_p = savebuffer + SAVESTRINGSIZE; + memset(vcheck, 0, sizeof(vcheck)); + sprintf (vcheck, "version %i", VERSION); + if (strcmp ((char*)save_p, vcheck)) return; + save_p += VERSIONSIZE; + gameskill = *save_p++; + gameepisode = *save_p++; + gamemap = *save_p++; + for (i = 0; i < MAXPLAYERS; ++i) playeringame[i] = *save_p++; + G_InitNew(gameskill, gameepisode, gamemap); + a = *save_p++; + b = *save_p++; + c = *save_p++; + leveltime = (a<<16) + (b<<8) + c; + P_UnArchivePlayers(); + P_UnArchiveWorld(); + P_UnArchiveThinkers(); + P_UnArchiveSpecials(); + if (*save_p != 0x1d) I_Error("Bad savegame"); + Z_Free(savebuffer); + if (setsizeneeded) R_ExecuteSetViewSize(); + R_FillBackScreen(); +} + void -G_DeferedInitNew -( skill_t skill, - int episode, - int map) -{ - d_skill = skill; - d_episode = episode; - d_map = map; - gameaction = ga_newgame; -} -void G_DoNewGame (void) +G_SaveGame(int slot, char* description) { - demoplayback = false; - netdemo = false; - netgame = false; - deathmatch = false; - playeringame[1] = playeringame[2] = playeringame[3] = 0; - respawnparm = false; - fastparm = false; - nomonsters = false; - consoleplayer = 0; - G_InitNew (d_skill, d_episode, d_map); - gameaction = ga_nothing; -} -extern int skytexture; + savegameslot = slot; + strcpy(savedescription, description); + sendsave = true; +} + void -G_InitNew -( skill_t skill, - int episode, - int map ) -{ - int i; - if (paused) - { - paused = false; - S_ResumeSound (); - } - if (skill > sk_nightmare) - skill = sk_nightmare; - if (episode < 1) - episode = 1; - if ( gamemode == retail ) - { - if (episode > 4) - episode = 4; - } - else if ( gamemode == shareware ) - { - if (episode > 1) - episode = 1; - } - else - { - if (episode > 3) - episode = 3; - } - if (map < 1) - map = 1; - if ( (map > 9) - && ( gamemode != commercial) ) - map = 9; - M_ClearRandom (); - if (skill == sk_nightmare || respawnparm ) - respawnmonsters = true; - else - respawnmonsters = false; - if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare) ) - { - for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) - states[i].tics >>= 1; - mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; - mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; - mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; - } - else if (skill != sk_nightmare && gameskill == sk_nightmare) - { - for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) - states[i].tics <<= 1; - mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; - mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; - mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; - } - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].playerstate = PST_REBORN; - usergame = true; - paused = false; - demoplayback = false; - automapactive = false; - viewactive = true; - gameepisode = episode; - gamemap = map; - gameskill = skill; - viewactive = true; - if ( gamemode == commercial) - { - skytexture = R_TextureNumForName ("SKY3"); - if (gamemap < 12) - skytexture = R_TextureNumForName ("SKY1"); +G_DoSaveGame() +{ + char* description; + char name[100]; + char name2[VERSIONSIZE]; + int i, length; + + if (M_CheckParm("-cdrom")) + sprintf(name, "c:\\doomdata\\%s%d.dsg", lang[SAVEGAMENAME], savegameslot); else - if (gamemap < 21) - skytexture = R_TextureNumForName ("SKY2"); - } - else - switch (episode) - { - case 1: - skytexture = R_TextureNumForName ("SKY1"); - break; - case 2: - skytexture = R_TextureNumForName ("SKY2"); - break; - case 3: - skytexture = R_TextureNumForName ("SKY3"); - break; - case 4: - skytexture = R_TextureNumForName ("SKY4"); - break; - } - G_DoLoadLevel (); -} -#define DEMOMARKER 0x80 -void G_ReadDemoTiccmd (ticcmd_t* cmd) -{ - if (*demo_p == DEMOMARKER) - { - G_CheckDemoStatus (); - return; - } - cmd->forwardmove = ((signed char)*demo_p++); - cmd->sidemove = ((signed char)*demo_p++); - cmd->angleturn = ((unsigned char)*demo_p++)<<8; - cmd->buttons = (unsigned char)*demo_p++; -} -void G_WriteDemoTiccmd (ticcmd_t* cmd) -{ - if (gamekeydown['q']) - G_CheckDemoStatus (); - *demo_p++ = cmd->forwardmove; - *demo_p++ = cmd->sidemove; - *demo_p++ = (cmd->angleturn+128)>>8; - *demo_p++ = cmd->buttons; - demo_p -= 4; - if (demo_p > demoend - 16) - { - G_CheckDemoStatus (); - return; - } - G_ReadDemoTiccmd (cmd); -} -void G_RecordDemo (char* name) -{ - int i; - int maxsize; - usergame = false; - strcpy (demoname, name); - strcat (demoname, ".lmp"); - maxsize = 0x20000; - i = M_CheckParm ("-maxdemo"); - if (i && i<myargc-1) - maxsize = atoi(myargv[i+1])*1024; - demobuffer = Z_Malloc (maxsize,PU_STATIC,NULL); - demoend = demobuffer + maxsize; - demorecording = true; -} -void G_BeginRecording (void) -{ - int i; - demo_p = demobuffer; - *demo_p++ = VERSION; - *demo_p++ = gameskill; - *demo_p++ = gameepisode; - *demo_p++ = gamemap; - *demo_p++ = deathmatch; - *demo_p++ = respawnparm; - *demo_p++ = fastparm; - *demo_p++ = nomonsters; - *demo_p++ = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) - *demo_p++ = playeringame[i]; -} -char* defdemoname; -void G_DeferedPlayDemo (char* name) -{ - defdemoname = name; - gameaction = ga_playdemo; -} -void G_DoPlayDemo (void) -{ - skill_t skill; - int i, episode, map; - gameaction = ga_nothing; - demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC); - if ( *demo_p++ != VERSION) - { - fprintf( stderr, "Demo is from a different game version!\n"); - gameaction = ga_nothing; - return; - } - skill = *demo_p++; - episode = *demo_p++; - map = *demo_p++; - deathmatch = *demo_p++; - respawnparm = *demo_p++; - fastparm = *demo_p++; - nomonsters = *demo_p++; - consoleplayer = *demo_p++; - for (i=0 ; i<MAXPLAYERS ; i++) - playeringame[i] = *demo_p++; - if (playeringame[1]) - { - netgame = true; - netdemo = true; - } - precache = false; - G_InitNew (skill, episode, map); - precache = true; - usergame = false; - demoplayback = true; -} -void G_TimeDemo (char* name) -{ - nodrawers = M_CheckParm ("-nodraw"); - noblit = M_CheckParm ("-noblit"); - timingdemo = true; - singletics = true; - defdemoname = name; - gameaction = ga_playdemo; -} -/* -=================== -= -= G_CheckDemoStatus -= -= Called after a death or level completion to allow demos to be cleaned up -= Returns true if a new demo loop action will take place -=================== -*/ -boolean G_CheckDemoStatus (void) -{ - int endtime; - if (timingdemo) - { - endtime = I_GetTime (); - I_Error ("timed %i gametics in %i realtics",gametic - , endtime-starttime); - } - if (demoplayback) - { - if (singledemo) - I_Quit (); - Z_ChangeTag (demobuffer, PU_CACHE); - demoplayback = false; + sprintf(name, "%s%d.dsg", lang[SAVEGAMENAME], savegameslot); + description = savedescription; + save_p = savebuffer = screens[1]+0x4000; + memcpy (save_p, description, SAVESTRINGSIZE); + save_p += SAVESTRINGSIZE; + memset (name2,0,sizeof(name2)); + sprintf (name2,"version %i",VERSION); + memcpy (save_p, name2, VERSIONSIZE); + save_p += VERSIONSIZE; + *save_p++ = gameskill; + *save_p++ = gameepisode; + *save_p++ = gamemap; + for (i=0 ; i<MAXPLAYERS ; i++) + *save_p++ = playeringame[i]; + *save_p++ = leveltime>>16; + *save_p++ = leveltime>>8; + *save_p++ = leveltime; + P_ArchivePlayers(); + P_ArchiveWorld(); + P_ArchiveThinkers(); + P_ArchiveSpecials(); + *save_p++ = 0x1d; + length = save_p - savebuffer; + if (length > SAVEGAMESIZE) I_Error("Savegame buffer overrun"); + M_WriteFile(name, savebuffer, length); + gameaction = ga_nothing; + savedescription[0] = 0; + players[consoleplayer].message = lang[GGSAVED]; + R_FillBackScreen(); +} + +void +G_DeferedInitNew(skill_t skill, int episode, int map) +{ + d_skill = skill; + d_episode = episode; + d_map = map; + gameaction = ga_newgame; +} + +void +G_DoNewGame() +{ + demoplayback = false; netdemo = false; netgame = false; deathmatch = false; @@ -1190,16 +756,186 @@ boolean G_CheckDemoStatus (void) fastparm = false; nomonsters = false; consoleplayer = 0; - D_AdvanceDemo (); - return true; - } - if (demorecording) - { - *demo_p++ = DEMOMARKER; - M_WriteFile (demoname, demobuffer, demo_p - demobuffer); - Z_Free (demobuffer); - demorecording = false; - I_Error ("Demo %s recorded",demoname); - } - return false; -} + G_InitNew (d_skill, d_episode, d_map); + gameaction = ga_nothing; +} + +void +G_InitNew(skill_t skill, int episode, int map) +{ + int i; + + if (paused) { + paused = false; + S_ResumeSound(); + } + if (skill > sk_nightmare) + skill = sk_nightmare; + episode = 1; + if (map < 1) map = 1; + if (map > 9) map = 9; + M_ClearRandom(); + if (skill == sk_nightmare || respawnparm) + respawnmonsters = true; + else respawnmonsters = false; + if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare)) { + for (i = S_SARG_RUN1; i <= S_SARG_PAIN2; ++i) states[i].tics >>= 1; + mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; + mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; + mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; + } + if (skill != sk_nightmare && gameskill == sk_nightmare) { + for (i = S_SARG_RUN1; i <= S_SARG_PAIN2; ++i) states[i].tics <<= 1; + mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; + mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; + mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; + } + for (i = 0; i < MAXPLAYERS; ++i) players[i].playerstate = PST_REBORN; + usergame = true; + paused = false; + demoplayback = false; + automapactive = false; + viewactive = true; + gameepisode = episode; + gamemap = map; + gameskill = skill; + viewactive = true; + switch(episode) { + case 1: + skytexture = R_TextureNumForName("SKY1"); + break; + case 2: + skytexture = R_TextureNumForName("SKY2"); + break; + case 3: + skytexture = R_TextureNumForName("SKY3"); + break; + case 4: + skytexture = R_TextureNumForName("SKY4"); + break; + } + G_DoLoadLevel(); +} + +void +G_ReadDemoTiccmd(ticcmd_t* cmd) +{ + if (*demo_p == DEMOMARKER) { + G_CheckDemoStatus(); + return; + } + cmd->forwardmove = ((signed char)*demo_p++); + cmd->sidemove = ((signed char)*demo_p++); + cmd->angleturn = ((unsigned char)*demo_p++)<<8; + cmd->buttons = (unsigned char)*demo_p++; +} + +void +G_WriteDemoTiccmd(ticcmd_t* cmd) +{ + if (gamekeydown['q']) G_CheckDemoStatus(); + *demo_p++ = cmd->forwardmove; + *demo_p++ = cmd->sidemove; + *demo_p++ = (cmd->angleturn+128)>>8; + *demo_p++ = cmd->buttons; + demo_p -= 4; + if (demo_p > demoend - 16) { + G_CheckDemoStatus(); + return; + } + G_ReadDemoTiccmd(cmd); +} + +void +G_BeginRecording() +{ + int i; + + demo_p = demobuffer; + *demo_p++ = VERSION; + *demo_p++ = gameskill; + *demo_p++ = gameepisode; + *demo_p++ = gamemap; + *demo_p++ = deathmatch; + *demo_p++ = respawnparm; + *demo_p++ = fastparm; + *demo_p++ = nomonsters; + *demo_p++ = consoleplayer; + for (i = 0; i < MAXPLAYERS; ++i) + *demo_p++ = playeringame[i]; +} + +void +G_DeferedPlayDemo(char* name) +{ + defdemoname = name; + gameaction = ga_playdemo; +} + +void +G_DoPlayDemo() +{ + skill_t skill; + int i, episode, map; + + gameaction = ga_nothing; + demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC); + if (*demo_p++ != VERSION) { + fprintf( stderr, "Demo is from a different game version!\n"); + gameaction = ga_nothing; + return; + } + + skill = *demo_p++; + episode = *demo_p++; + map = *demo_p++; + deathmatch = *demo_p++; + respawnparm = *demo_p++; + fastparm = *demo_p++; + nomonsters = *demo_p++; + consoleplayer = *demo_p++; + for (i = 0; i < MAXPLAYERS; ++i) playeringame[i] = *demo_p++; + if (playeringame[1]) { + netgame = true; + netdemo = true; + } + precache = false; + G_InitNew(skill, episode, map); + precache = true; + usergame = false; + demoplayback = true; +} + +boolean +G_CheckDemoStatus() +{ + int endtime; + + if (timingdemo) { + endtime = I_GetTime(); + I_Error("timed %i gametics in %i realtics", gametic , endtime-starttime); + } + if (demoplayback) { + if (singledemo) I_Quit (); + Z_ChangeTag(demobuffer, PU_CACHE); + demoplayback = false; + netdemo = false; + netgame = false; + deathmatch = false; + playeringame[1] = playeringame[2] = playeringame[3] = 0; + respawnparm = false; + fastparm = false; + nomonsters = false; + consoleplayer = 0; + D_AdvanceDemo(); + return true; + } + if (demorecording) { + *demo_p++ = DEMOMARKER; + M_WriteFile(demoname, demobuffer, demo_p - demobuffer); + Z_Free(demobuffer); + demorecording = false; + I_Error("Demo %s recorded",demoname); + } + return false; +} diff --git a/src/g_game.h b/src/g_game.h @@ -1,23 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __G_GAME__ #define __G_GAME__ + #include "doomdef.h" #include "d_event.h" + + + + + + void G_DeathMatchSpawnPlayer (int playernum); + void G_InitNew (skill_t skill, int episode, int map); + + + + void G_DeferedInitNew (skill_t skill, int episode, int map); + void G_DeferedPlayDemo (char* demo); + + + void G_LoadGame (char* name); + void G_DoLoadGame (void); + + void G_SaveGame (int slot, char* description); + + void G_RecordDemo (char* name); + void G_BeginRecording (void); + void G_PlayDemo (char* name); void G_TimeDemo (char* name); boolean G_CheckDemoStatus (void); + void G_ExitLevel (void); void G_SecretExitLevel (void); + void G_WorldDone (void); + void G_Ticker (void); boolean G_Responder (event_t* ev); + void G_ScreenShot (void); + + #endif + + + + + diff --git a/src/hu_lib.c b/src/hu_lib.c @@ -1,21 +1,28 @@ #include <ctype.h> + #include "doomdef.h" + #include "v_video.h" -#include "m_swap.h" #include "hu_lib.h" #include "r_local.h" #include "r_draw.h" + + #define noterased viewwindowx + extern boolean automapactive; + void HUlib_init(void) { } + void HUlib_clearTextLine(hu_textline_t* t) { t->len = 0; t->l[0] = 0; t->needsupdate = true; } + void HUlib_initTextLine ( hu_textline_t* t, @@ -30,11 +37,13 @@ HUlib_initTextLine t->sc = sc; HUlib_clearTextLine(t); } + boolean HUlib_addCharToTextLine ( hu_textline_t* t, char ch ) { + if (t->len == HU_MAXLINELENGTH) return false; else @@ -44,9 +53,12 @@ HUlib_addCharToTextLine t->needsupdate = 4; return true; } + } + boolean HUlib_delCharFromTextLine(hu_textline_t* t) { + if (!t->len) return false; else { @@ -54,16 +66,21 @@ boolean HUlib_delCharFromTextLine(hu_textline_t* t) t->needsupdate = 4; return true; } + } + void HUlib_drawTextLine ( hu_textline_t* l, boolean drawcursor ) { + int i; int w; int x; unsigned char c; + + x = l->x; for (i=0;i<l->len;i++) { @@ -72,10 +89,10 @@ HUlib_drawTextLine && c >= l->sc && c <= '_') { - w = SHORT(l->f[c - l->sc]->width); + w = l->f[c - l->sc]->width; if (x+w > SCREENWIDTH) break; - V_DrawPatchDirect(x, l->y, FG, l->f[c - l->sc]); + V_DrawPatch(x, l->y, FG, l->f[c - l->sc]); x += w; } else @@ -85,21 +102,31 @@ HUlib_drawTextLine break; } } + + if (drawcursor - && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) + && x + l->f['_' - l->sc]->width <= SCREENWIDTH) { - V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]); + V_DrawPatch(x, l->y, FG, l->f['_' - l->sc]); } } + + + void HUlib_eraseTextLine(hu_textline_t* l) { int lh; int y; int yoffset; + + + + + if (!automapactive && viewwindowx && l->needsupdate) { - lh = SHORT(l->f[0]->height) + 1; + lh = l->f[0]->height + 1; for (y=l->y,yoffset=y*SCREENWIDTH ; y<l->y+lh ; y++,yoffset+=SCREENWIDTH) { if (y < viewwindowy || y >= viewwindowy + viewheight) @@ -108,11 +135,15 @@ void HUlib_eraseTextLine(hu_textline_t* l) { R_VideoErase(yoffset, viewwindowx); R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); + } } } + if (l->needsupdate) l->needsupdate--; + } + void HUlib_initSText ( hu_stext_t* s, @@ -123,25 +154,34 @@ HUlib_initSText int startchar, boolean* on ) { + int i; + s->h = h; s->on = on; s->laston = true; s->cl = 0; for (i=0;i<h;i++) - HUlib_initTextLine(&s->l[i], - x, y - i*(SHORT(font[0]->height)+1), - font, startchar); + HUlib_initTextLine(&s->l[i], x, y - i*(font[0]->height+1), font, startchar); + } + void HUlib_addLineToSText(hu_stext_t* s) { + int i; + + if (++s->cl == s->h) s->cl = 0; HUlib_clearTextLine(&s->l[s->cl]); + + for (i=0 ; i<s->h ; i++) s->l[i].needsupdate = 4; + } + void HUlib_addMessageToSText ( hu_stext_t* s, @@ -152,27 +192,39 @@ HUlib_addMessageToSText if (prefix) while (*prefix) HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++)); + while (*msg) HUlib_addCharToTextLine(&s->l[s->cl], *(msg++)); } + void HUlib_drawSText(hu_stext_t* s) { int i, idx; hu_textline_t *l; + if (!*s->on) return; + + for (i=0 ; i<s->h ; i++) { idx = s->cl - i; if (idx < 0) idx += s->h; + l = &s->l[idx]; + + HUlib_drawTextLine(l, false); } + } + void HUlib_eraseSText(hu_stext_t* s) { + int i; + for (i=0 ; i<s->h ; i++) { if (s->laston && !*s->on) @@ -180,36 +232,39 @@ void HUlib_eraseSText(hu_stext_t* s) HUlib_eraseTextLine(&s->l[i]); } s->laston = *s->on; + } + void -HUlib_initIText -( hu_itext_t* it, - int x, - int y, - patch_t** font, - int startchar, - boolean* on ) +HUlib_initIText(hu_itext_t* it, int x, int y, patch_t** font, int startchar, boolean* on) { it->lm = 0; it->on = on; it->laston = true; HUlib_initTextLine(&it->l, x, y, font, startchar); } + + + void HUlib_delCharFromIText(hu_itext_t* it) { if (it->l.len != it->lm) HUlib_delCharFromTextLine(&it->l); } + void HUlib_eraseLineFromIText(hu_itext_t* it) { while (it->lm != it->l.len) HUlib_delCharFromTextLine(&it->l); } + + void HUlib_resetIText(hu_itext_t* it) { it->lm = 0; HUlib_clearTextLine(&it->l); } + void HUlib_addPrefixToIText ( hu_itext_t* it, @@ -219,11 +274,15 @@ HUlib_addPrefixToIText HUlib_addCharToTextLine(&it->l, *(str++)); it->lm = it->l.len; } + + + boolean HUlib_keyInIText ( hu_itext_t* it, unsigned char ch ) { + if (ch >= ' ' && ch <= '_') HUlib_addCharToTextLine(&it->l, (char) ch); else @@ -232,15 +291,22 @@ HUlib_keyInIText else if (ch != KEY_ENTER) return false; + return true; + } + void HUlib_drawIText(hu_itext_t* it) { + hu_textline_t *l = &it->l; + if (!*it->on) return; HUlib_drawTextLine(l, true); + } + void HUlib_eraseIText(hu_itext_t* it) { if (it->laston && !*it->on) @@ -248,3 +314,4 @@ void HUlib_eraseIText(hu_itext_t* it) HUlib_eraseTextLine(&it->l); it->laston = *it->on; } + diff --git a/src/hu_lib.h b/src/hu_lib.h @@ -1,79 +1,58 @@ #ifndef __HULIB__ #define __HULIB__ + #include "r_defs.h" + #define BG 1 #define FG 0 #define HU_CHARERASE KEY_BACKSPACE #define HU_MAXLINES 4 #define HU_MAXLINELENGTH 80 -typedef struct -{ - int x; - int y; - patch_t** f; - int sc; - char l[HU_MAXLINELENGTH+1]; - int len; + +typedef struct { + int x; + int y; + patch_t** f; + int sc; + char l[HU_MAXLINELENGTH+1]; + int len; int needsupdate; } hu_textline_t; -typedef struct -{ - hu_textline_t l[HU_MAXLINES]; - int h; - int cl; - boolean* on; - boolean laston; + +typedef struct { + hu_textline_t l[HU_MAXLINES]; + int h; + int cl; + boolean* on; + boolean laston; } hu_stext_t; -typedef struct -{ - hu_textline_t l; - int lm; - boolean* on; - boolean laston; + +typedef struct { + hu_textline_t l; + int lm; + boolean* on; + boolean laston; } hu_itext_t; + void HUlib_init(void); -void HUlib_clearTextLine(hu_textline_t *t); -void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); +void HUlib_clearTextLine(hu_textline_t *t); +void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); boolean HUlib_delCharFromTextLine(hu_textline_t *t); -void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); -void HUlib_eraseTextLine(hu_textline_t *l); -void -HUlib_initSText -( hu_stext_t* s, - int x, - int y, - int h, - patch_t** font, - int startchar, - boolean* on ); +void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); +void HUlib_eraseTextLine(hu_textline_t *l); +void HUlib_initSText(hu_stext_t* s, int x, int y, int h, patch_t** font, int startchar, boolean* on); void HUlib_addLineToSText(hu_stext_t* s); -void -HUlib_addMessageToSText -( hu_stext_t* s, - char* prefix, - char* msg ); +void HUlib_addMessageToSText(hu_stext_t* s, char* prefix, char* msg); void HUlib_drawSText(hu_stext_t* s); void HUlib_eraseSText(hu_stext_t* s); -void -HUlib_initIText -( hu_itext_t* it, - int x, - int y, - patch_t** font, - int startchar, - boolean* on ); +void HUlib_initIText(hu_itext_t* it, int x, int y, patch_t** font, int startchar, boolean* on); void HUlib_delCharFromIText(hu_itext_t* it); void HUlib_eraseLineFromIText(hu_itext_t* it); void HUlib_resetIText(hu_itext_t* it); -void -HUlib_addPrefixToIText -( hu_itext_t* it, - char* str ); -boolean -HUlib_keyInIText -( hu_itext_t* it, - unsigned char ch ); +void HUlib_addPrefixToIText(hu_itext_t* it, char* str); +boolean HUlib_keyInIText(hu_itext_t* it, unsigned char ch); void HUlib_drawIText(hu_itext_t* it); void HUlib_eraseIText(hu_itext_t* it); + #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c @@ -1,7 +1,7 @@ #include <ctype.h> + #include "doomdef.h" #include "z_zone.h" -#include "m_swap.h" #include "hu_stuff.h" #include "hu_lib.h" #include "w_wad.h" @@ -9,39 +9,42 @@ #include "doomstat.h" #include "dstrings.h" #include "sounds.h" -#define HU_TITLE (mapnames[(gameepisode-1)*9+gamemap-1]) -#define HU_TITLE2 (mapnames2[gamemap-1]) -#define HU_TITLEP (mapnamesp[gamemap-1]) -#define HU_TITLET (mapnamest[gamemap-1]) + +#define HU_TITLE (lang[mapnames[(gameepisode-1)*9+gamemap-1]]) +#define HU_TITLE2 (lang[mapnames2[gamemap-1]]) +#define HU_TITLEP (lang[mapnamesp[gamemap-1]]) +#define HU_TITLET (lang[mapnamest[gamemap-1]]) #define HU_TITLEHEIGHT 1 #define HU_TITLEX 0 -#define HU_TITLEY (167 - SHORT(hu_font[0]->height)) +#define HU_TITLEY (167 - hu_font[0]->height) #define HU_INPUTTOGGLE 't' -#define HU_INPUTX HU_MSGX -#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(hu_font[0]->height) +1)) +#define HU_INPUTX HU_MSGX +#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(hu_font[0]->height) +1) #define HU_INPUTWIDTH 64 #define HU_INPUTHEIGHT 1 -char* chat_macros[] = -{ - HUSTR_CHATMACRO0, - HUSTR_CHATMACRO1, - HUSTR_CHATMACRO2, - HUSTR_CHATMACRO3, - HUSTR_CHATMACRO4, - HUSTR_CHATMACRO5, - HUSTR_CHATMACRO6, - HUSTR_CHATMACRO7, - HUSTR_CHATMACRO8, - HUSTR_CHATMACRO9 +#define QUEUESIZE 128 + +int chat_macros[] = { + HUSTR_CHATMACRO0, + HUSTR_CHATMACRO1, + HUSTR_CHATMACRO2, + HUSTR_CHATMACRO3, + HUSTR_CHATMACRO4, + HUSTR_CHATMACRO5, + HUSTR_CHATMACRO6, + HUSTR_CHATMACRO7, + HUSTR_CHATMACRO8, + HUSTR_CHATMACRO9 }; -char* player_names[] = -{ - HUSTR_PLRGREEN, - HUSTR_PLRINDIGO, - HUSTR_PLRBROWN, - HUSTR_PLRRED + +int player_names[] = { + HUSTR_PLRGREEN, + HUSTR_PLRINDIGO, + HUSTR_PLRBROWN, + HUSTR_PLRRED }; -char chat_char; + +char chat_char; static player_t* plr; patch_t* hu_font[HU_FONTSIZE]; static hu_textline_t w_title; @@ -58,552 +61,487 @@ static int message_counter; extern int showMessages; extern boolean automapactive; static boolean headsupactive = false; -char* mapnames[] = -{ - HUSTR_E1M1, - HUSTR_E1M2, - HUSTR_E1M3, - HUSTR_E1M4, - HUSTR_E1M5, - HUSTR_E1M6, - HUSTR_E1M7, - HUSTR_E1M8, - HUSTR_E1M9, - HUSTR_E2M1, - HUSTR_E2M2, - HUSTR_E2M3, - HUSTR_E2M4, - HUSTR_E2M5, - HUSTR_E2M6, - HUSTR_E2M7, - HUSTR_E2M8, - HUSTR_E2M9, - HUSTR_E3M1, - HUSTR_E3M2, - HUSTR_E3M3, - HUSTR_E3M4, - HUSTR_E3M5, - HUSTR_E3M6, - HUSTR_E3M7, - HUSTR_E3M8, - HUSTR_E3M9, - HUSTR_E4M1, - HUSTR_E4M2, - HUSTR_E4M3, - HUSTR_E4M4, - HUSTR_E4M5, - HUSTR_E4M6, - HUSTR_E4M7, - HUSTR_E4M8, - HUSTR_E4M9, - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL" +static char chatchars[QUEUESIZE]; +static int head = 0; +static int tail = 0; + + +int mapnames[] = { + HUSTR_E1M1, + HUSTR_E1M2, + HUSTR_E1M3, + HUSTR_E1M4, + HUSTR_E1M5, + HUSTR_E1M6, + HUSTR_E1M7, + HUSTR_E1M8, + HUSTR_E1M9, + HUSTR_E2M1, + HUSTR_E2M2, + HUSTR_E2M3, + HUSTR_E2M4, + HUSTR_E2M5, + HUSTR_E2M6, + HUSTR_E2M7, + HUSTR_E2M8, + HUSTR_E2M9, + HUSTR_E3M1, + HUSTR_E3M2, + HUSTR_E3M3, + HUSTR_E3M4, + HUSTR_E3M5, + HUSTR_E3M6, + HUSTR_E3M7, + HUSTR_E3M8, + HUSTR_E3M9, + HUSTR_E4M1, + HUSTR_E4M2, + HUSTR_E4M3, + HUSTR_E4M4, + HUSTR_E4M5, + HUSTR_E4M6, + HUSTR_E4M7, + HUSTR_E4M8, + HUSTR_E4M9, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL }; -char* mapnames2[] = -{ - HUSTR_1, - HUSTR_2, - HUSTR_3, - HUSTR_4, - HUSTR_5, - HUSTR_6, - HUSTR_7, - HUSTR_8, - HUSTR_9, - HUSTR_10, - HUSTR_11, - HUSTR_12, - HUSTR_13, - HUSTR_14, - HUSTR_15, - HUSTR_16, - HUSTR_17, - HUSTR_18, - HUSTR_19, - HUSTR_20, - HUSTR_21, - HUSTR_22, - HUSTR_23, - HUSTR_24, - HUSTR_25, - HUSTR_26, - HUSTR_27, - HUSTR_28, - HUSTR_29, - HUSTR_30, - HUSTR_31, - HUSTR_32 + +int mapnames2[] = { + HUSTR_1, + HUSTR_2, + HUSTR_3, + HUSTR_4, + HUSTR_5, + HUSTR_6, + HUSTR_7, + HUSTR_8, + HUSTR_9, + HUSTR_10, + HUSTR_11, + HUSTR_12, + HUSTR_13, + HUSTR_14, + HUSTR_15, + HUSTR_16, + HUSTR_17, + HUSTR_18, + HUSTR_19, + HUSTR_20, + HUSTR_21, + HUSTR_22, + HUSTR_23, + HUSTR_24, + HUSTR_25, + HUSTR_26, + HUSTR_27, + HUSTR_28, + HUSTR_29, + HUSTR_30, + HUSTR_31, + HUSTR_32 }; -char* mapnamesp[] = -{ - PHUSTR_1, - PHUSTR_2, - PHUSTR_3, - PHUSTR_4, - PHUSTR_5, - PHUSTR_6, - PHUSTR_7, - PHUSTR_8, - PHUSTR_9, - PHUSTR_10, - PHUSTR_11, - PHUSTR_12, - PHUSTR_13, - PHUSTR_14, - PHUSTR_15, - PHUSTR_16, - PHUSTR_17, - PHUSTR_18, - PHUSTR_19, - PHUSTR_20, - PHUSTR_21, - PHUSTR_22, - PHUSTR_23, - PHUSTR_24, - PHUSTR_25, - PHUSTR_26, - PHUSTR_27, - PHUSTR_28, - PHUSTR_29, - PHUSTR_30, - PHUSTR_31, - PHUSTR_32 + +int mapnamesp[] = { + PHUSTR_1, + PHUSTR_2, + PHUSTR_3, + PHUSTR_4, + PHUSTR_5, + PHUSTR_6, + PHUSTR_7, + PHUSTR_8, + PHUSTR_9, + PHUSTR_10, + PHUSTR_11, + PHUSTR_12, + PHUSTR_13, + PHUSTR_14, + PHUSTR_15, + PHUSTR_16, + PHUSTR_17, + PHUSTR_18, + PHUSTR_19, + PHUSTR_20, + PHUSTR_21, + PHUSTR_22, + PHUSTR_23, + PHUSTR_24, + PHUSTR_25, + PHUSTR_26, + PHUSTR_27, + PHUSTR_28, + PHUSTR_29, + PHUSTR_30, + PHUSTR_31, + PHUSTR_32 }; -char *mapnamest[] = -{ - THUSTR_1, - THUSTR_2, - THUSTR_3, - THUSTR_4, - THUSTR_5, - THUSTR_6, - THUSTR_7, - THUSTR_8, - THUSTR_9, - THUSTR_10, - THUSTR_11, - THUSTR_12, - THUSTR_13, - THUSTR_14, - THUSTR_15, - THUSTR_16, - THUSTR_17, - THUSTR_18, - THUSTR_19, - THUSTR_20, - THUSTR_21, - THUSTR_22, - THUSTR_23, - THUSTR_24, - THUSTR_25, - THUSTR_26, - THUSTR_27, - THUSTR_28, - THUSTR_29, - THUSTR_30, - THUSTR_31, - THUSTR_32 + +int mapnamest[] = { + THUSTR_1, + THUSTR_2, + THUSTR_3, + THUSTR_4, + THUSTR_5, + THUSTR_6, + THUSTR_7, + THUSTR_8, + THUSTR_9, + THUSTR_10, + THUSTR_11, + THUSTR_12, + THUSTR_13, + THUSTR_14, + THUSTR_15, + THUSTR_16, + THUSTR_17, + THUSTR_18, + THUSTR_19, + THUSTR_20, + THUSTR_21, + THUSTR_22, + THUSTR_23, + THUSTR_24, + THUSTR_25, + THUSTR_26, + THUSTR_27, + THUSTR_28, + THUSTR_29, + THUSTR_30, + THUSTR_31, + THUSTR_32 }; + const char* shiftxform; -const char french_shiftxform[] = -{ - 0, - 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, - ' ', '!', '"', '#', '$', '%', '&', - '"', - '(', ')', '*', '+', - '?', - '_', - '>', - '?', - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '/', - '.', - '<', - '+', - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', - '!', - ']', - '"', '_', - '\'', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 +const char french_shiftxform[] = { + 0, + 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, + ' ', '!', '"', '#', '$', '%', '&', + '"', + '(', ')', '*', '+', + '?', + '_', + '>', + '?', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '/', + '.', + '<', + '+', + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', + '!', + ']', + '"', '_', + '\'', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 + }; -const char english_shiftxform[] = -{ - 0, - 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, - ' ', '!', '"', '#', '$', '%', '&', - '"', - '(', ')', '*', '+', - '<', - '_', - '>', - '?', - ')', - '!', - '@', - '#', - '$', - '%', - '^', - '&', - '*', - '(', - ':', - ':', - '<', - '+', - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', - '!', - ']', - '"', '_', - '\'', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 + +const char english_shiftxform[] = { + 0, + 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, + ' ', '!', '"', '#', '$', '%', '&', + '"', + '(', ')', '*', '+', + '<', + '_', + '>', + '?', + ')', + '!', + '@', + '#', + '$', + '%', + '^', + '&', + '*', + '(', + ':', + ':', + '<', + '+', + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', + '!', + ']', + '"', '_', + '\'', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 }; -char frenchKeyMap[128]= -{ - 0, - 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, - ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!', - '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?', - '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', - 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_', - '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', - 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127 + +char frenchKeyMap[128] = { + 0, + 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, + ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!', + '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?', + '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', + 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_', + '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', + 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127 }; + char ForeignTranslation(unsigned char ch) { - return ch < 128 ? frenchKeyMap[ch] : ch; + return ch < 128 ? frenchKeyMap[ch] : ch; } -void HU_Init(void) + +void +HU_Init() { - int i; - int j; - char buffer[9]; - if (french) - shiftxform = french_shiftxform; - else + + int i, j; + char buffer[9]; + shiftxform = english_shiftxform; - j = HU_FONTSTART; - for (i=0;i<HU_FONTSIZE;i++) - { - sprintf(buffer, "STCFN%.3d", j++); - hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC); - } + j = HU_FONTSTART; + for (i = 0; i < HU_FONTSIZE; ++i) { + sprintf(buffer, "STCFN%.3d", j++); + hu_font[i] = (patch_t*)W_CacheLumpName(buffer, PU_STATIC); + } } -void HU_Stop(void) + +void +HU_Stop() { - headsupactive = false; + headsupactive = false; } -void HU_Start(void) + +void +HU_Start() { - int i; - char* s; - if (headsupactive) - HU_Stop(); - plr = &players[consoleplayer]; - message_on = false; - message_dontfuckwithme = false; - message_nottobefuckedwith = false; - chat_on = false; - HUlib_initSText(&w_message, - HU_MSGX, HU_MSGY, HU_MSGHEIGHT, - hu_font, - HU_FONTSTART, &message_on); - HUlib_initTextLine(&w_title, - HU_TITLEX, HU_TITLEY, - hu_font, - HU_FONTSTART); - switch ( gamemode ) - { - case shareware: - case registered: - case retail: + char* s; + int i; + + if (headsupactive) + HU_Stop(); + plr = &players[consoleplayer]; + message_on = false; + message_dontfuckwithme = false; + message_nottobefuckedwith = false; + chat_on = false; + HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, hu_font, HU_FONTSTART, &message_on); + HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, hu_font, HU_FONTSTART); s = HU_TITLE; - break; -/* FIXME - case pack_plut: - s = HU_TITLEP; - break; - case pack_tnt: - s = HU_TITLET; - break; -*/ - case commercial: - default: - s = HU_TITLE2; - break; - } - while (*s) - HUlib_addCharToTextLine(&w_title, *(s++)); - HUlib_initIText(&w_chat, - HU_INPUTX, HU_INPUTY, - hu_font, - HU_FONTSTART, &chat_on); - for (i=0 ; i<MAXPLAYERS ; i++) - HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, &always_off); - headsupactive = true; + while (*s) + HUlib_addCharToTextLine(&w_title, *(s++)); + HUlib_initIText(&w_chat, HU_INPUTX, HU_INPUTY, hu_font, HU_FONTSTART, &chat_on); + for (i = 0; i < MAXPLAYERS; ++i) + HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, &always_off); + headsupactive = true; } -void HU_Drawer(void) + +void +HU_Drawer() { - HUlib_drawSText(&w_message); - HUlib_drawIText(&w_chat); - if (automapactive) - HUlib_drawTextLine(&w_title, false); + HUlib_drawSText(&w_message); + HUlib_drawIText(&w_chat); + if (automapactive) + HUlib_drawTextLine(&w_title, false); } -void HU_Erase(void) + +void +HU_Erase() { - HUlib_eraseSText(&w_message); - HUlib_eraseIText(&w_chat); - HUlib_eraseTextLine(&w_title); + HUlib_eraseSText(&w_message); + HUlib_eraseIText(&w_chat); + HUlib_eraseTextLine(&w_title); } -void HU_Ticker(void) + +void +HU_Ticker() { - int i, rc; - char c; - if (message_counter && !--message_counter) - { - message_on = false; - message_nottobefuckedwith = false; - } - if (showMessages || message_dontfuckwithme) - { - if ((plr->message && !message_nottobefuckedwith) - || (plr->message && message_dontfuckwithme)) - { - HUlib_addMessageToSText(&w_message, 0, plr->message); - plr->message = 0; - message_on = true; - message_counter = HU_MSGTIMEOUT; - message_nottobefuckedwith = message_dontfuckwithme; - message_dontfuckwithme = 0; + int i, rc; + char c; + + if (message_counter && !--message_counter) { + message_on = false; + message_nottobefuckedwith = false; } - } - if (netgame) - { - for (i=0 ; i<MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - if (i != consoleplayer - && (c = players[i].cmd.chatchar)) - { - if (c <= HU_BROADCAST) - chat_dest[i] = c; - else - { - if (c >= 'a' && c <= 'z') - c = (char) shiftxform[(unsigned char) c]; - rc = HUlib_keyInIText(&w_inputbuffer[i], c); - if (rc && c == KEY_ENTER) - { - if (w_inputbuffer[i].l.len - && (chat_dest[i] == consoleplayer+1 - || chat_dest[i] == HU_BROADCAST)) - { - HUlib_addMessageToSText(&w_message, - player_names[i], - w_inputbuffer[i].l.l); - message_nottobefuckedwith = true; - message_on = true; - message_counter = HU_MSGTIMEOUT; - if ( gamemode == commercial ) - S_StartSound(0, sfx_radio); - else - S_StartSound(0, sfx_tink); + if (showMessages || message_dontfuckwithme) { + if ((plr->message && !message_nottobefuckedwith) || (plr->message && message_dontfuckwithme)) { + HUlib_addMessageToSText(&w_message, 0, plr->message); + plr->message = 0; + message_on = true; + message_counter = HU_MSGTIMEOUT; + message_nottobefuckedwith = message_dontfuckwithme; + message_dontfuckwithme = 0; + } + } + if (netgame) { + for (i = 0 ; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) continue; + if (i != consoleplayer && (c = players[i].cmd.chatchar)) { + if (c <= HU_BROADCAST) + chat_dest[i] = c; + else { + if (c >= 'a' && c <= 'z') + c = (char) shiftxform[(unsigned char) c]; + rc = HUlib_keyInIText(&w_inputbuffer[i], c); + if (rc && c == KEY_ENTER) { + if (w_inputbuffer[i].l.len && (chat_dest[i] == consoleplayer+1 || chat_dest[i] == HU_BROADCAST)) { + HUlib_addMessageToSText(&w_message, lang[player_names[i]], w_inputbuffer[i].l.l); + message_nottobefuckedwith = true; + message_on = true; + message_counter = HU_MSGTIMEOUT; + S_StartSound(0, sfx_tink); + } + HUlib_resetIText(&w_inputbuffer[i]); + } + } + players[i].cmd.chatchar = 0; } - HUlib_resetIText(&w_inputbuffer[i]); - } } - players[i].cmd.chatchar = 0; - } } - } } -#define QUEUESIZE 128 -static char chatchars[QUEUESIZE]; -static int head = 0; -static int tail = 0; -void HU_queueChatChar(char c) + + +void +HU_queueChatChar(char c) { - if (((head + 1) & (QUEUESIZE-1)) == tail) - { - plr->message = HUSTR_MSGU; - } - else - { - chatchars[head] = c; - head = (head + 1) & (QUEUESIZE-1); - } + if (((head + 1) & (QUEUESIZE-1)) == tail) + plr->message = lang[HUSTR_MSGU]; + else { + chatchars[head] = c; + head = (head + 1) & (QUEUESIZE-1); + } } -char HU_dequeueChatChar(void) + +char +HU_dequeueChatChar() { - char c; - if (head != tail) - { - c = chatchars[tail]; - tail = (tail + 1) & (QUEUESIZE-1); - } - else - { - c = 0; - } - return c; + char c; + + if (head != tail) { + c = chatchars[tail]; + tail = (tail + 1) & (QUEUESIZE-1); + } else c = 0; + return c; } -boolean HU_Responder(event_t *ev) + +boolean +HU_Responder(event_t *ev) { - static char lastmessage[HU_MAXLINELENGTH+1]; - char* macromessage; - boolean eatkey = false; - static boolean shiftdown = false; - static boolean altdown = false; - unsigned char c; - int i; - int numplayers; - static char destination_keys[MAXPLAYERS] = - { - HUSTR_KEYGREEN, - HUSTR_KEYINDIGO, - HUSTR_KEYBROWN, - HUSTR_KEYRED - }; - static int num_nobrainers = 0; - numplayers = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - numplayers += playeringame[i]; - if (ev->data1 == KEY_RSHIFT) - { - shiftdown = ev->type == ev_keydown; - return false; - } - else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) - { - altdown = ev->type == ev_keydown; - return false; - } - if (ev->type != ev_keydown) - return false; - if (!chat_on) - { - if (ev->data1 == HU_MSGREFRESH) - { - message_on = true; - message_counter = HU_MSGTIMEOUT; - eatkey = true; + static char lastmessage[HU_MAXLINELENGTH+1]; + static boolean shiftdown = false; + static boolean altdown = false; + static int num_nobrainers = 0; + static char destination_keys[MAXPLAYERS] = { 'g', 'i', 'b', 'r' } ; + char* macromessage; + boolean eatkey; + unsigned char c; + int i, numplayers; + + eatkey = false; + numplayers = 0; + for (i = 0; i < MAXPLAYERS; ++i) + numplayers += playeringame[i]; + if (ev->data1 == KEY_RSHIFT) { + shiftdown = ev->type == ev_keydown; + return false; } - else if (netgame && ev->data1 == HU_INPUTTOGGLE) - { - eatkey = chat_on = true; - HUlib_resetIText(&w_chat); - HU_queueChatChar(HU_BROADCAST); + if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) { + altdown = ev->type == ev_keydown; + return false; } - else if (netgame && numplayers > 2) - { - for (i=0; i<MAXPLAYERS ; i++) - { - if (ev->data1 == destination_keys[i]) - { - if (playeringame[i] && i!=consoleplayer) - { + if (ev->type != ev_keydown) + return false; + if (!chat_on) { + if (ev->data1 == HU_MSGREFRESH) { + message_on = true; + message_counter = HU_MSGTIMEOUT; + eatkey = true; + } + if (netgame && ev->data1 == HU_INPUTTOGGLE) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); - HU_queueChatChar(i+1); - break; - } - else if (i == consoleplayer) - { - num_nobrainers++; - if (num_nobrainers < 3) - plr->message = HUSTR_TALKTOSELF1; - else if (num_nobrainers < 6) - plr->message = HUSTR_TALKTOSELF2; - else if (num_nobrainers < 9) - plr->message = HUSTR_TALKTOSELF3; - else if (num_nobrainers < 32) - plr->message = HUSTR_TALKTOSELF4; - else - plr->message = HUSTR_TALKTOSELF5; - } + HU_queueChatChar(HU_BROADCAST); } - } - } - } - else - { - c = ev->data1; - if (altdown) - { - c = c - '0'; - if (c > 9) - return false; - macromessage = chat_macros[c]; - HU_queueChatChar(KEY_ENTER); - while (*macromessage) - HU_queueChatChar(*macromessage++); - HU_queueChatChar(KEY_ENTER); - chat_on = false; - strcpy(lastmessage, chat_macros[c]); - plr->message = lastmessage; - eatkey = true; - } - else - { - if (french) - c = ForeignTranslation(c); - if (shiftdown || (c >= 'a' && c <= 'z')) - c = shiftxform[c]; - eatkey = HUlib_keyInIText(&w_chat, c); - if (eatkey) - { - HU_queueChatChar(c); - } - if (c == KEY_ENTER) - { - chat_on = false; - if (w_chat.l.len) - { - strcpy(lastmessage, w_chat.l.l); - plr->message = lastmessage; + if (netgame && numplayers > 2) { + for (i = 0; i < MAXPLAYERS; ++i) { + if (ev->data1 == destination_keys[i]) { + if (playeringame[i] && i!=consoleplayer) { + eatkey = chat_on = true; + HUlib_resetIText(&w_chat); + HU_queueChatChar(i+1); + break; + } + if (i == consoleplayer) { + ++num_nobrainers; + if (num_nobrainers < 3) plr->message = lang[HUSTR_TALKTOSELF1]; + else if (num_nobrainers < 6) plr->message = lang[HUSTR_TALKTOSELF2]; + else if (num_nobrainers < 9) plr->message = lang[HUSTR_TALKTOSELF3]; + else if (num_nobrainers < 32) plr->message = lang[HUSTR_TALKTOSELF4]; + else plr->message = lang[HUSTR_TALKTOSELF5]; + } + } + } + } + } else { + c = ev->data1; + if (altdown) { + c = c - '0'; + if (c > 9) + return false; + macromessage = lang[chat_macros[c]]; + HU_queueChatChar(KEY_ENTER); + while (*macromessage) + HU_queueChatChar(*macromessage++); + HU_queueChatChar(KEY_ENTER); + chat_on = false; + strcpy(lastmessage, lang[chat_macros[c]]); + plr->message = lastmessage; + eatkey = true; + } else { + if (shiftdown || (c >= 'a' && c <= 'z')) + c = shiftxform[c]; + eatkey = HUlib_keyInIText(&w_chat, c); + if (eatkey) + HU_queueChatChar(c); + if (c == KEY_ENTER) { + chat_on = false; + if (w_chat.l.len) { + strcpy(lastmessage, w_chat.l.l); + plr->message = lastmessage; + } + } + if (c == KEY_ESCAPE) + chat_on = false; } - } - else if (c == KEY_ESCAPE) - chat_on = false; } - } - return eatkey; + return eatkey; } diff --git a/src/hu_stuff.h b/src/hu_stuff.h @@ -1,7 +1,9 @@ #ifndef __HU_STUFF_H__ #define __HU_STUFF_H__ + #include "d_event.h" -#define HU_FONTSTART '!' + +#define HU_FONTSTART '!' #define HU_FONTEND '_' #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) #define HU_BROADCAST 5 @@ -11,6 +13,7 @@ #define HU_MSGWIDTH 64 #define HU_MSGHEIGHT 1 #define HU_MSGTIMEOUT (4*TICRATE) + void HU_Init(void); void HU_Start(void); boolean HU_Responder(event_t* ev); @@ -18,4 +21,5 @@ void HU_Ticker(void); void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); + #endif diff --git a/src/i_main.c b/src/i_main.c @@ -1,13 +1,13 @@ #include "doomdef.h" + #include "m_argv.h" #include "d_main.h" + int -main -( int argc, - char** argv ) +main(int argc, char** argv) { myargc = argc; myargv = argv; - D_DoomMain (); + D_DoomMain(); return 0; } diff --git a/src/i_net.c b/src/i_net.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> + #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -8,41 +9,68 @@ #include <unistd.h> #include <netdb.h> #include <sys/ioctl.h> + #include "i_system.h" #include "d_event.h" #include "d_net.h" #include "m_argv.h" + #include "doomstat.h" -#ifdef __GNUG__ -#pragma implementation "i_net.h" -#endif + #include "i_net.h" + +/* #define ntohl(x) \ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ (((unsigned long int)(x) & 0xff000000U) >> 24))) + #define ntohs(x) \ ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ - (((unsigned short int)(x) & 0xff00) >> 8))) + (((unsigned short int)(x) & 0xff00) >> 8))) \ + #define htonl(x) ntohl(x) #define htons(x) ntohs(x) +*/ + void NetSend (void); boolean NetListen (void); + + + + + + int DOOMPORT = (IPPORT_USERRESERVED +0x1d ); + int sendsocket; int insocket; + struct sockaddr_in sendaddress[MAXNETNODES]; + void (*netget) (void); void (*netsend) (void); + + + + + int UDPsocket (void) { int s; + + s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (s<0) I_Error ("can't create socket: %s",strerror(errno)); + return s; } + + + + void BindToLocalPort ( int s, @@ -50,18 +78,27 @@ BindToLocalPort { int v; struct sockaddr_in address; + memset (&address, 0, sizeof(address)); address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = port; + v = bind (s, (void *)&address, sizeof(address)); if (v == -1) I_Error ("BindToPort: bind: %s", strerror(errno)); } + + + + + void PacketSend (void) { int c; doomdata_t sw; + + sw.checksum = htonl(netbuffer->checksum); sw.player = netbuffer->player; sw.retransmitfrom = netbuffer->retransmitfrom; @@ -76,20 +113,30 @@ void PacketSend (void) sw.cmds[c].chatchar = netbuffer->cmds[c].chatchar; sw.cmds[c].buttons = netbuffer->cmds[c].buttons; } + + c = sendto (sendsocket , &sw, doomcom->datalength ,0,(void *)&sendaddress[doomcom->remotenode] ,sizeof(sendaddress[doomcom->remotenode])); + + + } + + + + + void PacketGet (void) { int i; int c; struct sockaddr_in fromaddress; - socklen_t fromlen; + unsigned int fromlen; doomdata_t sw; - + fromlen = sizeof(fromaddress); - c = recvfrom(insocket, &sw, sizeof(sw), 0 , (struct sockaddr *)&fromaddress, &fromlen ); + c = recvfrom (insocket, &sw, sizeof(sw), 0, (struct sockaddr *)&fromaddress, &fromlen ); if (c == -1 ) { if (errno != EWOULDBLOCK) @@ -97,27 +144,36 @@ void PacketGet (void) doomcom->remotenode = -1; return; } + { static int first=1; if (first) printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1)); first = 0; } + + for (i=0 ; i<doomcom->numnodes ; i++) if ( fromaddress.sin_addr.s_addr == sendaddress[i].sin_addr.s_addr ) break; + if (i == doomcom->numnodes) { + doomcom->remotenode = -1; - return; + return; } + doomcom->remotenode = i; doomcom->datalength = c; + + netbuffer->checksum = ntohl(sw.checksum); netbuffer->player = sw.player; netbuffer->retransmitfrom = sw.retransmitfrom; netbuffer->starttic = sw.starttic; netbuffer->numtics = sw.numtics; + for (c=0 ; c< netbuffer->numtics ; c++) { netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove; @@ -128,27 +184,42 @@ void PacketGet (void) netbuffer->cmds[c].buttons = sw.cmds[c].buttons; } } + + + int GetLocalAddress (void) { char hostname[1024]; struct hostent* hostentry; int v; + + v = gethostname (hostname, sizeof(hostname)); if (v == -1) I_Error ("GetLocalAddress : gethostname: errno %d",errno); + hostentry = gethostbyname (hostname); if (!hostentry) I_Error ("GetLocalAddress : gethostbyname: couldn't get local host"); + return *(int *)hostentry->h_addr_list[0]; } + + + + + void I_InitNetwork (void) { boolean trueval = true; int i; int p; struct hostent* hostentry; + doomcom = malloc (sizeof (*doomcom) ); memset (doomcom, 0, sizeof(*doomcom) ); + + i = M_CheckParm ("-dup"); if (i && i< myargc-1) { @@ -160,19 +231,25 @@ void I_InitNetwork (void) } else doomcom-> ticdup = 1; + if (M_CheckParm ("-extratic")) doomcom-> extratics = 1; else doomcom-> extratics = 0; + p = M_CheckParm ("-port"); if (p && p<myargc-1) { DOOMPORT = atoi (myargv[p+1]); printf ("using alternate port %i\n",DOOMPORT); } + + + i = M_CheckParm ("-net"); if (!i) { + netgame = false; doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes = 1; @@ -180,11 +257,16 @@ void I_InitNetwork (void) doomcom->consoleplayer = 0; return; } + netsend = PacketSend; netget = PacketGet; netgame = true; + + doomcom->consoleplayer = myargv[i+1][0]-'1'; + doomcom->numnodes = 1; + i++; while (++i < myargc && myargv[i][0] != '-') { @@ -205,13 +287,19 @@ void I_InitNetwork (void) } doomcom->numnodes++; } + doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes; + + insocket = UDPsocket (); BindToLocalPort (insocket,htons(DOOMPORT)); ioctl (insocket, FIONBIO, &trueval); + sendsocket = UDPsocket (); } + + void I_NetCmd (void) { if (doomcom->command == CMD_SEND) @@ -225,3 +313,4 @@ void I_NetCmd (void) else I_Error ("Bad net cmd: %i\n",doomcom->command); } + diff --git a/src/i_net.h b/src/i_net.h @@ -1,8 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_NET__ #define __I_NET__ + + #ifdef __GNUG__ #pragma interface #endif + + + + + + void I_InitNetwork (void); void I_NetCmd (void); + + #endif + + + + + diff --git a/src/i_sound.c b/src/i_sound.c @@ -1,53 +1,132 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -#include <errno.h> + #include <math.h> +#include <errno.h> + #include <sys/time.h> #include <sys/types.h> + #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> + + #include <linux/soundcard.h> + + #include <time.h> #include <signal.h> + #include "z_zone.h" + #include "i_system.h" #include "i_sound.h" #include "m_argv.h" #include "m_misc.h" #include "w_wad.h" + #include "doomdef.h" + + #ifdef SNDSERV + FILE* sndserver=0; char* sndserver_filename = "./sndserver "; #elif SNDINTR + + + + #define SOUND_INTERVAL 500 + + int I_SoundSetTimer( int duration_of_tick ); void I_SoundDelTimer( void ); #else + #endif + + + + + static int flag = 0; + + + + + + + + #define SAMPLECOUNT 512 #define NUM_CHANNELS 8 + #define BUFMUL 4 #define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) + #define SAMPLERATE 11025 #define SAMPLESIZE 2 + + int lengths[NUMSFX]; + + int audio_fd; + + + + + signed short mixbuffer[MIXBUFFERSIZE]; + + + unsigned int channelstep[NUM_CHANNELS]; + unsigned int channelstepremainder[NUM_CHANNELS]; + + + unsigned char* channels[NUM_CHANNELS]; unsigned char* channelsend[NUM_CHANNELS]; + + + + + + + int channelstart[NUM_CHANNELS]; + + + + + int channelhandles[NUM_CHANNELS]; + + + int channelids[NUM_CHANNELS]; + + int steptable[256]; + + int vol_lookup[128*256]; + + int* channelleftvol_lookup[NUM_CHANNELS]; int* channelrightvol_lookup[NUM_CHANNELS]; + + + + + + + void myioctl ( int fd, @@ -55,6 +134,7 @@ myioctl int* arg ) { int rc; + rc = ioctl(fd, command, arg); if (rc < 0) { @@ -63,6 +143,15 @@ myioctl exit(-1); } } + + + + + + + + + void* getsfx ( char* sfxname, @@ -75,22 +164,73 @@ getsfx int paddedsize; char name[20]; int sfxlump; - sprintf(name, "ds%s", sfxname); + + + + + sprintf(name, "DS%s", sfxname); + + + + + + + + + + + if ( W_CheckNumForName(name) == -1 ) - sfxlump = W_GetNumForName("dspistol"); + sfxlump = W_GetNumForName("DSPISTOL"); else sfxlump = W_GetNumForName(name); + size = W_LumpLength( sfxlump ); + + + + + + + sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC ); + + + paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT; + + paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 ); + + + + + memcpy( paddedsfx, sfx, size ); for (i=size ; i<paddedsize+8 ; i++) paddedsfx[i] = 128; + + Z_Free( sfx ); + + *len = paddedsize; + + return (void *) (paddedsfx + 8); } + + + + + + + + + + + + int addsfx ( int sfxid, @@ -99,13 +239,19 @@ addsfx int seperation ) { static unsigned short handlenums = 0; + int i; int rc = -1; + int oldest = gametic; int oldestnum = 0; int slot; + int rightvol; int leftvol; + + + if ( sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful @@ -113,16 +259,23 @@ addsfx || sfxid == sfx_stnmov || sfxid == sfx_pistol ) { + for (i=0 ; i<NUM_CHANNELS ; i++) { + if ( (channels[i]) && (channelids[i] == sfxid) ) { + channels[i] = 0; + + break; } } } + + for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++) { if (channelstart[i] < oldest) @@ -131,62 +284,159 @@ addsfx oldest = channelstart[i]; } } + + + + + if (i == NUM_CHANNELS) slot = oldestnum; else slot = i; + + + + channels[slot] = (unsigned char *) S_sfx[sfxid].data; + channelsend[slot] = channels[slot] + lengths[sfxid]; + + if (!handlenums) handlenums = 100; + + + channelhandles[slot] = rc = handlenums++; + + + channelstep[slot] = step; + channelstepremainder[slot] = 0; + channelstart[slot] = gametic; + + + seperation += 1; + + + + leftvol = volume - ((volume*seperation*seperation) >> 16); seperation = seperation - 257; rightvol = volume - ((volume*seperation*seperation) >> 16); + + if (rightvol < 0 || rightvol > 127) I_Error("rightvol out of bounds"); + if (leftvol < 0 || leftvol > 127) I_Error("leftvol out of bounds"); + + + channelleftvol_lookup[slot] = &vol_lookup[leftvol*256]; channelrightvol_lookup[slot] = &vol_lookup[rightvol*256]; + + + channelids[slot] = sfxid; + + return rc; } + + + + + + + + + + + + + + void I_SetChannels() { + + + int i; int j; + int* steptablemid = steptable + 128; + + /*for (i=0; i<NUM_CHANNELS; i++) { channels[i] = 0; }*/ + + + for (i=-128 ; i<128 ; i++) steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0); + + + + + for (i=0 ; i<128 ; i++) for (j=0 ; j<256 ; j++) vol_lookup[i*256+j] = (i*(j-128)*256)/127; } + + void I_SetSfxVolume(int volume) { + + + + + snd_SfxVolume = volume; } + + void I_SetMusicVolume(int volume) { + snd_MusicVolume = volume; + + } + + + + + + int I_GetSfxLumpNum(sfxinfo_t* sfx) { char namebuf[9]; - sprintf(namebuf, "ds%s", sfx->name); + sprintf(namebuf, "DS%s", sfx->name); return W_GetNumForName(namebuf); } + + + + + + + + + + + + + int I_StartSound ( int id, @@ -195,96 +445,201 @@ I_StartSound int pitch, int priority ) { + + priority = 0; + #ifdef SNDSERV if (sndserver) { fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep); fflush(sndserver); } + return id; #else + + + + id = addsfx( id, vol, steptable[pitch], sep ); + + + return id; #endif } + + + void I_StopSound (int handle) { + + + + + + handle = 0; } + + int I_SoundIsPlaying(int handle) { + return gametic < handle; } + + + + + + + + + + + + + + + + + void I_UpdateSound( void ) { #ifdef SNDINTR static int misses = 0; #endif + + + + register unsigned int sample; register int dl; register int dr; + + signed short* leftout; signed short* rightout; signed short* leftend; + int step; + + int chan; + + + leftout = mixbuffer; rightout = mixbuffer+1; step = 2; + + + leftend = mixbuffer + SAMPLECOUNT*step; + + + + while (leftout != leftend) { + dl = 0; dr = 0; + + + + for ( chan = 0; chan < NUM_CHANNELS; chan++ ) { + if (channels[ chan ]) { + sample = *channels[ chan ]; + + + + dl += channelleftvol_lookup[ chan ][sample]; dr += channelrightvol_lookup[ chan ][sample]; + channelstepremainder[ chan ] += channelstep[ chan ]; + channels[ chan ] += channelstepremainder[ chan ] >> 16; + channelstepremainder[ chan ] &= 65536-1; + + if (channels[ chan ] >= channelsend[ chan ]) channels[ chan ] = 0; } } + + + + + + + if (dl > 0x7fff) *leftout = 0x7fff; else if (dl < -0x8000) *leftout = -0x8000; else *leftout = dl; + + if (dr > 0x7fff) *rightout = 0x7fff; else if (dr < -0x8000) *rightout = -0x8000; else *rightout = dr; + + leftout += step; rightout += step; } + #ifdef SNDINTR + if ( flag ) { misses += flag; flag = 0; } + if ( misses > 10 ) { fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n"); misses = 0; } + + flag++; #endif } + + + + + + + + + + void I_SubmitSound(void) { + write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); } + + + void I_UpdateSoundParams ( int handle, @@ -292,44 +647,76 @@ I_UpdateSoundParams int sep, int pitch) { + + + + + + handle = vol = sep = pitch = 0; } + + + + void I_ShutdownSound(void) { #ifdef SNDSERV if (sndserver) { + fprintf(sndserver, "q\n"); fflush(sndserver); } #else + int done = 0; int i; + + + fprintf( stderr, "I_ShutdownSound: NOT finishing pending sounds\n"); fflush( stderr ); + while ( !done ) { for( i=0 ; i<8 && !channels[i] ; i++); + + + done=1; } #ifdef SNDINTR I_SoundDelTimer(); #endif + + close ( audio_fd ); #endif + + return; } + + + + + + void I_InitSound() { #ifdef SNDSERV char buffer[256]; + if (getenv("DOOMWADDIR")) sprintf(buffer, "%s/%s", getenv("DOOMWADDIR"), sndserver_filename); else sprintf(buffer, "%s", sndserver_filename); + + if ( !access(buffer, X_OK) ) { strcat(buffer, " -quiet"); @@ -338,126 +725,230 @@ I_InitSound() else fprintf(stderr, "Could not start sound server [%s]\n", buffer); #else + int i; + #ifdef SNDINTR fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL ); I_SoundSetTimer( SOUND_INTERVAL ); #endif + + fprintf( stderr, "I_InitSound: "); + audio_fd = open("/dev/dsp", O_WRONLY); if (audio_fd<0) fprintf(stderr, "Could not open /dev/dsp\n"); + + i = 11 | (2<<16); myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); myioctl(audio_fd, SNDCTL_DSP_RESET, 0); + i=SAMPLERATE; + myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); + i=1; myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); + myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); + if (i&=AFMT_S16_LE) myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); else fprintf(stderr, "Could not play signed 16 data\n"); + fprintf(stderr, " configured audio device\n" ); + + + fprintf( stderr, "I_InitSound: "); + for (i=1 ; i<NUMSFX ; i++) { + if (!S_sfx[i].link) { + S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] ); } else { + S_sfx[i].data = S_sfx[i].link->data; lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)]; } } + fprintf( stderr, " pre-cached all sound data\n"); + + for ( i = 0; i< MIXBUFFERSIZE; i++ ) mixbuffer[i] = 0; + + fprintf(stderr, "I_InitSound: sound module ready\n"); + #endif } + + + + + + + + + void I_InitMusic(void) { } void I_ShutdownMusic(void) { } + static int looping=0; static int musicdies=-1; + void I_PlaySong(int handle, int looping) { + handle = looping = 0; musicdies = gametic + TICRATE*30; } + void I_PauseSong (int handle) { + handle = 0; } + void I_ResumeSong (int handle) { + handle = 0; } + void I_StopSong(int handle) { + handle = 0; + looping = 0; musicdies = 0; } + void I_UnRegisterSong(int handle) { + handle = 0; } + int I_RegisterSong(void* data) { + data = NULL; + return 1; } + + int I_QrySongPlaying(int handle) { + handle = 0; return looping || musicdies > gametic; } + + + + + + + + + + + #ifdef sun typedef sigset_t tSigSet; #else typedef int tSigSet; #endif + + + + + + static int /*__itimer_which*/ itimer = ITIMER_REAL; + static int sig = SIGALRM; + + void I_HandleSoundTimer( int ignore ) { + + + + if ( flag ) { + + write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); + + flag = 0; } else return; + + ignore = 0; return; } + + int I_SoundSetTimer( int duration_of_tick ) { + struct itimerval value; struct itimerval ovalue; struct sigaction act; struct sigaction oact; + int res; + + + + + act.sa_handler = I_HandleSoundTimer; #ifndef sun + #endif act.sa_flags = SA_RESTART; + sigaction( sig, &act, &oact ); + value.it_interval.tv_sec = 0; value.it_interval.tv_usec = duration_of_tick; value.it_value.tv_sec = 0; value.it_value.tv_usec = duration_of_tick; + + res = setitimer( itimer, &value, &ovalue ); + + if ( res == -1 ) fprintf( stderr, "I_SoundSetTimer: interrupt n.a.\n"); + return res; } + + + void I_SoundDelTimer() { + if ( I_SoundSetTimer( 0 ) == -1) fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n"); } diff --git a/src/i_sound.h b/src/i_sound.h @@ -1,19 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_SOUND__ #define __I_SOUND__ + #include "doomdef.h" + + #ifdef SNDSERV #include <stdio.h> extern FILE* sndserver; extern char* sndserver_filename; #endif + #include "doomstat.h" #include "sounds.h" + + + + void I_InitSound(); + + void I_UpdateSound(void); void I_SubmitSound(void); + + void I_ShutdownSound(void); + + + + + + + void I_SetChannels(); + + int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ); + + + int I_StartSound ( int id, @@ -21,24 +67,56 @@ I_StartSound int sep, int pitch, int priority ); + + + void I_StopSound(int handle); + + + + int I_SoundIsPlaying(int handle); + + + void I_UpdateSoundParams ( int handle, int vol, int sep, int pitch ); + + + + + void I_InitMusic(void); void I_ShutdownMusic(void); + void I_SetMusicVolume(int volume); + void I_PauseSong(int handle); void I_ResumeSong(int handle); + int I_RegisterSong(void *data); + + + + void I_PlaySong ( int handle, int looping ); + void I_StopSong(int handle); + void I_UnRegisterSong(int handle); + + + #endif + + + + + diff --git a/src/i_system.c b/src/i_system.c @@ -4,102 +4,69 @@ #include <stdarg.h> #include <sys/time.h> #include <unistd.h> + #include "doomdef.h" #include "m_misc.h" #include "i_video.h" #include "i_sound.h" #include "d_net.h" #include "g_game.h" -#ifdef __GNUG__ -#pragma implementation "i_system.h" -#endif #include "i_system.h" -int mb_used = 6; -void -I_Tactile -( int on, - int off, - int total ) -{ - on = off = total = 0; -} -ticcmd_t emptycmd; -ticcmd_t* I_BaseTiccmd(void) -{ - return &emptycmd; -} -int I_GetHeapSize (void) + +int +I_GetTime() { - return mb_used*1024*1024; -} -byte* I_ZoneBase (int* size) -{ - *size = mb_used*1024*1024; - return (byte *) malloc (*size); -} -int I_GetTime (void) -{ - struct timeval tp; - struct timezone tzp; - int newtics; - static int basetime=0; - gettimeofday(&tp, &tzp); + struct timeval tp; + static int basetime = 0; + int newtics; + + gettimeofday(&tp, NULL); if (!basetime) - basetime = tp.tv_sec; - newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000; + basetime = tp.tv_sec; + newtics = (tp.tv_sec-basetime) * TICRATE + tp.tv_usec * TICRATE / 1000000; return newtics; } -void I_Init (void) + +void +I_Init() { I_InitSound(); } -void I_Quit (void) + +void +I_Quit() { D_QuitNetGame (); I_ShutdownSound(); I_ShutdownMusic(); - M_SaveDefaults (); I_ShutdownGraphics(); exit(0); } -void I_WaitVBL(int count) + +void +I_WaitVBL(int count) { -#ifdef SGI - sginap(1); -#else -#ifdef SUN - sleep(0); -#else usleep (count * (1000000/70) ); -#endif -#endif -} -void I_BeginRead(void) -{ -} -void I_EndRead(void) -{ -} -byte* I_AllocLow(int length) -{ - byte* mem; - mem = (byte *)malloc (length); - memset (mem,0,length); - return mem; } + extern boolean demorecording; -void I_Error (char *error, ...) + +void +I_Error(char *error, ...) { va_list argptr; - va_start (argptr,error); - fprintf (stderr, "Error: "); - vfprintf (stderr,error,argptr); - fprintf (stderr, "\n"); - va_end (argptr); - fflush( stderr ); + int i; + + va_start(argptr,error); + fprintf(stderr, "Error: "); + vfprintf(stderr,error,argptr); + fprintf(stderr, "\n"); + va_end(argptr); + fflush(stderr); if (demorecording) - G_CheckDemoStatus(); - D_QuitNetGame (); + G_CheckDemoStatus(); + D_QuitNetGame(); I_ShutdownGraphics(); - exit(-1); + i = *(int*)0; + exit(i); } diff --git a/src/i_system.h b/src/i_system.h @@ -1,18 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_SYSTEM__ #define __I_SYSTEM__ + #include "d_ticcmd.h" #include "d_event.h" + #ifdef __GNUG__ #pragma interface #endif + + + void I_Init (void); + + + + byte* I_ZoneBase (int *size); + + + + int I_GetTime (void); + + + + + + + + + + void I_StartFrame (void); + + + + + + + void I_StartTic (void); + + + + + + + + + ticcmd_t* I_BaseTiccmd (void); + + + + void I_Quit (void); + + + + byte* I_AllocLow (int length); + void I_Tactile (int on, int off, int total); + + void I_Error (char *error, ...); + + #endif + + + + + diff --git a/src/i_video.h b/src/i_video.h @@ -1,16 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_VIDEO__ #define __I_VIDEO__ -#include "doomtype.h" + + +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + void I_InitGraphics (void); + + void I_ShutdownGraphics(void); + + void I_SetPalette (byte* palette); + void I_UpdateNoBlit (void); void I_FinishUpdate (void); + + void I_WaitVBL(int count); + void I_ReadScreen (byte* scr); + void I_BeginRead (void); void I_EndRead (void); + + + #endif + + + + + diff --git a/src/info.c b/src/info.c @@ -1,11 +1,9 @@ #include "sounds.h" #include "m_fixed.h" -#ifdef __GNUG__ -#pragma implementation "info.h" -#endif #include "info.h" #include "p_mobj.h" -char *sprnames[NUMSPRITES] = { + +char* sprnames[NUMSPRITES] = { "TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG", "MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2", "PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS", @@ -21,7 +19,8 @@ char *sprnames[NUMSPRITES] = { "COL5","TBLU","TGRN","TRED","SMBT","SMGT","SMRT","HDB1","HDB2","HDB3", "HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2" }; -void A_Light0(); + +void A_Light0(); void A_WeaponReady(); void A_Lower(); void A_Raise(); @@ -95,6 +94,7 @@ void A_BrainSpit(); void A_SpawnSound(); void A_SpawnFly(); void A_BrainExplode(); + state_t states[NUMSTATES] = { {SPR_TROO,0,-1,{NULL},S_NULL,0,0}, {SPR_SHTG,4,0,{A_Light0},S_NULL,0,0}, @@ -1064,3430 +1064,3568 @@ state_t states[NUMSTATES] = { {SPR_TLP2,32770,4,{NULL},S_TECH2LAMP4,0,0}, {SPR_TLP2,32771,4,{NULL},S_TECH2LAMP,0,0} }; + + mobjinfo_t mobjinfo[NUMMOBJTYPES] = { { - -1, - S_PLAY, - 100, - S_PLAY_RUN1, - sfx_None, - 0, - sfx_None, - S_PLAY_PAIN, - 255, - sfx_plpain, - S_NULL, - S_PLAY_ATK1, - S_PLAY_DIE1, - S_PLAY_XDIE1, - sfx_pldeth, - 0, - 16*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, - S_NULL - }, - { - 3004, - S_POSS_STND, - 20, - S_POSS_RUN1, - sfx_posit1, - 8, - sfx_pistol, - S_POSS_PAIN, - 200, - sfx_popain, - 0, - S_POSS_ATK1, - S_POSS_DIE1, - S_POSS_XDIE1, - sfx_podth1, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_POSS_RAISE1 - }, - { - 9, - S_SPOS_STND, - 30, - S_SPOS_RUN1, - sfx_posit2, - 8, - 0, - S_SPOS_PAIN, - 170, - sfx_popain, - 0, - S_SPOS_ATK1, - S_SPOS_DIE1, - S_SPOS_XDIE1, - sfx_podth2, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SPOS_RAISE1 - }, - { - 64, - S_VILE_STND, - 700, - S_VILE_RUN1, - sfx_vilsit, - 8, - 0, - S_VILE_PAIN, - 10, - sfx_vipain, - 0, - S_VILE_ATK1, - S_VILE_DIE1, - S_NULL, - sfx_vildth, - 15, - 20*FRACUNIT, - 56*FRACUNIT, - 500, - 0, - sfx_vilact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - -1, - S_FIRE1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 66, - S_SKEL_STND, - 300, - S_SKEL_RUN1, - sfx_skesit, - 8, - 0, - S_SKEL_PAIN, - 100, - sfx_popain, - S_SKEL_FIST1, - S_SKEL_MISS1, - S_SKEL_DIE1, - S_NULL, - sfx_skedth, - 10, - 20*FRACUNIT, - 56*FRACUNIT, - 500, - 0, - sfx_skeact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SKEL_RAISE1 - }, - { - -1, - S_TRACER, - 1000, - S_NULL, - sfx_skeatk, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_TRACEEXP1, - S_NULL, - sfx_barexp, - 10*FRACUNIT, - 11*FRACUNIT, - 8*FRACUNIT, - 100, - 10, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_SMOKE1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 67, - S_FATT_STND, - 600, - S_FATT_RUN1, - sfx_mansit, - 8, - 0, - S_FATT_PAIN, - 80, - sfx_mnpain, - 0, - S_FATT_ATK1, - S_FATT_DIE1, - S_NULL, - sfx_mandth, - 8, - 48*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_FATT_RAISE1 - }, - { - -1, - S_FATSHOT1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_FATSHOTX1, - S_NULL, - sfx_firxpl, - 20*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 8, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - 65, - S_CPOS_STND, - 70, - S_CPOS_RUN1, - sfx_posit2, - 8, - 0, - S_CPOS_PAIN, - 170, - sfx_popain, - 0, - S_CPOS_ATK1, - S_CPOS_DIE1, - S_CPOS_XDIE1, - sfx_podth2, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_CPOS_RAISE1 - }, - { - 3001, - S_TROO_STND, - 60, - S_TROO_RUN1, - sfx_bgsit1, - 8, - 0, - S_TROO_PAIN, - 200, - sfx_popain, - S_TROO_ATK1, - S_TROO_ATK1, - S_TROO_DIE1, - S_TROO_XDIE1, - sfx_bgdth1, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_bgact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_TROO_RAISE1 - }, - { - 3002, - S_SARG_STND, - 150, - S_SARG_RUN1, - sfx_sgtsit, - 8, - sfx_sgtatk, - S_SARG_PAIN, - 180, - sfx_dmpain, - S_SARG_ATK1, - 0, - S_SARG_DIE1, - S_NULL, - sfx_sgtdth, - 10, - 30*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SARG_RAISE1 - }, - { - 58, - S_SARG_STND, - 150, - S_SARG_RUN1, - sfx_sgtsit, - 8, - sfx_sgtatk, - S_SARG_PAIN, - 180, - sfx_dmpain, - S_SARG_ATK1, - 0, - S_SARG_DIE1, - S_NULL, - sfx_sgtdth, - 10, - 30*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_SHADOW|MF_COUNTKILL, - S_SARG_RAISE1 - }, - { - 3005, - S_HEAD_STND, - 400, - S_HEAD_RUN1, - sfx_cacsit, - 8, - 0, - S_HEAD_PAIN, - 128, - sfx_dmpain, - 0, - S_HEAD_ATK1, - S_HEAD_DIE1, - S_NULL, - sfx_cacdth, - 8, - 31*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, - S_HEAD_RAISE1 - }, - { - 3003, - S_BOSS_STND, - 1000, - S_BOSS_RUN1, - sfx_brssit, - 8, - 0, - S_BOSS_PAIN, - 50, - sfx_dmpain, - S_BOSS_ATK1, - S_BOSS_ATK1, - S_BOSS_DIE1, - S_NULL, - sfx_brsdth, - 8, - 24*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BOSS_RAISE1 - }, - { - -1, - S_BRBALL1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_BRBALLX1, - S_NULL, - sfx_firxpl, - 15*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 8, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - 69, - S_BOS2_STND, - 500, - S_BOS2_RUN1, - sfx_kntsit, - 8, - 0, - S_BOS2_PAIN, - 50, - sfx_dmpain, - S_BOS2_ATK1, - S_BOS2_ATK1, - S_BOS2_DIE1, - S_NULL, - sfx_kntdth, - 8, - 24*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BOS2_RAISE1 - }, - { - 3006, - S_SKULL_STND, - 100, - S_SKULL_RUN1, - 0, - 8, - sfx_sklatk, - S_SKULL_PAIN, - 256, - sfx_dmpain, - 0, - S_SKULL_ATK1, - S_SKULL_DIE1, - S_NULL, - sfx_firxpl, - 8, - 16*FRACUNIT, - 56*FRACUNIT, - 50, - 3, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY, - S_NULL - }, - { - 7, - S_SPID_STND, - 3000, - S_SPID_RUN1, - sfx_spisit, - 8, - sfx_shotgn, - S_SPID_PAIN, - 40, - sfx_dmpain, - 0, - S_SPID_ATK1, - S_SPID_DIE1, - S_NULL, - sfx_spidth, - 12, - 128*FRACUNIT, - 100*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 68, - S_BSPI_STND, - 500, - S_BSPI_SIGHT, - sfx_bspsit, - 8, - 0, - S_BSPI_PAIN, - 128, - sfx_dmpain, - 0, - S_BSPI_ATK1, - S_BSPI_DIE1, - S_NULL, - sfx_bspdth, - 12, - 64*FRACUNIT, - 64*FRACUNIT, - 600, - 0, - sfx_bspact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BSPI_RAISE1 - }, - { - 16, - S_CYBER_STND, - 4000, - S_CYBER_RUN1, - sfx_cybsit, - 8, - 0, - S_CYBER_PAIN, - 20, - sfx_dmpain, - 0, - S_CYBER_ATK1, - S_CYBER_DIE1, - S_NULL, - sfx_cybdth, - 16, - 40*FRACUNIT, - 110*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 71, - S_PAIN_STND, - 400, - S_PAIN_RUN1, - sfx_pesit, - 8, - 0, - S_PAIN_PAIN, - 128, - sfx_pepain, - 0, - S_PAIN_ATK1, - S_PAIN_DIE1, - S_NULL, - sfx_pedth, - 8, - 31*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, - S_PAIN_RAISE1 - }, - { - 84, - S_SSWV_STND, - 50, - S_SSWV_RUN1, - sfx_sssit, - 8, - 0, - S_SSWV_PAIN, - 170, - sfx_popain, - 0, - S_SSWV_ATK1, - S_SSWV_DIE1, - S_SSWV_XDIE1, - sfx_ssdth, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SSWV_RAISE1 - }, - { - 72, - S_KEENSTND, - 100, - S_NULL, - sfx_None, - 8, - sfx_None, - S_KEENPAIN, - 256, - sfx_keenpn, - S_NULL, - S_NULL, - S_COMMKEEN, - S_NULL, - sfx_keendt, - 0, - 16*FRACUNIT, - 72*FRACUNIT, - 10000000, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 88, - S_BRAIN, - 250, - S_NULL, - sfx_None, - 8, - sfx_None, - S_BRAIN_PAIN, - 255, - sfx_bospn, - S_NULL, - S_NULL, - S_BRAIN_DIE1, - S_NULL, - sfx_bosdth, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 10000000, - 0, - sfx_None, - MF_SOLID|MF_SHOOTABLE, - S_NULL - }, - { - 89, - S_BRAINEYE, - 1000, - S_BRAINEYESEE, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 32*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOSECTOR, - S_NULL - }, - { - 87, - S_NULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 32*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOSECTOR, - S_NULL - }, - { - -1, - S_SPAWN1, - 1000, - S_NULL, - sfx_bospit, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_firxpl, - 10*FRACUNIT, - 6*FRACUNIT, - 32*FRACUNIT, - 100, - 3, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY|MF_NOCLIP, - S_NULL - }, - { - -1, - S_SPAWNFIRE1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 2035, - S_BAR1, - 20, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_BEXP, - S_NULL, - sfx_barexp, - 0, - 10*FRACUNIT, - 42*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SHOOTABLE|MF_NOBLOOD, - S_NULL - }, - { - -1, - S_TBALL1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_TBALLX1, - S_NULL, - sfx_firxpl, - 10*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 3, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_RBALL1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_RBALLX1, - S_NULL, - sfx_firxpl, - 10*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 5, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_ROCKET, - 1000, - S_NULL, - sfx_rlaunc, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_EXPLODE1, - S_NULL, - sfx_barexp, - 20*FRACUNIT, - 11*FRACUNIT, - 8*FRACUNIT, - 100, - 20, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_PLASBALL, - 1000, - S_NULL, - sfx_plasma, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_PLASEXP, - S_NULL, - sfx_firxpl, - 25*FRACUNIT, - 13*FRACUNIT, - 8*FRACUNIT, - 100, - 5, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_BFGSHOT, - 1000, - S_NULL, - 0, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_BFGLAND, - S_NULL, - sfx_rxplod, - 25*FRACUNIT, - 13*FRACUNIT, - 8*FRACUNIT, - 100, - 100, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_ARACH_PLAZ, - 1000, - S_NULL, - sfx_plasma, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_ARACH_PLEX, - S_NULL, - sfx_firxpl, - 25*FRACUNIT, - 13*FRACUNIT, - 8*FRACUNIT, - 100, - 5, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_PUFF1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_BLOOD1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP, - S_NULL - }, - { - -1, - S_TFOG, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_IFOG, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 14, - S_NULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOSECTOR, - S_NULL - }, - { - -1, - S_BFGEXP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 2018, - S_ARM1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2019, - S_ARM2, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2014, - S_BON1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2015, - S_BON2, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 5, - S_BKEY, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 13, - S_RKEY, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 6, - S_YKEY, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 39, - S_YSKULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 38, - S_RSKULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 40, - S_BSKULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_NOTDMATCH, - S_NULL - }, - { - 2011, - S_STIM, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2012, - S_MEDI, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2013, - S_SOUL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2022, - S_PINV, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2023, - S_PSTR, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2024, - S_PINS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2025, - S_SUIT, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2026, - S_PMAP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2045, - S_PVIS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 83, - S_MEGA, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL|MF_COUNTITEM, - S_NULL - }, - { - 2007, - S_CLIP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2048, - S_AMMO, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2010, - S_ROCK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2046, - S_BROK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2047, - S_CELL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 17, - S_CELP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2008, - S_SHEL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2049, - S_SBOX, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 8, - S_BPAK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2006, - S_BFUG, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2002, - S_MGUN, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2005, - S_CSAW, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2003, - S_LAUN, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2004, - S_PLAS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 2001, - S_SHOT, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 82, - S_SHOT2, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPECIAL, - S_NULL - }, - { - 85, - S_TECHLAMP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 86, - S_TECH2LAMP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 2028, - S_COLU, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 30, - S_TALLGRNCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 31, - S_SHRTGRNCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 32, - S_TALLREDCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 33, - S_SHRTREDCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 37, - S_SKULLCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 36, - S_HEARTCOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 41, - S_EVILEYE, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 42, - S_FLOATSKULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 43, - S_TORCHTREE, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 44, - S_BLUETORCH, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 45, - S_GREENTORCH, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 46, - S_REDTORCH, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 55, - S_BTORCHSHRT, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 56, - S_GTORCHSHRT, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 57, - S_RTORCHSHRT, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 47, - S_STALAGTITE, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 48, - S_TECHPILLAR, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 34, - S_CANDLESTIK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 35, - S_CANDELABRA, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 49, - S_BLOODYTWITCH, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 68*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 50, - S_MEAT2, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 84*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 51, - S_MEAT3, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 84*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 52, - S_MEAT4, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 68*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 53, - S_MEAT5, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 52*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 59, - S_MEAT2, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 84*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 60, - S_MEAT4, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 68*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 61, - S_MEAT3, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 52*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 62, - S_MEAT5, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 52*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 63, - S_BLOODYTWITCH, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 68*FRACUNIT, - 100, - 0, - sfx_None, - MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 22, - S_HEAD_DIE6, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 15, - S_PLAY_DIE7, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 18, - S_POSS_DIE5, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 21, - S_SARG_DIE6, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 23, - S_SKULL_DIE6, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 20, - S_TROO_DIE5, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 19, - S_SPOS_DIE5, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 10, - S_PLAY_XDIE9, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 12, - S_PLAY_XDIE9, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 28, - S_HEADSONSTICK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 24, - S_GIBS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - 0, - S_NULL - }, - { - 27, - S_HEADONASTICK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 29, - S_HEADCANDLES, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 25, - S_DEADSTICK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 26, - S_LIVESTICK, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 54, - S_BIGTREE, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 32*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 70, - S_BBAR1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID, - S_NULL - }, - { - 73, - S_HANGNOGUTS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 88*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 74, - S_HANGBNOBRAIN, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 88*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 75, - S_HANGTLOOKDN, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 64*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 76, - S_HANGTSKULL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 64*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 77, - S_HANGTLOOKUP, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 64*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 78, - S_HANGTNOBRAIN, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 16*FRACUNIT, - 64*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, - S_NULL - }, - { - 79, - S_COLONGIBS, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP, - S_NULL - }, - { - 80, - S_SMALLPOOL, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP, - S_NULL - }, - { - 81, - S_BRAINSTEM, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP, - S_NULL + -1, + S_PLAY, + 100, + S_PLAY_RUN1, + sfx_None, + 0, + sfx_None, + S_PLAY_PAIN, + 255, + sfx_plpain, + S_NULL, + S_PLAY_ATK1, + S_PLAY_DIE1, + S_PLAY_XDIE1, + sfx_pldeth, + 0, + 16*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, + S_NULL + }, + + { + 3004, + S_POSS_STND, + 20, + S_POSS_RUN1, + sfx_posit1, + 8, + sfx_pistol, + S_POSS_PAIN, + 200, + sfx_popain, + 0, + S_POSS_ATK1, + S_POSS_DIE1, + S_POSS_XDIE1, + sfx_podth1, + 8, + 20*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_posact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_POSS_RAISE1 + }, + + { + 9, + S_SPOS_STND, + 30, + S_SPOS_RUN1, + sfx_posit2, + 8, + 0, + S_SPOS_PAIN, + 170, + sfx_popain, + 0, + S_SPOS_ATK1, + S_SPOS_DIE1, + S_SPOS_XDIE1, + sfx_podth2, + 8, + 20*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_posact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_SPOS_RAISE1 + }, + + { + 64, + S_VILE_STND, + 700, + S_VILE_RUN1, + sfx_vilsit, + 8, + 0, + S_VILE_PAIN, + 10, + sfx_vipain, + 0, + S_VILE_ATK1, + S_VILE_DIE1, + S_NULL, + sfx_vildth, + 15, + 20*FRACUNIT, + 56*FRACUNIT, + 500, + 0, + sfx_vilact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_NULL + }, + + { + -1, + S_FIRE1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + 66, + S_SKEL_STND, + 300, + S_SKEL_RUN1, + sfx_skesit, + 8, + 0, + S_SKEL_PAIN, + 100, + sfx_popain, + S_SKEL_FIST1, + S_SKEL_MISS1, + S_SKEL_DIE1, + S_NULL, + sfx_skedth, + 10, + 20*FRACUNIT, + 56*FRACUNIT, + 500, + 0, + sfx_skeact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_SKEL_RAISE1 + }, + + { + -1, + S_TRACER, + 1000, + S_NULL, + sfx_skeatk, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_TRACEEXP1, + S_NULL, + sfx_barexp, + 10*FRACUNIT, + 11*FRACUNIT, + 8*FRACUNIT, + 100, + 10, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_SMOKE1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + 67, + S_FATT_STND, + 600, + S_FATT_RUN1, + sfx_mansit, + 8, + 0, + S_FATT_PAIN, + 80, + sfx_mnpain, + 0, + S_FATT_ATK1, + S_FATT_DIE1, + S_NULL, + sfx_mandth, + 8, + 48*FRACUNIT, + 64*FRACUNIT, + 1000, + 0, + sfx_posact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_FATT_RAISE1 + }, + + { + -1, + S_FATSHOT1, + 1000, + S_NULL, + sfx_firsht, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_FATSHOTX1, + S_NULL, + sfx_firxpl, + 20*FRACUNIT, + 6*FRACUNIT, + 8*FRACUNIT, + 100, + 8, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + 65, + S_CPOS_STND, + 70, + S_CPOS_RUN1, + sfx_posit2, + 8, + 0, + S_CPOS_PAIN, + 170, + sfx_popain, + 0, + S_CPOS_ATK1, + S_CPOS_DIE1, + S_CPOS_XDIE1, + sfx_podth2, + 8, + 20*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_posact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_CPOS_RAISE1 + }, + + { + 3001, + S_TROO_STND, + 60, + S_TROO_RUN1, + sfx_bgsit1, + 8, + 0, + S_TROO_PAIN, + 200, + sfx_popain, + S_TROO_ATK1, + S_TROO_ATK1, + S_TROO_DIE1, + S_TROO_XDIE1, + sfx_bgdth1, + 8, + 20*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_bgact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_TROO_RAISE1 + }, + + { + 3002, + S_SARG_STND, + 150, + S_SARG_RUN1, + sfx_sgtsit, + 8, + sfx_sgtatk, + S_SARG_PAIN, + 180, + sfx_dmpain, + S_SARG_ATK1, + 0, + S_SARG_DIE1, + S_NULL, + sfx_sgtdth, + 10, + 30*FRACUNIT, + 56*FRACUNIT, + 400, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_SARG_RAISE1 + }, + + { + 58, + S_SARG_STND, + 150, + S_SARG_RUN1, + sfx_sgtsit, + 8, + sfx_sgtatk, + S_SARG_PAIN, + 180, + sfx_dmpain, + S_SARG_ATK1, + 0, + S_SARG_DIE1, + S_NULL, + sfx_sgtdth, + 10, + 30*FRACUNIT, + 56*FRACUNIT, + 400, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_SHADOW|MF_COUNTKILL, + S_SARG_RAISE1 + }, + + { + 3005, + S_HEAD_STND, + 400, + S_HEAD_RUN1, + sfx_cacsit, + 8, + 0, + S_HEAD_PAIN, + 128, + sfx_dmpain, + 0, + S_HEAD_ATK1, + S_HEAD_DIE1, + S_NULL, + sfx_cacdth, + 8, + 31*FRACUNIT, + 56*FRACUNIT, + 400, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, + S_HEAD_RAISE1 + }, + + { + 3003, + S_BOSS_STND, + 1000, + S_BOSS_RUN1, + sfx_brssit, + 8, + 0, + S_BOSS_PAIN, + 50, + sfx_dmpain, + S_BOSS_ATK1, + S_BOSS_ATK1, + S_BOSS_DIE1, + S_NULL, + sfx_brsdth, + 8, + 24*FRACUNIT, + 64*FRACUNIT, + 1000, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_BOSS_RAISE1 + }, + + { + -1, + S_BRBALL1, + 1000, + S_NULL, + sfx_firsht, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_BRBALLX1, + S_NULL, + sfx_firxpl, + 15*FRACUNIT, + 6*FRACUNIT, + 8*FRACUNIT, + 100, + 8, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + 69, + S_BOS2_STND, + 500, + S_BOS2_RUN1, + sfx_kntsit, + 8, + 0, + S_BOS2_PAIN, + 50, + sfx_dmpain, + S_BOS2_ATK1, + S_BOS2_ATK1, + S_BOS2_DIE1, + S_NULL, + sfx_kntdth, + 8, + 24*FRACUNIT, + 64*FRACUNIT, + 1000, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_BOS2_RAISE1 + }, + + { + 3006, + S_SKULL_STND, + 100, + S_SKULL_RUN1, + 0, + 8, + sfx_sklatk, + S_SKULL_PAIN, + 256, + sfx_dmpain, + 0, + S_SKULL_ATK1, + S_SKULL_DIE1, + S_NULL, + sfx_firxpl, + 8, + 16*FRACUNIT, + 56*FRACUNIT, + 50, + 3, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY, + S_NULL + }, + + { + 7, + S_SPID_STND, + 3000, + S_SPID_RUN1, + sfx_spisit, + 8, + sfx_shotgn, + S_SPID_PAIN, + 40, + sfx_dmpain, + 0, + S_SPID_ATK1, + S_SPID_DIE1, + S_NULL, + sfx_spidth, + 12, + 128*FRACUNIT, + 100*FRACUNIT, + 1000, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_NULL + }, + + { + 68, + S_BSPI_STND, + 500, + S_BSPI_SIGHT, + sfx_bspsit, + 8, + 0, + S_BSPI_PAIN, + 128, + sfx_dmpain, + 0, + S_BSPI_ATK1, + S_BSPI_DIE1, + S_NULL, + sfx_bspdth, + 12, + 64*FRACUNIT, + 64*FRACUNIT, + 600, + 0, + sfx_bspact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_BSPI_RAISE1 + }, + + { + 16, + S_CYBER_STND, + 4000, + S_CYBER_RUN1, + sfx_cybsit, + 8, + 0, + S_CYBER_PAIN, + 20, + sfx_dmpain, + 0, + S_CYBER_ATK1, + S_CYBER_DIE1, + S_NULL, + sfx_cybdth, + 16, + 40*FRACUNIT, + 110*FRACUNIT, + 1000, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_NULL + }, + + { + 71, + S_PAIN_STND, + 400, + S_PAIN_RUN1, + sfx_pesit, + 8, + 0, + S_PAIN_PAIN, + 128, + sfx_pepain, + 0, + S_PAIN_ATK1, + S_PAIN_DIE1, + S_NULL, + sfx_pedth, + 8, + 31*FRACUNIT, + 56*FRACUNIT, + 400, + 0, + sfx_dmact, + MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, + S_PAIN_RAISE1 + }, + + { + 84, + S_SSWV_STND, + 50, + S_SSWV_RUN1, + sfx_sssit, + 8, + 0, + S_SSWV_PAIN, + 170, + sfx_popain, + 0, + S_SSWV_ATK1, + S_SSWV_DIE1, + S_SSWV_XDIE1, + sfx_ssdth, + 8, + 20*FRACUNIT, + 56*FRACUNIT, + 100, + 0, + sfx_posact, + MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, + S_SSWV_RAISE1 + }, + + { + 72, + S_KEENSTND, + 100, + S_NULL, + sfx_None, + 8, + sfx_None, + S_KEENPAIN, + 256, + sfx_keenpn, + S_NULL, + S_NULL, + S_COMMKEEN, + S_NULL, + sfx_keendt, + 0, + 16*FRACUNIT, + 72*FRACUNIT, + 10000000, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY|MF_SHOOTABLE|MF_COUNTKILL, + S_NULL + }, + + { + 88, + S_BRAIN, + 250, + S_NULL, + sfx_None, + 8, + sfx_None, + S_BRAIN_PAIN, + 255, + sfx_bospn, + S_NULL, + S_NULL, + S_BRAIN_DIE1, + S_NULL, + sfx_bosdth, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 10000000, + 0, + sfx_None, + MF_SOLID|MF_SHOOTABLE, + S_NULL + }, + + { + 89, + S_BRAINEYE, + 1000, + S_BRAINEYESEE, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 32*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOSECTOR, + S_NULL + }, + + { + 87, + S_NULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 32*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOSECTOR, + S_NULL + }, + + { + -1, + S_SPAWN1, + 1000, + S_NULL, + sfx_bospit, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_firxpl, + 10*FRACUNIT, + 6*FRACUNIT, + 32*FRACUNIT, + 100, + 3, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY|MF_NOCLIP, + S_NULL + }, + + { + -1, + S_SPAWNFIRE1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + 2035, + S_BAR1, + 20, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_BEXP, + S_NULL, + sfx_barexp, + 0, + 10*FRACUNIT, + 42*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SHOOTABLE|MF_NOBLOOD, + S_NULL + }, + + { + -1, + S_TBALL1, + 1000, + S_NULL, + sfx_firsht, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_TBALLX1, + S_NULL, + sfx_firxpl, + 10*FRACUNIT, + 6*FRACUNIT, + 8*FRACUNIT, + 100, + 3, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_RBALL1, + 1000, + S_NULL, + sfx_firsht, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_RBALLX1, + S_NULL, + sfx_firxpl, + 10*FRACUNIT, + 6*FRACUNIT, + 8*FRACUNIT, + 100, + 5, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_ROCKET, + 1000, + S_NULL, + sfx_rlaunc, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_EXPLODE1, + S_NULL, + sfx_barexp, + 20*FRACUNIT, + 11*FRACUNIT, + 8*FRACUNIT, + 100, + 20, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_PLASBALL, + 1000, + S_NULL, + sfx_plasma, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_PLASEXP, + S_NULL, + sfx_firxpl, + 25*FRACUNIT, + 13*FRACUNIT, + 8*FRACUNIT, + 100, + 5, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_BFGSHOT, + 1000, + S_NULL, + 0, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_BFGLAND, + S_NULL, + sfx_rxplod, + 25*FRACUNIT, + 13*FRACUNIT, + 8*FRACUNIT, + 100, + 100, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_ARACH_PLAZ, + 1000, + S_NULL, + sfx_plasma, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_ARACH_PLEX, + S_NULL, + sfx_firxpl, + 25*FRACUNIT, + 13*FRACUNIT, + 8*FRACUNIT, + 100, + 5, + sfx_None, + MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_PUFF1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_BLOOD1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP, + S_NULL + }, + + { + -1, + S_TFOG, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + -1, + S_IFOG, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + 14, + S_NULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOSECTOR, + S_NULL + }, + + { + -1, + S_BFGEXP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP|MF_NOGRAVITY, + S_NULL + }, + + { + 2018, + S_ARM1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2019, + S_ARM2, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2014, + S_BON1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2015, + S_BON2, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 5, + S_BKEY, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 13, + S_RKEY, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 6, + S_YKEY, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 39, + S_YSKULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 38, + S_RSKULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 40, + S_BSKULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_NOTDMATCH, + S_NULL + }, + + { + 2011, + S_STIM, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2012, + S_MEDI, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2013, + S_SOUL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2022, + S_PINV, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2023, + S_PSTR, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2024, + S_PINS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2025, + S_SUIT, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2026, + S_PMAP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2045, + S_PVIS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 83, + S_MEGA, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL|MF_COUNTITEM, + S_NULL + }, + + { + 2007, + S_CLIP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2048, + S_AMMO, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2010, + S_ROCK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2046, + S_BROK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2047, + S_CELL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 17, + S_CELP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2008, + S_SHEL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2049, + S_SBOX, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 8, + S_BPAK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2006, + S_BFUG, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2002, + S_MGUN, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2005, + S_CSAW, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2003, + S_LAUN, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2004, + S_PLAS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 2001, + S_SHOT, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 82, + S_SHOT2, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPECIAL, + S_NULL + }, + + { + 85, + S_TECHLAMP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 86, + S_TECH2LAMP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 2028, + S_COLU, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 30, + S_TALLGRNCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 31, + S_SHRTGRNCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 32, + S_TALLREDCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 33, + S_SHRTREDCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 37, + S_SKULLCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 36, + S_HEARTCOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 41, + S_EVILEYE, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 42, + S_FLOATSKULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 43, + S_TORCHTREE, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 44, + S_BLUETORCH, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 45, + S_GREENTORCH, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 46, + S_REDTORCH, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 55, + S_BTORCHSHRT, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 56, + S_GTORCHSHRT, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 57, + S_RTORCHSHRT, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 47, + S_STALAGTITE, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 48, + S_TECHPILLAR, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 34, + S_CANDLESTIK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 35, + S_CANDELABRA, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 49, + S_BLOODYTWITCH, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 68*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 50, + S_MEAT2, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 84*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 51, + S_MEAT3, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 84*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 52, + S_MEAT4, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 68*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 53, + S_MEAT5, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 52*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 59, + S_MEAT2, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 84*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 60, + S_MEAT4, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 68*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 61, + S_MEAT3, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 52*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 62, + S_MEAT5, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 52*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 63, + S_BLOODYTWITCH, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 68*FRACUNIT, + 100, + 0, + sfx_None, + MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 22, + S_HEAD_DIE6, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 15, + S_PLAY_DIE7, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 18, + S_POSS_DIE5, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 21, + S_SARG_DIE6, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 23, + S_SKULL_DIE6, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 20, + S_TROO_DIE5, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 19, + S_SPOS_DIE5, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 10, + S_PLAY_XDIE9, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 12, + S_PLAY_XDIE9, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 28, + S_HEADSONSTICK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 24, + S_GIBS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + 0, + S_NULL + }, + + { + 27, + S_HEADONASTICK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 29, + S_HEADCANDLES, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 25, + S_DEADSTICK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 26, + S_LIVESTICK, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 54, + S_BIGTREE, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 32*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 70, + S_BBAR1, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID, + S_NULL + }, + + { + 73, + S_HANGNOGUTS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 88*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 74, + S_HANGBNOBRAIN, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 88*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 75, + S_HANGTLOOKDN, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 64*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 76, + S_HANGTSKULL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 64*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 77, + S_HANGTLOOKUP, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 64*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 78, + S_HANGTNOBRAIN, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 16*FRACUNIT, + 64*FRACUNIT, + 100, + 0, + sfx_None, + MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, + S_NULL + }, + + { + 79, + S_COLONGIBS, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP, + S_NULL + }, + + { + 80, + S_SMALLPOOL, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP, + S_NULL + }, + + { + 81, + S_BRAINSTEM, + 1000, + S_NULL, + sfx_None, + 8, + sfx_None, + S_NULL, + 0, + sfx_None, + S_NULL, + S_NULL, + S_NULL, + S_NULL, + sfx_None, + 0, + 20*FRACUNIT, + 16*FRACUNIT, + 100, + 0, + sfx_None, + MF_NOBLOCKMAP, + S_NULL } }; diff --git a/src/info.h b/src/info.h @@ -1,8 +1,13 @@ #ifndef __INFO__ #define __INFO__ + #include "d_think.h" -typedef enum -{ + +typedef struct state_t state_t; +typedef struct mobjinfo_t mobjinfo_t; + + +typedef enum { SPR_TROO, SPR_SHTG, SPR_PUNG, @@ -142,9 +147,9 @@ typedef enum SPR_TLMP, SPR_TLP2, NUMSPRITES -} spritenum_t; -typedef enum -{ +}spritenum_t; + +typedef enum { S_NULL, S_LIGHTDONE, S_PUNCH, @@ -1113,18 +1118,24 @@ typedef enum S_TECH2LAMP3, S_TECH2LAMP4, NUMSTATES -} statenum_t; -typedef struct -{ +}statenum_t; + + +struct state_t { spritenum_t sprite; long frame; long tics; + actionf_t action; statenum_t nextstate; long misc1, misc2; -} state_t; +}; + extern state_t states[NUMSTATES]; extern char *sprnames[NUMSPRITES]; + + + typedef enum { MT_PLAYER, MT_POSSESSED, @@ -1264,9 +1275,9 @@ typedef enum { MT_MISC85, MT_MISC86, NUMMOBJTYPES -} mobjtype_t; -typedef struct -{ +}mobjtype_t; + +struct mobjinfo_t { int doomednum; int spawnstate; int spawnhealth; @@ -1290,6 +1301,14 @@ typedef struct int activesound; int flags; int raisestate; -} mobjinfo_t; + +}; + extern mobjinfo_t mobjinfo[NUMMOBJTYPES]; + #endif + + + + + diff --git a/src/lang-gen.sh b/src/lang-gen.sh @@ -0,0 +1 @@ +awk 'BEGIN{print "enum {"} /\/\*/{print "\t" $(NF)} END{print "};"}' lang.c|sed 's/\/\*//;s/\*\///' diff --git a/src/lang.c b/src/lang.c @@ -0,0 +1,550 @@ +#include "doomdef.h" + +char* english[] = { + "NEWLEVEL" /*NEWLEVEL*/, + "press a key." /*PRESSKEY*/, + "press y or n." /*PRESSYN*/, + "Development mode ON.\n" /*D_DEVSTR*/, + "CD-ROM Version" /*D_CDROM*/, + "you can't do load while in a net game!\n\n" + "press a key." /*LOADNET*/, + "you can't quickload during a netgame!\n\n" + "press a key." /*QLOADNET*/, + "you haven't picked a quicksave slot yet!\n\n" + "press a key." /*QSAVESPOT*/, + "you can't save if you aren't playing!\n\n" + "press a key." /*SAVEDEAD*/, + "quicksave over your game named\n\n'%s'?\n\n" + "press y or n." /*QSPROMPT*/, + "do you want to quickload the game named\n\n'%s'?\n\n" + "press y or n." /*QLPROMPT*/, + "you can't start a new game\nwhile in a network game.\n\n" + "press a key." /*NEWGAME*/, + "are you sure? this skill level\nisn't even remotely fair.\n\n" + "press a key." /*NIGHTMARE*/, + "this is the shareware version of doom.\n\nyou need to order the entire trilogy.\n\n" + "press a key." /*SWSTRING*/, + "Messages OFF" /*MSGOFF*/, + "Messages ON" /*MSGON*/, + "you can't end a netgame!\n\n" + "press a key." /*NETEND*/, + "are you sure you want to end the game?\n\n" + "press a key." /*ENDGAME*/, + "(press y to quit)" /*DOSY*/, + "High detail" /*DETAILHI*/, + "Low detail" /*DETAILLO*/, + "Gamma correction OFF" /*GAMMALVL0*/, + "Gamma correction level 1" /*GAMMALVL1*/, + "Gamma correction level 2" /*GAMMALVL2*/, + "Gamma correction level 3" /*GAMMALVL3*/, + "Gamma correction level 4" /*GAMMALVL4*/, + "empty slot" /*EMPTYSTRING*/, + "Picked up the armor." /*GOTARMOR*/, + "Picked up the MegaArmor!" /*GOTMEGA*/, + "Picked up a health bonus." /*GOTHTHBONUS*/, + "Picked up an armor bonus." /*GOTARMBONUS*/, + "Picked up a stimpack." /*GOTSTIM*/, + "Picked up a medikit that you REALLY need!" /*GOTMEDINEED*/, + "Picked up a medikit." /*GOTMEDIKIT*/, + "Supercharge!" /*GOTSUPER*/, + "Picked up a blue keycard." /*GOTBLUECARD*/, + "Picked up a yellow keycard." /*GOTYELWCARD*/, + "Picked up a red keycard." /*GOTREDCARD*/, + "Picked up a blue skull key." /*GOTBLUESKUL*/, + "Picked up a yellow skull key." /*GOTYELWSKUL*/, + "Picked up a red skull key." /*GOTREDSKULL*/, + "Invulnerability!" /*GOTINVUL*/, + "Berserk!" /*GOTBERSERK*/, + "Partial Invisibility" /*GOTINVIS*/, + "Radiation Shielding Suit" /*GOTSUIT*/, + "Computer Area Map" /*GOTMAP*/, + "Light Amplification Visor" /*GOTVISOR*/, + "MegaSphere!" /*GOTMSPHERE*/, + "Picked up a clip." /*GOTCLIP*/, + "Picked up a box of bullets." /*GOTCLIPBOX*/, + "Picked up a rocket." /*GOTROCKET*/, + "Picked up a box of rockets." /*GOTROCKBOX*/, + "Picked up an energy cell." /*GOTCELL*/, + "Picked up an energy cell pack." /*GOTCELLBOX*/, + "Picked up 4 shotgun shells." /*GOTSHELLS*/, + "Picked up a box of shotgun shells." /*GOTSHELLBOX*/, + "Picked up a backpack full of ammo!" /*GOTBACKPACK*/, + "You got the BFG9000! Oh, yes." /*GOTBFG9000*/, + "You got the chaingun!" /*GOTCHAINGUN*/, + "A chainsaw! Find some meat!" /*GOTCHAINSAW*/, + "You got the rocket launcher!" /*GOTLAUNCHER*/, + "You got the plasma gun!" /*GOTPLASMA*/, + "You got the shotgun!" /*GOTSHOTGUN*/, + "You got the super shotgun!" /*GOTSHOTGUN2*/, + "You need a blue key to activate this object" /*PD_BLUEO*/, + "You need a red key to activate this object" /*PD_REDO*/, + "You need a yellow key to activate this object" /*PD_YELLOWO*/, + "You need a blue key to open this door" /*PD_BLUEK*/, + "You need a red key to open this door" /*PD_REDK*/, + "You need a yellow key to open this door" /*PD_YELLOWK*/, + "game saved." /*GGSAVED*/, + "[Message unsent]" /*HUSTR_MSGU*/, + "E1M1" /*HUSTR_E1M1*/, + "E1M2" /*HUSTR_E1M2*/, + "E1M3" /*HUSTR_E1M3*/, + "E1M4" /*HUSTR_E1M4*/, + "E1M5" /*HUSTR_E1M5*/, + "E1M6" /*HUSTR_E1M6*/, + "E1M7" /*HUSTR_E1M7*/, + "E1M8" /*HUSTR_E1M8*/, + "E1M9" /*HUSTR_E1M9*/, + "E2M1" /*HUSTR_E2M1*/, + "E2M2" /*HUSTR_E2M2*/, + "E2M3" /*HUSTR_E2M3*/, + "E2M4" /*HUSTR_E2M4*/, + "E2M5" /*HUSTR_E2M5*/, + "E2M6" /*HUSTR_E2M6*/, + "E2M7" /*HUSTR_E2M7*/, + "E2M8" /*HUSTR_E2M8*/, + "E2M9" /*HUSTR_E2M9*/, + "E3M1" /*HUSTR_E3M1*/, + "E3M2" /*HUSTR_E3M2*/, + "E3M3" /*HUSTR_E3M3*/, + "E3M4" /*HUSTR_E3M4*/, + "E3M5" /*HUSTR_E3M5*/, + "E3M6" /*HUSTR_E3M6*/, + "E3M7" /*HUSTR_E3M7*/, + "E3M8" /*HUSTR_E3M8*/, + "E3M9" /*HUSTR_E3M9*/, + "E4M1" /*HUSTR_E4M1*/, + "E4M2" /*HUSTR_E4M2*/, + "E4M3" /*HUSTR_E4M3*/, + "E4M4" /*HUSTR_E4M4*/, + "E4M5" /*HUSTR_E4M5*/, + "E4M6" /*HUSTR_E4M6*/, + "E4M7" /*HUSTR_E4M7*/, + "E4M8" /*HUSTR_E4M8*/, + "E4M9" /*HUSTR_E4M9*/, + "level 1" /*HUSTR_1*/, + "level 2" /*HUSTR_2*/, + "level 3" /*HUSTR_3*/, + "level 4" /*HUSTR_4*/, + "level 5" /*HUSTR_5*/, + "level 6" /*HUSTR_6*/, + "level 7" /*HUSTR_7*/, + "level 8" /*HUSTR_8*/, + "level 9" /*HUSTR_9*/, + "level 10" /*HUSTR_10*/, + "level 11" /*HUSTR_11*/, + "level 12" /*HUSTR_12*/, + "level 13" /*HUSTR_13*/, + "level 14" /*HUSTR_14*/, + "level 15" /*HUSTR_15*/, + "level 16" /*HUSTR_16*/, + "level 17" /*HUSTR_17*/, + "level 18" /*HUSTR_18*/, + "level 19" /*HUSTR_19*/, + "level 20" /*HUSTR_20*/, + "level 21" /*HUSTR_21*/, + "level 22" /*HUSTR_22*/, + "level 23" /*HUSTR_23*/, + "level 24" /*HUSTR_24*/, + "level 25" /*HUSTR_25*/, + "level 26" /*HUSTR_26*/, + "level 27" /*HUSTR_27*/, + "level 28" /*HUSTR_28*/, + "level 29" /*HUSTR_29*/, + "level 30" /*HUSTR_30*/, + "level 31" /*HUSTR_31*/, + "level 32" /*HUSTR_32*/, + "level 1" /*PHUSTR_1*/, + "level 2" /*PHUSTR_2*/, + "level 3" /*PHUSTR_3*/, + "level 4" /*PHUSTR_4*/, + "level 5" /*PHUSTR_5*/, + "level 6" /*PHUSTR_6*/, + "level 7" /*PHUSTR_7*/, + "level 8" /*PHUSTR_8*/, + "level 9" /*PHUSTR_9*/, + "level 10" /*PHUSTR_10*/, + "level 11" /*PHUSTR_11*/, + "level 12" /*PHUSTR_12*/, + "level 13" /*PHUSTR_13*/, + "level 14" /*PHUSTR_14*/, + "level 15" /*PHUSTR_15*/, + "level 16" /*PHUSTR_16*/, + "level 17" /*PHUSTR_17*/, + "level 18" /*PHUSTR_18*/, + "level 19" /*PHUSTR_19*/, + "level 20" /*PHUSTR_20*/, + "level 21" /*PHUSTR_21*/, + "level 22" /*PHUSTR_22*/, + "level 23" /*PHUSTR_23*/, + "level 24" /*PHUSTR_24*/, + "level 25" /*PHUSTR_25*/, + "level 26" /*PHUSTR_26*/, + "level 27" /*PHUSTR_27*/, + "level 28" /*PHUSTR_28*/, + "level 29" /*PHUSTR_29*/, + "level 30" /*PHUSTR_30*/, + "level 31" /*PHUSTR_31*/, + "level 32" /*PHUSTR_32*/, + "level 1" /*THUSTR_1*/, + "level 2" /*THUSTR_2*/, + "level 3" /*THUSTR_3*/, + "level 4" /*THUSTR_4*/, + "level 5" /*THUSTR_5*/, + "level 6" /*THUSTR_6*/, + "level 7" /*THUSTR_7*/, + "level 8" /*THUSTR_8*/, + "level 9" /*THUSTR_9*/, + "level 10" /*THUSTR_10*/, + "level 11" /*THUSTR_11*/, + "level 12" /*THUSTR_12*/, + "level 13" /*THUSTR_13*/, + "level 14" /*THUSTR_14*/, + "level 15" /*THUSTR_15*/, + "level 16" /*THUSTR_16*/, + "level 17" /*THUSTR_17*/, + "level 18" /*THUSTR_18*/, + "level 19" /*THUSTR_19*/, + "level 20" /*THUSTR_20*/, + "level 21" /*THUSTR_21*/, + "level 22" /*THUSTR_22*/, + "level 23" /*THUSTR_23*/, + "level 24" /*THUSTR_24*/, + "level 25" /*THUSTR_25*/, + "level 26" /*THUSTR_26*/, + "level 27" /*THUSTR_27*/, + "level 28" /*THUSTR_28*/, + "level 29" /*THUSTR_29*/, + "level 30" /*THUSTR_30*/, + "level 31" /*THUSTR_31*/, + "level 32" /*THUSTR_32*/, + "I'm ready to kick butt!" /*HUSTR_CHATMACRO1*/, + "I'm OK." /*HUSTR_CHATMACRO2*/, + "I'm not looking too good!" /*HUSTR_CHATMACRO3*/, + "Help!" /*HUSTR_CHATMACRO4*/, + "You suck!" /*HUSTR_CHATMACRO5*/, + "Next time, scumbag..." /*HUSTR_CHATMACRO6*/, + "Come here!" /*HUSTR_CHATMACRO7*/, + "I'll take care of it." /*HUSTR_CHATMACRO8*/, + "Yes" /*HUSTR_CHATMACRO9*/, + "No" /*HUSTR_CHATMACRO0*/, + "You mumble to yourself" /*HUSTR_TALKTOSELF1*/, + "Who's there?" /*HUSTR_TALKTOSELF2*/, + "You scare yourself" /*HUSTR_TALKTOSELF3*/, + "You start to rave" /*HUSTR_TALKTOSELF4*/, + "You've lost it..." /*HUSTR_TALKTOSELF5*/, + "[Message Sent]" /*HUSTR_MESSAGESENT*/, + "Green" /*HUSTR_PLRGREEN*/, + "Indigo" /*HUSTR_PLRINDIGO*/, + "Brown" /*HUSTR_PLRBROWN*/, + "Red" /*HUSTR_PLRRED*/, + "g" /*HUSTR_KEYGREEN*/, + "i" /*HUSTR_KEYINDIGO*/, + "b" /*HUSTR_KEYBROWN*/, + "r" /*HUSTR_KEYRED*/, + "Follow Mode ON" /*AMSTR_FOLLOWON*/, + "Follow Mode OFF" /*AMSTR_FOLLOWOFF*/, + "Grid ON" /*AMSTR_GRIDON*/, + "Grid OFF" /*AMSTR_GRIDOFF*/, + "Marked Spot" /*AMSTR_MARKEDSPOT*/, + "All Marks Cleared" /*AMSTR_MARKSCLEARED*/, + "Music Change" /*STSTR_MUS*/, + "IMPOSSIBLE SELECTION" /*STSTR_NOMUS*/, + "Degreelessness Mode On" /*STSTR_DQDON*/, + "Degreelessness Mode Off" /*STSTR_DQDOFF*/, + "Very Happy Ammo Added" /*STSTR_KFAADDED*/, + "Ammo (no keys) Added" /*STSTR_FAADDED*/, + "No Clipping Mode ON" /*STSTR_NCON*/, + "No Clipping Mode OFF" /*STSTR_NCOFF*/, + "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp" /*STSTR_BEHOLD*/, + "Power-up Toggled" /*STSTR_BEHOLDX*/, + "... doesn't suck - GM" /*STSTR_CHOPPERS*/, + "Changing Level..." /*STSTR_CLEV*/, + "Once you beat the big badasses and\n" + "clean out the moon base you're supposed\n" + "to win, aren't you? Aren't you? Where's\n" + "your fat reward and ticket home? What\n" + "the hell is this? It's not supposed to\n" + "end this way!\n" + "\n" + "It stinks like rotten meat, but looks\n" + "like the lost Deimos base. Looks like\n" + "you're stuck on The Shores of Hell.\n" + "The only way out is through.\n" + "\n" + "To continue the DOOM experience, play\n" + "The Shores of Hell and its amazing\n" + "sequel, Inferno!\n" /*E1TEXT*/, + "You've done it! The hideous cyber-\n" + "demon lord that ruled the lost Deimos\n" + "moon base has been slain and you\n" + "are triumphant! But ... where are\n" + "you? You clamber to the edge of the\n" + "moon and look down to see the awful\n" + "truth.\n" + "\n" + "Deimos floats above Hell itself!\n" + "You've never heard of anyone escaping\n" + "from Hell, but you'll make the bastards\n" + "sorry they ever heard of you! Quickly,\n" + "you rappel down to the surface of\n" + "Hell.\n" + "\n" + "Now, it's on to the final chapter of\n" + "DOOM! -- Inferno." /*E2TEXT*/, + "The loathsome spiderdemon that\n" + "masterminded the invasion of the moon\n" + "bases and caused so much death has had\n" + "its ass kicked for all time.\n" + "\n" + "A hidden doorway opens and you enter.\n" + "You've proven too tough for Hell to\n" + "contain, and now Hell at last plays\n" + "fair -- for you emerge from the door\n" + "to see the green fields of Earth!\n" + "Home at last.\n" + "\n" + "You wonder what's been happening on\n" + "Earth while you were battling evil\n" + "unleashed. It's good that no Hell-\n" + "spawn could have come through that\n" + "door with you ..." /*E3TEXT*/, + "the spider mastermind must have sent forth\n" + "its legions of hellspawn before your\n" + "final confrontation with that terrible\n" + "beast from hell. but you stepped forward\n" + "and brought forth eternal damnation and\n" + "suffering upon the horde as a true hero\n" + "would in the face of something so evil.\n" + "\n" + "besides, someone was gonna pay for what\n" + "happened to daisy, your pet rabbit.\n" + "\n" + "but now, you see spread before you more\n" + "potential pain and gibbitude as a nation\n" + "of demons run amok among our cities.\n" + "\n" + "next stop, hell on earth!" /*E4TEXT*/, + "YOU HAVE ENTERED DEEPLY INTO THE INFESTED\n" + "STARPORT. BUT SOMETHING IS WRONG. THE\n" + "MONSTERS HAVE BROUGHT THEIR OWN REALITY\n" + "WITH THEM, AND THE STARPORT'S TECHNOLOGY\n" + "IS BEING SUBVERTED BY THEIR PRESENCE.\n" + "\n" + "AHEAD, YOU SEE AN OUTPOST OF HELL, A\n" + "FORTIFIED ZONE. IF YOU CAN GET PAST IT,\n" + "YOU CAN PENETRATE INTO THE HAUNTED HEART\n" + "OF THE STARBASE AND FIND THE CONTROLLING\n" + "SWITCH WHICH HOLDS EARTH'S POPULATION\n" + "HOSTAGE." /*C1TEXT*/, + "YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" + "HUMANKIND TO EVACUATE EARTH AND ESCAPE\n" + "THE NIGHTMARE. NOW YOU ARE THE ONLY\n" + "HUMAN LEFT ON THE FACE OF THE PLANET.\n" + "CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n" + "AND EVIL SPIRITS ARE YOUR ONLY NEIGHBORS.\n" + "YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n" + "THAT YOU HAVE SAVED YOUR SPECIES.\n" + "\n" + "BUT THEN, EARTH CONTROL BEAMS DOWN A\n" + "MESSAGE FROM SPACE" /*C2TEXT*/, + "YOU ARE AT THE CORRUPT HEART OF THE CITY,\n" + "SURROUNDED BY THE CORPSES OF YOUR ENEMIES.\n" + "YOU SEE NO WAY TO DESTROY THE CREATURES'\n" + "ENTRYWAY ON THIS SIDE, SO YOU CLENCH YOUR\n" + "TEETH AND PLUNGE THROUGH IT.\n" + "\n" + "THERE MUST BE A WAY TO CLOSE IT ON THE\n" + "OTHER SIDE. WHAT DO YOU CARE IF YOU'VE\n" + "GOT TO GO THROUGH HELL TO GET TO IT?" /*C3TEXT*/, + "THE HORRENDOUS VISAGE OF THE BIGGEST\n" + "DEMON YOU'VE EVER SEEN CRUMBLES BEFORE\n" + "YOU, AFTER YOU PUMP YOUR ROCKETS INTO\n" + "HIS EXPOSED BRAIN. THE MONSTER SHRIVELS\n" + "UP AND DIES, ITS THRASHING LIMBS\n" + "DEVASTATING UNTOLD MILES OF HELL'S\n" + "SURFACE.\n" + "\n" + "YOU'VE DONE IT. THE INVASION IS OVER.\n" + "EARTH IS SAVED. HELL IS A WRECK. YOU\n" + "WONDER WHERE BAD FOLKS WILL GO WHEN THEY\n" + "DIE, NOW. WIPING THE SWEAT FROM YOUR\n" + "FOREHEAD YOU BEGIN THE LONG TREK BACK\n" + "HOME. REBUILDING EARTH OUGHT TO BE A\n" + "LOT MORE FUN THAN RUINING IT WAS.\n" /*C4TEXT*/, + "CONGRATULATIONS, YOU'VE FOUND THE SECRET\n" + "LEVEL! LOOKS LIKE IT'S BEEN BUILT BY\n" + "HUMANS, RATHER THAN DEMONS. YOU WONDER\n" + "WHO THE INMATES OF THIS CORNER OF HELL\n" + "WILL BE." /*C5TEXT*/, + "CONGRATULATIONS, YOU'VE FOUND THE\n" + "SUPER SECRET LEVEL! YOU'D BETTER\n" + "BLAZE THROUGH THIS ONE!\n" /*C6TEXT*/, + "You gloat over the steaming carcass of the\n" + "Guardian. With its death, you've wrested\n" + "the Accelerator from the stinking claws\n" + "of Hell. You relax and glance around the\n" + "room. Damn! There was supposed to be at\n" + "least one working prototype, but you can't\n" + "see it. The demons must have taken it.\n" + "\n" + "You must find the prototype, or all your\n" + "struggles will have been wasted. Keep\n" + "moving, keep fighting, keep killing.\n" + "Oh yes, keep living, too." /*P1TEXT*/, + "Even the deadly Arch-Vile labyrinth could\n" + "not stop you, and you've gotten to the\n" + "prototype Accelerator which is soon\n" + "efficiently and permanently deactivated.\n" + "\n" + "You're good at that kind of thing." /*P2TEXT*/, + "You've bashed and battered your way into\n" + "the heart of the devil-hive. Time for a\n" + "Search-and-Destroy mission, aimed at the\n" + "Gatekeeper, whose foul offspring is\n" + "cascading to Earth. Yeah, he's bad. But\n" + "you know who's worse!\n" + "\n" + "Grinning evilly, you check your gear, and\n" + "get ready to give the bastard a little Hell\n" + "of your own making!" /*P3TEXT*/, + "The Gatekeeper's evil face is splattered\n" + "all over the place. As its tattered corpse\n" + "collapses, an inverted Gate forms and\n" + "sucks down the shards of the last\n" + "prototype Accelerator, not to mention the\n" + "few remaining demons. You're done. Hell\n" + "has gone back to pounding bad dead folks \n" + "instead of good live ones. Remember to\n" + "tell your grandkids to put a rocket\n" + "launcher in your coffin. If you go to Hell\n" + "when you die, you'll need it for some\n" + "final cleaning-up ..." /*P4TEXT*/, + "You've found the second-hardest level we\n" + "got. Hope you have a saved game a level or\n" + "two previous. If not, be prepared to die\n" + "aplenty. For master marines only." /*P5TEXT*/, + "Betcha wondered just what WAS the hardest\n" + "level we had ready for ya? Now you know.\n" + "No one gets out alive." /*P6TEXT*/, + "You've fought your way out of the infested\n" + "experimental labs. It seems that UAC has\n" + "once again gulped it down. With their\n" + "high turnover, it must be hard for poor\n" + "old UAC to buy corporate health insurance\n" + "nowadays..\n" + "\n" + "Ahead lies the military complex, now\n" + "swarming with diseased horrors hot to get\n" + "their teeth into you. With luck, the\n" + "complex still has some warlike ordnance\n" + "laying around." /*T1TEXT*/, + "You hear the grinding of heavy machinery\n" + "ahead. You sure hope they're not stamping\n" + "out new hellspawn, but you're ready to\n" + "ream out a whole herd if you have to.\n" + "They might be planning a blood feast, but\n" + "you feel about as mean as two thousand\n" + "maniacs packed into one mad killer.\n" + "\n" + "You don't plan to go down easy." /*T2TEXT*/, + "The vista opening ahead looks real damn\n" + "familiar. Smells familiar, too -- like\n" + "fried excrement. You didn't like this\n" + "place before, and you sure as hell ain't\n" + "planning to like it now. The more you\n" + "brood on it, the madder you get.\n" + "Hefting your gun, an evil grin trickles\n" + "onto your face. Time to take some names." /*T3TEXT*/, + "Suddenly, all is silent, from one horizon\n" + "to the other. The agonizing echo of Hell\n" + "fades away, the nightmare sky turns to\n" + "blue, the heaps of monster corpses start \n" + "to evaporate along with the evil stench \n" + "that filled the air. Jeeze, maybe you've\n" + "done it. Have you really won?\n" + "\n" + "Something rumbles in the distance.\n" + "A blue light begins to glow inside the\n" + "ruined skull of the demon-spitter." /*T4TEXT*/, + "What now? Looks totally different. Kind\n" + "of like King Tut's condo. Well,\n" + "whatever's here can't be any worse\n" + "than usual. Can it? Or maybe it's best\n" + "to let sleeping gods lie.." /*T5TEXT*/, + "Time for a vacation. You've burst the\n" + "bowels of hell and by golly you're ready\n" + "for a break. You mutter to yourself,\n" + "Maybe someone else can kick Hell's ass\n" + "next time around. Ahead lies a quiet town,\n" + "with peaceful flowing water, quaint\n" + "buildings, and presumably no Hellspawn.\n" + "\n" + "As you step off the transport, you hear\n" + "the stomp of a cyberdemon's iron shoe." /*T6TEXT*/, + "ZOMBIEMAN" /*CC_ZOMBIE*/, + "SHOTGUN GUY" /*CC_SHOTGUN*/, + "HEAVY WEAPON DUDE" /*CC_HEAVY*/, + "IMP" /*CC_IMP*/, + "DEMON" /*CC_DEMON*/, + "LOST SOUL" /*CC_LOST*/, + "CACODEMON" /*CC_CACO*/, + "HELL KNIGHT" /*CC_HELL*/, + "BARON OF HELL" /*CC_BARON*/, + "ARACHNOTRON" /*CC_ARACH*/, + "PAIN ELEMENTAL" /*CC_PAIN*/, + "REVENANT" /*CC_REVEN*/, + "MANCUBUS" /*CC_MANCU*/, + "ARCH-VILE" /*CC_ARCH*/, + "THE SPIDER MASTERMIND" /*CC_SPIDER*/, + "THE CYBERDEMON" /*CC_CYBER*/, + "OUR HERO" /*CC_HERO*/, + "doomsav" /*SAVEGAMENAME*/, + "devmaps" /*DEVMAPS*/, + "devdata" /*DEVDATA*/, + "are you sure you want to\n" + "quit this great game?" /*QUITMSG0*/, + "please don't leave, there's more\n" + "demons to toast!" /*QUITMSG1*/, + "let's beat it -- this is turning\n" + "into a bloodbath!" /*QUITMSG2*/, + "i wouldn't leave if i were you.\n" + "dos is much worse." /*QUITMSG3*/, + "you're trying to say you like dos\n" + "better than me, right?" /*QUITMSG4*/, + "don't leave yet -- there's a\n" + "demon around that corner!" /*QUITMSG5*/, + "ya know, next time you come in here\n" + "i'm gonna toast ya." /*QUITMSG6*/, + "go ahead and leave. see if i care." /*QUITMSG7*/, + "you want to quit?\n" + "then, thou hast lost an eighth!" /*QUITMSG8*/, + "don't go now, there's a \n" + "dimensional shambler waiting\n" + "at the dos prompt!" /*QUITMSG9*/, + "get outta here and go back\n" + "to your boring programs." /*QUITMSG10*/, + "if i were your boss, i'd \n" + " deathmatch ya in a minute!" /*QUITMSG11*/, + "look, bud. you leave now\n" + "and you forfeit your body count!" /*QUITMSG12*/, + "just leave. when you come\n" + "back, i'll be waiting with a bat." /*QUITMSG13*/, + "you're lucky i don't smack\n" + "you for thinking about leaving." /*QUITMSG14*/, + "fuck you, pussy!\n" + "get the fuck out!" /*QUITMSG15*/, + "you quit and i'll jizz\n" + "in your cystholes!" /*QUITMSG16*/, + "if you leave, i'll make \n" + "the lord drink my jizz." /*QUITMSG17*/, + "hey, ron! can we say\n" + "'fuck' in the game?" /*QUITMSG18*/, + "i'd leave: this is just\n" + "more monsters and levels.\n" + "what a load." /*QUITMSG19*/, + "suck it down, asshole! \n" + "you're a fucking wimp!" /*QUITMSG20*/, + "don't quit now! we're \n" + "still spending your money!" /*QUITMSG21*/ +}; + +char** lang = english; diff --git a/src/m_argv.c b/src/m_argv.c @@ -1,13 +1,14 @@ #include <string.h> -int myargc; -char** myargv; -int M_CheckParm (char *check) + +int myargc; +char** myargv; + +int +M_CheckParm(char* check) { - int i; - for (i = 1;i<myargc;i++) - { - if ( !strcasecmp(check, myargv[i]) ) - return i; - } + int i; + + for (i = 1; i < myargc; ++i) + if (!strcasecmp(check, myargv[i])) return i; return 0; } diff --git a/src/m_argv.h b/src/m_argv.h @@ -1,6 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __M_ARGV__ #define __M_ARGV__ + + + + extern int myargc; extern char** myargv; + + + int M_CheckParm (char* check); + + #endif + + + + + diff --git a/src/m_bbox.c b/src/m_bbox.c @@ -1,24 +1,21 @@ -#ifdef __GNUG__ -#pragma implementation "m_bbox.h" -#endif #include "m_bbox.h" -void M_ClearBox (fixed_t *box) + +void +M_ClearBox(fixed_t* box) { - box[BOXTOP] = box[BOXRIGHT] = MININT; - box[BOXBOTTOM] = box[BOXLEFT] = MAXINT; + box[BOXTOP] = box[BOXRIGHT] = INT_MIN; + box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX; } + void -M_AddToBox -( fixed_t* box, - fixed_t x, - fixed_t y ) +M_AddToBox(fixed_t* box, fixed_t x, fixed_t y) { - if (x<box[BOXLEFT]) - box[BOXLEFT] = x; - else if (x>box[BOXRIGHT]) - box[BOXRIGHT] = x; - if (y<box[BOXBOTTOM]) - box[BOXBOTTOM] = y; - else if (y>box[BOXTOP]) - box[BOXTOP] = y; + if (x < box[BOXLEFT]) + box[BOXLEFT] = x; + else if (x > box[BOXRIGHT]) + box[BOXRIGHT] = x; + if (y < box[BOXBOTTOM]) + box[BOXBOTTOM] = y; + else if (y > box[BOXTOP]) + box[BOXTOP] = y; } diff --git a/src/m_bbox.h b/src/m_bbox.h @@ -1,18 +1,18 @@ #ifndef __M_BBOX__ #define __M_BBOX__ + #include <values.h> + #include "m_fixed.h" -enum -{ + +enum { BOXTOP, BOXBOTTOM, BOXLEFT, BOXRIGHT }; -void M_ClearBox (fixed_t* box); -void -M_AddToBox -( fixed_t* box, - fixed_t x, - fixed_t y ); + +void M_ClearBox(fixed_t* box); +void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y); + #endif diff --git a/src/m_cheat.c b/src/m_cheat.c @@ -1,6 +1,17 @@ #include "m_cheat.h" + + + + + static int firsttime = 1; static unsigned char cheat_xlate_table[256]; + + + + + + int cht_CheckCheat ( cheatseq_t* cht, @@ -8,19 +19,23 @@ cht_CheckCheat { int i; int rc = 0; + if (firsttime) { firsttime = 0; for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i); } + if (!cht->p) cht->p = cht->sequence; + if (*cht->p == 0) *(cht->p++) = key; else if (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; else cht->p = cht->sequence; + if (*cht->p == 1) cht->p++; else if (*cht->p == 0xff) @@ -28,16 +43,21 @@ cht_CheckCheat cht->p = cht->sequence; rc = 1; } + return rc; } + void cht_GetParam ( cheatseq_t* cht, char* buffer ) { + unsigned char *p, c; + p = cht->sequence; while (*(p++) != 1); + do { c = *p; @@ -45,6 +65,10 @@ cht_GetParam *(p++) = 0; } while (c && *p!=0xff ); + if (*p==0xff) *buffer = 0; + } + + diff --git a/src/m_cheat.h b/src/m_cheat.h @@ -1,19 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __M_CHEAT__ #define __M_CHEAT__ + + + + + #define SCRAMBLE(a) \ ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) + typedef struct { unsigned char* sequence; unsigned char* p; + } cheatseq_t; + int cht_CheckCheat ( cheatseq_t* cht, char key ); + + void cht_GetParam ( cheatseq_t* cht, char* buffer ); + + #endif + + + + + diff --git a/src/m_fixed.c b/src/m_fixed.c @@ -1,39 +1,30 @@ +#include <limits.h> + #include "stdlib.h" -#include "doomtype.h" +#include "doomdef.h" #include "i_system.h" -#ifdef __GNUG__ -#pragma implementation "m_fixed.h" -#endif #include "m_fixed.h" + fixed_t -FixedMul -( fixed_t a, - fixed_t b ) +FixedMul(fixed_t a, fixed_t b) { - return ((long) a * (long) b) >> FRACBITS; + return ((long)a * (long)b) >> FRACBITS; } + fixed_t -FixedDiv -( fixed_t a, - fixed_t b ) +FixedDiv(fixed_t a, fixed_t b) { - if ( (abs(a)>>14) >= abs(b)) - return (a^b)<0 ? MININT : MAXINT; + if ((abs(a) >> 14) >= abs(b)) return (a^b)<0 ? INT_MIN : INT_MAX; return FixedDiv2 (a,b); } + fixed_t -FixedDiv2 -( fixed_t a, - fixed_t b ) +FixedDiv2(fixed_t a, fixed_t b) { -#if 0 - long long c; - c = ((long long)a<<16) / ((long long)b); - return (fixed_t) c; -#endif double c; + c = ((double)a) / ((double)b) * FRACUNIT; if (c >= 2147483648.0 || c < -2147483648.0) - I_Error("FixedDiv: divide by zero"); - return (fixed_t) c; + I_Error("FixedDiv: divide by zero"); + return (fixed_t)c; } diff --git a/src/m_fixed.h b/src/m_fixed.h @@ -1,12 +1,13 @@ #ifndef __M_FIXED__ #define __M_FIXED__ -#ifdef __GNUG__ -#pragma interface -#endif -#define FRACBITS 16 -#define FRACUNIT (1<<FRACBITS) + +#define FRACBITS 16 +#define FRACUNIT (1 << FRACBITS) + typedef int fixed_t; -fixed_t FixedMul (fixed_t a, fixed_t b); -fixed_t FixedDiv (fixed_t a, fixed_t b); -fixed_t FixedDiv2 (fixed_t a, fixed_t b); + +fixed_t FixedMul(fixed_t a, fixed_t b); +fixed_t FixedDiv(fixed_t a, fixed_t b); +fixed_t FixedDiv2(fixed_t a, fixed_t b); + #endif diff --git a/src/m_menu.c b/src/m_menu.c @@ -4,8 +4,9 @@ #include <fcntl.h> #include <stdlib.h> #include <ctype.h> + +#include "m_swap.h" #include "doomdef.h" -#include "dstrings.h" #include "d_main.h" #include "i_system.h" #include "i_video.h" @@ -16,11 +17,32 @@ #include "hu_stuff.h" #include "g_game.h" #include "m_argv.h" -#include "m_swap.h" #include "s_sound.h" #include "doomstat.h" #include "sounds.h" #include "m_menu.h" + +#define SAVESTRINGSIZE 24 +#define SKULLXOFF -32 +#define LINEHEIGHT 16 + +typedef struct { + short status; + char name[10]; + void (*routine)(int choice); + char alphaKey; +} menuitem_t; + +typedef struct menu_s { + short numitems; + struct menu_s* prevMenu; + menuitem_t* menuitems; + void (*routine)(); + short x; + short y; + short lastOn; +} menu_t; + extern patch_t* hu_font[HU_FONTSIZE]; extern boolean message_dontfuckwithme; extern boolean chat_on; @@ -31,54 +53,62 @@ int screenblocks; int screenSize; int quickSaveSlot; int messageToPrint; -char* messageString; +char* messageString; int messx; int messy; int messageLastMenuActive; boolean messageNeedsInput; -void (*messageRoutine)(int response); -#define SAVESTRINGSIZE 24 -char gammamsg[5][26] = -{ - GAMMALVL0, - GAMMALVL1, - GAMMALVL2, - GAMMALVL3, - GAMMALVL4 -}; -int saveStringEnter; -int saveSlot; -int saveCharIndex; +void (*messageRoutine)(int response); +int saveStringEnter; +int saveSlot; +int saveCharIndex; char saveOldString[SAVESTRINGSIZE]; boolean inhelpscreens; boolean menuactive; -#define SKULLXOFF -32 -#define LINEHEIGHT 16 extern boolean sendpause; char savegamestrings[10][SAVESTRINGSIZE]; +char tempstring[160]; char endstring[160]; -typedef struct -{ - short status; - char name[10]; - void (*routine)(int choice); - char alphaKey; -} menuitem_t; -typedef struct menu_s -{ - short numitems; - struct menu_s* prevMenu; - menuitem_t* menuitems; - void (*routine)(); - short x; - short y; - short lastOn; -} menu_t; short itemOn; short skullAnimCounter; short whichSkull; -char skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"}; menu_t* currentMenu; +int epi; + +int gammamsg[] = { + GAMMALVL0, + GAMMALVL1, + GAMMALVL2, + GAMMALVL3, + GAMMALVL4 +}; + +char skullName[2][/*8*/9] = {"M_SKULL1", "M_SKULL2"}; +char detailNames[2][9] = {"M_GDHIGH", "M_GDLOW"}; +char msgNames[2][9] = {"M_MSGOFF", "M_MSGON"}; +int quitsounds[8] = { + sfx_pldeth, + sfx_dmpain, + sfx_popain, + sfx_slop, + sfx_telept, + sfx_posit1, + sfx_posit3, + sfx_sgtatk +}; + +int quitsounds2[8] = { + sfx_vilact, + sfx_getpow, + sfx_boscub, + sfx_slop, + sfx_skeswg, + sfx_kntdth, + sfx_bspact, + sfx_sgtatk +}; + + void M_NewGame(int choice); void M_Episode(int choice); void M_ChooseSkill(int choice); @@ -100,1244 +130,1109 @@ void M_Sound(int choice); void M_FinishReadThis(int choice); void M_LoadSelect(int choice); void M_SaveSelect(int choice); -void M_ReadSaveStrings(void); -void M_QuickSave(void); -void M_QuickLoad(void); -void M_DrawMainMenu(void); -void M_DrawReadThis1(void); -void M_DrawReadThis2(void); -void M_DrawNewGame(void); -void M_DrawEpisode(void); -void M_DrawOptions(void); -void M_DrawSound(void); -void M_DrawLoad(void); -void M_DrawSave(void); -void M_DrawSaveLoadBorder(int x,int y); -void M_SetupNextMenu(menu_t *menudef); -void M_DrawThermo(int x,int y,int thermWidth,int thermDot); -void M_DrawEmptyCell(menu_t *menu,int item); -void M_DrawSelCell(menu_t *menu,int item); -void M_WriteText(int x, int y, char *string); -int M_StringWidth(char *string); -int M_StringHeight(char *string); -void M_StartControlPanel(void); -void M_StartMessage(char *string,void (*routine)(int),boolean input); -void M_StopMessage(void); -void M_ClearMenus (void); -enum -{ - newgame = 0, - options, - loadgame, - savegame, - readthis, - quitdoom, - main_end +void M_ReadSaveStrings(); +void M_QuickSave(); +void M_QuickLoad(); +void M_DrawMainMenu(); +void M_DrawReadThis1(); +void M_DrawReadThis2(); +void M_DrawNewGame(); +void M_DrawEpisode(); +void M_DrawOptions(); +void M_DrawSound(); +void M_DrawLoad(); +void M_DrawSave(); +void M_DrawSaveLoadBorder(int x, int y); +void M_SetupNextMenu(menu_t* menudef); +void M_DrawThermo(int x, int y, int thermWidth, int thermDot); +void M_DrawEmptyCell(menu_t* menu, int item); +void M_DrawSelCell(menu_t* menu, int item); +void M_WriteText(int x, int y, char* string); +int M_StringWidth(char* string); +int M_StringHeight(char* string); +void M_StartControlPanel(); +void M_StartMessage(char* string, void (*routine)(int), boolean input); +void M_StopMessage(); +void M_ClearMenus(); + +enum { + newgame = 0, + options, + loadgame, + savegame, + readthis, + quitdoom, + main_end } main_e; -menuitem_t MainMenu[]= -{ - {1,"M_NGAME",M_NewGame,'n'}, - {1,"M_OPTION",M_Options,'o'}, - {1,"M_LOADG",M_LoadGame,'l'}, - {1,"M_SAVEG",M_SaveGame,'s'}, - {1,"M_RDTHIS",M_ReadThis,'r'}, - {1,"M_QUITG",M_QuitDOOM,'q'} + +menuitem_t MainMenu[] = { + {1, "M_NGAME", M_NewGame, 'n'}, + {1, "M_OPTION", M_Options, 'o'}, + {1, "M_LOADG", M_LoadGame, 'l'}, + {1, "M_SAVEG", M_SaveGame, 's'}, + + {1, "M_RDTHIS", M_ReadThis, 'r'}, + {1, "M_QUITG", M_QuitDOOM, 'q'} }; -menu_t MainDef = -{ - main_end, - NULL, - MainMenu, - M_DrawMainMenu, - 97,64, - 0 + +menu_t MainDef = { + main_end, + NULL, + MainMenu, + M_DrawMainMenu, + 97, 64, + 0 }; -enum -{ - ep1, - ep2, - ep3, - ep4, - ep_end + +enum { + ep1, + ep2, + ep3, + ep4, + ep_end } episodes_e; -menuitem_t EpisodeMenu[]= -{ - {1,"M_EPI1", M_Episode,'k'}, - {1,"M_EPI2", M_Episode,'t'}, - {1,"M_EPI3", M_Episode,'i'}, - {1,"M_EPI4", M_Episode,'t'} + +menuitem_t EpisodeMenu[] = { + {1, "M_EPI1", M_Episode, 'k'}, + {1, "M_EPI2", M_Episode, 't'}, + {1, "M_EPI3", M_Episode, 'i'}, + {1, "M_EPI4", M_Episode, 't'} }; -menu_t EpiDef = -{ - ep_end, - &MainDef, - EpisodeMenu, - M_DrawEpisode, - 48,63, - ep1 + +menu_t EpiDef = { + ep_end, + &MainDef, + EpisodeMenu, + M_DrawEpisode, + 48, 63, + ep1 }; -enum -{ - killthings, - toorough, - hurtme, - violence, - nightmare, - newg_end + +enum { + killthings, + toorough, + hurtme, + violence, + nightmare, + newg_end } newgame_e; -menuitem_t NewGameMenu[]= -{ - {1,"M_JKILL", M_ChooseSkill, 'i'}, - {1,"M_ROUGH", M_ChooseSkill, 'h'}, - {1,"M_HURT", M_ChooseSkill, 'h'}, - {1,"M_ULTRA", M_ChooseSkill, 'u'}, - {1,"M_NMARE", M_ChooseSkill, 'n'} + +menuitem_t NewGameMenu[] = { + {1, "M_JKILL", M_ChooseSkill, 'i'}, + {1, "M_ROUGH", M_ChooseSkill, 'h'}, + {1, "M_HURT", M_ChooseSkill, 'h'}, + {1, "M_ULTRA", M_ChooseSkill, 'u'}, + {1, "M_NMARE", M_ChooseSkill, 'n'} }; -menu_t NewDef = -{ - newg_end, - &EpiDef, - NewGameMenu, - M_DrawNewGame, - 48,63, - hurtme + +menu_t NewDef = { + newg_end, + &EpiDef, + NewGameMenu, + M_DrawNewGame, + 48, 63, + hurtme }; -enum -{ - endgame, - messages, - detail, - scrnsize, - option_empty1, - mousesens, - option_empty2, - soundvol, - opt_end + +enum { + endgame, + messages, + detail, + scrnsize, + option_empty1, + mousesens, + option_empty2, + soundvol, + opt_end } options_e; -menuitem_t OptionsMenu[]= -{ - {1,"M_ENDGAM", M_EndGame,'e'}, - {1,"M_MESSG", M_ChangeMessages,'m'}, - {1,"M_DETAIL", M_ChangeDetail,'g'}, - {2,"M_SCRNSZ", M_SizeDisplay,'s'}, - {-1,"",0}, - {2,"M_MSENS", M_ChangeSensitivity,'m'}, - {-1,"",0}, - {1,"M_SVOL", M_Sound,'s'} + +menuitem_t OptionsMenu[] = { + {1, "M_ENDGAM", M_EndGame, 'e'}, + {1, "M_MESSG", M_ChangeMessages, 'm'}, + {1, "M_DETAIL", M_ChangeDetail, 'g'}, + {2, "M_SCRNSZ", M_SizeDisplay, 's'}, + {-1, "", 0}, + {2, "M_MSENS", M_ChangeSensitivity, 'm'}, + {-1, "", 0}, + {1, "M_SVOL", M_Sound, 's'} }; -menu_t OptionsDef = -{ - opt_end, - &MainDef, - OptionsMenu, - M_DrawOptions, - 60,37, - 0 + +menu_t OptionsDef = { + opt_end, + &MainDef, + OptionsMenu, + M_DrawOptions, + 60, 37, + 0 }; -enum -{ - rdthsempty1, - read1_end + +enum { + rdthsempty1, + read1_end } read_e; -menuitem_t ReadMenu1[] = -{ - {1,"",M_ReadThis2,0} + +menuitem_t ReadMenu1[] = { + {1, "", M_ReadThis2, 0} }; -menu_t ReadDef1 = -{ - read1_end, - &MainDef, - ReadMenu1, - M_DrawReadThis1, - 280,185, - 0 + +menu_t ReadDef1 = { + read1_end, + &MainDef, + ReadMenu1, + M_DrawReadThis1, + 280, 185, + 0 }; -enum -{ - rdthsempty2, - read2_end + +enum { + rdthsempty2, + read2_end } read_e2; -menuitem_t ReadMenu2[]= -{ - {1,"",M_FinishReadThis,0} + +menuitem_t ReadMenu2[] = { + {1, "", M_FinishReadThis, 0} }; -menu_t ReadDef2 = -{ - read2_end, - &ReadDef1, - ReadMenu2, - M_DrawReadThis2, - 330,175, - 0 + +menu_t ReadDef2 = { + read2_end, + &ReadDef1, + ReadMenu2, + M_DrawReadThis2, + 330, 175, + 0 }; -enum -{ - sfx_vol, - sfx_empty1, - music_vol, - sfx_empty2, - sound_end + +enum { + sfx_vol, + sfx_empty1, + music_vol, + sfx_empty2, + sound_end } sound_e; -menuitem_t SoundMenu[]= -{ - {2,"M_SFXVOL",M_SfxVol,'s'}, - {-1,"",0}, - {2,"M_MUSVOL",M_MusicVol,'m'}, - {-1,"",0} + +menuitem_t SoundMenu[] = { + {2, "M_SFXVOL", M_SfxVol, 's'}, + {-1, "", 0}, + {2, "M_MUSVOL", M_MusicVol, 'm'}, + {-1, "", 0} }; -menu_t SoundDef = -{ - sound_end, - &OptionsDef, - SoundMenu, - M_DrawSound, - 80,64, - 0 + +menu_t SoundDef = { + sound_end, + &OptionsDef, + SoundMenu, + M_DrawSound, + 80, 64, + 0 }; -enum -{ - load1, - load2, - load3, - load4, - load5, - load6, - load_end + +enum { + load1, + load2, + load3, + load4, + load5, + load6, + load_end } load_e; -menuitem_t LoadMenu[]= -{ - {1,"", M_LoadSelect,'1'}, - {1,"", M_LoadSelect,'2'}, - {1,"", M_LoadSelect,'3'}, - {1,"", M_LoadSelect,'4'}, - {1,"", M_LoadSelect,'5'}, - {1,"", M_LoadSelect,'6'} + +menuitem_t LoadMenu[] = { + {1, "", M_LoadSelect, '1'}, + {1, "", M_LoadSelect, '2'}, + {1, "", M_LoadSelect, '3'}, + {1, "", M_LoadSelect, '4'}, + {1, "", M_LoadSelect, '5'}, + {1, "", M_LoadSelect, '6'} }; -menu_t LoadDef = -{ - load_end, - &MainDef, - LoadMenu, - M_DrawLoad, - 80,54, - 0 + +menu_t LoadDef = { + load_end, + &MainDef, + LoadMenu, + M_DrawLoad, + 80, 54, + 0 }; -menuitem_t SaveMenu[]= -{ - {1,"", M_SaveSelect,'1'}, - {1,"", M_SaveSelect,'2'}, - {1,"", M_SaveSelect,'3'}, - {1,"", M_SaveSelect,'4'}, - {1,"", M_SaveSelect,'5'}, - {1,"", M_SaveSelect,'6'} + +menuitem_t SaveMenu[] = { + {1, "", M_SaveSelect, '1'}, + {1, "", M_SaveSelect, '2'}, + {1, "", M_SaveSelect, '3'}, + {1, "", M_SaveSelect, '4'}, + {1, "", M_SaveSelect, '5'}, + {1, "", M_SaveSelect, '6'} }; -menu_t SaveDef = -{ - load_end, - &MainDef, - SaveMenu, - M_DrawSave, - 80,54, - 0 + +menu_t SaveDef = { + load_end, + &MainDef, + SaveMenu, + M_DrawSave, + 80, 54, + 0 }; -void M_ReadSaveStrings(void) -{ - int handle; - int i; - char name[256]; - for (i = 0;i < load_end;i++) - { - if (M_CheckParm("-cdrom")) - sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i); - else - sprintf(name,SAVEGAMENAME"%d.dsg",i); - handle = open (name, O_RDONLY | 0, 0666); - if (handle == -1) - { - strcpy(&savegamestrings[i][0],EMPTYSTRING); - LoadMenu[i].status = 0; - continue; + +void +M_ReadSaveStrings() +{ + int i, handle; + char name[256]; + + for (i = 0;i < load_end;i++) { + if (M_CheckParm("-cdrom")) + sprintf(name, "c:\\doomdata\\%s%d.dsg", lang[SAVEGAMENAME], i); + else + sprintf(name, "%s%d.dsg", lang[SAVEGAMENAME], i); + handle = open(name, O_RDONLY | 0, 0666); + if (handle == -1) { + strcpy(&savegamestrings[i][0], lang[EMPTYSTRING]); + LoadMenu[i].status = 0; + continue; + } + read(handle, &savegamestrings[i], SAVESTRINGSIZE); + close(handle); + LoadMenu[i].status = 1; } - close (handle); - LoadMenu[i].status = 1; - } } -void M_DrawLoad(void) -{ - int i; - V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE)); - for (i = 0;i < load_end; i++) - { - M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); - M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); - } + +void +M_DrawLoad() +{ + int i; + + V_DrawPatch(72, 28, 0, W_CacheLumpName("M_LOADG", PU_CACHE)); + for (i = 0; i < load_end; ++i) { + M_DrawSaveLoadBorder(LoadDef.x, LoadDef.y+LINEHEIGHT*i); + M_WriteText(LoadDef.x, LoadDef.y+LINEHEIGHT*i, savegamestrings[i]); + } } -void M_DrawSaveLoadBorder(int x,int y) -{ - int i; - V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE)); - for (i = 0;i < 24;i++) - { - V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE)); - x += 8; - } - V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE)); + +void +M_DrawSaveLoadBorder(int x, int y) +{ + int i; + + V_DrawPatch(x - 8, y + 7, 0, W_CacheLumpName("M_LSLEFT", PU_CACHE)); + for (i = 0; i < 24; ++i) { + V_DrawPatch(x, y+7, 0, W_CacheLumpName("M_LSCNTR", PU_CACHE)); + x += 8; + } + V_DrawPatch(x, y + 7, 0, W_CacheLumpName("M_LSRGHT", PU_CACHE)); } -void M_LoadSelect(int choice) + +void +M_LoadSelect(int choice) { - char name[256]; - if (M_CheckParm("-cdrom")) - sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice); - else - sprintf(name,SAVEGAMENAME"%d.dsg",choice); - G_LoadGame (name); - M_ClearMenus (); + char name[256]; + + if (M_CheckParm("-cdrom")) + sprintf(name, "c:\\doomdata\\%s%d.dsg", lang[SAVEGAMENAME], choice); + else + sprintf(name, "%s%d.dsg", lang[SAVEGAMENAME], choice); + G_LoadGame(name); + M_ClearMenus(); } -void M_LoadGame (int choice) + +void +M_LoadGame(int choice) { - if (netgame) - { - M_StartMessage(LOADNET,NULL,false); - return; - } - M_SetupNextMenu(&LoadDef); - M_ReadSaveStrings(); + if (netgame) { + M_StartMessage(lang[LOADNET], NULL, false); + return; + } + M_SetupNextMenu(&LoadDef); + M_ReadSaveStrings(); } -void M_DrawSave(void) -{ - int i; - V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE)); - for (i = 0;i < load_end; i++) - { - M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); - M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); - } - if (saveStringEnter) - { - i = M_StringWidth(savegamestrings[saveSlot]); - M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_"); - } + +void +M_DrawSave() +{ + int i; + + V_DrawPatch(72, 28, 0, W_CacheLumpName("M_SAVEG", PU_CACHE)); + for (i = 0; i < load_end; ++i) { + M_DrawSaveLoadBorder(LoadDef.x, LoadDef.y+LINEHEIGHT*i); + M_WriteText(LoadDef.x, LoadDef.y+LINEHEIGHT*i, savegamestrings[i]); + } + if (saveStringEnter) { + i = M_StringWidth(savegamestrings[saveSlot]); + M_WriteText(LoadDef.x + i, LoadDef.y+LINEHEIGHT*saveSlot, "_"); + } } -void M_DoSave(int slot) + +void +M_DoSave(int slot) { - G_SaveGame (slot,savegamestrings[slot]); - M_ClearMenus (); - if (quickSaveSlot == -2) - quickSaveSlot = slot; + G_SaveGame(slot, savegamestrings[slot]); + M_ClearMenus(); + if (quickSaveSlot == -2) quickSaveSlot = slot; } -void M_SaveSelect(int choice) -{ - saveStringEnter = 1; - saveSlot = choice; - strcpy(saveOldString,savegamestrings[choice]); - if (!strcmp(savegamestrings[choice],EMPTYSTRING)) - savegamestrings[choice][0] = 0; - saveCharIndex = strlen(savegamestrings[choice]); + +void +M_SaveSelect(int choice) +{ + saveStringEnter = 1; + saveSlot = choice; + strcpy(saveOldString, savegamestrings[choice]); + if (!strcmp(savegamestrings[choice], lang[EMPTYSTRING])) + savegamestrings[choice][0] = 0; + saveCharIndex = strlen(savegamestrings[choice]); } -void M_SaveGame (int choice) + +void +M_SaveGame(int choice) { - if (!usergame) - { - M_StartMessage(SAVEDEAD,NULL,false); - return; - } - if (gamestate != GS_LEVEL) - return; - M_SetupNextMenu(&SaveDef); - M_ReadSaveStrings(); + if (!usergame) { + M_StartMessage(lang[SAVEDEAD], NULL, false); + return; + } + if (gamestate != GS_LEVEL) + return; + M_SetupNextMenu(&SaveDef); + M_ReadSaveStrings(); } -char tempstring[84]; -void M_QuickSaveResponse(int ch) + +void +M_QuickSaveResponse(int ch) { - if (ch == 'y') - { - M_DoSave(quickSaveSlot); - S_StartSound(NULL,sfx_swtchx); - } + if (ch == 'y') { + M_DoSave(quickSaveSlot); + S_StartSound(NULL, sfx_swtchx); + } } -void M_QuickSave(void) + +void +M_QuickSave() { - if (!usergame) - { - S_StartSound(NULL,sfx_oof); - return; - } - if (gamestate != GS_LEVEL) - return; - if (quickSaveSlot < 0) - { - M_StartControlPanel(); - M_ReadSaveStrings(); - M_SetupNextMenu(&SaveDef); - quickSaveSlot = -2; - return; - } - sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]); - M_StartMessage(tempstring, M_QuickSaveResponse, true); + if (!usergame) { + S_StartSound(NULL, sfx_oof); + return; + } + if (gamestate != GS_LEVEL) return; + if (quickSaveSlot < 0) { + M_StartControlPanel(); + M_ReadSaveStrings(); + M_SetupNextMenu(&SaveDef); + quickSaveSlot = -2; + return; + } + sprintf(tempstring, lang[QSPROMPT], savegamestrings[quickSaveSlot]); + M_StartMessage(tempstring, M_QuickSaveResponse, true); } + void M_QuickLoadResponse(int ch) { - if (ch == 'y') - { - M_LoadSelect(quickSaveSlot); - S_StartSound(NULL,sfx_swtchx); - } + if (ch == 'y') { + M_LoadSelect(quickSaveSlot); + S_StartSound(NULL, sfx_swtchx); + } } -void M_QuickLoad(void) + +void +M_QuickLoad() { - if (netgame) - { - M_StartMessage(QLOADNET,NULL,false); - return; - } - if (quickSaveSlot < 0) - { - M_StartMessage(QSAVESPOT,NULL,false); - return; - } - sprintf(tempstring, QLPROMPT, savegamestrings[quickSaveSlot]); - M_StartMessage(tempstring,M_QuickLoadResponse,true); + if (netgame) { + M_StartMessage(lang[QLOADNET], NULL, false); + return; + } + if (quickSaveSlot < 0) { + M_StartMessage(lang[QSAVESPOT], NULL, false); + return; + } + sprintf(tempstring, lang[QLPROMPT], savegamestrings[quickSaveSlot]); + M_StartMessage(tempstring, M_QuickLoadResponse, true); } -void M_DrawReadThis1(void) + +void +M_DrawReadThis1() { - inhelpscreens = true; - switch ( gamemode ) - { - case commercial: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE)); - break; - case shareware: - case registered: - case retail: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE)); - break; - default: - break; - } - return; + inhelpscreens = true; + V_DrawPatch(0, 0, 0, W_CacheLumpName("HELP1", PU_CACHE)); + return; } -void M_DrawReadThis2(void) + +void +M_DrawReadThis2() { - inhelpscreens = true; - switch ( gamemode ) - { - case retail: - case commercial: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE)); - break; - case shareware: - case registered: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE)); - break; - default: - break; - } - return; + inhelpscreens = true; + V_DrawPatch(0, 0, 0, W_CacheLumpName("HELP2", PU_CACHE)); + return; } -void M_DrawSound(void) + +void +M_DrawSound() { - V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE)); - M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1), - 16,snd_SfxVolume); - M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1), - 16,snd_MusicVolume); + V_DrawPatch(60, 38, 0, W_CacheLumpName("M_SVOL", PU_CACHE)); + M_DrawThermo(SoundDef.x, SoundDef.y+LINEHEIGHT*(sfx_vol+1), 16, snd_SfxVolume); + M_DrawThermo(SoundDef.x, SoundDef.y+LINEHEIGHT*(music_vol+1), 16, snd_MusicVolume); } -void M_Sound(int choice) + +void +M_Sound(int choice) { - M_SetupNextMenu(&SoundDef); + M_SetupNextMenu(&SoundDef); } -void M_SfxVol(int choice) -{ - switch(choice) - { - case 0: - if (snd_SfxVolume) - snd_SfxVolume--; - break; - case 1: - if (snd_SfxVolume < 15) - snd_SfxVolume++; - break; - } - S_SetSfxVolume(snd_SfxVolume /* *8 */); + +void +M_SfxVol(int choice) +{ + switch (choice) { + case 0: + if (snd_SfxVolume) + snd_SfxVolume--; + break; + case 1: + if (snd_SfxVolume < 15) + snd_SfxVolume++; + break; + } + S_SetSfxVolume(snd_SfxVolume /* *8 */); } -void M_MusicVol(int choice) -{ - switch(choice) - { - case 0: - if (snd_MusicVolume) - snd_MusicVolume--; - break; - case 1: - if (snd_MusicVolume < 15) - snd_MusicVolume++; - break; - } - S_SetMusicVolume(snd_MusicVolume /* *8 */); + +void +M_MusicVol(int choice) +{ + switch (choice) { + case 0: + if (snd_MusicVolume) snd_MusicVolume--; + break; + case 1: + if (snd_MusicVolume < 15) snd_MusicVolume++; + break; + } + S_SetMusicVolume(snd_MusicVolume /* *8 */); } -void M_DrawMainMenu(void) + +void +M_DrawMainMenu() { - V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE)); + V_DrawPatch(94, 2, 0, W_CacheLumpName("M_DOOM", PU_CACHE)); } -void M_DrawNewGame(void) + +void +M_DrawNewGame() { - V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE)); - V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE)); + V_DrawPatch(96, 14, 0, W_CacheLumpName("M_NEWG", PU_CACHE)); + V_DrawPatch(54, 38, 0, W_CacheLumpName("M_SKILL", PU_CACHE)); } -void M_NewGame(int choice) + +void +M_NewGame(int choice) { - if (netgame && !demoplayback) - { - M_StartMessage(NEWGAME,NULL,false); - return; - } - if ( gamemode == commercial ) - M_SetupNextMenu(&NewDef); - else + if (netgame && !demoplayback) { + M_StartMessage(lang[NEWGAME], NULL, false); + return; + } M_SetupNextMenu(&EpiDef); } -int epi; -void M_DrawEpisode(void) + + +void M_DrawEpisode() { - V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE)); + V_DrawPatch(54, 38, 0, W_CacheLumpName("M_EPISOD", PU_CACHE)); } -void M_VerifyNightmare(int ch) + +void +M_VerifyNightmare(int ch) { - if (ch != 'y') - return; - G_DeferedInitNew(nightmare,epi+1,1); - M_ClearMenus (); + if (ch != 'y') return; + G_DeferedInitNew(nightmare, epi+1, 1); + M_ClearMenus(); } -void M_ChooseSkill(int choice) + +void +M_ChooseSkill(int choice) { - if (choice == nightmare) - { - M_StartMessage(NIGHTMARE,M_VerifyNightmare,true); - return; - } - G_DeferedInitNew(choice,epi+1,1); - M_ClearMenus (); + if (choice == nightmare) { + M_StartMessage(lang[NIGHTMARE], M_VerifyNightmare, true); + return; + } + G_DeferedInitNew(choice, epi+1, 1); + M_ClearMenus(); } -void M_Episode(int choice) + +void +M_Episode(int choice) { - if ( (gamemode == shareware) - && choice) - { - M_StartMessage(SWSTRING,NULL,false); - M_SetupNextMenu(&ReadDef1); - return; - } - if ( (gamemode == registered) - && (choice > 2)) - { - fprintf( stderr, - "M_Episode: 4th episode requires UltimateDOOM\n"); - choice = 0; - } - epi = choice; - M_SetupNextMenu(&NewDef); + if (choice) { + M_StartMessage(lang[SWSTRING], NULL, false); + M_SetupNextMenu(&ReadDef1); + return; + } + epi = choice; + M_SetupNextMenu(&NewDef); } -char detailNames[2][9] = {"M_GDHIGH","M_GDLOW"}; -char msgNames[2][9] = {"M_MSGOFF","M_MSGON"}; -void M_DrawOptions(void) + + +void +M_DrawOptions() { - V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE)); - V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0, - W_CacheLumpName(detailNames[detailLevel],PU_CACHE)); - V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0, - W_CacheLumpName(msgNames[showMessages],PU_CACHE)); - M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1), - 10,mouseSensitivity); - M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1), - 9,screenSize); + V_DrawPatch(108, 15, 0, W_CacheLumpName("M_OPTTTL", PU_CACHE)); + V_DrawPatch(OptionsDef.x + 175, OptionsDef.y+LINEHEIGHT*detail, 0, W_CacheLumpName(detailNames[detailLevel], PU_CACHE)); + V_DrawPatch(OptionsDef.x + 120, OptionsDef.y+LINEHEIGHT*messages, 0, W_CacheLumpName(msgNames[showMessages], PU_CACHE)); + M_DrawThermo(OptionsDef.x, OptionsDef.y+LINEHEIGHT*(mousesens+1), 10, mouseSensitivity); + M_DrawThermo(OptionsDef.x, OptionsDef.y+LINEHEIGHT*(scrnsize+1), 9, screenSize); } -void M_Options(int choice) + +void +M_Options(int choice) { - M_SetupNextMenu(&OptionsDef); + M_SetupNextMenu(&OptionsDef); } -void M_ChangeMessages(int choice) + +void +M_ChangeMessages(int choice) { - choice = 0; - showMessages = 1 - showMessages; - if (!showMessages) - players[consoleplayer].message = MSGOFF; - else - players[consoleplayer].message = MSGON ; - message_dontfuckwithme = true; + choice = 0; + showMessages = 1 - showMessages; + if (!showMessages) + players[consoleplayer].message = lang[MSGOFF]; + else + players[consoleplayer].message = lang[MSGON]; + message_dontfuckwithme = true; } -void M_EndGameResponse(int ch) + +void +M_EndGameResponse(int ch) { - if (ch != 'y') - return; - currentMenu->lastOn = itemOn; - M_ClearMenus (); - D_StartTitle (); + if (ch != 'y') return; + currentMenu->lastOn = itemOn; + M_ClearMenus(); + D_StartTitle(); } -void M_EndGame(int choice) + +void +M_EndGame(int choice) { - choice = 0; - if (!usergame) - { - S_StartSound(NULL,sfx_oof); - return; - } - if (netgame) - { - M_StartMessage(NETEND,NULL,false); - return; - } - M_StartMessage(ENDGAME,M_EndGameResponse,true); + choice = 0; + if (!usergame) { + S_StartSound(NULL, sfx_oof); + return; + } + if (netgame) { + M_StartMessage(lang[NETEND], NULL, false); + return; + } + M_StartMessage(lang[ENDGAME], M_EndGameResponse, true); } -void M_ReadThis(int choice) + +void +M_ReadThis(int choice) { - choice = 0; - M_SetupNextMenu(&ReadDef1); + choice = 0; + M_SetupNextMenu(&ReadDef1); } -void M_ReadThis2(int choice) + +void +M_ReadThis2(int choice) { - choice = 0; - M_SetupNextMenu(&ReadDef2); + choice = 0; + M_SetupNextMenu(&ReadDef2); } -void M_FinishReadThis(int choice) + +void +M_FinishReadThis(int choice) { - choice = 0; - M_SetupNextMenu(&MainDef); + choice = 0; + M_SetupNextMenu(&MainDef); } -int quitsounds[8] = -{ - sfx_pldeth, - sfx_dmpain, - sfx_popain, - sfx_slop, - sfx_telept, - sfx_posit1, - sfx_posit3, - sfx_sgtatk -}; -int quitsounds2[8] = -{ - sfx_vilact, - sfx_getpow, - sfx_boscub, - sfx_slop, - sfx_skeswg, - sfx_kntdth, - sfx_bspact, - sfx_sgtatk -}; -void M_QuitResponse(int ch) + + + +void +M_QuitResponse(int ch) { - if (ch != 'y') - return; - if (!netgame) - { - if (gamemode == commercial) - S_StartSound(NULL,quitsounds2[(gametic>>2)&7]); - else - S_StartSound(NULL,quitsounds[(gametic>>2)&7]); - I_WaitVBL(105); - } - I_Quit (); + if (ch != 'y') return; + if (!netgame) { + S_StartSound(NULL, quitsounds[(gametic>>2)&7]); + I_WaitVBL(105); + } + I_Quit(); } -void M_QuitDOOM(int choice) + +void +M_QuitDOOM(int choice) { - if (language != english ) - sprintf(endstring,"%s\n\n"DOSY, endmsg[0] ); - else - sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]); - M_StartMessage(endstring,M_QuitResponse,true); + sprintf(endstring, "%s\n\n%s", lang[DOSY], lang[QUITMSG0 + (gametic % (QUITMSG21 - QUITMSG0 + 2))]); + M_StartMessage(endstring, M_QuitResponse, true); } -void M_ChangeSensitivity(int choice) -{ - switch(choice) - { - case 0: - if (mouseSensitivity) - mouseSensitivity--; - break; - case 1: - if (mouseSensitivity < 9) - mouseSensitivity++; - break; - } + +void +M_ChangeSensitivity(int choice) +{ + switch (choice) { + case 0: + if (mouseSensitivity) mouseSensitivity--; + break; + case 1: + if (mouseSensitivity < 9) mouseSensitivity++; + break; + } } -void M_ChangeDetail(int choice) + +void +M_ChangeDetail(int choice) { - choice = 0; - detailLevel = 1 - detailLevel; - fprintf( stderr, "M_ChangeDetail: low detail mode n.a.\n"); - return; - /*R_SetViewSize (screenblocks, detailLevel); - if (!detailLevel) - players[consoleplayer].message = DETAILHI; - else - players[consoleplayer].message = DETAILLO;*/ + choice = 0; + detailLevel = 1 - detailLevel; + fprintf(stderr, "M_ChangeDetail: low detail mode n.a.\n"); + return; } -void M_SizeDisplay(int choice) + +void +M_SizeDisplay(int choice) { - switch(choice) - { - case 0: - if (screenSize > 0) - { - screenblocks--; - screenSize--; + if (!choice && screenSize > 0) { + --screenblocks; + --screenSize; } - break; - case 1: - if (screenSize < 8) - { - screenblocks++; - screenSize++; + if (choice == 1 && screenSize < 8) { + ++screenblocks; + ++screenSize; } - break; - } - R_SetViewSize (screenblocks, detailLevel); + R_SetViewSize(screenblocks, detailLevel); } + void -M_DrawThermo -( int x, - int y, - int thermWidth, - int thermDot ) +M_DrawThermo(int x, int y, int thermWidth, int thermDot) { - int xx; - int i; - xx = x; - V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE)); - xx += 8; - for (i=0;i<thermWidth;i++) - { - V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMM",PU_CACHE)); + int xx; + int i; + + xx = x; + V_DrawPatch(xx, y, 0, W_CacheLumpName("M_THERML", PU_CACHE)); xx += 8; - } - V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMR",PU_CACHE)); - V_DrawPatchDirect ((x+8) + thermDot*8,y, - 0,W_CacheLumpName("M_THERMO",PU_CACHE)); + for (i = 0; i < thermWidth; ++i) { + V_DrawPatch(xx, y, 0, W_CacheLumpName("M_THERMM", PU_CACHE)); + xx += 8; + } + V_DrawPatch(xx, y, 0, W_CacheLumpName("M_THERMR", PU_CACHE)); + V_DrawPatch((x+8) + thermDot*8, y, 0, W_CacheLumpName("M_THERMO", PU_CACHE)); } + void -M_DrawEmptyCell -( menu_t* menu, - int item ) +M_DrawEmptyCell(menu_t* menu, int item) { - V_DrawPatchDirect (menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, - W_CacheLumpName("M_CELL1",PU_CACHE)); + V_DrawPatch(menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, W_CacheLumpName("M_CELL1", PU_CACHE)); } + void -M_DrawSelCell -( menu_t* menu, - int item ) +M_DrawSelCell(menu_t* menu, int item) { - V_DrawPatchDirect (menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, - W_CacheLumpName("M_CELL2",PU_CACHE)); + V_DrawPatch(menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, W_CacheLumpName("M_CELL2", PU_CACHE)); } + void -M_StartMessage -( char* string, - void (*routine)(int), - boolean input ) -{ - messageLastMenuActive = menuactive; - messageToPrint = 1; - messageString = string; - messageRoutine = routine; - messageNeedsInput = input; - menuactive = true; - return; +M_StartMessage(char* string, void (*routine)(int), boolean input) +{ + messageLastMenuActive = menuactive; + messageToPrint = 1; + messageString = string; + messageRoutine = routine; + messageNeedsInput = input; + menuactive = true; + return; } -void M_StopMessage(void) + +void +M_StopMessage() { - menuactive = messageLastMenuActive; - messageToPrint = 0; + menuactive = messageLastMenuActive; + messageToPrint = 0; } -int M_StringWidth(char* string) -{ - int i; - int w = 0; - int c; - for (i = 0;i < strlen(string);i++) - { - c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE) - w += 4; - else - w += SHORT (hu_font[c]->width); - } - return w; + +int +M_StringWidth(char* string) +{ + int i, w, c; + + w = 0; + for (i = 0;i < strlen(string);i++) { + c = toupper(string[i]) - HU_FONTSTART; + if (c < 0 || c >= HU_FONTSIZE) w += 4; + else w += SHORT(hu_font[c]->width); + } + return w; } -int M_StringHeight(char* string) -{ - int i; - int h; - int height = SHORT(hu_font[0]->height); - h = height; - for (i = 0;i < strlen(string);i++) - if (string[i] == '\n') - h += height; - return h; + +int +M_StringHeight(char* string) +{ + int i, h, height; + + height = SHORT(hu_font[0]->height); + h = height; + for (i = 0;i < strlen(string);i++) + if (string[i] == '\n') h += height; + return h; } + void -M_WriteText -( int x, - int y, - char* string) -{ - int w; - char* ch; - int c; - int cx; - int cy; - ch = string; - cx = x; - cy = y; - while(1) - { - c = *ch++; - if (!c) - break; - if (c == '\n') - { - cx = x; - cy += 12; - continue; - } - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c>= HU_FONTSIZE) - { - cx += 4; - continue; +M_WriteText(int x, int y, char* string) +{ + char* ch; + int c, cx, cy, w; + + ch = string; + cx = x; + cy = y; + while (1) { + c = *ch++; + if (!c) break; + if (c == '\n') { + cx = x; + cy += 12; + continue; + } + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c>= HU_FONTSIZE) { + cx += 4; + continue; + } + w = SHORT(hu_font[c]->width); + if (cx+w > SCREENWIDTH) break; + V_DrawPatch(cx, cy, 0, hu_font[c]); + cx+=w; } - w = SHORT (hu_font[c]->width); - if (cx+w > SCREENWIDTH) - break; - V_DrawPatchDirect(cx, cy, 0, hu_font[c]); - cx+=w; - } } -boolean M_Responder (event_t* ev) -{ - int ch; - int i; - static int joywait = 0; - static int mousewait = 0; - static int mousey = 0; - static int lasty = 0; - static int mousex = 0; - static int lastx = 0; - ch = -1; - if (ev->type == ev_joystick && joywait < I_GetTime()) - { - if (ev->data3 == -1) - { - ch = KEY_UPARROW; - joywait = I_GetTime() + 5; - } - else if (ev->data3 == 1) - { - ch = KEY_DOWNARROW; - joywait = I_GetTime() + 5; - } - if (ev->data2 == -1) - { - ch = KEY_LEFTARROW; - joywait = I_GetTime() + 2; - } - else if (ev->data2 == 1) - { - ch = KEY_RIGHTARROW; - joywait = I_GetTime() + 2; - } - if (ev->data1&1) - { - ch = KEY_ENTER; - joywait = I_GetTime() + 5; + +boolean +M_Responder(event_t* ev) +{ + int i, ch; + static int joywait, mousewait, mousey, mousex, lasty, lastx; + + joywait = mousewait = mousey = mousex = lasty = lastx = 0; + ch = -1; + if (ev->type == ev_joystick && joywait < I_GetTime()) { + if (ev->data3 == -1) { + ch = KEY_UPARROW; + joywait = I_GetTime() + 5; + } + else if (ev->data3 == 1) { + ch = KEY_DOWNARROW; + joywait = I_GetTime() + 5; + } + if (ev->data2 == -1) { + ch = KEY_LEFTARROW; + joywait = I_GetTime() + 2; + } + else if (ev->data2 == 1) { + ch = KEY_RIGHTARROW; + joywait = I_GetTime() + 2; + } + if (ev->data1&1) { + ch = KEY_ENTER; + joywait = I_GetTime() + 5; + } + if (ev->data1&2) { + ch = KEY_BACKSPACE; + joywait = I_GetTime() + 5; + } + } else { + if (ev->type == ev_mouse && mousewait < I_GetTime()) { + mousey += ev->data3; + if (mousey < lasty-30) { + ch = KEY_DOWNARROW; + mousewait = I_GetTime() + 5; + mousey = lasty -= 30; + } else if (mousey > lasty+30) { + ch = KEY_UPARROW; + mousewait = I_GetTime() + 5; + mousey = lasty += 30; + } + mousex += ev->data2; + if (mousex < lastx-30) { + ch = KEY_LEFTARROW; + mousewait = I_GetTime() + 5; + mousex = lastx -= 30; + } + else if (mousex > lastx+30) { + ch = KEY_RIGHTARROW; + mousewait = I_GetTime() + 5; + mousex = lastx += 30; + } + if (ev->data1&1) { + ch = KEY_ENTER; + mousewait = I_GetTime() + 15; + } + if (ev->data1&2) { + ch = KEY_BACKSPACE; + mousewait = I_GetTime() + 15; + } + } else { + if (ev->type == ev_keydown) ch = ev->data1; + } } - if (ev->data1&2) - { - ch = KEY_BACKSPACE; - joywait = I_GetTime() + 5; + if (ch == -1) return false; + if (saveStringEnter) { + switch (ch) { + case KEY_BACKSPACE: + if (saveCharIndex > 0) { + saveCharIndex--; + savegamestrings[saveSlot][saveCharIndex] = 0; + } + break; + case KEY_ESCAPE: + saveStringEnter = 0; + strcpy(&savegamestrings[saveSlot][0], saveOldString); + break; + case KEY_ENTER: + saveStringEnter = 0; + if (savegamestrings[saveSlot][0]) M_DoSave(saveSlot); + break; + default: + ch = toupper(ch); + if (ch != 32) + if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE) + break; + if (ch >= 32 && ch <= 127 && saveCharIndex < SAVESTRINGSIZE-1 && M_StringWidth(savegamestrings[saveSlot]) < (SAVESTRINGSIZE-2)*8) { + savegamestrings[saveSlot][saveCharIndex++] = ch; + savegamestrings[saveSlot][saveCharIndex] = 0; + } + break; + } + return true; } - } - else - { - if (ev->type == ev_mouse && mousewait < I_GetTime()) - { - mousey += ev->data3; - if (mousey < lasty-30) - { - ch = KEY_DOWNARROW; - mousewait = I_GetTime() + 5; - mousey = lasty -= 30; - } - else if (mousey > lasty+30) - { - ch = KEY_UPARROW; - mousewait = I_GetTime() + 5; - mousey = lasty += 30; - } - mousex += ev->data2; - if (mousex < lastx-30) - { - ch = KEY_LEFTARROW; - mousewait = I_GetTime() + 5; - mousex = lastx -= 30; - } - else if (mousex > lastx+30) - { - ch = KEY_RIGHTARROW; - mousewait = I_GetTime() + 5; - mousex = lastx += 30; - } - if (ev->data1&1) - { - ch = KEY_ENTER; - mousewait = I_GetTime() + 15; - } - if (ev->data1&2) - { - ch = KEY_BACKSPACE; - mousewait = I_GetTime() + 15; - } + if (messageToPrint) { + if (messageNeedsInput && !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE)) return false; + menuactive = messageLastMenuActive; + messageToPrint = 0; + if (messageRoutine) messageRoutine(ch); + menuactive = false; + S_StartSound(NULL, sfx_swtchx); + return true; } - else - if (ev->type == ev_keydown) - { - ch = ev->data1; - } - } - if (ch == -1) - return false; - if (saveStringEnter) - { - switch(ch) - { - case KEY_BACKSPACE: - if (saveCharIndex > 0) - { - saveCharIndex--; - savegamestrings[saveSlot][saveCharIndex] = 0; - } - break; - case KEY_ESCAPE: - saveStringEnter = 0; - strcpy(&savegamestrings[saveSlot][0],saveOldString); - break; - case KEY_ENTER: - saveStringEnter = 0; - if (savegamestrings[saveSlot][0]) - M_DoSave(saveSlot); - break; - default: - ch = toupper(ch); - if (ch != 32) - if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE) - break; - if (ch >= 32 && ch <= 127 && - saveCharIndex < SAVESTRINGSIZE-1 && - M_StringWidth(savegamestrings[saveSlot]) < - (SAVESTRINGSIZE-2)*8) - { - savegamestrings[saveSlot][saveCharIndex++] = ch; - savegamestrings[saveSlot][saveCharIndex] = 0; - } - break; + if (!menuactive) { + switch (ch) { + case KEY_MINUS: + if (automapactive || chat_on) return false; + M_SizeDisplay(0); + S_StartSound(NULL, sfx_stnmov); + return true; + case KEY_EQUALS: + if (automapactive || chat_on) return false; + M_SizeDisplay(1); + S_StartSound(NULL, sfx_stnmov); + return true; + case KEY_F1: + M_StartControlPanel(); + currentMenu = &ReadDef1; + itemOn = 0; + S_StartSound(NULL, sfx_swtchn); + return true; + case KEY_F2: + M_StartControlPanel(); + S_StartSound(NULL, sfx_swtchn); + M_SaveGame(0); + return true; + case KEY_F3: + M_StartControlPanel(); + S_StartSound(NULL, sfx_swtchn); + M_LoadGame(0); + return true; + case KEY_F4: + M_StartControlPanel(); + currentMenu = &SoundDef; + itemOn = sfx_vol; + S_StartSound(NULL, sfx_swtchn); + return true; + case KEY_F5: + M_ChangeDetail(0); + S_StartSound(NULL, sfx_swtchn); + return true; + case KEY_F6: + S_StartSound(NULL, sfx_swtchn); + M_QuickSave(); + return true; + case KEY_F7: + S_StartSound(NULL, sfx_swtchn); + M_EndGame(0); + return true; + case KEY_F8: + M_ChangeMessages(0); + S_StartSound(NULL, sfx_swtchn); + return true; + case KEY_F9: + S_StartSound(NULL, sfx_swtchn); + M_QuickLoad(); + return true; + case KEY_F10: + S_StartSound(NULL, sfx_swtchn); + M_QuitDOOM(0); + return true; + case KEY_F11: + usegamma++; + if (usegamma > 4) usegamma = 0; + players[consoleplayer].message = lang[gammamsg[usegamma]]; + I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); + return true; + } } - return true; - } - if (messageToPrint) - { - if (messageNeedsInput == true && - !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE)) - return false; - menuactive = messageLastMenuActive; - messageToPrint = 0; - if (messageRoutine) - messageRoutine(ch); - menuactive = false; - S_StartSound(NULL,sfx_swtchx); - return true; - } - if (devparm && ch == KEY_F1) - { - G_ScreenShot (); - return true; - } - if (!menuactive) - switch(ch) - { - case KEY_MINUS: - if (automapactive || chat_on) - return false; - M_SizeDisplay(0); - S_StartSound(NULL,sfx_stnmov); - return true; - case KEY_EQUALS: - if (automapactive || chat_on) + if (!menuactive) { + if (ch == KEY_ESCAPE) { + M_StartControlPanel(); + S_StartSound(NULL, sfx_swtchn); + return true; + } return false; - M_SizeDisplay(1); - S_StartSound(NULL,sfx_stnmov); - return true; - case KEY_F1: - M_StartControlPanel (); - if ( gamemode == retail ) - currentMenu = &ReadDef2; - else - currentMenu = &ReadDef1; - itemOn = 0; - S_StartSound(NULL,sfx_swtchn); - return true; - case KEY_F2: - M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); - M_SaveGame(0); - return true; - case KEY_F3: - M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); - M_LoadGame(0); - return true; - case KEY_F4: - M_StartControlPanel (); - currentMenu = &SoundDef; - itemOn = sfx_vol; - S_StartSound(NULL,sfx_swtchn); - return true; - case KEY_F5: - M_ChangeDetail(0); - S_StartSound(NULL,sfx_swtchn); - return true; - case KEY_F6: - S_StartSound(NULL,sfx_swtchn); - M_QuickSave(); - return true; - case KEY_F7: - S_StartSound(NULL,sfx_swtchn); - M_EndGame(0); - return true; - case KEY_F8: - M_ChangeMessages(0); - S_StartSound(NULL,sfx_swtchn); - return true; - case KEY_F9: - S_StartSound(NULL,sfx_swtchn); - M_QuickLoad(); - return true; - case KEY_F10: - S_StartSound(NULL,sfx_swtchn); - M_QuitDOOM(0); - return true; - case KEY_F11: - usegamma++; - if (usegamma > 4) - usegamma = 0; - players[consoleplayer].message = gammamsg[usegamma]; - I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); - return true; - } - if (!menuactive) - { - if (ch == KEY_ESCAPE) - { - M_StartControlPanel (); - S_StartSound(NULL,sfx_swtchn); - return true; } + switch (ch) { + case KEY_DOWNARROW: + do { + if (itemOn+1 > currentMenu->numitems-1) itemOn = 0; + else itemOn++; + S_StartSound(NULL, sfx_pstop); + } while (currentMenu->menuitems[itemOn].status==-1); + return true; + case KEY_UPARROW: + do { + if (!itemOn) itemOn = currentMenu->numitems-1; + else itemOn--; + S_StartSound(NULL, sfx_pstop); + } while (currentMenu->menuitems[itemOn].status==-1); + return true; + case KEY_LEFTARROW: + if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { + S_StartSound(NULL, sfx_stnmov); + currentMenu->menuitems[itemOn].routine(0); + } + return true; + case KEY_RIGHTARROW: + if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { + S_StartSound(NULL, sfx_stnmov); + currentMenu->menuitems[itemOn].routine(1); + } + return true; + case KEY_ENTER: + if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status) { + currentMenu->lastOn = itemOn; + if (currentMenu->menuitems[itemOn].status == 2) { + currentMenu->menuitems[itemOn].routine(1); + S_StartSound(NULL, sfx_stnmov); + } else { + currentMenu->menuitems[itemOn].routine(itemOn); + S_StartSound(NULL, sfx_pistol); + } + } + return true; + case KEY_ESCAPE: + currentMenu->lastOn = itemOn; + M_ClearMenus(); + S_StartSound(NULL, sfx_swtchx); + return true; + case KEY_BACKSPACE: + currentMenu->lastOn = itemOn; + if (currentMenu->prevMenu) { + currentMenu = currentMenu->prevMenu; + itemOn = currentMenu->lastOn; + S_StartSound(NULL, sfx_swtchn); + } + return true; + default: + for (i = itemOn+1;i < currentMenu->numitems;i++) + if (currentMenu->menuitems[i].alphaKey == ch) { + itemOn = i; + S_StartSound(NULL, sfx_pstop); + return true; + } + for (i = 0;i <= itemOn;i++) + if (currentMenu->menuitems[i].alphaKey == ch) { + itemOn = i; + S_StartSound(NULL, sfx_pstop); + return true; + } + break; + } return false; - } - switch (ch) - { - case KEY_DOWNARROW: - do - { - if (itemOn+1 > currentMenu->numitems-1) - itemOn = 0; - else itemOn++; - S_StartSound(NULL,sfx_pstop); - } while(currentMenu->menuitems[itemOn].status==-1); - return true; - case KEY_UPARROW: - do - { - if (!itemOn) - itemOn = currentMenu->numitems-1; - else itemOn--; - S_StartSound(NULL,sfx_pstop); - } while(currentMenu->menuitems[itemOn].status==-1); - return true; - case KEY_LEFTARROW: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status == 2) - { - S_StartSound(NULL,sfx_stnmov); - currentMenu->menuitems[itemOn].routine(0); - } - return true; - case KEY_RIGHTARROW: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status == 2) - { - S_StartSound(NULL,sfx_stnmov); - currentMenu->menuitems[itemOn].routine(1); - } - return true; - case KEY_ENTER: - if (currentMenu->menuitems[itemOn].routine && - currentMenu->menuitems[itemOn].status) - { - currentMenu->lastOn = itemOn; - if (currentMenu->menuitems[itemOn].status == 2) - { - currentMenu->menuitems[itemOn].routine(1); - S_StartSound(NULL,sfx_stnmov); - } - else - { - currentMenu->menuitems[itemOn].routine(itemOn); - S_StartSound(NULL,sfx_pistol); - } - } - return true; - case KEY_ESCAPE: - currentMenu->lastOn = itemOn; - M_ClearMenus (); - S_StartSound(NULL,sfx_swtchx); - return true; - case KEY_BACKSPACE: - currentMenu->lastOn = itemOn; - if (currentMenu->prevMenu) - { - currentMenu = currentMenu->prevMenu; - itemOn = currentMenu->lastOn; - S_StartSound(NULL,sfx_swtchn); - } - return true; - default: - for (i = itemOn+1;i < currentMenu->numitems;i++) - if (currentMenu->menuitems[i].alphaKey == ch) - { - itemOn = i; - S_StartSound(NULL,sfx_pstop); - return true; - } - for (i = 0;i <= itemOn;i++) - if (currentMenu->menuitems[i].alphaKey == ch) - { - itemOn = i; - S_StartSound(NULL,sfx_pstop); - return true; - } - break; - } - return false; } -void M_StartControlPanel (void) + +void +M_StartControlPanel() { - if (menuactive) - return; - menuactive = 1; - currentMenu = &MainDef; - itemOn = currentMenu->lastOn; + if (menuactive) return; + menuactive = 1; + currentMenu = &MainDef; + itemOn = currentMenu->lastOn; } -void M_Drawer (void) -{ - static short x; - static short y; - short i; - short max; - char string[40]; - int start; - inhelpscreens = false; - if (messageToPrint) - { - start = 0; - y = 100 - M_StringHeight(messageString)/2; - while(*(messageString+start)) - { - for (i = 0;i < strlen(messageString+start);i++) - if (*(messageString+start+i) == '\n') - { - memset(string,0,40); - strncpy(string,messageString+start,i); - start += i+1; - break; + +void +M_Drawer() +{ + static short x, y; + char string[40]; + int start; + short i, max; + + inhelpscreens = false; + if (messageToPrint) { + start = 0; + y = 100 - M_StringHeight(messageString)/2; + while (messageString[start]) { + for (i = 0; i < strlen(messageString+start); ++i) + if ((messageString[start+i]) == '\n') { + memset(string, 0, 40); + strncpy(string, messageString+start, i); + start += i + 1; + break; + } + if (i == strlen(messageString+start)) { + strcpy(string, messageString+start); + start += i; + } + x = 160 - M_StringWidth(string)/2; + M_WriteText(x, y, string); + y += SHORT(hu_font[0]->height); } - if (i == strlen(messageString+start)) - { - strcpy(string,messageString+start); - start += i; - } - x = 160 - M_StringWidth(string)/2; - M_WriteText(x,y,string); - y += SHORT(hu_font[0]->height); + return; } - return; - } - if (!menuactive) - return; - if (currentMenu->routine) - currentMenu->routine(); - x = currentMenu->x; - y = currentMenu->y; - max = currentMenu->numitems; - for (i=0;i<max;i++) - { - if (currentMenu->menuitems[i].name[0]) - V_DrawPatchDirect (x,y,0, - W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE)); - y += LINEHEIGHT; - } - V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0, - W_CacheLumpName(skullName[whichSkull],PU_CACHE)); + if (!menuactive) return; + if (currentMenu->routine) currentMenu->routine(); + x = currentMenu->x; + y = currentMenu->y; + max = currentMenu->numitems; + for (i = 0; i < max; ++i) { + if (currentMenu->menuitems[i].name[0]) V_DrawPatch(x, y, 0, W_CacheLumpName(currentMenu->menuitems[i].name, PU_CACHE)); + y += LINEHEIGHT; + } + V_DrawPatch(x + SKULLXOFF, currentMenu->y - 5 + itemOn*LINEHEIGHT, 0, W_CacheLumpName(skullName[whichSkull], PU_CACHE)); } -void M_ClearMenus (void) + +void +M_ClearMenus() { - menuactive = 0; + menuactive = 0; } -void M_SetupNextMenu(menu_t *menudef) + +void +M_SetupNextMenu(menu_t* menudef) { - currentMenu = menudef; - itemOn = currentMenu->lastOn; + currentMenu = menudef; + itemOn = currentMenu->lastOn; } -void M_Ticker (void) + +void +M_Ticker() { - if (--skullAnimCounter <= 0) - { - whichSkull ^= 1; - skullAnimCounter = 8; - } + if (--skullAnimCounter <= 0) { + whichSkull ^= 1; + skullAnimCounter = 8; + } } -void M_Init (void) -{ - currentMenu = &MainDef; - menuactive = 0; - itemOn = currentMenu->lastOn; - whichSkull = 0; - skullAnimCounter = 10; - screenSize = screenblocks - 3; - messageToPrint = 0; - messageString = NULL; - messageLastMenuActive = menuactive; - quickSaveSlot = -1; - switch ( gamemode ) - { - case commercial: - MainMenu[readthis] = MainMenu[quitdoom]; - MainDef.numitems--; - MainDef.y += 8; - NewDef.prevMenu = &MainDef; - ReadDef1.routine = M_DrawReadThis1; - ReadDef1.x = 330; - ReadDef1.y = 165; - ReadMenu1[0].routine = M_FinishReadThis; - break; - case shareware: - case registered: + +void +M_Init() +{ + currentMenu = &MainDef; + menuactive = 0; + itemOn = currentMenu->lastOn; + whichSkull = 0; + skullAnimCounter = 10; + screenSize = screenblocks - 3; + messageToPrint = 0; + messageString = NULL; + messageLastMenuActive = menuactive; + quickSaveSlot = -1; EpiDef.numitems--; - break; - case retail: - default: - break; - } } diff --git a/src/m_menu.h b/src/m_menu.h @@ -1,9 +1,12 @@ #ifndef __M_MENU__ #define __M_MENU__ + #include "d_event.h" + boolean M_Responder (event_t *ev); -void M_Ticker (void); -void M_Drawer (void); -void M_Init (void); +void M_Ticker(void); +void M_Drawer(void); +void M_Init(void); void M_StartControlPanel (void); + #endif diff --git a/src/m_misc.c b/src/m_misc.c @@ -1,12 +1,14 @@ -#include <sys/stat.h> -#include <sys/types.h> +#include <ctype.h> #include <fcntl.h> #include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> -#include <ctype.h> + +#include "m_misc.h" +#include "m_swap.h" #include "doomdef.h" #include "z_zone.h" -#include "m_swap.h" #include "m_argv.h" #include "w_wad.h" #include "i_system.h" @@ -15,331 +17,114 @@ #include "hu_stuff.h" #include "doomstat.h" #include "dstrings.h" -#include "m_misc.h" -extern patch_t* hu_font[HU_FONTSIZE]; -int -M_DrawText -( int x, - int y, - boolean direct, - char* string ) -{ - int c; - int w; - while (*string) - { - c = toupper(*string) - HU_FONTSTART; - string++; - if (c < 0 || c> HU_FONTSIZE) - { - x += 4; - continue; - } - w = SHORT (hu_font[c]->width); - if (x+w > SCREENWIDTH) - break; - if (direct) - V_DrawPatchDirect(x, y, 0, hu_font[c]); - else - V_DrawPatch(x, y, 0, hu_font[c]); - x+=w; - } - return x; -} -#ifndef O_BINARY -#define O_BINARY 0 -#endif -boolean -M_WriteFile -( char const* name, - void* source, - int length ) -{ - int handle; - int count; - handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - if (handle == -1) - return false; - count = write (handle, source, length); - close (handle); - if (count < length) - return false; - return true; -} -int -M_ReadFile -( char const* name, - byte** buffer ) -{ - int handle, count, length; - struct stat fileinfo; - byte *buf; - handle = open (name, O_RDONLY | O_BINARY, 0666); - if (handle == -1) - I_Error ("Couldn't read file %s", name); - if (fstat (handle,&fileinfo) == -1) - I_Error ("Couldn't read file %s", name); - length = fileinfo.st_size; - buf = Z_Malloc (length, PU_STATIC, NULL); - count = read (handle, buf, length); - close (handle); - if (count < length) - I_Error ("Couldn't read file %s", name); - *buffer = buf; - return length; -} -int usemouse; -int usejoystick; -extern int key_right; -extern int key_left; -extern int key_up; -extern int key_down; -extern int key_strafeleft; -extern int key_straferight; -extern int key_fire; -extern int key_use; -extern int key_strafe; -extern int key_speed; -extern int mousebfire; -extern int mousebstrafe; -extern int mousebforward; -extern int joybfire; -extern int joybstrafe; -extern int joybuse; -extern int joybspeed; -extern int viewwidth; -extern int viewheight; -extern int mouseSensitivity; -extern int showMessages; -extern int detailLevel; -extern int screenblocks; -extern int showMessages; -extern int numChannels; -#ifdef SNDSERV -extern char* sndserver_filename; -extern int mb_used; -#endif -#ifdef LINUX -char* mousetype; -char* mousedev; -#endif -extern char* chat_macros[]; -typedef struct -{ - char* name; - int* location; - long defaultvalue; - long scantranslate; - long untranslated; -} default_t; -default_t defaults[] = -{ - {"mouse_sensitivity",&mouseSensitivity, 5}, - {"sfx_volume",&snd_SfxVolume, 8}, - {"music_volume",&snd_MusicVolume, 8}, - {"show_messages",&showMessages, 1}, - {"key_right",&key_right, KEY_RIGHTARROW}, - {"key_left",&key_left, KEY_LEFTARROW}, - {"key_up",&key_up, KEY_UPARROW}, - {"key_down",&key_down, KEY_DOWNARROW}, - {"key_strafeleft",&key_strafeleft, ','}, - {"key_straferight",&key_straferight, '.'}, - {"key_fire",&key_fire, KEY_RCTRL}, - {"key_use",&key_use, ' '}, - {"key_strafe",&key_strafe, KEY_RALT}, - {"key_speed",&key_speed, KEY_RSHIFT}, - {"mb_used", &mb_used, 2}, - {"use_mouse",&usemouse, 1}, - {"mouseb_fire",&mousebfire,0}, - {"mouseb_strafe",&mousebstrafe,1}, - {"mouseb_forward",&mousebforward,2}, - {"use_joystick",&usejoystick, 0}, - {"joyb_fire",&joybfire,0}, - {"joyb_strafe",&joybstrafe,1}, - {"joyb_use",&joybuse,3}, - {"joyb_speed",&joybspeed,2}, - {"screenblocks",&screenblocks, 9}, - {"detaillevel",&detailLevel, 0}, - {"snd_channels",&numChannels, 3}, - {"usegamma",&usegamma, 0}, - {"chatmacro0", (int*) &chat_macros[0], (long)HUSTR_CHATMACRO0 }, - {"chatmacro1", (int*) &chat_macros[1], (long)HUSTR_CHATMACRO1 }, - {"chatmacro2", (int*) &chat_macros[2], (long)HUSTR_CHATMACRO2 }, - {"chatmacro3", (int*) &chat_macros[3], (long)HUSTR_CHATMACRO3 }, - {"chatmacro4", (int*) &chat_macros[4], (long)HUSTR_CHATMACRO4 }, - {"chatmacro5", (int*) &chat_macros[5], (long)HUSTR_CHATMACRO5 }, - {"chatmacro6", (int*) &chat_macros[6], (long)HUSTR_CHATMACRO6 }, - {"chatmacro7", (int*) &chat_macros[7], (long)HUSTR_CHATMACRO7 }, - {"chatmacro8", (int*) &chat_macros[8], (long)HUSTR_CHATMACRO8 }, - {"chatmacro9", (int*) &chat_macros[9], (long)HUSTR_CHATMACRO9 } +extern int key_right; +extern int key_left; +extern int key_up; +extern int key_down; +extern int key_strafeleft; +extern int key_straferight; +extern int key_fire; +extern int key_use; +extern int key_strafe; +extern int key_speed; +extern int mousebfire; +extern int mousebstrafe; +extern int mousebforward; +extern int joybfire; +extern int joybstrafe; +extern int joybuse; +extern int joybspeed; +extern int mouseSensitivity; +extern int showMessages; +extern int detailLevel; +extern int screenblocks; +extern int numChannels; +extern char* chat_macros[]; + +int usemouse; +int usejoystick; + +typedef struct default_t Default; + +struct default_t { + int* location; + long defaultvalue; + long scantranslate; + long untranslated; }; -int numdefaults; -char* defaultfile; -void M_SaveDefaults (void) -{ - int i; - int v; - FILE* f; - f = fopen (defaultfile, "w"); - if (!f) - return; - for (i=0 ; i<numdefaults ; i++) - { - if (defaults[i].defaultvalue > -0xfff - && defaults[i].defaultvalue < 0xfff) - { - v = *defaults[i].location; - fprintf (f,"%s\t\t%i\n",defaults[i].name,v); - } else { - fprintf (f,"%s\t\t\"%s\"\n",defaults[i].name, - * (char **) (defaults[i].location)); - } - } - fclose (f); -} -extern byte scantokey[128]; -void M_LoadDefaults (void) + +Default defaults[] = { + /* location default*/ + { &mouseSensitivity, 5 }, + { &snd_SfxVolume, 8 }, + { &snd_MusicVolume, 8 }, + { &showMessages, 1 }, + { &key_right, KEY_RIGHTARROW }, + { &key_left, KEY_LEFTARROW }, + { &key_up, KEY_UPARROW }, + { &key_down, KEY_DOWNARROW }, + { &key_strafeleft, ',' }, + { &key_straferight, '.' }, + { &key_fire, KEY_RCTRL }, + { &key_use, ' ' }, + { &key_strafe, KEY_RALT }, + { &key_speed, KEY_RSHIFT }, + { &usemouse, 1 }, + { &mousebfire, 0 }, + { &mousebstrafe, 1 }, + { &mousebforward, 2 }, + { &usejoystick, 0 }, + { &joybfire, 0 }, + { &joybstrafe, 1 }, + { &joybuse, 3 }, + { &joybspeed, 2 }, + { &screenblocks, 9 }, + { &detailLevel, 0 }, + { &numChannels, 3 }, + { &usegamma, 0 }, + { (int*)&chat_macros[0], (long)HUSTR_CHATMACRO0 }, + { (int*)&chat_macros[1], (long)HUSTR_CHATMACRO1 }, + { (int*)&chat_macros[2], (long)HUSTR_CHATMACRO2 }, + { (int*)&chat_macros[3], (long)HUSTR_CHATMACRO3 }, + { (int*)&chat_macros[4], (long)HUSTR_CHATMACRO4 }, + { (int*)&chat_macros[5], (long)HUSTR_CHATMACRO5 }, + { (int*)&chat_macros[6], (long)HUSTR_CHATMACRO6 }, + { (int*)&chat_macros[7], (long)HUSTR_CHATMACRO7 }, + { (int*)&chat_macros[8], (long)HUSTR_CHATMACRO8 }, + { (int*)&chat_macros[9], (long)HUSTR_CHATMACRO9 } +}; + +void +M_LoadDefaults() { - int i; - int len; - FILE* f; - char def[80]; - char strparm[100]; - char* newstring; - unsigned int parm; - boolean isstring; - numdefaults = sizeof(defaults)/sizeof(defaults[0]); - for (i=0 ; i<numdefaults ; i++) - *defaults[i].location = defaults[i].defaultvalue; - i = M_CheckParm ("-config"); - if (i && i<myargc-1) - { - defaultfile = myargv[i+1]; - printf (" default file: %s\n",defaultfile); - } - else - defaultfile = basedefault; - f = fopen (defaultfile, "r"); - if (f) - { - while (!feof(f)) - { - isstring = false; - if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2) - { - if (strparm[0] == '"') - { - isstring = true; - len = strlen(strparm); - newstring = (char *) malloc(len); - strparm[len-1] = 0; - strcpy(newstring, strparm+1); - } - else if (strparm[0] == '0' && strparm[1] == 'x') - sscanf(strparm+2, "%x", &parm); - else - sscanf(strparm, "%ud", &parm); - for (i=0 ; i<numdefaults ; i++) - if (!strcmp(def, defaults[i].name)) - { - if (!isstring) - *defaults[i].location = parm; - else - *defaults[i].location = - (long) newstring; - break; - } - } - } - fclose (f); - } + uint i; + + for (i = 0; i < LENGTH(defaults); ++i) + *defaults[i].location = defaults[i].defaultvalue; } -typedef struct -{ - char manufacturer; - char version; - char encoding; - char bits_per_pixel; - unsigned short xmin; - unsigned short ymin; - unsigned short xmax; - unsigned short ymax; - unsigned short hres; - unsigned short vres; - unsigned char palette[48]; - char reserved; - char color_planes; - unsigned short bytes_per_line; - unsigned short palette_type; - char filler[58]; - unsigned char data; -} pcx_t; + void -WritePCXfile -( char* filename, - byte* data, - int width, - int height, - byte* palette ) +M_WriteFile(char* name, void* src, uint n) { - int i; - int length; - pcx_t* pcx; - byte* pack; - pcx = Z_Malloc (width*height*2+1000, PU_STATIC, NULL); - pcx->manufacturer = 0x0a; - pcx->version = 5; - pcx->encoding = 1; - pcx->bits_per_pixel = 8; - pcx->xmin = 0; - pcx->ymin = 0; - pcx->xmax = SHORT(width-1); - pcx->ymax = SHORT(height-1); - pcx->hres = SHORT(width); - pcx->vres = SHORT(height); - memset (pcx->palette,0,sizeof(pcx->palette)); - pcx->color_planes = 1; - pcx->bytes_per_line = SHORT(width); - pcx->palette_type = SHORT(2); - memset (pcx->filler,0,sizeof(pcx->filler)); - pack = &pcx->data; - for (i=0 ; i<width*height ; i++) - { - if ( (*data & 0xc0) != 0xc0) - *pack++ = *data++; - else - { - *pack++ = 0xc1; - *pack++ = *data++; - } - } - *pack++ = 0x0c; - for (i=0 ; i<768 ; i++) - *pack++ = *palette++; - length = pack - (byte *)pcx; - M_WriteFile (filename, pcx, length); - Z_Free (pcx); + FILE* f; + + f = fopen(name, "w"); + fwrite(src, n, 1, f); + fclose(f); } -void M_ScreenShot (void) + +void +M_ReadFile(char* name, uchar** buf) { - int i; - byte* linear; - char lbmname[12]; - linear = screens[2]; - I_ReadScreen (linear); - strcpy(lbmname,"DOOM00.pcx"); - for (i=0 ; i<=99 ; i++) - { - lbmname[4] = i/10 + '0'; - lbmname[5] = i%10 + '0'; - if (access(lbmname,0) == -1) - break; - } - if (i==100) - I_Error ("M_ScreenShot: Couldn't create a PCX"); - WritePCXfile (lbmname, linear, - SCREENWIDTH, SCREENHEIGHT, - W_CacheLumpName ("PLAYPAL",PU_CACHE)); - players[consoleplayer].message = "screen shot"; + FILE* f; + ulong n; + + f = fopen(name, "r"); + fseek(f, 0, SEEK_END); + n = ftell(f); + fseek(f, 0, SEEK_SET); + *buf = Z_Malloc(n, PU_STATIC, NULL); + fread(*buf, n, 1, f); + fclose(f); } diff --git a/src/m_misc.h b/src/m_misc.h @@ -1,22 +1,10 @@ #ifndef __M_MISC__ #define __M_MISC__ -#include "doomtype.h" -boolean -M_WriteFile -( char const* name, - void* source, - int length ); -int -M_ReadFile -( char const* name, - byte** buffer ); -void M_ScreenShot (void); -void M_LoadDefaults (void); -void M_SaveDefaults (void); -int -M_DrawText -( int x, - int y, - boolean direct, - char* string ); + +#include "doomdef.h" + +void M_WriteFile(char* name, void* src, uint n); +void M_ReadFile(char* name, uchar** buf); +void M_LoadDefaults(); + #endif diff --git a/src/m_random.c b/src/m_random.c @@ -19,19 +19,28 @@ unsigned char rndtable[256] = { 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 120, 163, 236, 249 }; + int rndindex = 0; int prndindex = 0; + + int P_Random (void) { prndindex = (prndindex+1)&0xff; return rndtable[prndindex]; } + int M_Random (void) { rndindex = (rndindex+1)&0xff; return rndtable[rndindex]; } + void M_ClearRandom (void) { rndindex = prndindex = 0; } + + + + diff --git a/src/m_random.h b/src/m_random.h @@ -1,7 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __M_RANDOM__ #define __M_RANDOM__ -#include "doomtype.h" + + +#include "doomdef.h" + + + + + int M_Random (void); + + int P_Random (void); + + void M_ClearRandom (void); + + #endif + + + + + diff --git a/src/m_swap.c b/src/m_swap.c @@ -1,18 +1,21 @@ -#ifdef __GNUG__ -#pragma implementation "m_swap.h" -#endif #include "m_swap.h" + #ifndef __BIG_ENDIAN__ -unsigned short SwapSHORT(unsigned short x) + +unsigned short +SwapSHORT(unsigned short x) { return (x>>8) | (x<<8); } -unsigned long SwapLONG( unsigned long x) + +unsigned long +SwapLONG( unsigned long x) { return - (x>>24) + (x >> 24) | ((x>>8) & 0xff00) | ((x<<8) & 0xff0000) | (x<<24); } + #endif diff --git a/src/m_swap.h b/src/m_swap.h @@ -1,8 +1,6 @@ #ifndef __M_SWAP__ #define __M_SWAP__ -#ifdef __GNUG__ -#pragma interface -#endif + #ifdef __BIG_ENDIAN__ short SwapSHORT(short); long SwapLONG(long); @@ -12,4 +10,5 @@ long SwapLONG(long); #define SHORT(x) (x) #define LONG(x) (x) #endif + #endif diff --git a/src/p_ceilng.c b/src/p_ceilng.c @@ -1,23 +1,44 @@ #include "z_zone.h" #include "doomdef.h" #include "p_local.h" + #include "s_sound.h" + + #include "doomstat.h" #include "r_state.h" + + #include "sounds.h" + + + + + + ceiling_t* activeceilings[MAXCEILINGS]; + + + + + + void T_MoveCeiling (ceiling_t* ceiling) { result_e res; + switch(ceiling->direction) { case 0: + break; case 1: + res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->topheight, false,1,ceiling->direction); + if (!(leveltime&7)) { switch(ceiling->type) @@ -27,9 +48,11 @@ void T_MoveCeiling (ceiling_t* ceiling) default: S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov); + break; } } + if (res == pastdest) { switch(ceiling->type) @@ -37,6 +60,7 @@ void T_MoveCeiling (ceiling_t* ceiling) case raiseToHighest: P_RemoveActiveCeiling(ceiling); break; + case silentCrushAndRaise: S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_pstop); @@ -44,16 +68,21 @@ void T_MoveCeiling (ceiling_t* ceiling) case crushAndRaise: ceiling->direction = -1; break; + default: break; } + } break; + case -1: + res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->bottomheight, ceiling->crush,1,ceiling->direction); + if (!(leveltime&7)) { switch(ceiling->type) @@ -64,6 +93,7 @@ void T_MoveCeiling (ceiling_t* ceiling) sfx_stnmov); } } + if (res == pastdest) { switch(ceiling->type) @@ -76,10 +106,12 @@ void T_MoveCeiling (ceiling_t* ceiling) case fastCrushAndRaise: ceiling->direction = 1; break; + case lowerAndCrush: case lowerToFloor: P_RemoveActiveCeiling(ceiling); break; + default: break; } @@ -95,6 +127,7 @@ void T_MoveCeiling (ceiling_t* ceiling) case lowerAndCrush: ceiling->speed = CEILSPEED / 8; break; + default: break; } @@ -103,6 +136,12 @@ void T_MoveCeiling (ceiling_t* ceiling) break; } } + + + + + + int EV_DoCeiling ( line_t* line, @@ -112,8 +151,11 @@ EV_DoCeiling int rtn; sector_t* sec; ceiling_t* ceiling; + secnum = -1; rtn = 0; + + switch(type) { case fastCrushAndRaise: @@ -123,11 +165,14 @@ EV_DoCeiling default: break; } + while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; + + rtn = 1; ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); P_AddThinker (&ceiling->thinker); @@ -135,6 +180,7 @@ EV_DoCeiling ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; ceiling->sector = sec; ceiling->crush = false; + switch(type) { case fastCrushAndRaise: @@ -144,6 +190,7 @@ EV_DoCeiling ceiling->direction = -1; ceiling->speed = CEILSPEED * 2; break; + case silentCrushAndRaise: case crushAndRaise: ceiling->crush = true; @@ -156,21 +203,29 @@ EV_DoCeiling ceiling->direction = -1; ceiling->speed = CEILSPEED; break; + case raiseToHighest: ceiling->topheight = P_FindHighestCeilingSurrounding(sec); ceiling->direction = 1; ceiling->speed = CEILSPEED; break; } + ceiling->tag = sec->tag; ceiling->type = type; P_AddActiveCeiling(ceiling); } return rtn; } + + + + + void P_AddActiveCeiling(ceiling_t* c) { int i; + for (i = 0; i < MAXCEILINGS;i++) { if (activeceilings[i] == NULL) @@ -180,9 +235,16 @@ void P_AddActiveCeiling(ceiling_t* c) } } } + + + + + + void P_RemoveActiveCeiling(ceiling_t* c) { int i; + for (i = 0;i < MAXCEILINGS;i++) { if (activeceilings[i] == c) @@ -194,9 +256,16 @@ void P_RemoveActiveCeiling(ceiling_t* c) } } } + + + + + + void P_ActivateInStasisCeiling(line_t* line) { int i; + for (i = 0;i < MAXCEILINGS;i++) { if (activeceilings[i] @@ -209,10 +278,18 @@ void P_ActivateInStasisCeiling(line_t* line) } } } + + + + + + + int EV_CeilingCrushStop(line_t *line) { int i; int rtn; + rtn = 0; for (i = 0;i < MAXCEILINGS;i++) { @@ -226,5 +303,7 @@ int EV_CeilingCrushStop(line_t *line) rtn = 1; } } + + return rtn; } diff --git a/src/p_doors.c b/src/p_doors.c @@ -6,45 +6,38 @@ #include "r_state.h" #include "dstrings.h" #include "sounds.h" -#if 0 -slidename_t slideFrameNames[MAXSLIDEDOORS] = -{ - {"GDOORF1","GDOORF2","GDOORF3","GDOORF4", - "GDOORB1","GDOORB2","GDOORB3","GDOORB4"}, - {"\0","\0","\0","\0"} -}; -#endif -void T_VerticalDoor (vldoor_t* door) + +void +T_VerticalDoor(vldoor_t* door) { - result_e res; - switch(door->direction) - { - case 0: - if (!--door->topcountdown) - { - switch(door->type) - { - case blazeRaise: - door->direction = -1; - S_StartSound((mobj_t *)&door->sector->soundorg, - sfx_bdcls); - break; - case normal: - door->direction = -1; - S_StartSound((mobj_t *)&door->sector->soundorg, - sfx_dorcls); - break; - case close30ThenOpen: - door->direction = 1; - S_StartSound((mobj_t *)&door->sector->soundorg, - sfx_doropn); - break; - default: - break; - } - } - break; - case 2: + result_e res; + + switch (door->direction) { + case 0: + if (!--door->topcountdown) { + switch(door->type) { + case blazeRaise: + door->direction = -1; + S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); + break; + case normal: + door->direction = -1; + S_StartSound((mobj_t *)&door->sector->soundorg, + sfx_dorcls); + break; + + case close30ThenOpen: + door->direction = 1; + S_StartSound((mobj_t *)&door->sector->soundorg, + sfx_doropn); + break; + + default: + break; + } + } + break; + case 2: if (!--door->topcountdown) { switch(door->type) @@ -55,12 +48,15 @@ void T_VerticalDoor (vldoor_t* door) S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; + default: break; } } break; + case -1: + res = T_MovePlane(door->sector, door->speed, door->sector->floorheight, @@ -76,15 +72,18 @@ void T_VerticalDoor (vldoor_t* door) S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); break; + case normal: case close: door->sector->specialdata = NULL; P_RemoveThinker (&door->thinker); break; + case close30ThenOpen: door->direction = 0; door->topcountdown = 35*30; break; + default: break; } @@ -96,6 +95,7 @@ void T_VerticalDoor (vldoor_t* door) case blazeClose: case close: break; + default: door->direction = 1; S_StartSound((mobj_t *)&door->sector->soundorg, @@ -104,11 +104,14 @@ void T_VerticalDoor (vldoor_t* door) } } break; + case 1: + res = T_MovePlane(door->sector, door->speed, door->topheight, false,1,door->direction); + if (res == pastdest) { switch(door->type) @@ -118,12 +121,14 @@ void T_VerticalDoor (vldoor_t* door) door->direction = 0; door->topcountdown = door->topwait; break; + case close30ThenOpen: case blazeOpen: case open: door->sector->specialdata = NULL; P_RemoveThinker (&door->thinker); break; + default: break; } @@ -131,6 +136,7 @@ void T_VerticalDoor (vldoor_t* door) break; } } + int EV_DoLockedDoor ( line_t* line, @@ -138,9 +144,12 @@ EV_DoLockedDoor mobj_t* thing ) { player_t* p; + p = thing->player; + if (!p) return 0; + switch(line->special) { case 99: @@ -149,22 +158,24 @@ EV_DoLockedDoor return 0; if (!p->cards[it_bluecard] && !p->cards[it_blueskull]) { - p->message = PD_BLUEO; + p->message = lang[PD_BLUEO]; S_StartSound(NULL,sfx_oof); return 0; } break; + case 134: case 135: if ( !p ) return 0; if (!p->cards[it_redcard] && !p->cards[it_redskull]) { - p->message = PD_REDO; + p->message = lang[PD_REDO]; S_StartSound(NULL,sfx_oof); return 0; } break; + case 136: case 137: if ( !p ) @@ -172,14 +183,17 @@ EV_DoLockedDoor if (!p->cards[it_yellowcard] && !p->cards[it_yellowskull]) { - p->message = PD_YELLOWO; + p->message = lang[PD_YELLOWO]; S_StartSound(NULL,sfx_oof); return 0; } break; } + return EV_DoDoor(line,type); } + + int EV_DoDoor ( line_t* line, @@ -188,22 +202,29 @@ EV_DoDoor int secnum,rtn; sector_t* sec; vldoor_t* door; + secnum = -1; rtn = 0; + while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; + + + rtn = 1; door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; + door->thinker.function.acp1 = (actionf_p1) T_VerticalDoor; door->sector = sec; door->type = type; door->topwait = VDOORWAIT; door->speed = VDOORSPEED; + switch(type) { case blazeClose: @@ -214,6 +235,7 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); break; + case close: door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4*FRACUNIT; @@ -221,12 +243,14 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_dorcls); break; + case close30ThenOpen: door->topheight = sec->ceilingheight; door->direction = -1; S_StartSound((mobj_t *)&door->sector->soundorg, sfx_dorcls); break; + case blazeRaise: case blazeOpen: door->direction = 1; @@ -237,6 +261,7 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdopn); break; + case normal: case open: door->direction = 1; @@ -246,12 +271,19 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; + default: break; } + } return rtn; } + + + + + void EV_VerticalDoor ( line_t* line, @@ -261,46 +293,58 @@ EV_VerticalDoor sector_t* sec; vldoor_t* door; int side; + side = 0; + + player = thing->player; + switch(line->special) { case 26: case 32: if ( !player ) return; + if (!player->cards[it_bluecard] && !player->cards[it_blueskull]) { - player->message = PD_BLUEK; + player->message = lang[PD_BLUEK]; S_StartSound(NULL,sfx_oof); return; } break; + case 27: case 34: if ( !player ) return; + if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull]) { - player->message = PD_YELLOWK; + player->message = lang[PD_YELLOWK]; S_StartSound(NULL,sfx_oof); return; } break; + case 28: case 33: if ( !player ) return; + if (!player->cards[it_redcard] && !player->cards[it_redskull]) { - player->message = PD_REDK; + player->message = lang[PD_REDK]; S_StartSound(NULL,sfx_oof); return; } break; } + + sec = sides[ line->sidenum[side^1]] .sector; + if (sec->specialdata) { door = sec->specialdata; @@ -317,25 +361,33 @@ EV_VerticalDoor { if (!thing->player) return; + door->direction = -1; } return; } } + + switch(line->special) { case 117: case 118: S_StartSound((mobj_t *)&sec->soundorg,sfx_bdopn); break; + case 1: case 31: S_StartSound((mobj_t *)&sec->soundorg,sfx_doropn); break; + default: S_StartSound((mobj_t *)&sec->soundorg,sfx_doropn); break; } + + + door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; @@ -344,6 +396,7 @@ EV_VerticalDoor door->direction = 1; door->speed = VDOORSPEED; door->topwait = VDOORWAIT; + switch(line->special) { case 1: @@ -352,6 +405,7 @@ EV_VerticalDoor case 28: door->type = normal; break; + case 31: case 32: case 33: @@ -359,6 +413,7 @@ EV_VerticalDoor door->type = open; line->special = 0; break; + case 117: door->type = blazeRaise; door->speed = VDOORSPEED*4; @@ -372,9 +427,12 @@ EV_VerticalDoor door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4*FRACUNIT; } -void P_SpawnDoorCloseIn30 (sector_t* sec) + +void +P_SpawnDoorCloseIn30(sector_t* sec) { vldoor_t* door; + door = Z_Malloc ( sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; @@ -386,16 +444,21 @@ void P_SpawnDoorCloseIn30 (sector_t* sec) door->speed = VDOORSPEED; door->topcountdown = 30 * 35; } + void P_SpawnDoorRaiseIn5Mins ( sector_t* sec, int secnum ) { vldoor_t* door; + door = Z_Malloc ( sizeof(*door), PU_LEVSPEC, 0); + P_AddThinker (&door->thinker); + sec->specialdata = door; sec->special = 0; + door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; door->sector = sec; door->direction = 2; @@ -406,161 +469,3 @@ P_SpawnDoorRaiseIn5Mins door->topwait = VDOORWAIT; door->topcountdown = 5 * 60 * 35; } -#if 0 -slideframe_t slideFrames[MAXSLIDEDOORS]; -void P_InitSlidingDoorFrames(void) -{ - int i; - int f1; - int f2; - int f3; - int f4; - if ( gamemode != commercial) - return; - for (i = 0;i < MAXSLIDEDOORS; i++) - { - if (!slideFrameNames[i].frontFrame1[0]) - break; - f1 = R_TextureNumForName(slideFrameNames[i].frontFrame1); - f2 = R_TextureNumForName(slideFrameNames[i].frontFrame2); - f3 = R_TextureNumForName(slideFrameNames[i].frontFrame3); - f4 = R_TextureNumForName(slideFrameNames[i].frontFrame4); - slideFrames[i].frontFrames[0] = f1; - slideFrames[i].frontFrames[1] = f2; - slideFrames[i].frontFrames[2] = f3; - slideFrames[i].frontFrames[3] = f4; - f1 = R_TextureNumForName(slideFrameNames[i].backFrame1); - f2 = R_TextureNumForName(slideFrameNames[i].backFrame2); - f3 = R_TextureNumForName(slideFrameNames[i].backFrame3); - f4 = R_TextureNumForName(slideFrameNames[i].backFrame4); - slideFrames[i].backFrames[0] = f1; - slideFrames[i].backFrames[1] = f2; - slideFrames[i].backFrames[2] = f3; - slideFrames[i].backFrames[3] = f4; - } -} -int P_FindSlidingDoorType(line_t* line) -{ - int i; - int val; - for (i = 0;i < MAXSLIDEDOORS;i++) - { - val = sides[line->sidenum[0]].midtexture; - if (val == slideFrames[i].frontFrames[0]) - return i; - } - return -1; -} -void T_SlidingDoor (slidedoor_t* door) -{ - switch(door->status) - { - case sd_opening: - if (!door->timer--) - { - if (++door->frame == SNUMFRAMES) - { - sides[door->line->sidenum[0]].midtexture = 0; - sides[door->line->sidenum[1]].midtexture = 0; - door->line->flags &= ML_BLOCKING^0xff; - if (door->type == sdt_openOnly) - { - door->frontsector->specialdata = NULL; - P_RemoveThinker (&door->thinker); - break; - } - door->timer = SDOORWAIT; - door->status = sd_waiting; - } - else - { - door->timer = SWAITTICS; - sides[door->line->sidenum[0]].midtexture = - slideFrames[door->whichDoorIndex]. - frontFrames[door->frame]; - sides[door->line->sidenum[1]].midtexture = - slideFrames[door->whichDoorIndex]. - backFrames[door->frame]; - } - } - break; - case sd_waiting: - if (!door->timer--) - { - if (door->frontsector->thinglist != NULL || - door->backsector->thinglist != NULL) - { - door->timer = SDOORWAIT; - break; - } - door->status = sd_closing; - door->timer = SWAITTICS; - } - break; - case sd_closing: - if (!door->timer--) - { - if (--door->frame < 0) - { - door->line->flags |= ML_BLOCKING; - door->frontsector->specialdata = NULL; - P_RemoveThinker (&door->thinker); - break; - } - else - { - door->timer = SWAITTICS; - sides[door->line->sidenum[0]].midtexture = - slideFrames[door->whichDoorIndex]. - frontFrames[door->frame]; - sides[door->line->sidenum[1]].midtexture = - slideFrames[door->whichDoorIndex]. - backFrames[door->frame]; - } - } - break; - } -} -void -EV_SlidingDoor -( line_t* line, - mobj_t* thing ) -{ - sector_t* sec; - slidedoor_t* door; - if (gamemode != commercial) - return; - sec = line->frontsector; - door = NULL; - if (sec->specialdata) - { - if (!thing->player) - return; - door = sec->specialdata; - if (door->type == sdt_openAndClose) - { - if (door->status == sd_waiting) - door->status = sd_closing; - } - else - return; - } - if (!door) - { - door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); - P_AddThinker (&door->thinker); - sec->specialdata = door; - door->type = sdt_openAndClose; - door->status = sd_opening; - door->whichDoorIndex = P_FindSlidingDoorType(line); - if (door->whichDoorIndex < 0) - I_Error("EV_SlidingDoor: Can't use texture for sliding door!"); - door->frontsector = sec; - door->backsector = line->backsector; - door->thinker.function = T_SlidingDoor; - door->timer = SWAITTICS; - door->frame = 0; - door->line = line; - } -} -#endif diff --git a/src/p_enemy.c b/src/p_enemy.c @@ -1,4 +1,5 @@ #include <stdlib.h> + #include "m_random.h" #include "i_system.h" #include "doomdef.h" @@ -8,1333 +9,1126 @@ #include "doomstat.h" #include "r_state.h" #include "sounds.h" -typedef enum -{ - DI_EAST, - DI_NORTHEAST, - DI_NORTH, - DI_NORTHWEST, - DI_WEST, - DI_SOUTHWEST, - DI_SOUTH, - DI_SOUTHEAST, - DI_NODIR, - NUMDIRS + +#define FATSPREAD (ANG90/8) +#define MAXSPECIALCROSS 8 +#define SKULLSPEED (20*FRACUNIT) + +typedef enum { + DI_EAST, + DI_NORTHEAST, + DI_NORTH, + DI_NORTHWEST, + DI_WEST, + DI_SOUTHWEST, + DI_SOUTH, + DI_SOUTHEAST, + DI_NODIR, + NUMDIRS } dirtype_t; -dirtype_t opposite[] = -{ + +extern line_t* spechit[MAXSPECIALCROSS]; +extern int numspechit; +mobj_t* corpsehit; +mobj_t* vileobj; +mobj_t* braintargets[32]; +fixed_t viletryx; +fixed_t viletryy; +int numbraintargets; +int braintargeton; +int TRACEANGLE = 0xc000000; +fixed_t xspeed[8] = {FRACUNIT,47000,0,-47000,-FRACUNIT,-47000,0,47000}; +fixed_t yspeed[8] = {0,47000,FRACUNIT,47000,0,-47000,-FRACUNIT,-47000}; +dirtype_t opposite[] = { DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_EAST, DI_NORTHEAST, DI_NORTH, DI_NORTHWEST, DI_NODIR }; -dirtype_t diags[] = -{ - DI_NORTHWEST, DI_NORTHEAST, DI_SOUTHWEST, DI_SOUTHEAST +dirtype_t diags[] = { + DI_NORTHWEST, DI_NORTHEAST, DI_SOUTHWEST, DI_SOUTHEAST }; + + void A_Fall (mobj_t *actor); +void A_SpawnFly (mobj_t* mo); + mobj_t* soundtarget; + void -P_RecursiveSound -( sector_t* sec, - int soundblocks ) -{ - int i; - line_t* check; - sector_t* other; - if (sec->validcount == validcount - && sec->soundtraversed <= soundblocks+1) - { - return; - } - sec->validcount = validcount; - sec->soundtraversed = soundblocks+1; - sec->soundtarget = soundtarget; - for (i=0 ;i<sec->linecount ; i++) - { - check = sec->lines[i]; - if (! (check->flags & ML_TWOSIDED) ) - continue; - P_LineOpening (check); - if (openrange <= 0) - continue; - if ( sides[ check->sidenum[0] ].sector == sec) - other = sides[ check->sidenum[1] ] .sector; - else - other = sides[ check->sidenum[0] ].sector; - if (check->flags & ML_SOUNDBLOCK) - { - if (!soundblocks) - P_RecursiveSound (other, 1); +P_RecursiveSound(sector_t* sec, int soundblocks) +{ + sector_t* other; + line_t* check; + int i; + + if (sec->validcount == validcount && sec->soundtraversed <= soundblocks+1) return; + sec->validcount = validcount; + sec->soundtraversed = soundblocks+1; + sec->soundtarget = soundtarget; + for (i = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + if (!(check->flags & ML_TWOSIDED)) continue; + P_LineOpening(check); + if (openrange <= 0) continue; + if (sides[check->sidenum[0]].sector == sec) other = sides[check->sidenum[1]].sector; + else other = sides[ check->sidenum[0] ].sector; + if (check->flags & ML_SOUNDBLOCK) { + if (!soundblocks) + P_RecursiveSound (other, 1); + } else P_RecursiveSound (other, soundblocks); } - else - P_RecursiveSound (other, soundblocks); - } } + void -P_NoiseAlert -( mobj_t* target, - mobj_t* emmiter ) +P_NoiseAlert(mobj_t* target, mobj_t* emmiter) { - soundtarget = target; - validcount++; - P_RecursiveSound (emmiter->subsector->sector, 0); + soundtarget = target; + validcount++; + P_RecursiveSound(emmiter->subsector->sector, 0); } -boolean P_CheckMeleeRange (mobj_t* actor) + +boolean +P_CheckMeleeRange(mobj_t* actor) { - mobj_t* pl; - fixed_t dist; - if (!actor->target) - return false; - pl = actor->target; - dist = P_AproxDistance (pl->x-actor->x, pl->y-actor->y); - if (dist >= MELEERANGE-20*FRACUNIT+pl->info->radius) - return false; - if (! P_CheckSight (actor, actor->target) ) - return false; - return true; + mobj_t* pl; + fixed_t dist; + + if (!actor->target) return false; + pl = actor->target; + dist = P_AproxDistance (pl->x-actor->x, pl->y-actor->y); + if (dist >= MELEERANGE-20*FRACUNIT+pl->info->radius) return false; + if (!P_CheckSight (actor, actor->target)) return false; + return true; } -boolean P_CheckMissileRange (mobj_t* actor) + +boolean +P_CheckMissileRange(mobj_t* actor) { - fixed_t dist; - if (! P_CheckSight (actor, actor->target) ) - return false; - if ( actor->flags & MF_JUSTHIT ) - { - actor->flags &= ~MF_JUSTHIT; + fixed_t dist; + + if (!P_CheckSight(actor, actor->target)) return false; + if (actor->flags & MF_JUSTHIT) { + actor->flags &= ~MF_JUSTHIT; + return true; + } + if (actor->reactiontime) return false; + dist = P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) - 64*FRACUNIT; + if (!actor->info->meleestate) dist -= 128*FRACUNIT; + dist >>= 16; + if (actor->type == MT_VILE) + if (dist > 14*64) return false; + if (actor->type == MT_UNDEAD) { + if (dist < 196) return false; + dist >>= 1; + } + if (actor->type == MT_CYBORG || actor->type == MT_SPIDER || actor->type == MT_SKULL) dist >>= 1; + if (dist > 200) dist = 200; + if (actor->type == MT_CYBORG && dist > 160) dist = 160; + if (P_Random() < dist) return false; return true; - } - if (actor->reactiontime) - return false; - dist = P_AproxDistance ( actor->x-actor->target->x, - actor->y-actor->target->y) - 64*FRACUNIT; - if (!actor->info->meleestate) - dist -= 128*FRACUNIT; - dist >>= 16; - if (actor->type == MT_VILE) - { - if (dist > 14*64) - return false; - } - if (actor->type == MT_UNDEAD) - { - if (dist < 196) - return false; - dist >>= 1; - } - if (actor->type == MT_CYBORG - || actor->type == MT_SPIDER - || actor->type == MT_SKULL) - { - dist >>= 1; - } - if (dist > 200) - dist = 200; - if (actor->type == MT_CYBORG && dist > 160) - dist = 160; - if (P_Random () < dist) - return false; - return true; } -fixed_t xspeed[8] = {FRACUNIT,47000,0,-47000,-FRACUNIT,-47000,0,47000}; -fixed_t yspeed[8] = {0,47000,FRACUNIT,47000,0,-47000,-FRACUNIT,-47000}; -#define MAXSPECIALCROSS 8 -extern line_t* spechit[MAXSPECIALCROSS]; -extern int numspechit; -boolean P_Move (mobj_t* actor) -{ - fixed_t tryx; - fixed_t tryy; - line_t* ld; - boolean try_ok; - boolean good; - if (actor->movedir == DI_NODIR) - return false; - if ((unsigned)actor->movedir >= 8) - I_Error ("Weird actor->movedir!"); - tryx = actor->x + actor->info->speed*xspeed[actor->movedir]; - tryy = actor->y + actor->info->speed*yspeed[actor->movedir]; - try_ok = P_TryMove (actor, tryx, tryy); - if (!try_ok) - { - if (actor->flags & MF_FLOAT && floatok) - { - if (actor->z < tmfloorz) - actor->z += FLOATSPEED; - else - actor->z -= FLOATSPEED; - actor->flags |= MF_INFLOAT; - return true; + +boolean +P_Move(mobj_t* actor) +{ + line_t* ld; + fixed_t tryx, tryy; + boolean good, try_ok; + + if (actor->movedir == DI_NODIR) return false; + if ((unsigned)actor->movedir >= 8) I_Error("Weird actor->movedir!"); + tryx = actor->x + actor->info->speed*xspeed[actor->movedir]; + tryy = actor->y + actor->info->speed*yspeed[actor->movedir]; + try_ok = P_TryMove (actor, tryx, tryy); + if (!try_ok) { + if (actor->flags & MF_FLOAT && floatok) { + if (actor->z < tmfloorz) actor->z += FLOATSPEED; + else actor->z -= FLOATSPEED; + actor->flags |= MF_INFLOAT; + return true; + } + if (!numspechit) return false; + actor->movedir = DI_NODIR; + good = false; + while (numspechit--) { + ld = spechit[numspechit]; + if (P_UseSpecialLine (actor, ld,0)) good = true; + } + return good; + } else actor->flags &= ~MF_INFLOAT; + if (! (actor->flags & MF_FLOAT) ) actor->z = actor->floorz; + return true; +} + +boolean +P_TryWalk(mobj_t* actor) +{ + if (!P_Move(actor)) return false; + actor->movecount = P_Random() & 15; + return true; +} + +void +P_NewChaseDir(mobj_t* actor) +{ + fixed_t deltax; + fixed_t deltay; + dirtype_t olddir, turnaround, d[3]; + int tdir; + + if (!actor->target) I_Error("P_NewChaseDir: called with no target"); + olddir = actor->movedir; + turnaround=opposite[olddir]; + deltax = actor->target->x - actor->x; + deltay = actor->target->y - actor->y; + if (deltax>10*FRACUNIT) d[1] = DI_EAST; + else if (deltax<-10*FRACUNIT) d[1] = DI_WEST; + else d[1] =DI_NODIR; + if (deltay<-10*FRACUNIT) d[2] = DI_SOUTH; + else if (deltay>10*FRACUNIT) d[2] = DI_NORTH; + else d[2] = DI_NODIR; + if (d[1] != DI_NODIR && d[2] != DI_NODIR) { + actor->movedir = diags[((deltay<0) << 1) + (deltax > 0)]; + if (actor->movedir != turnaround && P_TryWalk(actor)) return; } - if (!numspechit) - return false; - actor->movedir = DI_NODIR; - good = false; - while (numspechit--) - { - ld = spechit[numspechit]; - if (P_UseSpecialLine (actor, ld,0)) - good = true; + if (P_Random() > 200 || abs(deltay)>abs(deltax)) { + tdir=d[1]; + d[1]=d[2]; + d[2]=tdir; } - return good; - } - else - { - actor->flags &= ~MF_INFLOAT; - } - if (! (actor->flags & MF_FLOAT) ) - actor->z = actor->floorz; - return true; -} -boolean P_TryWalk (mobj_t* actor) -{ - if (!P_Move (actor)) - { - return false; - } - actor->movecount = P_Random()&15; - return true; -} -void P_NewChaseDir (mobj_t* actor) -{ - fixed_t deltax; - fixed_t deltay; - dirtype_t d[3]; - int tdir; - dirtype_t olddir; - dirtype_t turnaround; - if (!actor->target) - I_Error ("P_NewChaseDir: called with no target"); - olddir = actor->movedir; - turnaround=opposite[olddir]; - deltax = actor->target->x - actor->x; - deltay = actor->target->y - actor->y; - if (deltax>10*FRACUNIT) - d[1]= DI_EAST; - else if (deltax<-10*FRACUNIT) - d[1]= DI_WEST; - else - d[1]=DI_NODIR; - if (deltay<-10*FRACUNIT) - d[2]= DI_SOUTH; - else if (deltay>10*FRACUNIT) - d[2]= DI_NORTH; - else - d[2]=DI_NODIR; - if (d[1] != DI_NODIR - && d[2] != DI_NODIR) - { - actor->movedir = diags[((deltay<0)<<1)+(deltax>0)]; - if (actor->movedir != turnaround && P_TryWalk(actor)) - return; - } - if (P_Random() > 200 - || abs(deltay)>abs(deltax)) - { - tdir=d[1]; - d[1]=d[2]; - d[2]=tdir; - } - if (d[1]==turnaround) - d[1]=DI_NODIR; - if (d[2]==turnaround) - d[2]=DI_NODIR; - if (d[1]!=DI_NODIR) - { - actor->movedir = d[1]; - if (P_TryWalk(actor)) - { - return; + if (d[1]==turnaround) d[1]=DI_NODIR; + if (d[2]==turnaround) d[2]=DI_NODIR; + if (d[1]!=DI_NODIR) { + actor->movedir = d[1]; + if (P_TryWalk(actor)) return; } - } - if (d[2]!=DI_NODIR) - { - actor->movedir =d[2]; - if (P_TryWalk(actor)) - return; - } - if (olddir!=DI_NODIR) - { - actor->movedir =olddir; - if (P_TryWalk(actor)) - return; - } - if (P_Random()&1) - { - for ( tdir=DI_EAST; - tdir<=DI_SOUTHEAST; - tdir++ ) - { - if (tdir!=turnaround) - { - actor->movedir =tdir; - if ( P_TryWalk(actor) ) - return; - } + if (d[2]!=DI_NODIR) { + actor->movedir =d[2]; + if (P_TryWalk(actor)) return; } - } - else - { - for ( tdir=DI_SOUTHEAST; - tdir != (DI_EAST-1); - tdir-- ) - { - if (tdir!=turnaround) - { - actor->movedir =tdir; - if ( P_TryWalk(actor) ) - return; - } + if (olddir!=DI_NODIR) { + actor->movedir = olddir; + if (P_TryWalk(actor)) return; } - } - if (turnaround != DI_NODIR) - { - actor->movedir =turnaround; - if ( P_TryWalk(actor) ) - return; - } - actor->movedir = DI_NODIR; + if (P_Random() & 1) { + for (tdir=DI_EAST; tdir<=DI_SOUTHEAST; ++tdir) { + if (tdir!=turnaround) { + actor->movedir =tdir; + if (P_TryWalk(actor)) return; + } + } + } else { + for (tdir=DI_SOUTHEAST; tdir != (DI_EAST-1); --tdir) { + if (tdir!=turnaround) { + actor->movedir =tdir; + if (P_TryWalk(actor)) return; + } + } + } + if (turnaround != DI_NODIR) { + actor->movedir =turnaround; + if (P_TryWalk(actor)) return; + } + actor->movedir = DI_NODIR; } + boolean -P_LookForPlayers -( mobj_t* actor, - boolean allaround ) -{ - int c; - int stop; - player_t* player; - angle_t an; - fixed_t dist; - c = 0; - stop = (actor->lastlook-1)&3; - for ( ; ; actor->lastlook = (actor->lastlook+1)&3 ) - { - if (!playeringame[actor->lastlook]) - continue; - if (c++ == 2 - || actor->lastlook == stop) - { - return false; +P_LookForPlayers(mobj_t* actor, boolean allaround) +{ + player_t* player; + angle_t an; + fixed_t dist; + int c, stop; + + c = 0; + stop = (actor->lastlook-1) & 3; + for (;; actor->lastlook = (actor->lastlook+1)&3) { + if (!playeringame[actor->lastlook]) continue; + if (c++ == 2 || actor->lastlook == stop) return false; + player = &players[actor->lastlook]; + if (player->health <= 0) continue; + if (!P_CheckSight (actor, player->mo)) continue; + if (!allaround) { + an = R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y) - actor->angle; + if (an > ANG90 && an < ANG270) { + dist = P_AproxDistance (player->mo->x - actor->x, player->mo->y - actor->y); + if (dist > MELEERANGE) continue; + } + } + actor->target = player->mo; + return true; } - player = &players[actor->lastlook]; - if (player->health <= 0) - continue; - if (!P_CheckSight (actor, player->mo)) - continue; - if (!allaround) - { - an = R_PointToAngle2 (actor->x, - actor->y, - player->mo->x, - player->mo->y) - - actor->angle; - if (an > ANG90 && an < ANG270) - { - dist = P_AproxDistance (player->mo->x - actor->x, - player->mo->y - actor->y); - if (dist > MELEERANGE) - continue; - } + return false; +} + +void +A_KeenDie(mobj_t* mo) +{ + thinker_t* th; + mobj_t* mo2; + line_t junk; + + A_Fall(mo); + for (th = thinkercap.next; th != &thinkercap; th = th->next) { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + mo2 = (mobj_t *)th; + if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) return; } - actor->target = player->mo; - return true; - } - return false; -} -void A_KeenDie (mobj_t* mo) -{ - thinker_t* th; - mobj_t* mo2; - line_t junk; - A_Fall (mo); - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - mo2 = (mobj_t *)th; - if (mo2 != mo - && mo2->type == mo->type - && mo2->health > 0) - { - return; + junk.tag = 666; + EV_DoDoor(&junk, open); +} + +void +A_Look (mobj_t* actor) +{ + mobj_t* targ; + int sound; + + actor->threshold = 0; + targ = actor->subsector->sector->soundtarget; + if (targ && (targ->flags & MF_SHOOTABLE)) { + actor->target = targ; + if (actor->flags & MF_AMBUSH) { + if (P_CheckSight (actor, actor->target)) + goto seeyou; + } else goto seeyou; + if (!P_LookForPlayers (actor, false)) return; + seeyou: + if (actor->info->seesound) { + switch (actor->info->seesound) { + case sfx_posit1: + case sfx_posit2: + case sfx_posit3: + sound = sfx_posit1+P_Random()%3; + break; + case sfx_bgsit1: + case sfx_bgsit2: + sound = sfx_bgsit1+P_Random()%2; + break; + default: + sound = actor->info->seesound; + break; + } + if (actor->type==MT_SPIDER || actor->type == MT_CYBORG) S_StartSound (NULL, sound); + else S_StartSound (actor, sound); + } + P_SetMobjState (actor, actor->info->seestate); + } +} + +void +A_Chase(mobj_t* actor) +{ + int delta; + + if (actor->reactiontime) --actor->reactiontime; + if (actor->threshold) { + if (!actor->target || actor->target->health <= 0) actor->threshold = 0; + else actor->threshold--; } - } - junk.tag = 666; - EV_DoDoor(&junk,open); -} -void A_Look (mobj_t* actor) -{ - mobj_t* targ; - actor->threshold = 0; - targ = actor->subsector->sector->soundtarget; - if (targ - && (targ->flags & MF_SHOOTABLE) ) - { - actor->target = targ; - if ( actor->flags & MF_AMBUSH ) - { - if (P_CheckSight (actor, actor->target)) - goto seeyou; + if (actor->movedir < 8) { + actor->angle &= (7<<29); + delta = actor->angle - (actor->movedir << 29); + if (delta > 0) actor->angle -= ANG90/2; + if (delta < 0) actor->angle += ANG90/2; } - else - goto seeyou; - } - if (!P_LookForPlayers (actor, false) ) - return; - seeyou: - if (actor->info->seesound) - { - int sound; - switch (actor->info->seesound) - { - case sfx_posit1: - case sfx_posit2: - case sfx_posit3: - sound = sfx_posit1+P_Random()%3; - break; - case sfx_bgsit1: - case sfx_bgsit2: - sound = sfx_bgsit1+P_Random()%2; - break; - default: - sound = actor->info->seesound; - break; + if (!actor->target || !(actor->target->flags&MF_SHOOTABLE)) { + if (P_LookForPlayers(actor,true)) return; + P_SetMobjState(actor, actor->info->spawnstate); + return; } - if (actor->type==MT_SPIDER - || actor->type == MT_CYBORG) - { - S_StartSound (NULL, sound); + if (actor->flags & MF_JUSTATTACKED) { + actor->flags &= ~MF_JUSTATTACKED; + if (gameskill != sk_nightmare && !fastparm) P_NewChaseDir(actor); + return; } - else - S_StartSound (actor, sound); - } - P_SetMobjState (actor, actor->info->seestate); -} -void A_Chase (mobj_t* actor) -{ - int delta; - if (actor->reactiontime) - actor->reactiontime--; - if (actor->threshold) - { - if (!actor->target - || actor->target->health <= 0) - { - actor->threshold = 0; + if (actor->info->meleestate && P_CheckMeleeRange (actor)) { + if (actor->info->attacksound) S_StartSound (actor, actor->info->attacksound); + P_SetMobjState (actor, actor->info->meleestate); + return; } - else - actor->threshold--; - } - if (actor->movedir < 8) - { - actor->angle &= (7<<29); - delta = actor->angle - (actor->movedir << 29); - if (delta > 0) - actor->angle -= ANG90/2; - else if (delta < 0) - actor->angle += ANG90/2; - } - if (!actor->target - || !(actor->target->flags&MF_SHOOTABLE)) - { - if (P_LookForPlayers(actor,true)) - return; - P_SetMobjState (actor, actor->info->spawnstate); - return; - } - if (actor->flags & MF_JUSTATTACKED) - { - actor->flags &= ~MF_JUSTATTACKED; - if (gameskill != sk_nightmare && !fastparm) - P_NewChaseDir (actor); - return; - } - if (actor->info->meleestate - && P_CheckMeleeRange (actor)) - { - if (actor->info->attacksound) - S_StartSound (actor, actor->info->attacksound); - P_SetMobjState (actor, actor->info->meleestate); - return; - } - if (actor->info->missilestate) - { - if (gameskill < sk_nightmare - && !fastparm && actor->movecount) - { - goto nomissile; + if (actor->info->missilestate) { + if (gameskill < sk_nightmare && !fastparm && actor->movecount) goto nomissile; + if (!P_CheckMissileRange(actor)) goto nomissile; + P_SetMobjState (actor, actor->info->missilestate); + actor->flags |= MF_JUSTATTACKED; + return; } - if (!P_CheckMissileRange (actor)) - goto nomissile; - P_SetMobjState (actor, actor->info->missilestate); - actor->flags |= MF_JUSTATTACKED; - return; - } - nomissile: - if (netgame - && !actor->threshold - && !P_CheckSight (actor, actor->target) ) - { - if (P_LookForPlayers(actor,true)) - return; - } - if (--actor->movecount<0 - || !P_Move (actor)) - { - P_NewChaseDir (actor); - } - if (actor->info->activesound - && P_Random () < 3) - { - S_StartSound (actor, actor->info->activesound); - } -} -void A_FaceTarget (mobj_t* actor) -{ - if (!actor->target) - return; - actor->flags &= ~MF_AMBUSH; - actor->angle = R_PointToAngle2 (actor->x, - actor->y, - actor->target->x, - actor->target->y); - if (actor->target->flags & MF_SHADOW) - actor->angle += (P_Random()-P_Random())<<21; -} -void A_PosAttack (mobj_t* actor) -{ - int angle; - int damage; - int slope; - if (!actor->target) - return; - A_FaceTarget (actor); - angle = actor->angle; - slope = P_AimLineAttack (actor, angle, MISSILERANGE); - S_StartSound (actor, sfx_pistol); - angle += (P_Random()-P_Random())<<20; - damage = ((P_Random()%5)+1)*3; - P_LineAttack (actor, angle, MISSILERANGE, slope, damage); -} -void A_SPosAttack (mobj_t* actor) -{ - int i; - int angle; - int bangle; - int damage; - int slope; - if (!actor->target) - return; - S_StartSound (actor, sfx_shotgn); - A_FaceTarget (actor); - bangle = actor->angle; - slope = P_AimLineAttack (actor, bangle, MISSILERANGE); - for (i=0 ; i<3 ; i++) - { + nomissile: + if (netgame && !actor->threshold && !P_CheckSight (actor, actor->target)) + if (P_LookForPlayers(actor,true)) return; + if (--actor->movecount < 0 || !P_Move (actor)) + P_NewChaseDir (actor); + if (actor->info->activesound && P_Random() < 3) S_StartSound (actor, actor->info->activesound); +} + +void +A_FaceTarget(mobj_t* actor) +{ + if (!actor->target) return; + actor->flags &= ~MF_AMBUSH; + actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + if (actor->target->flags & MF_SHADOW) actor->angle += (P_Random()-P_Random())<<21; +} + +void +A_PosAttack(mobj_t* actor) +{ + int angle, damage, slope; + + if (!actor->target) return; + A_FaceTarget (actor); + angle = actor->angle; + slope = P_AimLineAttack (actor, angle, MISSILERANGE); + S_StartSound (actor, sfx_pistol); + angle += (P_Random()-P_Random())<<20; + damage = ((P_Random()%5)+1)*3; + P_LineAttack (actor, angle, MISSILERANGE, slope, damage); +} + +void +A_SPosAttack(mobj_t* actor) +{ + int i, angle, bangle, damage, slope; + + if (!actor->target) return; + S_StartSound(actor, sfx_shotgn); + A_FaceTarget(actor); + bangle = actor->angle; + slope = P_AimLineAttack (actor, bangle, MISSILERANGE); + for (i = 0; i < 3; ++i) { + angle = bangle + ((P_Random()-P_Random()) << 20); + damage = ((P_Random()%5)+1)*3; + P_LineAttack (actor, angle, MISSILERANGE, slope, damage); + } +} + +void +A_CPosAttack(mobj_t* actor) +{ + int angle, bangle, damage, slope; + + if (!actor->target) return; + S_StartSound(actor, sfx_shotgn); + A_FaceTarget(actor); + bangle = actor->angle; + slope = P_AimLineAttack(actor, bangle, MISSILERANGE); angle = bangle + ((P_Random()-P_Random())<<20); damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); - } -} -void A_CPosAttack (mobj_t* actor) -{ - int angle; - int bangle; - int damage; - int slope; - if (!actor->target) - return; - S_StartSound (actor, sfx_shotgn); - A_FaceTarget (actor); - bangle = actor->angle; - slope = P_AimLineAttack (actor, bangle, MISSILERANGE); - angle = bangle + ((P_Random()-P_Random())<<20); - damage = ((P_Random()%5)+1)*3; - P_LineAttack (actor, angle, MISSILERANGE, slope, damage); -} -void A_CPosRefire (mobj_t* actor) -{ - A_FaceTarget (actor); - if (P_Random () < 40) - return; - if (!actor->target - || actor->target->health <= 0 - || !P_CheckSight (actor, actor->target) ) - { - P_SetMobjState (actor, actor->info->seestate); - } -} -void A_SpidRefire (mobj_t* actor) -{ - A_FaceTarget (actor); - if (P_Random () < 10) - return; - if (!actor->target - || actor->target->health <= 0 - || !P_CheckSight (actor, actor->target) ) - { - P_SetMobjState (actor, actor->info->seestate); - } -} -void A_BspiAttack (mobj_t *actor) -{ - if (!actor->target) - return; - A_FaceTarget (actor); - P_SpawnMissile (actor, actor->target, MT_ARACHPLAZ); -} -void A_TroopAttack (mobj_t* actor) -{ - int damage; - if (!actor->target) - return; - A_FaceTarget (actor); - if (P_CheckMeleeRange (actor)) - { - S_StartSound (actor, sfx_claw); - damage = (P_Random()%8+1)*3; - P_DamageMobj (actor->target, actor, actor, damage); - return; - } - P_SpawnMissile (actor, actor->target, MT_TROOPSHOT); -} -void A_SargAttack (mobj_t* actor) -{ - int damage; - if (!actor->target) - return; - A_FaceTarget (actor); - if (P_CheckMeleeRange (actor)) - { - damage = ((P_Random()%10)+1)*4; - P_DamageMobj (actor->target, actor, actor, damage); - } -} -void A_HeadAttack (mobj_t* actor) -{ - int damage; - if (!actor->target) - return; - A_FaceTarget (actor); - if (P_CheckMeleeRange (actor)) - { - damage = (P_Random()%6+1)*10; - P_DamageMobj (actor->target, actor, actor, damage); - return; - } - P_SpawnMissile (actor, actor->target, MT_HEADSHOT); -} -void A_CyberAttack (mobj_t* actor) -{ - if (!actor->target) - return; - A_FaceTarget (actor); - P_SpawnMissile (actor, actor->target, MT_ROCKET); -} -void A_BruisAttack (mobj_t* actor) -{ - int damage; - if (!actor->target) - return; - if (P_CheckMeleeRange (actor)) - { - S_StartSound (actor, sfx_claw); - damage = (P_Random()%8+1)*10; - P_DamageMobj (actor->target, actor, actor, damage); - return; - } - P_SpawnMissile (actor, actor->target, MT_BRUISERSHOT); -} -void A_SkelMissile (mobj_t* actor) -{ - mobj_t* mo; - if (!actor->target) - return; - A_FaceTarget (actor); - actor->z += 16*FRACUNIT; - mo = P_SpawnMissile (actor, actor->target, MT_TRACER); - actor->z -= 16*FRACUNIT; - mo->x += mo->momx; - mo->y += mo->momy; - mo->tracer = actor->target; -} -int TRACEANGLE = 0xc000000; +} + +void +A_CPosRefire(mobj_t* actor) +{ + A_FaceTarget(actor); + + if (P_Random() < 40) return; + if (!actor->target || actor->target->health <= 0 || !P_CheckSight (actor, actor->target)) P_SetMobjState (actor, actor->info->seestate); +} + +void +A_SpidRefire(mobj_t* actor) +{ + A_FaceTarget(actor); + + if (P_Random() < 10) return; + if (!actor->target || actor->target->health <= 0 || !P_CheckSight (actor, actor->target)) P_SetMobjState (actor, actor->info->seestate); +} + +void +A_BspiAttack(mobj_t *actor) +{ + if (!actor->target) return; + A_FaceTarget (actor); + P_SpawnMissile (actor, actor->target, MT_ARACHPLAZ); +} + +void +A_TroopAttack(mobj_t* actor) +{ + int damage; + + if (!actor->target) return; + A_FaceTarget (actor); + if (P_CheckMeleeRange (actor)) { + S_StartSound (actor, sfx_claw); + damage = (P_Random()%8+1)*3; + P_DamageMobj (actor->target, actor, actor, damage); + return; + } + P_SpawnMissile (actor, actor->target, MT_TROOPSHOT); +} + +void +A_SargAttack(mobj_t* actor) +{ + int damage; + + if (!actor->target) return; + A_FaceTarget(actor); + if (P_CheckMeleeRange (actor)) { + damage = ((P_Random()%10)+1)*4; + P_DamageMobj (actor->target, actor, actor, damage); + } +} + +void +A_HeadAttack(mobj_t* actor) +{ + int damage; + + if (!actor->target) return; + A_FaceTarget(actor); + if (P_CheckMeleeRange (actor)) { + damage = (P_Random()%6+1)*10; + P_DamageMobj (actor->target, actor, actor, damage); + return; + } + P_SpawnMissile (actor, actor->target, MT_HEADSHOT); +} + +void +A_CyberAttack(mobj_t* actor) +{ + if (!actor->target) return; + A_FaceTarget (actor); + P_SpawnMissile (actor, actor->target, MT_ROCKET); +} + +void +A_BruisAttack(mobj_t* actor) +{ + int damage; + + if (!actor->target) return; + if (P_CheckMeleeRange (actor)) { + S_StartSound (actor, sfx_claw); + damage = (P_Random()%8+1)*10; + P_DamageMobj (actor->target, actor, actor, damage); + return; + } + P_SpawnMissile (actor, actor->target, MT_BRUISERSHOT); +} + +void +A_SkelMissile(mobj_t* actor) +{ + mobj_t* mo; + + if (!actor->target) return; + A_FaceTarget (actor); + actor->z += 16*FRACUNIT; + mo = P_SpawnMissile (actor, actor->target, MT_TRACER); + actor->z -= 16*FRACUNIT; + mo->x += mo->momx; + mo->y += mo->momy; + mo->tracer = actor->target; +} + + void A_Tracer (mobj_t* actor) { - angle_t exact; - fixed_t dist; - fixed_t slope; - mobj_t* dest; - mobj_t* th; - if (gametic & 3) - return; - P_SpawnPuff (actor->x, actor->y, actor->z); - th = P_SpawnMobj (actor->x-actor->momx, - actor->y-actor->momy, - actor->z, MT_SMOKE); - th->momz = FRACUNIT; - th->tics -= P_Random()&3; - if (th->tics < 1) - th->tics = 1; - dest = actor->tracer; - if (!dest || dest->health <= 0) - return; - exact = R_PointToAngle2 (actor->x, - actor->y, - dest->x, - dest->y); - if (exact != actor->angle) - { - if (exact - actor->angle > 0x80000000) - { - actor->angle -= TRACEANGLE; - if (exact - actor->angle < 0x80000000) - actor->angle = exact; + angle_t exact; + fixed_t dist; + fixed_t slope; + mobj_t* dest; + mobj_t* th; + + if (gametic & 3) return; + P_SpawnPuff(actor->x, actor->y, actor->z); + th = P_SpawnMobj (actor->x-actor->momx, actor->y-actor->momy, actor->z, MT_SMOKE); + th->momz = FRACUNIT; + th->tics -= P_Random() & 3; + if (th->tics < 1) th->tics = 1; + dest = actor->tracer; + if (!dest || dest->health <= 0) return; + exact = R_PointToAngle2(actor->x, actor->y, dest->x, dest->y); + if (exact != actor->angle) { + if (exact - actor->angle > 0x80000000) { + actor->angle -= TRACEANGLE; + if (exact - actor->angle < 0x80000000) + actor->angle = exact; + } else { + actor->angle += TRACEANGLE; + if (exact - actor->angle > 0x80000000) + actor->angle = exact; + } } - else - { - actor->angle += TRACEANGLE; - if (exact - actor->angle > 0x80000000) - actor->angle = exact; + exact = actor->angle>>ANGLETOFINESHIFT; + actor->momx = FixedMul (actor->info->speed, finecosine[exact]); + actor->momy = FixedMul (actor->info->speed, finesine[exact]); + dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); + dist = dist / actor->info->speed; + if (dist < 1) dist = 1; + slope = (dest->z+40*FRACUNIT - actor->z) / dist; + if (slope < actor->momz) actor->momz -= FRACUNIT/8; + else actor->momz += FRACUNIT/8; +} + +void +A_SkelWhoosh(mobj_t* actor) +{ + if (!actor->target) return; + A_FaceTarget (actor); + S_StartSound (actor,sfx_skeswg); +} + +void +A_SkelFist(mobj_t* actor) +{ + int damage; + + if (!actor->target) return; + A_FaceTarget (actor); + if (P_CheckMeleeRange (actor)) { + damage = ((P_Random()%10)+1)*6; + S_StartSound (actor, sfx_skepch); + P_DamageMobj (actor->target, actor, actor, damage); } - } - exact = actor->angle>>ANGLETOFINESHIFT; - actor->momx = FixedMul (actor->info->speed, finecosine[exact]); - actor->momy = FixedMul (actor->info->speed, finesine[exact]); - dist = P_AproxDistance (dest->x - actor->x, - dest->y - actor->y); - dist = dist / actor->info->speed; - if (dist < 1) - dist = 1; - slope = (dest->z+40*FRACUNIT - actor->z) / dist; - if (slope < actor->momz) - actor->momz -= FRACUNIT/8; - else - actor->momz += FRACUNIT/8; -} -void A_SkelWhoosh (mobj_t* actor) -{ - if (!actor->target) - return; - A_FaceTarget (actor); - S_StartSound (actor,sfx_skeswg); -} -void A_SkelFist (mobj_t* actor) -{ - int damage; - if (!actor->target) - return; - A_FaceTarget (actor); - if (P_CheckMeleeRange (actor)) - { - damage = ((P_Random()%10)+1)*6; - S_StartSound (actor, sfx_skepch); - P_DamageMobj (actor->target, actor, actor, damage); - } } -mobj_t* corpsehit; -mobj_t* vileobj; -fixed_t viletryx; -fixed_t viletryy; -boolean PIT_VileCheck (mobj_t* thing) -{ - int maxdist; - boolean check; - if (!(thing->flags & MF_CORPSE) ) - return true; - if (thing->tics != -1) - return true; - if (thing->info->raisestate == S_NULL) - return true; - maxdist = thing->info->radius + mobjinfo[MT_VILE].radius; - if ( abs(thing->x - viletryx) > maxdist - || abs(thing->y - viletryy) > maxdist ) - return true; - corpsehit = thing; - corpsehit->momx = corpsehit->momy = 0; - corpsehit->height <<= 2; - check = P_CheckPosition (corpsehit, corpsehit->x, corpsehit->y); - corpsehit->height >>= 2; - if (!check) - return true; - return false; -} -void A_VileChase (mobj_t* actor) -{ - int xl; - int xh; - int yl; - int yh; - int bx; - int by; - mobjinfo_t* info; - mobj_t* temp; - if (actor->movedir != DI_NODIR) - { - viletryx = - actor->x + actor->info->speed*xspeed[actor->movedir]; - viletryy = - actor->y + actor->info->speed*yspeed[actor->movedir]; - xl = (viletryx - bmaporgx - MAXRADIUS*2)>>MAPBLOCKSHIFT; - xh = (viletryx - bmaporgx + MAXRADIUS*2)>>MAPBLOCKSHIFT; - yl = (viletryy - bmaporgy - MAXRADIUS*2)>>MAPBLOCKSHIFT; - yh = (viletryy - bmaporgy + MAXRADIUS*2)>>MAPBLOCKSHIFT; - vileobj = actor; - for (bx=xl ; bx<=xh ; bx++) - { - for (by=yl ; by<=yh ; by++) - { - if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) - { - temp = actor->target; - actor->target = corpsehit; - A_FaceTarget (actor); - actor->target = temp; - P_SetMobjState (actor, S_VILE_HEAL1); - S_StartSound (corpsehit, sfx_slop); - info = corpsehit->info; - P_SetMobjState (corpsehit,info->raisestate); - corpsehit->height <<= 2; - corpsehit->flags = info->flags; - corpsehit->health = info->spawnhealth; - corpsehit->target = NULL; - return; + +boolean +PIT_VileCheck(mobj_t* thing) +{ + boolean check; + int maxdist; + + if (!(thing->flags & MF_CORPSE)) return true; + if (thing->tics != -1) return true; + if (thing->info->raisestate == S_NULL) return true; + maxdist = thing->info->radius + mobjinfo[MT_VILE].radius; + if (abs(thing->x - viletryx) > maxdist || abs(thing->y - viletryy) > maxdist) return true; + corpsehit = thing; + corpsehit->momx = corpsehit->momy = 0; + corpsehit->height <<= 2; + check = P_CheckPosition (corpsehit, corpsehit->x, corpsehit->y); + corpsehit->height >>= 2; + if (!check) return true; + return false; +} + +void +A_VileChase(mobj_t* actor) +{ + mobjinfo_t* info; + mobj_t* temp; + int xl, xh, yl, yh, bx, by; + + if (actor->movedir != DI_NODIR) { + viletryx = actor->x + actor->info->speed*xspeed[actor->movedir]; + viletryy = actor->y + actor->info->speed*yspeed[actor->movedir]; + xl = (viletryx - bmaporgx - MAXRADIUS*2)>>MAPBLOCKSHIFT; + xh = (viletryx - bmaporgx + MAXRADIUS*2)>>MAPBLOCKSHIFT; + yl = (viletryy - bmaporgy - MAXRADIUS*2)>>MAPBLOCKSHIFT; + yh = (viletryy - bmaporgy + MAXRADIUS*2)>>MAPBLOCKSHIFT; + vileobj = actor; + for (bx=xl ; bx<=xh ; bx++) { + for (by=yl ; by<=yh ; by++) { + if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) { + temp = actor->target; + actor->target = corpsehit; + A_FaceTarget (actor); + actor->target = temp; + P_SetMobjState (actor, S_VILE_HEAL1); + S_StartSound (corpsehit, sfx_slop); + info = corpsehit->info; + P_SetMobjState (corpsehit,info->raisestate); + corpsehit->height <<= 2; + corpsehit->flags = info->flags; + corpsehit->health = info->spawnhealth; + corpsehit->target = NULL; + return; + } + } } - } } - } - A_Chase (actor); + A_Chase (actor); } -void A_VileStart (mobj_t* actor) + +void +A_VileStart(mobj_t* actor) { - S_StartSound (actor, sfx_vilatk); + S_StartSound (actor, sfx_vilatk); } -void A_Fire (mobj_t* actor); -void A_StartFire (mobj_t* actor) + +void A_Fire(mobj_t* actor); + +void +A_StartFire(mobj_t* actor) { - S_StartSound(actor,sfx_flamst); - A_Fire(actor); + S_StartSound(actor,sfx_flamst); + A_Fire(actor); } -void A_FireCrackle (mobj_t* actor) + +void +A_FireCrackle(mobj_t* actor) { - S_StartSound(actor,sfx_flame); - A_Fire(actor); + S_StartSound(actor,sfx_flame); + A_Fire(actor); } + void A_Fire (mobj_t* actor) { - mobj_t* dest; - unsigned an; - dest = actor->tracer; - if (!dest) - return; - if (!P_CheckSight (actor->target, dest) ) - return; - an = dest->angle >> ANGLETOFINESHIFT; - P_UnsetThingPosition (actor); - actor->x = dest->x + FixedMul (24*FRACUNIT, finecosine[an]); - actor->y = dest->y + FixedMul (24*FRACUNIT, finesine[an]); - actor->z = dest->z; - P_SetThingPosition (actor); -} -void A_VileTarget (mobj_t* actor) -{ - mobj_t* fog; - if (!actor->target) - return; - A_FaceTarget (actor); - fog = P_SpawnMobj (actor->target->x, - actor->target->x, - actor->target->z, MT_FIRE); - actor->tracer = fog; - fog->target = actor; - fog->tracer = actor->target; - A_Fire (fog); -} -void A_VileAttack (mobj_t* actor) -{ - mobj_t* fire; - int an; - if (!actor->target) - return; - A_FaceTarget (actor); - if (!P_CheckSight (actor, actor->target) ) - return; - S_StartSound (actor, sfx_barexp); - P_DamageMobj (actor->target, actor, actor, 20); - actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; - an = actor->angle >> ANGLETOFINESHIFT; - fire = actor->tracer; - if (!fire) - return; - fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); - fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); - P_RadiusAttack (fire, actor, 70 ); -} -#define FATSPREAD (ANG90/8) -void A_FatRaise (mobj_t *actor) -{ - A_FaceTarget (actor); - S_StartSound (actor, sfx_manatk); -} -void A_FatAttack1 (mobj_t* actor) -{ - mobj_t* mo; - int an; - A_FaceTarget (actor); - actor->angle += FATSPREAD; - P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo->angle += FATSPREAD; - an = mo->angle >> ANGLETOFINESHIFT; - mo->momx = FixedMul (mo->info->speed, finecosine[an]); - mo->momy = FixedMul (mo->info->speed, finesine[an]); -} -void A_FatAttack2 (mobj_t* actor) -{ - mobj_t* mo; - int an; - A_FaceTarget (actor); - actor->angle -= FATSPREAD; - P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo->angle -= FATSPREAD*2; - an = mo->angle >> ANGLETOFINESHIFT; - mo->momx = FixedMul (mo->info->speed, finecosine[an]); - mo->momy = FixedMul (mo->info->speed, finesine[an]); -} -void A_FatAttack3 (mobj_t* actor) -{ - mobj_t* mo; - int an; - A_FaceTarget (actor); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo->angle -= FATSPREAD/2; - an = mo->angle >> ANGLETOFINESHIFT; - mo->momx = FixedMul (mo->info->speed, finecosine[an]); - mo->momy = FixedMul (mo->info->speed, finesine[an]); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo->angle += FATSPREAD/2; - an = mo->angle >> ANGLETOFINESHIFT; - mo->momx = FixedMul (mo->info->speed, finecosine[an]); - mo->momy = FixedMul (mo->info->speed, finesine[an]); -} -#define SKULLSPEED (20*FRACUNIT) -void A_SkullAttack (mobj_t* actor) + mobj_t* dest; + unsigned an; + + dest = actor->tracer; + if (!dest) return; + if (!P_CheckSight (actor->target, dest)) return; + an = dest->angle >> ANGLETOFINESHIFT; + P_UnsetThingPosition (actor); + actor->x = dest->x + FixedMul (24*FRACUNIT, finecosine[an]); + actor->y = dest->y + FixedMul (24*FRACUNIT, finesine[an]); + actor->z = dest->z; + P_SetThingPosition (actor); +} + +void +A_VileTarget(mobj_t* actor) +{ + mobj_t* fog; + + if (!actor->target) return; + A_FaceTarget (actor); + fog = P_SpawnMobj (actor->target->x, actor->target->x, actor->target->z, MT_FIRE); + actor->tracer = fog; + fog->target = actor; + fog->tracer = actor->target; + A_Fire (fog); +} + +void +A_VileAttack(mobj_t* actor) { - mobj_t* dest; - angle_t an; - int dist; - if (!actor->target) - return; - dest = actor->target; - actor->flags |= MF_SKULLFLY; - S_StartSound (actor, actor->info->attacksound); - A_FaceTarget (actor); - an = actor->angle >> ANGLETOFINESHIFT; - actor->momx = FixedMul (SKULLSPEED, finecosine[an]); - actor->momy = FixedMul (SKULLSPEED, finesine[an]); - dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); - dist = dist / SKULLSPEED; - if (dist < 1) - dist = 1; - actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist; + mobj_t* fire; + int an; + + if (!actor->target) return; + A_FaceTarget(actor); + if (!P_CheckSight (actor, actor->target)) return; + S_StartSound (actor, sfx_barexp); + P_DamageMobj (actor->target, actor, actor, 20); + actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; + an = actor->angle >> ANGLETOFINESHIFT; + fire = actor->tracer; + if (!fire) return; + fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); + fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); + P_RadiusAttack (fire, actor, 70 ); +} + + +void +A_FatRaise(mobj_t *actor) +{ + A_FaceTarget(actor); + S_StartSound(actor, sfx_manatk); } + void -A_PainShootSkull -( mobj_t* actor, - angle_t angle ) -{ - fixed_t x; - fixed_t y; - fixed_t z; - mobj_t* newmobj; - angle_t an; - int prestep; - int count; - thinker_t* currentthinker; - count = 0; - currentthinker = thinkercap.next; - while (currentthinker != &thinkercap) - { - if ( (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) - && ((mobj_t *)currentthinker)->type == MT_SKULL) - count++; - currentthinker = currentthinker->next; - } - if (count > 20) - return; - an = angle >> ANGLETOFINESHIFT; - prestep = - 4*FRACUNIT - + 3*(actor->info->radius + mobjinfo[MT_SKULL].radius)/2; - x = actor->x + FixedMul (prestep, finecosine[an]); - y = actor->y + FixedMul (prestep, finesine[an]); - z = actor->z + 8*FRACUNIT; - newmobj = P_SpawnMobj (x , y, z, MT_SKULL); - if (!P_TryMove (newmobj, newmobj->x, newmobj->y)) - { - P_DamageMobj (newmobj,actor,actor,10000); - return; - } - newmobj->target = actor->target; - A_SkullAttack (newmobj); -} -void A_PainAttack (mobj_t* actor) -{ - if (!actor->target) - return; - A_FaceTarget (actor); - A_PainShootSkull (actor, actor->angle); -} -void A_PainDie (mobj_t* actor) -{ - A_Fall (actor); - A_PainShootSkull (actor, actor->angle+ANG90); - A_PainShootSkull (actor, actor->angle+ANG180); - A_PainShootSkull (actor, actor->angle+ANG270); -} -void A_Scream (mobj_t* actor) -{ - int sound; - switch (actor->info->deathsound) - { - case 0: - return; - case sfx_podth1: - case sfx_podth2: - case sfx_podth3: - sound = sfx_podth1 + P_Random ()%3; - break; - case sfx_bgdth1: - case sfx_bgdth2: - sound = sfx_bgdth1 + P_Random ()%2; - break; - default: - sound = actor->info->deathsound; - break; - } - if (actor->type==MT_SPIDER - || actor->type == MT_CYBORG) - { - S_StartSound (NULL, sound); - } - else - S_StartSound (actor, sound); -} -void A_XScream (mobj_t* actor) -{ - S_StartSound (actor, sfx_slop); -} -void A_Pain (mobj_t* actor) -{ - if (actor->info->painsound) - S_StartSound (actor, actor->info->painsound); -} -void A_Fall (mobj_t *actor) -{ - actor->flags &= ~MF_SOLID; -} -void A_Explode (mobj_t* thingy) -{ - P_RadiusAttack ( thingy, thingy->target, 128 ); -} -void A_BossDeath (mobj_t* mo) -{ - thinker_t* th; - mobj_t* mo2; - line_t junk; - int i; - if ( gamemode == commercial) - { - if (gamemap != 7) - return; - if ((mo->type != MT_FATSO) - && (mo->type != MT_BABY)) - return; - } - else - { - switch(gameepisode) - { - case 1: - if (gamemap != 8) - return; - if (mo->type != MT_BRUISER) - return; - break; - case 2: - if (gamemap != 8) - return; - if (mo->type != MT_CYBORG) - return; - break; - case 3: - if (gamemap != 8) - return; - if (mo->type != MT_SPIDER) - return; - break; - case 4: - switch(gamemap) - { - case 6: - if (mo->type != MT_CYBORG) - return; - break; - case 8: - if (mo->type != MT_SPIDER) - return; - break; - default: - return; - break; - } - break; - default: - if (gamemap != 8) - return; - break; - } - } - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i] && players[i].health > 0) - break; - if (i==MAXPLAYERS) - return; - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - mo2 = (mobj_t *)th; - if (mo2 != mo - && mo2->type == mo->type - && mo2->health > 0) - { - return; +A_FatAttack1(mobj_t* actor) +{ + mobj_t* mo; + int an; + + A_FaceTarget (actor); + actor->angle += FATSPREAD; + P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo->angle += FATSPREAD; + an = mo->angle >> ANGLETOFINESHIFT; + mo->momx = FixedMul (mo->info->speed, finecosine[an]); + mo->momy = FixedMul (mo->info->speed, finesine[an]); +} + +void +A_FatAttack2(mobj_t* actor) +{ + mobj_t* mo; + int an; + + A_FaceTarget (actor); + actor->angle -= FATSPREAD; + P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo->angle -= FATSPREAD*2; + an = mo->angle >> ANGLETOFINESHIFT; + mo->momx = FixedMul (mo->info->speed, finecosine[an]); + mo->momy = FixedMul (mo->info->speed, finesine[an]); +} + +void +A_FatAttack3(mobj_t* actor) +{ + mobj_t* mo; + int an; + + A_FaceTarget (actor); + mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo->angle -= FATSPREAD/2; + an = mo->angle >> ANGLETOFINESHIFT; + mo->momx = FixedMul (mo->info->speed, finecosine[an]); + mo->momy = FixedMul (mo->info->speed, finesine[an]); + mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo->angle += FATSPREAD/2; + an = mo->angle >> ANGLETOFINESHIFT; + mo->momx = FixedMul (mo->info->speed, finecosine[an]); + mo->momy = FixedMul (mo->info->speed, finesine[an]); +} + +void A_SkullAttack (mobj_t* actor) +{ + mobj_t* dest; + angle_t an; + int dist; + + if (!actor->target) return; + dest = actor->target; + actor->flags |= MF_SKULLFLY; + S_StartSound(actor, actor->info->attacksound); + A_FaceTarget(actor); + an = actor->angle >> ANGLETOFINESHIFT; + actor->momx = FixedMul(SKULLSPEED, finecosine[an]); + actor->momy = FixedMul(SKULLSPEED, finesine[an]); + dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); + dist = dist / SKULLSPEED; + if (dist < 1) dist = 1; + actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist; +} + +void +A_PainShootSkull(mobj_t* actor, angle_t angle) +{ + mobj_t* newmobj; + thinker_t* currentthinker; + fixed_t x, y, z; + angle_t an; + int prestep, count; + + count = 0; + currentthinker = thinkercap.next; + while (currentthinker != &thinkercap) { + if ((currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) && ((mobj_t*)currentthinker)->type == MT_SKULL) ++count; + currentthinker = currentthinker->next; } - } - if ( gamemode == commercial) - { - if (gamemap == 7) - { - if (mo->type == MT_FATSO) - { - junk.tag = 666; - EV_DoFloor(&junk,lowerFloorToLowest); - return; - } - if (mo->type == MT_BABY) - { - junk.tag = 667; - EV_DoFloor(&junk,raiseToTexture); + if (count > 20) return; + an = angle >> ANGLETOFINESHIFT; + prestep = 4 * FRACUNIT + 3 *(actor->info->radius + mobjinfo[MT_SKULL].radius)/2; + x = actor->x + FixedMul(prestep, finecosine[an]); + y = actor->y + FixedMul(prestep, finesine[an]); + z = actor->z + 8 * FRACUNIT; + newmobj = P_SpawnMobj (x, y, z, MT_SKULL); + if (!P_TryMove (newmobj, newmobj->x, newmobj->y)) { + P_DamageMobj (newmobj,actor,actor,10000); return; - } } - } - else - { - switch(gameepisode) - { - case 1: - junk.tag = 666; - EV_DoFloor (&junk, lowerFloorToLowest); - return; - break; - case 4: - switch(gamemap) - { - case 6: - junk.tag = 666; - EV_DoDoor (&junk, blazeOpen); - return; - break; - case 8: - junk.tag = 666; - EV_DoFloor (&junk, lowerFloorToLowest); - return; - break; - } + newmobj->target = actor->target; + A_SkullAttack (newmobj); +} + +void +A_PainAttack(mobj_t* actor) +{ + if (!actor->target) return; + A_FaceTarget(actor); + A_PainShootSkull(actor, actor->angle); +} + +void +A_PainDie(mobj_t* actor) +{ + A_Fall(actor); + A_PainShootSkull(actor, actor->angle+ANG90); + A_PainShootSkull(actor, actor->angle+ANG180); + A_PainShootSkull(actor, actor->angle+ANG270); +} + +void +A_Scream(mobj_t* actor) +{ + int sound; + + switch (actor->info->deathsound) { + case 0: + return; + case sfx_podth1: + case sfx_podth2: + case sfx_podth3: + sound = sfx_podth1 + P_Random ()%3; + break; + case sfx_bgdth1: + case sfx_bgdth2: + sound = sfx_bgdth1 + P_Random ()%2; + break; + default: + sound = actor->info->deathsound; + break; } - } - G_ExitLevel (); + if (actor->type==MT_SPIDER || actor->type == MT_CYBORG) S_StartSound(NULL, sound); + else S_StartSound(actor, sound); } -void A_Hoof (mobj_t* mo) + +void +A_XScream(mobj_t* actor) { - S_StartSound (mo, sfx_hoof); - A_Chase (mo); + S_StartSound (actor, sfx_slop); } -void A_Metal (mobj_t* mo) + +void +A_Pain(mobj_t* actor) { - S_StartSound (mo, sfx_metal); - A_Chase (mo); + if (actor->info->painsound) S_StartSound(actor, actor->info->painsound); } -void A_BabyMetal (mobj_t* mo) + +void +A_Fall(mobj_t *actor) { - S_StartSound (mo, sfx_bspwlk); - A_Chase (mo); + actor->flags &= ~MF_SOLID; } + void -A_OpenShotgun2 -( player_t* player, - pspdef_t* psp ) +A_Explode(mobj_t* thingy) { - S_StartSound (player->mo, sfx_dbopn); + P_RadiusAttack ( thingy, thingy->target, 128 ); } + void -A_LoadShotgun2 -( player_t* player, - pspdef_t* psp ) +A_BossDeath(mobj_t* mo) { - S_StartSound (player->mo, sfx_dbload); + thinker_t* th; + mobj_t* mo2; + line_t junk; + int i; + + switch (gameepisode) { + case 1: + if (gamemap != 8) return; + if (mo->type != MT_BRUISER) return; + break; + case 2: + if (gamemap != 8) return; + if (mo->type != MT_CYBORG) return; + break; + case 3: + if (gamemap != 8) return; + if (mo->type != MT_SPIDER) return; + break; + case 4: + switch (gamemap) { + case 6: + if (mo->type != MT_CYBORG) + return; + break; + case 8: + if (mo->type != MT_SPIDER) + return; + break; + default: + return; + break; + } + break; + default: + if (gamemap != 8) return; + break; + } + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].health > 0) break; + if (i == MAXPLAYERS) return; + for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + mo2 = (mobj_t*)th; + if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) return; + } + switch (gameepisode) { + case 1: + junk.tag = 666; + EV_DoFloor (&junk, lowerFloorToLowest); + return; + break; + case 4: + switch (gamemap) { + case 6: + junk.tag = 666; + EV_DoDoor (&junk, blazeOpen); + return; + break; + case 8: + junk.tag = 666; + EV_DoFloor (&junk, lowerFloorToLowest); + return; + break; + } + } + G_ExitLevel(); } + void -A_ReFire -( player_t* player, - pspdef_t* psp ); +A_Hoof(mobj_t* mo) +{ + S_StartSound(mo, sfx_hoof); + A_Chase(mo); +} + +void +A_Metal(mobj_t* mo) +{ + S_StartSound(mo, sfx_metal); + A_Chase(mo); +} + +void +A_BabyMetal(mobj_t* mo) +{ + S_StartSound(mo, sfx_bspwlk); + A_Chase(mo); +} + void -A_CloseShotgun2 -( player_t* player, - pspdef_t* psp ) +A_OpenShotgun2(player_t* player, pspdef_t* psp) { - S_StartSound (player->mo, sfx_dbcls); - A_ReFire(player,psp); + S_StartSound(player->mo, sfx_dbopn); } -mobj_t* braintargets[32]; -int numbraintargets; -int braintargeton; + +void +A_LoadShotgun2(player_t* player, pspdef_t* psp) +{ + S_StartSound (player->mo, sfx_dbload); +} + +void A_ReFire(player_t* player, pspdef_t* psp); + +void +A_CloseShotgun2(player_t* player, pspdef_t* psp) +{ + S_StartSound(player->mo, sfx_dbcls); + A_ReFire(player,psp); +} + void A_BrainAwake (mobj_t* mo) { - thinker_t* thinker; - mobj_t* m; - numbraintargets = 0; - braintargeton = 0; - thinker = thinkercap.next; - for (thinker = thinkercap.next ; - thinker != &thinkercap ; - thinker = thinker->next) - { - if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - m = (mobj_t *)thinker; - if (m->type == MT_BOSSTARGET ) - { - braintargets[numbraintargets] = m; - numbraintargets++; + thinker_t* thinker; + mobj_t* m; + + numbraintargets = 0; + braintargeton = 0; + thinker = thinkercap.next; + for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { + if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; + m = (mobj_t *)thinker; + if (m->type == MT_BOSSTARGET) { + braintargets[numbraintargets] = m; + numbraintargets++; + } } - } - S_StartSound (NULL,sfx_bossit); + S_StartSound(NULL,sfx_bossit); } -void A_BrainPain (mobj_t* mo) + +void +A_BrainPain(mobj_t* mo) +{ + S_StartSound(NULL,sfx_bospn); +} + +void +A_BrainScream(mobj_t* mo) { - S_StartSound (NULL,sfx_bospn); + mobj_t* th; + int x, y, z; + + for (x=mo->x - 196*FRACUNIT; x < mo->x + 320*FRACUNIT; x += FRACUNIT*8) { + y = mo->y - 320*FRACUNIT; + z = 128 + P_Random()*2*FRACUNIT; + th = P_SpawnMobj (x,y,z, MT_ROCKET); + th->momz = P_Random()*512; + P_SetMobjState(th, S_BRAINEXPLODE1); + th->tics -= P_Random() & 7; + if (th->tics < 1) th->tics = 1; + } + S_StartSound(NULL, sfx_bosdth); } -void A_BrainScream (mobj_t* mo) + +void +A_BrainExplode(mobj_t* mo) { - int x; - int y; - int z; - mobj_t* th; - for (x=mo->x - 196*FRACUNIT ; x< mo->x + 320*FRACUNIT ; x+= FRACUNIT*8) - { - y = mo->y - 320*FRACUNIT; + mobj_t* th; + int x, y, z; + + x = mo->x + (P_Random() - P_Random()) * 2048; + y = mo->y; z = 128 + P_Random()*2*FRACUNIT; th = P_SpawnMobj (x,y,z, MT_ROCKET); th->momz = P_Random()*512; - P_SetMobjState (th, S_BRAINEXPLODE1); - th->tics -= P_Random()&7; - if (th->tics < 1) - th->tics = 1; - } - S_StartSound (NULL,sfx_bosdth); -} -void A_BrainExplode (mobj_t* mo) -{ - int x; - int y; - int z; - mobj_t* th; - x = mo->x + (P_Random () - P_Random ())*2048; - y = mo->y; - z = 128 + P_Random()*2*FRACUNIT; - th = P_SpawnMobj (x,y,z, MT_ROCKET); - th->momz = P_Random()*512; - P_SetMobjState (th, S_BRAINEXPLODE1); - th->tics -= P_Random()&7; - if (th->tics < 1) - th->tics = 1; -} -void A_BrainDie (mobj_t* mo) -{ - G_ExitLevel (); -} -void A_BrainSpit (mobj_t* mo) -{ - mobj_t* targ; - mobj_t* newmobj; - static int easy = 0; - easy ^= 1; - if (gameskill <= sk_easy && (!easy)) - return; - targ = braintargets[braintargeton]; - braintargeton = (braintargeton+1)%numbraintargets; - newmobj = P_SpawnMissile (mo, targ, MT_SPAWNSHOT); - newmobj->target = targ; - newmobj->reactiontime = - ((targ->y - mo->y)/newmobj->momy) / newmobj->state->tics; - S_StartSound(NULL, sfx_bospit); + P_SetMobjState(th, S_BRAINEXPLODE1); + th->tics -= P_Random() & 7; + if (th->tics < 1) th->tics = 1; } -void A_SpawnFly (mobj_t* mo); -void A_SpawnSound (mobj_t* mo) -{ - S_StartSound (mo,sfx_boscub); - A_SpawnFly(mo); -} -void A_SpawnFly (mobj_t* mo) -{ - mobj_t* newmobj; - mobj_t* fog; - mobj_t* targ; - int r; - mobjtype_t type; - if (--mo->reactiontime) - return; - targ = mo->target; - fog = P_SpawnMobj (targ->x, targ->y, targ->z, MT_SPAWNFIRE); - S_StartSound (fog, sfx_telept); - r = P_Random (); - if ( r<50 ) - type = MT_TROOP; - else if (r<90) - type = MT_SERGEANT; - else if (r<120) - type = MT_SHADOWS; - else if (r<130) - type = MT_PAIN; - else if (r<160) - type = MT_HEAD; - else if (r<162) - type = MT_VILE; - else if (r<172) - type = MT_UNDEAD; - else if (r<192) - type = MT_BABY; - else if (r<222) - type = MT_FATSO; - else if (r<246) - type = MT_KNIGHT; - else - type = MT_BRUISER; - newmobj = P_SpawnMobj (targ->x, targ->y, targ->z, type); - if (P_LookForPlayers (newmobj, true) ) - P_SetMobjState (newmobj, newmobj->info->seestate); - P_TeleportMove (newmobj, newmobj->x, newmobj->y); - P_RemoveMobj (mo); -} -void A_PlayerScream (mobj_t* mo) -{ - int sound = sfx_pldeth; - if ( (gamemode == commercial) - && (mo->health < -50)) - { - sound = sfx_pdiehi; - } - S_StartSound (mo, sound); + +void +A_BrainDie(mobj_t* mo) +{ + G_ExitLevel(); +} + + +void +A_BrainSpit(mobj_t* mo) +{ + static int easy = 0; + mobj_t* targ; + mobj_t* newmobj; + + easy ^= 1; + if (gameskill <= sk_easy && (!easy)) return; + targ = braintargets[braintargeton]; + braintargeton = (braintargeton+1)%numbraintargets; + newmobj = P_SpawnMissile(mo, targ, MT_SPAWNSHOT); + newmobj->target = targ; + newmobj->reactiontime = ((targ->y - mo->y)/newmobj->momy) / newmobj->state->tics; + S_StartSound(NULL, sfx_bospit); +} + +void +A_SpawnSound(mobj_t* mo) +{ + S_StartSound(mo,sfx_boscub); + A_SpawnFly(mo); +} + +void +A_SpawnFly(mobj_t* mo) +{ + mobj_t* newmobj, *fog, *targ; + mobjtype_t type; + int r; + + if (--mo->reactiontime) return; + targ = mo->target; + fog = P_SpawnMobj(targ->x, targ->y, targ->z, MT_SPAWNFIRE); + S_StartSound(fog, sfx_telept); + r = P_Random(); + if (r < 50) type = MT_TROOP; + else if (r < 90) type = MT_SERGEANT; + else if (r < 120) type = MT_SHADOWS; + else if (r < 130) type = MT_PAIN; + else if (r < 160) type = MT_HEAD; + else if (r < 162) type = MT_VILE; + else if (r < 172) type = MT_UNDEAD; + else if (r < 192) type = MT_BABY; + else if (r < 222) type = MT_FATSO; + else if (r < 246) type = MT_KNIGHT; + else type = MT_BRUISER; + newmobj = P_SpawnMobj (targ->x, targ->y, targ->z, type); + if (P_LookForPlayers (newmobj, true)) P_SetMobjState(newmobj, newmobj->info->seestate); + P_TeleportMove(newmobj, newmobj->x, newmobj->y); + P_RemoveMobj(mo); +} + +void +A_PlayerScream(mobj_t* mo) +{ + int sound; + + sound = sfx_pldeth; + S_StartSound(mo, sound); } diff --git a/src/p_floor.c b/src/p_floor.c @@ -1,3 +1,9 @@ +/* + +T_MovePlane +Literally the same guy who wrote the P_ShootSpecialLine function + +*/ #include "z_zone.h" #include "doomdef.h" #include "p_local.h" @@ -5,155 +11,129 @@ #include "doomstat.h" #include "r_state.h" #include "sounds.h" + result_e -T_MovePlane -( sector_t* sector, - fixed_t speed, - fixed_t dest, - boolean crush, - int floorOrCeiling, - int direction ) +T_MovePlane(sector_t* sector, fixed_t speed, fixed_t dest, boolean crush, int floorOrCeiling, int direction) { boolean flag; fixed_t lastpos; - switch(floorOrCeiling) - { - case 0: - switch(direction) - { - case -1: - if (sector->floorheight - speed < dest) - { - lastpos = sector->floorheight; - sector->floorheight = dest; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - sector->floorheight =lastpos; - P_ChangeSector(sector,crush); - } - return pastdest; - } - else - { - lastpos = sector->floorheight; - sector->floorheight -= speed; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - sector->floorheight = lastpos; - P_ChangeSector(sector,crush); - return crushed; - } - } - break; - case 1: - if (sector->floorheight + speed > dest) - { - lastpos = sector->floorheight; - sector->floorheight = dest; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - sector->floorheight = lastpos; - P_ChangeSector(sector,crush); - } - return pastdest; - } - else - { - lastpos = sector->floorheight; - sector->floorheight += speed; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - if (crush == true) - return crushed; - sector->floorheight = lastpos; - P_ChangeSector(sector,crush); - return crushed; - } - } - break; - } - break; - case 1: - switch(direction) - { - case -1: - if (sector->ceilingheight - speed < dest) - { - lastpos = sector->ceilingheight; - sector->ceilingheight = dest; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); - } - return pastdest; - } - else - { - lastpos = sector->ceilingheight; - sector->ceilingheight -= speed; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - if (crush == true) - return crushed; - sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); - return crushed; - } - } - break; - case 1: - if (sector->ceilingheight + speed > dest) - { - lastpos = sector->ceilingheight; - sector->ceilingheight = dest; - flag = P_ChangeSector(sector,crush); - if (flag == true) - { - sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); - } - return pastdest; - } - else - { - lastpos = sector->ceilingheight; - sector->ceilingheight += speed; - flag = P_ChangeSector(sector,crush); -#if 0 - if (flag == true) - { - sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); - return crushed; - } -#endif - } - break; + switch (floorOrCeiling) { + case 0: + switch (direction) { + case -1: + if (sector->floorheight - speed < dest) { + lastpos = sector->floorheight; + sector->floorheight = dest; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + sector->floorheight =lastpos; + P_ChangeSector(sector,crush); + } + return pastdest; + } else { + lastpos = sector->floorheight; + sector->floorheight -= speed; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + sector->floorheight = lastpos; + P_ChangeSector(sector,crush); + return crushed; + } + } + break; + case 1: + if (sector->floorheight + speed > dest) { + lastpos = sector->floorheight; + sector->floorheight = dest; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + sector->floorheight = lastpos; + P_ChangeSector(sector,crush); + } + return pastdest; + } else { + lastpos = sector->floorheight; + sector->floorheight += speed; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + if (crush == true) + return crushed; + sector->floorheight = lastpos; + P_ChangeSector(sector, crush); + return crushed; + } + } + break; + } + break; + case 1: + switch (direction) { + case -1: + if (sector->ceilingheight - speed < dest) { + lastpos = sector->ceilingheight; + sector->ceilingheight = dest; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + sector->ceilingheight = lastpos; + P_ChangeSector(sector,crush); + } + return pastdest; + } else { + lastpos = sector->ceilingheight; + sector->ceilingheight -= speed; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + if (crush == true) + return crushed; + sector->ceilingheight = lastpos; + P_ChangeSector(sector,crush); + return crushed; + } + } + break; + case 1: + if (sector->ceilingheight + speed > dest) { + lastpos = sector->ceilingheight; + sector->ceilingheight = dest; + flag = P_ChangeSector(sector,crush); + if (flag == true) { + sector->ceilingheight = lastpos; + P_ChangeSector(sector,crush); + } + return pastdest; + } else { + lastpos = sector->ceilingheight; + sector->ceilingheight += speed; + flag = P_ChangeSector(sector,crush); + } + break; + } + break; } - break; - } - return ok; + return ok; } -void T_MoveFloor(floormove_t* floor) -{ - result_e res; + + + + + + void T_MoveFloor(floormove_t* floor) + { + result_e res; + res = T_MovePlane(floor->sector, floor->speed, floor->floordestheight, floor->crush,0,floor->direction); + if (!(leveltime&7)) S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_stnmov); + if (res == pastdest) { floor->sector->specialdata = NULL; + if (floor->direction == 1) { switch(floor->type) @@ -177,10 +157,16 @@ void T_MoveFloor(floormove_t* floor) } } P_RemoveThinker(&floor->thinker); + S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_pstop); } + } + + + + int EV_DoFloor ( line_t* line, @@ -191,13 +177,18 @@ EV_DoFloor int i; sector_t* sec; floormove_t* floor; + secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; + + if (sec->specialdata) continue; + + rtn = 1; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); @@ -205,6 +196,7 @@ EV_DoFloor floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; floor->type = floortype; floor->crush = false; + switch(floortype) { case lowerFloor: @@ -214,6 +206,7 @@ EV_DoFloor floor->floordestheight = P_FindHighestFloorSurrounding(sec); break; + case lowerFloorToLowest: floor->direction = -1; floor->sector = sec; @@ -221,6 +214,7 @@ EV_DoFloor floor->floordestheight = P_FindLowestFloorSurrounding(sec); break; + case turboLower: floor->direction = -1; floor->sector = sec; @@ -230,6 +224,7 @@ EV_DoFloor if (floor->floordestheight != sec->floorheight) floor->floordestheight += 8*FRACUNIT; break; + case raiseFloorCrush: floor->crush = true; case raiseFloor: @@ -243,6 +238,7 @@ EV_DoFloor floor->floordestheight -= (8*FRACUNIT)* (floortype == raiseFloorCrush); break; + case raiseFloorTurbo: floor->direction = 1; floor->sector = sec; @@ -250,6 +246,7 @@ EV_DoFloor floor->floordestheight = P_FindNextHighestFloor(sec,sec->floorheight); break; + case raiseFloorToNearest: floor->direction = 1; floor->sector = sec; @@ -257,6 +254,7 @@ EV_DoFloor floor->floordestheight = P_FindNextHighestFloor(sec,sec->floorheight); break; + case raiseFloor24: floor->direction = 1; floor->sector = sec; @@ -271,6 +269,7 @@ EV_DoFloor floor->floordestheight = floor->sector->floorheight + 512 * FRACUNIT; break; + case raiseFloor24AndChange: floor->direction = 1; floor->sector = sec; @@ -280,10 +279,12 @@ EV_DoFloor sec->floorpic = line->frontsector->floorpic; sec->special = line->frontsector->special; break; + case raiseToTexture: { - int minsize = MAXINT; + int minsize = INT_MAX; side_t* side; + floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; @@ -309,6 +310,7 @@ EV_DoFloor floor->sector->floorheight + minsize; } break; + case lowerAndChange: floor->direction = -1; floor->sector = sec; @@ -316,6 +318,7 @@ EV_DoFloor floor->floordestheight = P_FindLowestFloorSurrounding(sec); floor->texture = sec->floorpic; + for (i = 0; i < sec->linecount; i++) { if ( twoSided(secnum, i) ) @@ -323,6 +326,7 @@ EV_DoFloor if (getSide(secnum,i,0)->sector-sectors == secnum) { sec = getSector(secnum,i,1); + if (sec->floorheight == floor->floordestheight) { floor->texture = sec->floorpic; @@ -333,6 +337,7 @@ EV_DoFloor else { sec = getSector(secnum,i,0); + if (sec->floorheight == floor->floordestheight) { floor->texture = sec->floorpic; @@ -348,84 +353,73 @@ EV_DoFloor } return rtn; } + int -EV_BuildStairs -( line_t* line, - stair_e type ) +EV_BuildStairs(line_t* line, stair_e type) { - int secnum; - int height; - int i; - int newsecnum; - int texture; - int ok; - int rtn; - sector_t* sec; - sector_t* tsec; - floormove_t* floor; - fixed_t stairsize; - fixed_t speed; + int secnum, height, i, newsecnum, texture, ok, rtn; + sector_t* sec, *tsec; + floormove_t* floor; + fixed_t stairsize, speed; + secnum = -1; rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) - { - sec = &sectors[secnum]; - if (sec->specialdata) - continue; - rtn = 1; - floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); - P_AddThinker (&floor->thinker); - sec->specialdata = floor; - floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; - floor->direction = 1; - floor->sector = sec; - switch(type) - { - case build8: - speed = FLOORSPEED/4; - stairsize = 8*FRACUNIT; - break; - case turbo16: - speed = FLOORSPEED*4; - stairsize = 16*FRACUNIT; - break; - } - floor->speed = speed; - height = sec->floorheight + stairsize; - floor->floordestheight = height; - texture = sec->floorpic; - do - { - ok = 0; - for (i = 0;i < sec->linecount;i++) - { - if ( !((sec->lines[i])->flags & ML_TWOSIDED) ) - continue; - tsec = (sec->lines[i])->frontsector; - newsecnum = tsec-sectors; - if (secnum != newsecnum) - continue; - tsec = (sec->lines[i])->backsector; - newsecnum = tsec - sectors; - if (tsec->floorpic != texture) - continue; - height += stairsize; - if (tsec->specialdata) - continue; - sec = tsec; - secnum = newsecnum; - floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); + while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { + sec = &sectors[secnum]; + if (sec->specialdata) + continue; + rtn = 1; + floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); sec->specialdata = floor; - floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; + floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor; floor->direction = 1; floor->sector = sec; + switch (type) { + case build8: + speed = FLOORSPEED/4; + stairsize = 8*FRACUNIT; + break; + case turbo16: + default: + speed = FLOORSPEED*4; + stairsize = 16*FRACUNIT; + break; + } floor->speed = speed; + height = sec->floorheight + stairsize; floor->floordestheight = height; - ok = 1; - break; - } - } while(ok); - } - return rtn; + texture = sec->floorpic; + do { + ok = 0; + for (i = 0; i < sec->linecount; ++i) { + if (!((sec->lines[i])->flags & ML_TWOSIDED)) + continue; + tsec = (sec->lines[i])->frontsector; + newsecnum = tsec-sectors; + if (secnum != newsecnum) + continue; + tsec = (sec->lines[i])->backsector; + newsecnum = tsec - sectors; + if (tsec->floorpic != texture) + continue; + height += stairsize; + if (tsec->specialdata) + continue; + sec = tsec; + secnum = newsecnum; + floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0); + P_AddThinker(&floor->thinker); + sec->specialdata = floor; + floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; + floor->direction = 1; + floor->sector = sec; + floor->speed = speed; + floor->floordestheight = height; + ok = 1; + break; + } + } while (ok); + } + return rtn; } diff --git a/src/p_inter.c b/src/p_inter.c @@ -7,632 +7,454 @@ #include "am_map.h" #include "p_local.h" #include "s_sound.h" -#ifdef __GNUG__ -#pragma implementation "p_inter.h" -#endif #include "p_inter.h" + #define BONUSADD 6 + int maxammo[NUMAMMO] = {200, 50, 300, 50}; int clipammo[NUMAMMO] = {10, 4, 20, 1}; + boolean -P_GiveAmmo -( player_t* player, - ammotype_t ammo, - int num ) +P_GiveAmmo(player_t* player, ammotype_t ammo, int num) { - int oldammo; - if (ammo == am_noammo) - return false; - if (ammo < 0 || ammo > NUMAMMO) - I_Error ("P_GiveAmmo: bad type %i", ammo); - if ( player->ammo[ammo] == player->maxammo[ammo] ) - return false; - if (num) - num *= clipammo[ammo]; - else - num = clipammo[ammo]/2; - if (gameskill == sk_baby - || gameskill == sk_nightmare) - { - num <<= 1; - } - oldammo = player->ammo[ammo]; - player->ammo[ammo] += num; - if (player->ammo[ammo] > player->maxammo[ammo]) - player->ammo[ammo] = player->maxammo[ammo]; - if (oldammo) - return true; - switch (ammo) - { - case am_clip: - if (player->readyweapon == wp_fist) - { - if (player->weaponowned[wp_chaingun]) - player->pendingweapon = wp_chaingun; - else - player->pendingweapon = wp_pistol; + int oldammo; + if (ammo == am_noammo) return false; + if (ammo < 0 || ammo > NUMAMMO) I_Error("P_GiveAmmo: bad type %i", ammo); + if (player->ammo[ammo] == player->maxammo[ammo]) return false; + if (num) num *= clipammo[ammo]; + else num = clipammo[ammo]/2; + if (gameskill == sk_baby || gameskill == sk_nightmare) num <<= 1; + oldammo = player->ammo[ammo]; + player->ammo[ammo] += num; + if (player->ammo[ammo] > player->maxammo[ammo]) player->ammo[ammo] = player->maxammo[ammo]; + if (oldammo) return true; + switch(ammo) { + case am_clip: + if (player->readyweapon == wp_fist) { + if (player->weaponowned[wp_chaingun]) player->pendingweapon = wp_chaingun; + else player->pendingweapon = wp_pistol; + } + break; + case am_shell: + if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol) + if (player->weaponowned[wp_shotgun]) player->pendingweapon = wp_shotgun; + break; + case am_cell: + if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol) + if (player->weaponowned[wp_plasma]) + player->pendingweapon = wp_plasma; + break; + case am_misl: + if (player->readyweapon == wp_fist) + if (player->weaponowned[wp_missile]) + player->pendingweapon = wp_missile; + default: + break; } - break; - case am_shell: - if (player->readyweapon == wp_fist - || player->readyweapon == wp_pistol) - { - if (player->weaponowned[wp_shotgun]) - player->pendingweapon = wp_shotgun; - } - break; - case am_cell: - if (player->readyweapon == wp_fist - || player->readyweapon == wp_pistol) - { - if (player->weaponowned[wp_plasma]) - player->pendingweapon = wp_plasma; - } - break; - case am_misl: - if (player->readyweapon == wp_fist) - { - if (player->weaponowned[wp_missile]) - player->pendingweapon = wp_missile; - } - default: - break; - } - return true; + return true; } + boolean -P_GiveWeapon -( player_t* player, - weapontype_t weapon, - boolean dropped ) +P_GiveWeapon(player_t* player, weapontype_t weapon, boolean dropped) { - boolean gaveammo; - boolean gaveweapon; - if (netgame - && (deathmatch!=2) - && !dropped ) - { - if (player->weaponowned[weapon]) - return false; - player->bonuscount += BONUSADD; - player->weaponowned[weapon] = true; - if (deathmatch) - P_GiveAmmo (player, weaponinfo[weapon].ammo, 5); - else - P_GiveAmmo (player, weaponinfo[weapon].ammo, 2); - player->pendingweapon = weapon; - if (player == &players[consoleplayer]) - S_StartSound (NULL, sfx_wpnup); - return false; - } - if (weaponinfo[weapon].ammo != am_noammo) - { - if (dropped) - gaveammo = P_GiveAmmo (player, weaponinfo[weapon].ammo, 1); - else - gaveammo = P_GiveAmmo (player, weaponinfo[weapon].ammo, 2); - } - else - gaveammo = false; - if (player->weaponowned[weapon]) - gaveweapon = false; - else - { - gaveweapon = true; - player->weaponowned[weapon] = true; - player->pendingweapon = weapon; - } - return (gaveweapon || gaveammo); + boolean gaveammo; + boolean gaveweapon; + + if (netgame && (deathmatch!=2) && !dropped) { + if (player->weaponowned[weapon]) return false; + player->bonuscount += BONUSADD; + player->weaponowned[weapon] = true; + if (deathmatch) P_GiveAmmo(player, weaponinfo[weapon].ammo, 5); + else P_GiveAmmo(player, weaponinfo[weapon].ammo, 2); + player->pendingweapon = weapon; + if (player == &players[consoleplayer]) S_StartSound(NULL, sfx_wpnup); + return false; + } + if (weaponinfo[weapon].ammo != am_noammo) { + if (dropped) gaveammo = P_GiveAmmo(player, weaponinfo[weapon].ammo, 1); + else gaveammo = P_GiveAmmo(player, weaponinfo[weapon].ammo, 2); + } else gaveammo = false; + if (player->weaponowned[weapon]) gaveweapon = false; + else { + gaveweapon = true; + player->weaponowned[weapon] = true; + player->pendingweapon = weapon; + } + return(gaveweapon || gaveammo); } + boolean -P_GiveBody -( player_t* player, - int num ) +P_GiveBody(player_t* player, int num) { - if (player->health >= MAXHEALTH) - return false; - player->health += num; - if (player->health > MAXHEALTH) - player->health = MAXHEALTH; - player->mo->health = player->health; - return true; + if (player->health >= MAXHEALTH) return false; + player->health += num; + if (player->health > MAXHEALTH) player->health = MAXHEALTH; + player->mo->health = player->health; + return true; } + boolean -P_GiveArmor -( player_t* player, - int armortype ) +P_GiveArmor(player_t* player, int armortype) { - int hits; - hits = armortype*100; - if (player->armorpoints >= hits) - return false; - player->armortype = armortype; - player->armorpoints = hits; - return true; + int hits; + + hits = armortype * 100; + if (player->armorpoints >= hits) return false; + player->armortype = armortype; + player->armorpoints = hits; + return true; } + void -P_GiveCard -( player_t* player, - card_t card ) +P_GiveCard(player_t* player, card_t card) { - if (player->cards[card]) - return; - player->bonuscount = BONUSADD; - player->cards[card] = 1; + if (player->cards[card]) return; + player->bonuscount = BONUSADD; + player->cards[card] = 1; } + boolean -P_GivePower -( player_t* player, - int /*powertype_t*/ power ) +P_GivePower(player_t* player, int power) { - if (power == pw_invulnerability) - { - player->powers[power] = INVULNTICS; - return true; - } - if (power == pw_invisibility) - { - player->powers[power] = INVISTICS; - player->mo->flags |= MF_SHADOW; - return true; - } - if (power == pw_infrared) - { - player->powers[power] = INFRATICS; - return true; - } - if (power == pw_ironfeet) - { - player->powers[power] = IRONTICS; - return true; - } - if (power == pw_strength) - { - P_GiveBody (player, 100); + if (power == pw_invulnerability) { + player->powers[power] = INVULNTICS; + return true; + } + if (power == pw_invisibility) { + player->powers[power] = INVISTICS; + player->mo->flags |= MF_SHADOW; + return true; + } + if (power == pw_infrared) { + player->powers[power] = INFRATICS; + return true; + } + if (power == pw_ironfeet) { + player->powers[power] = IRONTICS; + return true; + } + if (power == pw_strength) { + P_GiveBody(player, 100); + player->powers[power] = 1; + return true; + } + if (player->powers[power]) return false; player->powers[power] = 1; return true; - } - if (player->powers[power]) - return false; - player->powers[power] = 1; - return true; } + void -P_TouchSpecialThing -( mobj_t* special, - mobj_t* toucher ) +P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) { - player_t* player; - int i; - fixed_t delta; - int sound; - delta = special->z - toucher->z; - if (delta > toucher->height - || delta < -8*FRACUNIT) - { - return; - } - sound = sfx_itemup; - player = toucher->player; - if (toucher->health <= 0) - return; - switch (special->sprite) - { - case SPR_ARM1: - if (!P_GiveArmor (player, 1)) - return; - player->message = GOTARMOR; - break; - case SPR_ARM2: - if (!P_GiveArmor (player, 2)) - return; - player->message = GOTMEGA; - break; - case SPR_BON1: - player->health++; - if (player->health > 200) - player->health = 200; - player->mo->health = player->health; - player->message = GOTHTHBONUS; - break; - case SPR_BON2: - player->armorpoints++; - if (player->armorpoints > 200) - player->armorpoints = 200; - if (!player->armortype) - player->armortype = 1; - player->message = GOTARMBONUS; - break; - case SPR_SOUL: - player->health += 100; - if (player->health > 200) - player->health = 200; - player->mo->health = player->health; - player->message = GOTSUPER; - sound = sfx_getpow; - break; - case SPR_MEGA: - if (gamemode != commercial) - return; - player->health = 200; - player->mo->health = player->health; - P_GiveArmor (player,2); - player->message = GOTMSPHERE; - sound = sfx_getpow; - break; - case SPR_BKEY: - if (!player->cards[it_bluecard]) - player->message = GOTBLUECARD; - P_GiveCard (player, it_bluecard); - if (!netgame) - break; - return; - case SPR_YKEY: - if (!player->cards[it_yellowcard]) - player->message = GOTYELWCARD; - P_GiveCard (player, it_yellowcard); - if (!netgame) - break; - return; - case SPR_RKEY: - if (!player->cards[it_redcard]) - player->message = GOTREDCARD; - P_GiveCard (player, it_redcard); - if (!netgame) - break; - return; - case SPR_BSKU: - if (!player->cards[it_blueskull]) - player->message = GOTBLUESKUL; - P_GiveCard (player, it_blueskull); - if (!netgame) - break; - return; - case SPR_YSKU: - if (!player->cards[it_yellowskull]) - player->message = GOTYELWSKUL; - P_GiveCard (player, it_yellowskull); - if (!netgame) - break; - return; - case SPR_RSKU: - if (!player->cards[it_redskull]) - player->message = GOTREDSKULL; - P_GiveCard (player, it_redskull); - if (!netgame) - break; - return; - case SPR_STIM: - if (!P_GiveBody (player, 10)) - return; - player->message = GOTSTIM; - break; - case SPR_MEDI: - if (!P_GiveBody (player, 25)) - return; - if (player->health < 25) - player->message = GOTMEDINEED; - else - player->message = GOTMEDIKIT; - break; - case SPR_PINV: - if (!P_GivePower (player, pw_invulnerability)) - return; - player->message = GOTINVUL; - sound = sfx_getpow; - break; - case SPR_PSTR: - if (!P_GivePower (player, pw_strength)) - return; - player->message = GOTBERSERK; - if (player->readyweapon != wp_fist) - player->pendingweapon = wp_fist; - sound = sfx_getpow; - break; - case SPR_PINS: - if (!P_GivePower (player, pw_invisibility)) - return; - player->message = GOTINVIS; - sound = sfx_getpow; - break; - case SPR_SUIT: - if (!P_GivePower (player, pw_ironfeet)) - return; - player->message = GOTSUIT; - sound = sfx_getpow; - break; - case SPR_PMAP: - if (!P_GivePower (player, pw_allmap)) - return; - player->message = GOTMAP; - sound = sfx_getpow; - break; - case SPR_PVIS: - if (!P_GivePower (player, pw_infrared)) - return; - player->message = GOTVISOR; - sound = sfx_getpow; - break; - case SPR_CLIP: - if (special->flags & MF_DROPPED) - { - if (!P_GiveAmmo (player,am_clip,0)) - return; + player_t* player; + int i, sound; + fixed_t delta; + + delta = special->z - toucher->z; + if (delta > toucher->height || delta < -8*FRACUNIT) return; + sound = sfx_itemup; + player = toucher->player; + if (toucher->health <= 0) return; + switch(special->sprite) { + case SPR_ARM1: + if (!P_GiveArmor(player, 1)) return; + player->message = lang[GOTARMOR]; + break; + case SPR_ARM2: + if (!P_GiveArmor(player, 2)) return; + player->message = lang[GOTMEGA]; + break; + case SPR_BON1: + player->health++; + if (player->health > 200) player->health = 200; + player->mo->health = player->health; + player->message = lang[GOTHTHBONUS]; + break; + case SPR_BON2: + player->armorpoints++; + if (player->armorpoints > 200) player->armorpoints = 200; + if (!player->armortype) player->armortype = 1; + player->message = lang[GOTARMBONUS]; + break; + case SPR_SOUL: + player->health += 100; + if (player->health > 200) player->health = 200; + player->mo->health = player->health; + player->message = lang[GOTSUPER]; + sound = sfx_getpow; + break; + case SPR_MEGA: + player->health = 200; + player->mo->health = player->health; + P_GiveArmor(player, 2); + player->message = lang[GOTMSPHERE]; + sound = sfx_getpow; + break; + case SPR_BKEY: + if (!player->cards[it_bluecard]) player->message = lang[GOTBLUECARD]; + P_GiveCard(player, it_bluecard); + if (!netgame) break; + return; + case SPR_YKEY: + if (!player->cards[it_yellowcard]) player->message = lang[GOTYELWCARD]; + P_GiveCard(player, it_yellowcard); + if (!netgame) break; + return; + case SPR_RKEY: + if (!player->cards[it_redcard]) player->message = lang[GOTREDCARD]; + P_GiveCard(player, it_redcard); + if (!netgame) break; + return; + case SPR_BSKU: + if (!player->cards[it_blueskull]) player->message = lang[GOTBLUESKUL]; + P_GiveCard(player, it_blueskull); + if (!netgame) break; + return; + case SPR_YSKU: + if (!player->cards[it_yellowskull]) player->message = lang[GOTYELWSKUL]; + P_GiveCard(player, it_yellowskull); + if (!netgame) break; + return; + case SPR_RSKU: + if (!player->cards[it_redskull]) player->message = lang[GOTREDSKULL]; + P_GiveCard(player, it_redskull); + if (!netgame) break; + return; + case SPR_STIM: + if (!P_GiveBody(player, 10)) return; + player->message = lang[GOTSTIM]; + break; + case SPR_MEDI: + if (!P_GiveBody(player, 25)) return; + if (player->health < 25) player->message = lang[GOTMEDINEED]; + else player->message = lang[GOTMEDIKIT]; + break; + case SPR_PINV: + if (!P_GivePower(player, pw_invulnerability)) return; + player->message = lang[GOTINVUL]; + sound = sfx_getpow; + break; + case SPR_PSTR: + if (!P_GivePower(player, pw_strength)) return; + player->message = lang[GOTBERSERK]; + if (player->readyweapon != wp_fist) player->pendingweapon = wp_fist; + sound = sfx_getpow; + break; + case SPR_PINS: + if (!P_GivePower(player, pw_invisibility)) return; + player->message = lang[GOTINVIS]; + sound = sfx_getpow; + break; + case SPR_SUIT: + if (!P_GivePower(player, pw_ironfeet)) return; + player->message = lang[GOTSUIT]; + sound = sfx_getpow; + break; + case SPR_PMAP: + if (!P_GivePower(player, pw_allmap)) return; + player->message = lang[GOTMAP]; + sound = sfx_getpow; + break; + case SPR_PVIS: + if (!P_GivePower(player, pw_infrared)) return; + player->message = lang[GOTVISOR]; + sound = sfx_getpow; + break; + case SPR_CLIP: + if (special->flags & MF_DROPPED) { + if (!P_GiveAmmo(player, am_clip, 0)) return; + } + else + if (!P_GiveAmmo(player, am_clip, 1)) + return; + player->message = lang[GOTCLIP]; + break; + case SPR_AMMO: + if (!P_GiveAmmo(player, am_clip, 5)) return; + player->message = lang[GOTCLIPBOX]; + break; + case SPR_ROCK: + if (!P_GiveAmmo(player, am_misl, 1)) return; + player->message = lang[GOTROCKET]; + break; + case SPR_BROK: + if (!P_GiveAmmo(player, am_misl, 5)) return; + player->message = lang[GOTROCKBOX]; + break; + case SPR_CELL: + if (!P_GiveAmmo(player, am_cell, 1)) return; + player->message = lang[GOTCELL]; + break; + case SPR_CELP: + if (!P_GiveAmmo(player, am_cell, 5)) return; + player->message = lang[GOTCELLBOX]; + break; + case SPR_SHEL: + if (!P_GiveAmmo(player, am_shell, 1)) return; + player->message = lang[GOTSHELLS]; + break; + case SPR_SBOX: + if (!P_GiveAmmo(player, am_shell, 5)) return; + player->message = lang[GOTSHELLBOX]; + break; + case SPR_BPAK: + if (!player->backpack) { + for (i=0 ; i<NUMAMMO ; i++) player->maxammo[i] *= 2; + player->backpack = true; + } + for (i=0 ; i<NUMAMMO ; i++) P_GiveAmmo(player, i, 1); + player->message = lang[GOTBACKPACK]; + break; + case SPR_BFUG: + if (!P_GiveWeapon(player, wp_bfg, false)) return; + player->message = lang[GOTBFG9000]; + sound = sfx_wpnup; + break; + case SPR_MGUN: + if (!P_GiveWeapon(player, wp_chaingun, special->flags&MF_DROPPED)) return; + player->message = lang[GOTCHAINGUN]; + sound = sfx_wpnup; + break; + case SPR_CSAW: + if (!P_GiveWeapon(player, wp_chainsaw, false)) return; + player->message = lang[GOTCHAINSAW]; + sound = sfx_wpnup; + break; + case SPR_LAUN: + if (!P_GiveWeapon(player, wp_missile, false)) return; + player->message = lang[GOTLAUNCHER]; + sound = sfx_wpnup; + break; + case SPR_PLAS: + if (!P_GiveWeapon(player, wp_plasma, false)) return; + player->message = lang[GOTPLASMA]; + sound = sfx_wpnup; + break; + case SPR_SHOT: + if (!P_GiveWeapon(player, wp_shotgun, special->flags&MF_DROPPED)) return; + player->message = lang[GOTSHOTGUN]; + sound = sfx_wpnup; + break; + case SPR_SGN2: + if (!P_GiveWeapon(player, wp_supershotgun, special->flags&MF_DROPPED)) return; + player->message = lang[GOTSHOTGUN2]; + sound = sfx_wpnup; + break; + default: + I_Error("P_SpecialThing: Unknown gettable thing"); } - else - { - if (!P_GiveAmmo (player,am_clip,1)) - return; - } - player->message = GOTCLIP; - break; - case SPR_AMMO: - if (!P_GiveAmmo (player, am_clip,5)) - return; - player->message = GOTCLIPBOX; - break; - case SPR_ROCK: - if (!P_GiveAmmo (player, am_misl,1)) - return; - player->message = GOTROCKET; - break; - case SPR_BROK: - if (!P_GiveAmmo (player, am_misl,5)) - return; - player->message = GOTROCKBOX; - break; - case SPR_CELL: - if (!P_GiveAmmo (player, am_cell,1)) - return; - player->message = GOTCELL; - break; - case SPR_CELP: - if (!P_GiveAmmo (player, am_cell,5)) - return; - player->message = GOTCELLBOX; - break; - case SPR_SHEL: - if (!P_GiveAmmo (player, am_shell,1)) - return; - player->message = GOTSHELLS; - break; - case SPR_SBOX: - if (!P_GiveAmmo (player, am_shell,5)) - return; - player->message = GOTSHELLBOX; - break; - case SPR_BPAK: - if (!player->backpack) - { - for (i=0 ; i<NUMAMMO ; i++) - player->maxammo[i] *= 2; - player->backpack = true; - } - for (i=0 ; i<NUMAMMO ; i++) - P_GiveAmmo (player, i, 1); - player->message = GOTBACKPACK; - break; - case SPR_BFUG: - if (!P_GiveWeapon (player, wp_bfg, false) ) - return; - player->message = GOTBFG9000; - sound = sfx_wpnup; - break; - case SPR_MGUN: - if (!P_GiveWeapon (player, wp_chaingun, special->flags&MF_DROPPED) ) - return; - player->message = GOTCHAINGUN; - sound = sfx_wpnup; - break; - case SPR_CSAW: - if (!P_GiveWeapon (player, wp_chainsaw, false) ) - return; - player->message = GOTCHAINSAW; - sound = sfx_wpnup; - break; - case SPR_LAUN: - if (!P_GiveWeapon (player, wp_missile, false) ) - return; - player->message = GOTLAUNCHER; - sound = sfx_wpnup; - break; - case SPR_PLAS: - if (!P_GiveWeapon (player, wp_plasma, false) ) - return; - player->message = GOTPLASMA; - sound = sfx_wpnup; - break; - case SPR_SHOT: - if (!P_GiveWeapon (player, wp_shotgun, special->flags&MF_DROPPED ) ) - return; - player->message = GOTSHOTGUN; - sound = sfx_wpnup; - break; - case SPR_SGN2: - if (!P_GiveWeapon (player, wp_supershotgun, special->flags&MF_DROPPED ) ) - return; - player->message = GOTSHOTGUN2; - sound = sfx_wpnup; - break; - default: - I_Error ("P_SpecialThing: Unknown gettable thing"); - } - if (special->flags & MF_COUNTITEM) - player->itemcount++; - P_RemoveMobj (special); - player->bonuscount += BONUSADD; - if (player == &players[consoleplayer]) - S_StartSound (NULL, sound); + if (special->flags & MF_COUNTITEM) player->itemcount++; + P_RemoveMobj(special); + player->bonuscount += BONUSADD; + if (player == &players[consoleplayer]) S_StartSound(NULL, sound); } + void -P_KillMobj -( mobj_t* source, - mobj_t* target ) +P_KillMobj(mobj_t* source, mobj_t* target) { - mobjtype_t item; - mobj_t* mo; - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); - if (target->type != MT_SKULL) - target->flags &= ~MF_NOGRAVITY; - target->flags |= MF_CORPSE|MF_DROPOFF; - target->height >>= 2; - if (source && source->player) - { - if (target->flags & MF_COUNTKILL) - source->player->killcount++; - if (target->player) - source->player->frags[target->player-players]++; - } - else if (!netgame && (target->flags & MF_COUNTKILL) ) - { - players[0].killcount++; - } - if (target->player) - { - if (!source) - target->player->frags[target->player-players]++; - target->flags &= ~MF_SOLID; - target->player->playerstate = PST_DEAD; - P_DropWeapon (target->player); - if (target->player == &players[consoleplayer] - && automapactive) - { - AM_Stop (); + mobjtype_t item; + mobj_t* mo; + + target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); + if (target->type != MT_SKULL) target->flags &= ~MF_NOGRAVITY; + target->flags |= MF_CORPSE|MF_DROPOFF; + target->height >>= 2; + if (source && source->player) { + if (target->flags & MF_COUNTKILL) source->player->killcount++; + if (target->player) source->player->frags[target->player-players]++; + } + else if (!netgame && (target->flags & MF_COUNTKILL)) players[0].killcount++; + if (target->player) { + if (!source) target->player->frags[target->player-players]++; + target->flags &= ~MF_SOLID; + target->player->playerstate = PST_DEAD; + P_DropWeapon(target->player); + if (target->player == &players[consoleplayer] && automapactive) AM_Stop(); } - } - if (target->health < -target->info->spawnhealth - && target->info->xdeathstate) - { - P_SetMobjState (target, target->info->xdeathstate); - } - else - P_SetMobjState (target, target->info->deathstate); - target->tics -= P_Random()&3; - if (target->tics < 1) + if (target->health < -target->info->spawnhealth && target->info->xdeathstate) P_SetMobjState(target, target->info->xdeathstate); + else P_SetMobjState(target, target->info->deathstate); + target->tics -= P_Random()&3; + if (target->tics < 1) target->tics = 1; - switch (target->type) - { - case MT_WOLFSS: - case MT_POSSESSED: - item = MT_CLIP; - break; - case MT_SHOTGUY: - item = MT_SHOTGUN; - break; - case MT_CHAINGUY: - item = MT_CHAINGUN; - break; - default: - return; - } - mo = P_SpawnMobj (target->x,target->y,ONFLOORZ, item); - mo->flags |= MF_DROPPED; + switch(target->type) { + case MT_WOLFSS: + case MT_POSSESSED: + item = MT_CLIP; + break; + case MT_SHOTGUY: + item = MT_SHOTGUN; + break; + case MT_CHAINGUY: + item = MT_CHAINGUN; + break; + default: + return; + } + mo = P_SpawnMobj(target->x, target->y, ONFLOORZ, item); + mo->flags |= MF_DROPPED; } + void -P_DamageMobj -( mobj_t* target, - mobj_t* inflictor, - mobj_t* source, - int damage ) +P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source, int damage) { - unsigned ang; - int saved; - player_t* player; - fixed_t thrust; - int temp; - if ( !(target->flags & MF_SHOOTABLE) ) - return; - if (target->health <= 0) - return; - if ( target->flags & MF_SKULLFLY ) - { - target->momx = target->momy = target->momz = 0; - } - player = target->player; - if (player && gameskill == sk_baby) - damage >>= 1; - if (inflictor - && !(target->flags & MF_NOCLIP) - && (!source - || !source->player - || source->player->readyweapon != wp_chainsaw)) - { - ang = R_PointToAngle2 ( inflictor->x, - inflictor->y, - target->x, - target->y); - thrust = damage*(FRACUNIT>>3)*100/target->info->mass; - if ( damage < 40 - && damage > target->health - && target->z - inflictor->z > 64*FRACUNIT - && (P_Random ()&1) ) - { - ang += ANG180; - thrust *= 4; + unsigned ang; + int saved; + player_t* player; + fixed_t thrust; + + if ( !(target->flags & MF_SHOOTABLE)) return; + if (target->health <= 0) return; + if ( target->flags & MF_SKULLFLY) target->momx = target->momy = target->momz = 0; + player = target->player; + if (player && gameskill == sk_baby) damage >>= 1; + if (inflictor && !(target->flags & MF_NOCLIP) && (!source || !source->player || source->player->readyweapon != wp_chainsaw)) { + ang = R_PointToAngle2(inflictor->x, inflictor->y, target->x, target->y); + thrust = damage*(FRACUNIT>>3)*100/target->info->mass; + if (damage < 40 && damage > target->health && target->z - inflictor->z > 64*FRACUNIT && (P_Random()&1)) { + ang += ANG180; + thrust *= 4; + } + ang >>= ANGLETOFINESHIFT; + target->momx += FixedMul(thrust, finecosine[ang]); + target->momy += FixedMul(thrust, finesine[ang]); } - ang >>= ANGLETOFINESHIFT; - target->momx += FixedMul (thrust, finecosine[ang]); - target->momy += FixedMul (thrust, finesine[ang]); - } - if (player) - { - if (target->subsector->sector->special == 11 - && damage >= target->health) - { - damage = target->health - 1; + if (player) { + return; + if (target->subsector->sector->special == 11 && damage >= target->health) + damage = target->health - 1; + if (damage < 1000 && ((player->cheats&CF_GODMODE) || player->powers[pw_invulnerability])) + return; + if (player->armortype) { + if (player->armortype == 1) saved = damage/3; + else saved = damage/2; + if (player->armorpoints <= saved) { + saved = player->armorpoints; + player->armortype = 0; + } + player->armorpoints -= saved; + damage -= saved; + } + player->health -= damage; + if (player->health < 0) player->health = 0; + player->attacker = source; + player->damagecount += damage; + if (player->damagecount > 100) + player->damagecount = 100; + } + target->health -= damage; + if (target->health <= 0) { + P_KillMobj(source, target); + return; } - if ( damage < 1000 - && ( (player->cheats&CF_GODMODE) - || player->powers[pw_invulnerability] ) ) - { - return; + if ((P_Random() < target->info->painchance) && !(target->flags&MF_SKULLFLY)) { + target->flags |= MF_JUSTHIT; + P_SetMobjState(target, target->info->painstate); } - if (player->armortype) - { - if (player->armortype == 1) - saved = damage/3; - else - saved = damage/2; - if (player->armorpoints <= saved) - { - saved = player->armorpoints; - player->armortype = 0; - } - player->armorpoints -= saved; - damage -= saved; + target->reactiontime = 0; + if ((!target->threshold || target->type == MT_VILE) && source && source != target && source->type != MT_VILE) { + target->target = source; + target->threshold = BASETHRESHOLD; + if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) + P_SetMobjState(target, target->info->seestate); } - player->health -= damage; - if (player->health < 0) - player->health = 0; - player->attacker = source; - player->damagecount += damage; - if (player->damagecount > 100) - player->damagecount = 100; - temp = damage < 100 ? damage : 100; - if (player == &players[consoleplayer]) - I_Tactile (40,10,40+temp*2); - } - target->health -= damage; - if (target->health <= 0) - { - P_KillMobj (source, target); - return; - } - if ( (P_Random () < target->info->painchance) - && !(target->flags&MF_SKULLFLY) ) - { - target->flags |= MF_JUSTHIT; - P_SetMobjState (target, target->info->painstate); - } - target->reactiontime = 0; - if ( (!target->threshold || target->type == MT_VILE) - && source && source != target - && source->type != MT_VILE) - { - target->target = source; - target->threshold = BASETHRESHOLD; - if (target->state == &states[target->info->spawnstate] - && target->info->seestate != S_NULL) - P_SetMobjState (target, target->info->seestate); - } } diff --git a/src/p_inter.h b/src/p_inter.h @@ -1,7 +1,6 @@ #ifndef __P_INTER__ #define __P_INTER__ -#ifdef __GNUG__ -#pragma interface -#endif + boolean P_GivePower(player_t*, int); + #endif diff --git a/src/p_lights.c b/src/p_lights.c @@ -1,36 +1,77 @@ #include "z_zone.h" #include "m_random.h" + #include "doomdef.h" #include "p_local.h" + + + #include "r_state.h" + + + + + + + + void T_FireFlicker (fireflicker_t* flick) { int amount; + if (--flick->count) return; + amount = (P_Random()&3)*16; + if (flick->sector->lightlevel - amount < flick->minlight) flick->sector->lightlevel = flick->minlight; else flick->sector->lightlevel = flick->maxlight - amount; + flick->count = 4; } + + + + + + void P_SpawnFireFlicker (sector_t* sector) { fireflicker_t* flick; + + + sector->special = 0; + flick = Z_Malloc ( sizeof(*flick), PU_LEVSPEC, 0); + P_AddThinker (&flick->thinker); + flick->thinker.function.acp1 = (actionf_p1) T_FireFlicker; flick->sector = sector; flick->maxlight = sector->lightlevel; flick->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel)+16; flick->count = 4; } + + + + + + + + + + + + void T_LightFlash (lightflash_t* flash) { if (--flash->count) return; + if (flash->sector->lightlevel == flash->maxlight) { flash-> sector->lightlevel = flash->minlight; @@ -41,25 +82,53 @@ void T_LightFlash (lightflash_t* flash) flash-> sector->lightlevel = flash->maxlight; flash->count = (P_Random()&flash->maxtime)+1; } + } + + + + + + + + + void P_SpawnLightFlash (sector_t* sector) { lightflash_t* flash; + + sector->special = 0; + flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); + P_AddThinker (&flash->thinker); + flash->thinker.function.acp1 = (actionf_p1) T_LightFlash; flash->sector = sector; flash->maxlight = sector->lightlevel; + flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); flash->maxtime = 64; flash->mintime = 7; flash->count = (P_Random()&flash->maxtime)+1; } + + + + + + + + + + + void T_StrobeFlash (strobe_t* flash) { if (--flash->count) return; + if (flash->sector->lightlevel == flash->minlight) { flash-> sector->lightlevel = flash->maxlight; @@ -70,7 +139,16 @@ void T_StrobeFlash (strobe_t* flash) flash-> sector->lightlevel = flash->minlight; flash->count =flash->darktime; } + } + + + + + + + + void P_SpawnStrobeFlash ( sector_t* sector, @@ -78,35 +156,55 @@ P_SpawnStrobeFlash int inSync ) { strobe_t* flash; + flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); + P_AddThinker (&flash->thinker); + flash->sector = sector; flash->darktime = fastOrSlow; flash->brighttime = STROBEBRIGHT; flash->thinker.function.acp1 = (actionf_p1) T_StrobeFlash; flash->maxlight = sector->lightlevel; flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); + if (flash->minlight == flash->maxlight) flash->minlight = 0; + + sector->special = 0; + if (!inSync) flash->count = (P_Random()&7)+1; else flash->count = 1; } + + + + + void EV_StartLightStrobing(line_t* line) { int secnum; sector_t* sec; + secnum = -1; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; + P_SpawnStrobeFlash (sec,SLOWDARK, 0); } } + + + + + + void EV_TurnTagLightsOff(line_t* line) { int i; @@ -115,7 +213,9 @@ void EV_TurnTagLightsOff(line_t* line) sector_t* sector; sector_t* tsec; line_t* templine; + sector = sectors; + for (j = 0;j < numsectors; j++, sector++) { if (sector->tag == line->tag) @@ -134,6 +234,11 @@ void EV_TurnTagLightsOff(line_t* line) } } } + + + + + void EV_LightTurnOn ( line_t* line, @@ -144,19 +249,26 @@ EV_LightTurnOn sector_t* sector; sector_t* temp; line_t* templine; + sector = sectors; + for (i=0;i<numsectors;i++, sector++) { if (sector->tag == line->tag) { + + + if (!bright) { for (j = 0;j < sector->linecount; j++) { templine = sector->lines[j]; temp = getNextSector(templine,sector); + if (!temp) continue; + if (temp->lightlevel > bright) bright = temp->lightlevel; } @@ -165,11 +277,18 @@ EV_LightTurnOn } } } + + + + + + void T_Glow(glow_t* g) { switch(g->direction) { case -1: + g->sector->lightlevel -= GLOWSPEED; if (g->sector->lightlevel <= g->minlight) { @@ -177,7 +296,9 @@ void T_Glow(glow_t* g) g->direction = 1; } break; + case 1: + g->sector->lightlevel += GLOWSPEED; if (g->sector->lightlevel >= g->maxlight) { @@ -187,15 +308,22 @@ void T_Glow(glow_t* g) break; } } + + void P_SpawnGlowingLight(sector_t* sector) { glow_t* g; + g = Z_Malloc( sizeof(*g), PU_LEVSPEC, 0); + P_AddThinker(&g->thinker); + g->sector = sector; g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); g->maxlight = sector->lightlevel; g->thinker.function.acp1 = (actionf_p1) T_Glow; g->direction = -1; + sector->special = 0; } + diff --git a/src/p_local.h b/src/p_local.h @@ -1,61 +1,125 @@ #ifndef __P_LOCAL__ #define __P_LOCAL__ + #ifndef __R_LOCAL__ #include "r_local.h" #endif + + #define FLOATSPEED (FRACUNIT*4) + + #define MAXHEALTH 100 #define VIEWHEIGHT (41*FRACUNIT) + + + #define MAPBLOCKUNITS 128 #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) #define MAPBLOCKSHIFT (FRACBITS+7) #define MAPBMASK (MAPBLOCKSIZE-1) #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) + + + #define PLAYERRADIUS 16*FRACUNIT + + + + #define MAXRADIUS 32*FRACUNIT + #define GRAVITY FRACUNIT #define MAXMOVE (30*FRACUNIT) + #define USERANGE (64*FRACUNIT) #define MELEERANGE (64*FRACUNIT) #define MISSILERANGE (32*64*FRACUNIT) + + #define BASETHRESHOLD 100 + + + + + + + + extern thinker_t thinkercap; + + void P_InitThinkers (void); void P_AddThinker (thinker_t* thinker); void P_RemoveThinker (thinker_t* thinker); + + + + + void P_SetupPsprites (player_t* curplayer); void P_MovePsprites (player_t* curplayer); void P_DropWeapon (player_t* player); + + + + + void P_PlayerThink (player_t* player); -#define ONFLOORZ MININT -#define ONCEILINGZ MAXINT + + + + + +#define ONFLOORZ INT_MIN +#define ONCEILINGZ INT_MAX + + #define ITEMQUESIZE 128 + extern mapthing_t itemrespawnque[ITEMQUESIZE]; extern int itemrespawntime[ITEMQUESIZE]; extern int iquehead; extern int iquetail; + + void P_RespawnSpecials (void); + mobj_t* P_SpawnMobj ( fixed_t x, fixed_t y, fixed_t z, mobjtype_t type ); + void P_RemoveMobj (mobj_t* th); boolean P_SetMobjState (mobj_t* mobj, statenum_t state); void P_MobjThinker (mobj_t* mobj); + void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type); void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type); + + + + + void P_NoiseAlert (mobj_t* target, mobj_t* emmiter); + + + + + typedef struct { fixed_t x; fixed_t y; fixed_t dx; fixed_t dy; + } divline_t; + typedef struct { fixed_t frac; @@ -65,27 +129,37 @@ typedef struct line_t* line; } d; } intercept_t; -#define MAXINTERCEPTS 128 -extern intercept_t intercepts[MAXINTERCEPTS]; + +#define INT_MAXERCEPTS 128 + +extern intercept_t intercepts[INT_MAXERCEPTS]; extern intercept_t* intercept_p; + typedef boolean (*traverser_t) (intercept_t *in); + fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line); int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line); void P_MakeDivline (line_t* li, divline_t* dl); fixed_t P_InterceptVector (divline_t* v2, divline_t* v1); int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld); + extern fixed_t opentop; extern fixed_t openbottom; extern fixed_t openrange; extern fixed_t lowfloor; + void P_LineOpening (line_t* linedef); + boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ); boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) ); + #define PT_ADDLINES 1 #define PT_ADDTHINGS 2 #define PT_EARLYOUT 4 + extern divline_t trace; + boolean P_PathTraverse ( fixed_t x1, @@ -94,25 +168,41 @@ P_PathTraverse fixed_t y2, int flags, boolean (*trav) (intercept_t *)); + void P_UnsetThingPosition (mobj_t* thing); void P_SetThingPosition (mobj_t* thing); + + + + + + + + extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; + + extern line_t* ceilingline; + boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y); boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y); void P_SlideMove (mobj_t* mo); boolean P_CheckSight (mobj_t* t1, mobj_t* t2); void P_UseLines (player_t* player); + boolean P_ChangeSector (sector_t* sector, boolean crunch); + extern mobj_t* linetarget; + fixed_t P_AimLineAttack ( mobj_t* t1, angle_t angle, fixed_t distance ); + void P_LineAttack ( mobj_t* t1, @@ -120,11 +210,18 @@ P_LineAttack fixed_t distance, fixed_t slope, int damage ); + void P_RadiusAttack ( mobj_t* spot, mobj_t* source, int damage ); + + + + + + extern byte* rejectmatrix; extern short* blockmaplump; extern short* blockmap; @@ -133,17 +230,39 @@ extern int bmapheight; extern fixed_t bmaporgx; extern fixed_t bmaporgy; extern mobj_t** blocklinks; + + + + + + extern int maxammo[NUMAMMO]; extern int clipammo[NUMAMMO]; + void P_TouchSpecialThing ( mobj_t* special, mobj_t* toucher ); + void P_DamageMobj ( mobj_t* target, mobj_t* inflictor, mobj_t* source, int damage ); + + + + + #include "p_spec.h" + + #endif + + + + + + + diff --git a/src/p_map.c b/src/p_map.c @@ -1,4 +1,5 @@ #include <stdlib.h> + #include "m_bbox.h" #include "m_random.h" #include "i_system.h" @@ -8,6 +9,9 @@ #include "doomstat.h" #include "r_state.h" #include "sounds.h" + +#define MAXSPECIALCROSS 8 + fixed_t tmbbox[4]; mobj_t* tmthing; int tmflags; @@ -18,254 +22,430 @@ fixed_t tmfloorz; fixed_t tmceilingz; fixed_t tmdropoffz; line_t* ceilingline; -#define MAXSPECIALCROSS 8 line_t* spechit[MAXSPECIALCROSS]; int numspechit; -boolean PIT_StompThing (mobj_t* thing) + +boolean +PIT_StompThing (mobj_t* thing) { - fixed_t blockdist; - if (!(thing->flags & MF_SHOOTABLE) ) + fixed_t blockdist; + + if (!(thing->flags & MF_SHOOTABLE)) return true; + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist ) + { + return true; - blockdist = thing->radius + tmthing->radius; - if ( abs(thing->x - tmx) >= blockdist - || abs(thing->y - tmy) >= blockdist ) - { + } + + + if (thing == tmthing) return true; - } - if (thing == tmthing) + + + if ( !tmthing->player && gamemap != 30) + return false; + + P_DamageMobj (thing, tmthing, tmthing, 10000); + return true; - if ( !tmthing->player && gamemap != 30) - return false; - P_DamageMobj (thing, tmthing, tmthing, 10000); - return true; } + + + + + boolean P_TeleportMove ( mobj_t* thing, fixed_t x, fixed_t y ) { - int xl; - int xh; - int yl; - int yh; - int bx; - int by; - subsector_t* newsubsec; - tmthing = thing; - tmflags = thing->flags; - tmx = x; - tmy = y; - tmbbox[BOXTOP] = y + tmthing->radius; - tmbbox[BOXBOTTOM] = y - tmthing->radius; - tmbbox[BOXRIGHT] = x + tmthing->radius; - tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector (x,y); - ceilingline = NULL; - tmfloorz = tmdropoffz = newsubsec->sector->floorheight; - tmceilingz = newsubsec->sector->ceilingheight; - validcount++; - numspechit = 0; - xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; - xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; - yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; - yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) + int xl; + int xh; + int yl; + int yh; + int bx; + int by; + + subsector_t* newsubsec; + + + tmthing = thing; + tmflags = thing->flags; + + tmx = x; + tmy = y; + + tmbbox[BOXTOP] = y + tmthing->radius; + tmbbox[BOXBOTTOM] = y - tmthing->radius; + tmbbox[BOXRIGHT] = x + tmthing->radius; + tmbbox[BOXLEFT] = x - tmthing->radius; + + newsubsec = R_PointInSubsector (x,y); + ceilingline = NULL; + + + + + + tmfloorz = tmdropoffz = newsubsec->sector->floorheight; + tmceilingz = newsubsec->sector->ceilingheight; + + validcount++; + numspechit = 0; + + + xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; + xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; + yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; + yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; + + for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockThingsIterator(bx,by,PIT_StompThing)) return false; - P_UnsetThingPosition (thing); - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->x = x; - thing->y = y; - P_SetThingPosition (thing); - return true; + + + + P_UnsetThingPosition (thing); + + thing->floorz = tmfloorz; + thing->ceilingz = tmceilingz; + thing->x = x; + thing->y = y; + + P_SetThingPosition (thing); + + return true; } + + + + + + + + + + + boolean PIT_CheckLine (line_t* ld) { - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] + if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP] ) return true; - if (P_BoxOnLineSide (tmbbox, ld) != -1) + + if (P_BoxOnLineSide (tmbbox, ld) != -1) return true; - if (!ld->backsector) - return false; - if (!(tmthing->flags & MF_MISSILE) ) - { + + + + + + + + + + + + + if (!ld->backsector) + return false; + + if (!(tmthing->flags & MF_MISSILE) ) + { if ( ld->flags & ML_BLOCKING ) - return false; + return false; + if ( !tmthing->player && ld->flags & ML_BLOCKMONSTERS ) - return false; - } - P_LineOpening (ld); - if (opentop < tmceilingz) - { + return false; + } + + + P_LineOpening (ld); + + + if (opentop < tmceilingz) + { tmceilingz = opentop; ceilingline = ld; - } - if (openbottom > tmfloorz) - tmfloorz = openbottom; - if (lowfloor < tmdropoffz) + } + + if (openbottom > tmfloorz) + tmfloorz = openbottom; + + if (lowfloor < tmdropoffz) tmdropoffz = lowfloor; - if (ld->special) - { + + + if (ld->special) + { spechit[numspechit] = ld; numspechit++; - } - return true; + } + + return true; } + + + + boolean PIT_CheckThing (mobj_t* thing) { - fixed_t blockdist; - boolean solid; - int damage; - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE) )) + fixed_t blockdist; + boolean solid; + int damage; + + if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE) )) return true; - blockdist = thing->radius + tmthing->radius; - if ( abs(thing->x - tmx) >= blockdist + + blockdist = thing->radius + tmthing->radius; + + if ( abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist ) - { - return true; - } - if (thing == tmthing) + { + + return true; + } + + + if (thing == tmthing) return true; - if (tmthing->flags & MF_SKULLFLY) - { + + + if (tmthing->flags & MF_SKULLFLY) + { damage = ((P_Random()%8)+1)*tmthing->info->damage; + P_DamageMobj (thing, tmthing, tmthing, damage); + tmthing->flags &= ~MF_SKULLFLY; tmthing->momx = tmthing->momy = tmthing->momz = 0; + P_SetMobjState (tmthing, tmthing->info->spawnstate); - return false; - } - if (tmthing->flags & MF_MISSILE) - { + + return false; + } + + + + if (tmthing->flags & MF_MISSILE) + { + if (tmthing->z > thing->z + thing->height) - return true; + return true; if (tmthing->z+tmthing->height < thing->z) - return true; + return true; + if (tmthing->target && ( - tmthing->target->type == thing->type || + tmthing->target->type == thing->type || (tmthing->target->type == MT_KNIGHT && thing->type == MT_BRUISER)|| (tmthing->target->type == MT_BRUISER && thing->type == MT_KNIGHT) ) ) { + if (thing == tmthing->target) return true; + if (thing->type != MT_PLAYER) { + + return false; } } + if (! (thing->flags & MF_SHOOTABLE) ) { - return !(thing->flags & MF_SOLID); + + return !(thing->flags & MF_SOLID); } + + damage = ((P_Random()%8)+1)*tmthing->info->damage; P_DamageMobj (thing, tmthing, tmthing->target, damage); - return false; - } - if (thing->flags & MF_SPECIAL) - { + + + return false; + } + + + if (thing->flags & MF_SPECIAL) + { solid = thing->flags&MF_SOLID; if (tmflags&MF_PICKUP) { + P_TouchSpecialThing (thing, tmthing); } return !solid; - } - return !(thing->flags & MF_SOLID); + } + + return !(thing->flags & MF_SOLID); } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + boolean P_CheckPosition ( mobj_t* thing, fixed_t x, fixed_t y ) { - int xl; - int xh; - int yl; - int yh; - int bx; - int by; - subsector_t* newsubsec; - tmthing = thing; - tmflags = thing->flags; - tmx = x; - tmy = y; - tmbbox[BOXTOP] = y + tmthing->radius; - tmbbox[BOXBOTTOM] = y - tmthing->radius; - tmbbox[BOXRIGHT] = x + tmthing->radius; - tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector (x,y); - ceilingline = NULL; - tmfloorz = tmdropoffz = newsubsec->sector->floorheight; - tmceilingz = newsubsec->sector->ceilingheight; - validcount++; - numspechit = 0; - if ( tmflags & MF_NOCLIP ) - return true; - xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; - xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; - yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; - yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) + int xl; + int xh; + int yl; + int yh; + int bx; + int by; + subsector_t* newsubsec; + + tmthing = thing; + tmflags = thing->flags; + + tmx = x; + tmy = y; + + tmbbox[BOXTOP] = y + tmthing->radius; + tmbbox[BOXBOTTOM] = y - tmthing->radius; + tmbbox[BOXRIGHT] = x + tmthing->radius; + tmbbox[BOXLEFT] = x - tmthing->radius; + + newsubsec = R_PointInSubsector (x,y); + ceilingline = NULL; + + + + + + tmfloorz = tmdropoffz = newsubsec->sector->floorheight; + tmceilingz = newsubsec->sector->ceilingheight; + + validcount++; + numspechit = 0; + + if ( tmflags & MF_NOCLIP ) + return true; + + + + + + + xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; + xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; + yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; + yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; + + for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockThingsIterator(bx,by,PIT_CheckThing)) return false; - xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) + + + xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + + for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockLinesIterator (bx,by,PIT_CheckLine)) return false; - return true; + + return true; } + + + + + + + boolean P_TryMove ( mobj_t* thing, fixed_t x, fixed_t y ) { - fixed_t oldx; - fixed_t oldy; - int side; - int oldside; - line_t* ld; - floatok = false; - if (!P_CheckPosition (thing, x, y)) - return false; - if ( !(thing->flags & MF_NOCLIP) ) - { + fixed_t oldx; + fixed_t oldy; + int side; + int oldside; + line_t* ld; + + floatok = false; + if (!P_CheckPosition (thing, x, y)) + return false; + + if ( !(thing->flags & MF_NOCLIP) ) + { if (tmceilingz - tmfloorz < thing->height) - return false; + return false; + floatok = true; - if ( !(thing->flags&MF_TELEPORT) + + if ( !(thing->flags&MF_TELEPORT) &&tmceilingz - thing->z < thing->height) - return false; + return false; + if ( !(thing->flags&MF_TELEPORT) && tmfloorz - thing->z > 24*FRACUNIT ) - return false; + return false; + if ( !(thing->flags&(MF_DROPOFF|MF_FLOAT)) && tmfloorz - tmdropoffz > 24*FRACUNIT ) - return false; - } - P_UnsetThingPosition (thing); - oldx = thing->x; - oldy = thing->y; - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - thing->x = x; - thing->y = y; - P_SetThingPosition (thing); - if (! (thing->flags&(MF_TELEPORT|MF_NOCLIP)) ) - { + return false; + } + + + + P_UnsetThingPosition (thing); + + oldx = thing->x; + oldy = thing->y; + thing->floorz = tmfloorz; + thing->ceilingz = tmceilingz; + thing->x = x; + thing->y = y; + + P_SetThingPosition (thing); + + + if (! (thing->flags&(MF_TELEPORT|MF_NOCLIP)) ) + { while (numspechit--) { + ld = spechit[numspechit]; side = P_PointOnLineSide (thing->x, thing->y, ld); oldside = P_PointOnLineSide (oldx, oldy, ld); @@ -275,332 +455,554 @@ P_TryMove P_CrossSpecialLine (ld-lines, oldside, thing); } } - } - return true; + } + + return true; } + + + + + + + + + + + + boolean P_ThingHeightClip (mobj_t* thing) { - boolean onfloor; - onfloor = (thing->z == thing->floorz); - P_CheckPosition (thing, thing->x, thing->y); - thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; - if (onfloor) - { + boolean onfloor; + + onfloor = (thing->z == thing->floorz); + + P_CheckPosition (thing, thing->x, thing->y); + + + thing->floorz = tmfloorz; + thing->ceilingz = tmceilingz; + + if (onfloor) + { + thing->z = thing->floorz; - } - else - { + } + else + { + if (thing->z+thing->height > thing->ceilingz) thing->z = thing->ceilingz - thing->height; - } - if (thing->ceilingz - thing->floorz < thing->height) + } + + if (thing->ceilingz - thing->floorz < thing->height) return false; - return true; + + return true; } + + + + + + + fixed_t bestslidefrac; fixed_t secondslidefrac; + line_t* bestslideline; line_t* secondslideline; + mobj_t* slidemo; + fixed_t tmxmove; fixed_t tmymove; + + + + + + + + void P_HitSlideLine (line_t* ld) { - int side; - angle_t lineangle; - angle_t moveangle; - angle_t deltaangle; - fixed_t movelen; - fixed_t newlen; - if (ld->slopetype == ST_HORIZONTAL) - { + int side; + + angle_t lineangle; + angle_t moveangle; + angle_t deltaangle; + + fixed_t movelen; + fixed_t newlen; + + + if (ld->slopetype == ST_HORIZONTAL) + { tmymove = 0; return; - } - if (ld->slopetype == ST_VERTICAL) - { + } + + if (ld->slopetype == ST_VERTICAL) + { tmxmove = 0; return; - } - side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); - lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); - if (side == 1) + } + + side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); + + lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); + + if (side == 1) lineangle += ANG180; - moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); - deltaangle = moveangle-lineangle; - if (deltaangle > ANG180) + + moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); + deltaangle = moveangle-lineangle; + + if (deltaangle > ANG180) deltaangle += ANG180; - lineangle >>= ANGLETOFINESHIFT; - deltaangle >>= ANGLETOFINESHIFT; - movelen = P_AproxDistance (tmxmove, tmymove); - newlen = FixedMul (movelen, finecosine[deltaangle]); - tmxmove = FixedMul (newlen, finecosine[lineangle]); - tmymove = FixedMul (newlen, finesine[lineangle]); + + + lineangle >>= ANGLETOFINESHIFT; + deltaangle >>= ANGLETOFINESHIFT; + + movelen = P_AproxDistance (tmxmove, tmymove); + newlen = FixedMul (movelen, finecosine[deltaangle]); + + tmxmove = FixedMul (newlen, finecosine[lineangle]); + tmymove = FixedMul (newlen, finesine[lineangle]); } + + + + + boolean PTR_SlideTraverse (intercept_t* in) { - line_t* li; - if (!in->isaline) + line_t* li; + + if (!in->isaline) I_Error ("PTR_SlideTraverse: not a line?"); - li = in->d.line; - if ( ! (li->flags & ML_TWOSIDED) ) - { + + li = in->d.line; + + if ( ! (li->flags & ML_TWOSIDED) ) + { if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) { - return true; + + return true; } goto isblocking; - } - P_LineOpening (li); - if (openrange < slidemo->height) - goto isblocking; - if (opentop - slidemo->z < slidemo->height) - goto isblocking; - if (openbottom - slidemo->z > 24*FRACUNIT ) - goto isblocking; - return true; - isblocking: - if (in->frac < bestslidefrac) - { + } + + + P_LineOpening (li); + + if (openrange < slidemo->height) + goto isblocking; + + if (opentop - slidemo->z < slidemo->height) + goto isblocking; + + if (openbottom - slidemo->z > 24*FRACUNIT ) + goto isblocking; + + + return true; + + + + isblocking: + if (in->frac < bestslidefrac) + { secondslidefrac = bestslidefrac; secondslideline = bestslideline; bestslidefrac = in->frac; bestslideline = li; - } - return false; + } + + return false; } + + + + + + + + + + + + void P_SlideMove (mobj_t* mo) { - fixed_t leadx; - fixed_t leady; - fixed_t trailx; - fixed_t traily; - fixed_t newx; - fixed_t newy; - int hitcount; - slidemo = mo; - hitcount = 0; + fixed_t leadx; + fixed_t leady; + fixed_t trailx; + fixed_t traily; + fixed_t newx; + fixed_t newy; + int hitcount; + + slidemo = mo; + hitcount = 0; + retry: - if (++hitcount == 3) - goto stairstep; - if (mo->momx > 0) - { + if (++hitcount == 3) + goto stairstep; + + + + if (mo->momx > 0) + { leadx = mo->x + mo->radius; trailx = mo->x - mo->radius; - } - else - { + } + else + { leadx = mo->x - mo->radius; trailx = mo->x + mo->radius; - } - if (mo->momy > 0) - { + } + + if (mo->momy > 0) + { leady = mo->y + mo->radius; traily = mo->y - mo->radius; - } - else - { + } + else + { leady = mo->y - mo->radius; traily = mo->y + mo->radius; - } - bestslidefrac = FRACUNIT+1; - P_PathTraverse ( leadx, leady, leadx+mo->momx, leady+mo->momy, + } + + bestslidefrac = FRACUNIT+1; + + P_PathTraverse ( leadx, leady, leadx+mo->momx, leady+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); - P_PathTraverse ( trailx, leady, trailx+mo->momx, leady+mo->momy, + P_PathTraverse ( trailx, leady, trailx+mo->momx, leady+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); - P_PathTraverse ( leadx, traily, leadx+mo->momx, traily+mo->momy, + P_PathTraverse ( leadx, traily, leadx+mo->momx, traily+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); - if (bestslidefrac == FRACUNIT+1) - { - stairstep: + + + if (bestslidefrac == FRACUNIT+1) + { + + stairstep: if (!P_TryMove (mo, mo->x, mo->y + mo->momy)) P_TryMove (mo, mo->x + mo->momx, mo->y); return; - } - bestslidefrac -= 0x800; - if (bestslidefrac > 0) - { + } + + + bestslidefrac -= 0x800; + if (bestslidefrac > 0) + { newx = FixedMul (mo->momx, bestslidefrac); newy = FixedMul (mo->momy, bestslidefrac); + if (!P_TryMove (mo, mo->x+newx, mo->y+newy)) goto stairstep; - } - bestslidefrac = FRACUNIT-(bestslidefrac+0x800); - if (bestslidefrac > FRACUNIT) + } + + + + bestslidefrac = FRACUNIT-(bestslidefrac+0x800); + + if (bestslidefrac > FRACUNIT) bestslidefrac = FRACUNIT; - if (bestslidefrac <= 0) + + if (bestslidefrac <= 0) return; - tmxmove = FixedMul (mo->momx, bestslidefrac); - tmymove = FixedMul (mo->momy, bestslidefrac); - P_HitSlideLine (bestslideline); - mo->momx = tmxmove; - mo->momy = tmymove; - if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove)) - { + + tmxmove = FixedMul (mo->momx, bestslidefrac); + tmymove = FixedMul (mo->momy, bestslidefrac); + + P_HitSlideLine (bestslideline); + + mo->momx = tmxmove; + mo->momy = tmymove; + + if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove)) + { goto retry; - } + } } -mobj_t* linetarget; + + + + + +mobj_t* linetarget; mobj_t* shootthing; -fixed_t shootz; + + + +fixed_t shootz; + int la_damage; fixed_t attackrange; + fixed_t aimslope; + + extern fixed_t topslope; -extern fixed_t bottomslope; +extern fixed_t bottomslope; + + + + + + boolean PTR_AimTraverse (intercept_t* in) { - line_t* li; - mobj_t* th; - fixed_t slope; - fixed_t thingtopslope; - fixed_t thingbottomslope; - fixed_t dist; - if (in->isaline) - { + line_t* li; + mobj_t* th; + fixed_t slope; + fixed_t thingtopslope; + fixed_t thingbottomslope; + fixed_t dist; + + if (in->isaline) + { li = in->d.line; + if ( !(li->flags & ML_TWOSIDED) ) - return false; + return false; + + + + P_LineOpening (li); + if (openbottom >= opentop) - return false; + return false; + dist = FixedMul (attackrange, in->frac); + if (li->frontsector->floorheight != li->backsector->floorheight) { slope = FixedDiv (openbottom - shootz , dist); if (slope > bottomslope) bottomslope = slope; } + if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { slope = FixedDiv (opentop - shootz , dist); if (slope < topslope) topslope = slope; } + if (topslope <= bottomslope) - return false; - return true; - } - th = in->d.thing; - if (th == shootthing) - return true; - if (!(th->flags&MF_SHOOTABLE)) - return true; - dist = FixedMul (attackrange, in->frac); - thingtopslope = FixedDiv (th->z+th->height - shootz , dist); - if (thingtopslope < bottomslope) - return true; - thingbottomslope = FixedDiv (th->z - shootz, dist); - if (thingbottomslope > topslope) - return true; - if (thingtopslope > topslope) + return false; + + return true; + } + + + th = in->d.thing; + if (th == shootthing) + return true; + + if (!(th->flags&MF_SHOOTABLE)) + return true; + + + dist = FixedMul (attackrange, in->frac); + thingtopslope = FixedDiv (th->z+th->height - shootz , dist); + + if (thingtopslope < bottomslope) + return true; + + thingbottomslope = FixedDiv (th->z - shootz, dist); + + if (thingbottomslope > topslope) + return true; + + + if (thingtopslope > topslope) thingtopslope = topslope; - if (thingbottomslope < bottomslope) + + if (thingbottomslope < bottomslope) thingbottomslope = bottomslope; - aimslope = (thingtopslope+thingbottomslope)/2; - linetarget = th; - return false; + + aimslope = (thingtopslope+thingbottomslope)/2; + linetarget = th; + + return false; } + + + + + boolean PTR_ShootTraverse (intercept_t* in) { - fixed_t x; - fixed_t y; - fixed_t z; - fixed_t frac; - line_t* li; - mobj_t* th; - fixed_t slope; - fixed_t dist; - fixed_t thingtopslope; - fixed_t thingbottomslope; - if (in->isaline) - { + fixed_t x; + fixed_t y; + fixed_t z; + fixed_t frac; + + line_t* li; + + mobj_t* th; + + fixed_t slope; + fixed_t dist; + fixed_t thingtopslope; + fixed_t thingbottomslope; + + if (in->isaline) + { li = in->d.line; + if (li->special) P_ShootSpecialLine (shootthing, li); + if ( !(li->flags & ML_TWOSIDED) ) goto hitline; + + P_LineOpening (li); + dist = FixedMul (attackrange, in->frac); + if (li->frontsector->floorheight != li->backsector->floorheight) { slope = FixedDiv (openbottom - shootz , dist); if (slope > aimslope) goto hitline; } + if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { slope = FixedDiv (opentop - shootz , dist); if (slope < aimslope) goto hitline; } + + return true; - hitline: + + + + hitline: + frac = in->frac - FixedDiv (4*FRACUNIT,attackrange); x = trace.x + FixedMul (trace.dx, frac); y = trace.y + FixedMul (trace.dy, frac); z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange)); + if (li->frontsector->ceilingpic == skyflatnum) { + if (z > li->frontsector->ceilingheight) return false; + + if (li->backsector && li->backsector->ceilingpic == skyflatnum) - return false; + return false; } + + P_SpawnPuff (x,y,z); - return false; - } - th = in->d.thing; - if (th == shootthing) - return true; - if (!(th->flags&MF_SHOOTABLE)) - return true; - dist = FixedMul (attackrange, in->frac); - thingtopslope = FixedDiv (th->z+th->height - shootz , dist); - if (thingtopslope < aimslope) - return true; - thingbottomslope = FixedDiv (th->z - shootz, dist); - if (thingbottomslope > aimslope) - return true; - frac = in->frac - FixedDiv (10*FRACUNIT,attackrange); - x = trace.x + FixedMul (trace.dx, frac); - y = trace.y + FixedMul (trace.dy, frac); - z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange)); - if (in->d.thing->flags & MF_NOBLOOD) + + + return false; + } + + + th = in->d.thing; + if (th == shootthing) + return true; + + if (!(th->flags&MF_SHOOTABLE)) + return true; + + + dist = FixedMul (attackrange, in->frac); + thingtopslope = FixedDiv (th->z+th->height - shootz , dist); + + if (thingtopslope < aimslope) + return true; + + thingbottomslope = FixedDiv (th->z - shootz, dist); + + if (thingbottomslope > aimslope) + return true; + + + + + frac = in->frac - FixedDiv (10*FRACUNIT,attackrange); + + x = trace.x + FixedMul (trace.dx, frac); + y = trace.y + FixedMul (trace.dy, frac); + z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange)); + + + + if (in->d.thing->flags & MF_NOBLOOD) P_SpawnPuff (x,y,z); - else + else P_SpawnBlood (x,y,z, la_damage); - if (la_damage) + + if (la_damage) P_DamageMobj (th, shootthing, shootthing, la_damage); - return false; + + + return false; + } + + + + + fixed_t P_AimLineAttack ( mobj_t* t1, angle_t angle, fixed_t distance ) { - fixed_t x2; - fixed_t y2; - angle >>= ANGLETOFINESHIFT; - shootthing = t1; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; - y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; - shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; - topslope = 100*FRACUNIT/160; - bottomslope = -100*FRACUNIT/160; - attackrange = distance; - linetarget = NULL; - P_PathTraverse ( t1->x, t1->y, + fixed_t x2; + fixed_t y2; + + angle >>= ANGLETOFINESHIFT; + shootthing = t1; + + x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; + y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; + shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; + + + topslope = 100*FRACUNIT/160; + bottomslope = -100*FRACUNIT/160; + + attackrange = distance; + linetarget = NULL; + + P_PathTraverse ( t1->x, t1->y, x2, y2, PT_ADDLINES|PT_ADDTHINGS, PTR_AimTraverse ); - if (linetarget) + + if (linetarget) return aimslope; - return 0; + + return 0; } + + + + + + + void P_LineAttack ( mobj_t* t1, @@ -609,157 +1011,273 @@ P_LineAttack fixed_t slope, int damage ) { - fixed_t x2; - fixed_t y2; - angle >>= ANGLETOFINESHIFT; - shootthing = t1; - la_damage = damage; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; - y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; - shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; - attackrange = distance; - aimslope = slope; - P_PathTraverse ( t1->x, t1->y, + fixed_t x2; + fixed_t y2; + + angle >>= ANGLETOFINESHIFT; + shootthing = t1; + la_damage = damage; + x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; + y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; + shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; + attackrange = distance; + aimslope = slope; + + P_PathTraverse ( t1->x, t1->y, x2, y2, PT_ADDLINES|PT_ADDTHINGS, PTR_ShootTraverse ); } + + + + + + mobj_t* usething; + boolean PTR_UseTraverse (intercept_t* in) { - int side; - if (!in->d.line->special) - { + int side; + + if (!in->d.line->special) + { P_LineOpening (in->d.line); if (openrange <= 0) { S_StartSound (usething, sfx_noway); - return false; + + + return false; + } + + return true ; } - return true ; - } - side = 0; - if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) + + side = 0; + if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) side = 1; - P_UseSpecialLine (usething, in->d.line, side); - return false; + + + + P_UseSpecialLine (usething, in->d.line, side); + + + return false; } -void P_UseLines (player_t* player) + + + + + + +void P_UseLines (player_t* player) { - int angle; - fixed_t x1; - fixed_t y1; - fixed_t x2; - fixed_t y2; - usething = player->mo; - angle = player->mo->angle >> ANGLETOFINESHIFT; - x1 = player->mo->x; - y1 = player->mo->y; - x2 = x1 + (USERANGE>>FRACBITS)*finecosine[angle]; - y2 = y1 + (USERANGE>>FRACBITS)*finesine[angle]; - P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse ); + int angle; + fixed_t x1; + fixed_t y1; + fixed_t x2; + fixed_t y2; + + usething = player->mo; + + angle = player->mo->angle >> ANGLETOFINESHIFT; + + x1 = player->mo->x; + y1 = player->mo->y; + x2 = x1 + (USERANGE>>FRACBITS)*finecosine[angle]; + y2 = y1 + (USERANGE>>FRACBITS)*finesine[angle]; + + P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse ); } + + + + + mobj_t* bombsource; mobj_t* bombspot; int bombdamage; + + + + + + + boolean PIT_RadiusAttack (mobj_t* thing) { - fixed_t dx; - fixed_t dy; - fixed_t dist; - if (!(thing->flags & MF_SHOOTABLE) ) + fixed_t dx; + fixed_t dy; + fixed_t dist; + + if (!(thing->flags & MF_SHOOTABLE) ) return true; - if (thing->type == MT_CYBORG + + + + if (thing->type == MT_CYBORG || thing->type == MT_SPIDER) - return true; - dx = abs(thing->x - bombspot->x); - dy = abs(thing->y - bombspot->y); - dist = dx>dy ? dx : dy; - dist = (dist - thing->radius) >> FRACBITS; - if (dist < 0) + return true; + + dx = abs(thing->x - bombspot->x); + dy = abs(thing->y - bombspot->y); + + dist = dx>dy ? dx : dy; + dist = (dist - thing->radius) >> FRACBITS; + + if (dist < 0) dist = 0; - if (dist >= bombdamage) - return true; - if ( P_CheckSight (thing, bombspot) ) - { + + if (dist >= bombdamage) + return true; + + if ( P_CheckSight (thing, bombspot) ) + { + P_DamageMobj (thing, bombspot, bombsource, bombdamage - dist); - } - return true; + } + + return true; } + + + + + + void P_RadiusAttack ( mobj_t* spot, mobj_t* source, int damage ) { - int x; - int y; - int xl; - int xh; - int yl; - int yh; - fixed_t dist; - dist = (damage+MAXRADIUS)<<FRACBITS; - yh = (spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT; - yl = (spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT; - xh = (spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT; - xl = (spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT; - bombspot = spot; - bombsource = source; - bombdamage = damage; - for (y=yl ; y<=yh ; y++) + int x; + int y; + + int xl; + int xh; + int yl; + int yh; + + fixed_t dist; + + dist = (damage+MAXRADIUS)<<FRACBITS; + yh = (spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT; + yl = (spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT; + xh = (spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT; + xl = (spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT; + bombspot = spot; + bombsource = source; + bombdamage = damage; + + for (y=yl ; y<=yh ; y++) for (x=xl ; x<=xh ; x++) P_BlockThingsIterator (x, y, PIT_RadiusAttack ); } + + + + + + + + + + + + + + + + boolean crushchange; boolean nofit; + + + + + boolean PIT_ChangeSector (mobj_t* thing) { - mobj_t* mo; - if (P_ThingHeightClip (thing)) - { + mobj_t* mo; + + if (P_ThingHeightClip (thing)) + { + return true; - } - if (thing->health <= 0) - { + } + + + + if (thing->health <= 0) + { P_SetMobjState (thing, S_GIBS); + thing->flags &= ~MF_SOLID; thing->height = 0; thing->radius = 0; - return true; - } - if (thing->flags & MF_DROPPED) - { + + + return true; + } + + + if (thing->flags & MF_DROPPED) + { P_RemoveMobj (thing); - return true; - } - if (! (thing->flags & MF_SHOOTABLE) ) - { - return true; - } - nofit = true; - if (crushchange && !(leveltime&3) ) - { + + + return true; + } + + if (! (thing->flags & MF_SHOOTABLE) ) + { + + return true; + } + + nofit = true; + + if (crushchange && !(leveltime&3) ) + { P_DamageMobj(thing,NULL,NULL,10); + + mo = P_SpawnMobj (thing->x, thing->y, thing->z + thing->height/2, MT_BLOOD); + mo->momx = (P_Random() - P_Random ())<<12; mo->momy = (P_Random() - P_Random ())<<12; - } - return true; + } + + + return true; } + + + + + + boolean P_ChangeSector ( sector_t* sector, boolean crunch ) { - int x; - int y; - nofit = false; - crushchange = crunch; - for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++) + int x; + int y; + + nofit = false; + crushchange = crunch; + + + for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++) for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++) P_BlockThingsIterator (x, y, PIT_ChangeSector); - return nofit; + + + return nofit; } + diff --git a/src/p_maputl.c b/src/p_maputl.c @@ -1,8 +1,10 @@ #include <stdlib.h> + #include "m_bbox.h" #include "doomdef.h" #include "p_local.h" #include "r_state.h" + fixed_t P_AproxDistance ( fixed_t dx, @@ -14,6 +16,12 @@ P_AproxDistance return dx+dy-(dx>>1); return dx+dy-(dy>>1); } + + + + + + int P_PointOnLineSide ( fixed_t x, @@ -24,66 +32,78 @@ P_PointOnLineSide fixed_t dy; fixed_t left; fixed_t right; + if (!line->dx) { if (x <= line->v1->x) return line->dy > 0; + return line->dy < 0; } if (!line->dy) { if (y <= line->v1->y) return line->dx < 0; + return line->dx > 0; } + dx = (x - line->v1->x); dy = (y - line->v1->y); + left = FixedMul ( line->dy>>FRACBITS , dx ); right = FixedMul ( dy , line->dx>>FRACBITS ); + if (right < left) return 0; return 1; } + + + + + + + + int -P_BoxOnLineSide -( fixed_t* tmbox, - line_t* ld ) +P_BoxOnLineSide(fixed_t* tmbox, line_t* ld) { - int p1; - int p2; - switch (ld->slopetype) - { - case ST_HORIZONTAL: - p1 = tmbox[BOXTOP] > ld->v1->y; - p2 = tmbox[BOXBOTTOM] > ld->v1->y; - if (ld->dx < 0) - { - p1 ^= 1; - p2 ^= 1; - } - break; - case ST_VERTICAL: - p1 = tmbox[BOXRIGHT] < ld->v1->x; - p2 = tmbox[BOXLEFT] < ld->v1->x; - if (ld->dy < 0) - { - p1 ^= 1; - p2 ^= 1; - } - break; - case ST_POSITIVE: - p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld); - p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld); - break; - case ST_NEGATIVE: - p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld); - p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld); - break; + int p1, p2; + + switch (ld->slopetype) { + case ST_HORIZONTAL: + p1 = tmbox[BOXTOP] > ld->v1->y; + p2 = tmbox[BOXBOTTOM] > ld->v1->y; + if (ld->dx < 0) { + p1 ^= 1; + p2 ^= 1; + } + break; + case ST_VERTICAL: + p1 = tmbox[BOXRIGHT] < ld->v1->x; + p2 = tmbox[BOXLEFT] < ld->v1->x; + if (ld->dy < 0) { + p1 ^= 1; + p2 ^= 1; + } + break; + case ST_POSITIVE: + p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld); + p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld); + break; + case ST_NEGATIVE: + p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld); + p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld); + break; + default: + p1 = p2 = 0; } if (p1 == p2) - return p1; + return p1; return -1; } + int P_PointOnDivlineSide ( fixed_t x, @@ -94,32 +114,46 @@ P_PointOnDivlineSide fixed_t dy; fixed_t left; fixed_t right; + if (!line->dx) { if (x <= line->x) return line->dy > 0; + return line->dy < 0; } if (!line->dy) { if (y <= line->y) return line->dx < 0; + return line->dx > 0; } + dx = (x - line->x); dy = (y - line->y); + + if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 ) { if ( (line->dy ^ dx) & 0x80000000 ) return 1; return 0; } + left = FixedMul ( line->dy>>8, dx>>8 ); right = FixedMul ( dy>>8 , line->dx>>8 ); + if (right < left) return 0; return 1; } + + + + + + void P_MakeDivline ( line_t* li, @@ -130,6 +164,16 @@ P_MakeDivline dl->dx = li->dx; dl->dy = li->dy; } + + + + + + + + + + fixed_t P_InterceptVector ( divline_t* v2, @@ -139,13 +183,19 @@ P_InterceptVector fixed_t frac; fixed_t num; fixed_t den; + den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy); + if (den == 0) return 0; + + num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy ) +FixedMul ( (v2->y - v1->y)>>8, v1->dx ); + frac = FixedDiv (num , den); + return frac; #else float frac; @@ -159,6 +209,7 @@ P_InterceptVector float v2y; float v2dx; float v2dy; + v1x = (float)v1->x/FRACUNIT; v1y = (float)v1->y/FRACUNIT; v1dx = (float)v1->dx/FRACUNIT; @@ -167,33 +218,52 @@ P_InterceptVector v2y = (float)v2->y/FRACUNIT; v2dx = (float)v2->dx/FRACUNIT; v2dy = (float)v2->dy/FRACUNIT; + den = v1dy*v2dx - v1dx*v2dy; + if (den == 0) return 0; + num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; frac = num / den; + return frac*FRACUNIT; #endif } + + + + + + + + fixed_t opentop; fixed_t openbottom; fixed_t openrange; fixed_t lowfloor; + + void P_LineOpening (line_t* linedef) { sector_t* front; sector_t* back; + if (linedef->sidenum[1] == -1) { + openrange = 0; return; } + front = linedef->frontsector; back = linedef->backsector; + if (front->ceilingheight < back->ceilingheight) opentop = front->ceilingheight; else opentop = back->ceilingheight; + if (front->floorheight > back->floorheight) { openbottom = front->floorheight; @@ -204,31 +274,55 @@ void P_LineOpening (line_t* linedef) openbottom = back->floorheight; lowfloor = front->floorheight; } + openrange = opentop - openbottom; } + + + + + + + + + + + + + + void P_UnsetThingPosition (mobj_t* thing) { int blockx; int blocky; + if ( ! (thing->flags & MF_NOSECTOR) ) { + + if (thing->snext) thing->snext->sprev = thing->sprev; + if (thing->sprev) thing->sprev->snext = thing->snext; else thing->subsector->sector->thinglist = thing->snext; } + if ( ! (thing->flags & MF_NOBLOCKMAP) ) { + + if (thing->bnext) thing->bnext->bprev = thing->bprev; + if (thing->bprev) thing->bprev->bnext = thing->bnext; else { blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; + if (blockx>=0 && blockx < bmapwidth && blocky>=0 && blocky <bmapheight) { @@ -237,6 +331,14 @@ void P_UnsetThingPosition (mobj_t* thing) } } } + + + + + + + + void P_SetThingPosition (mobj_t* thing) { @@ -245,21 +347,34 @@ P_SetThingPosition (mobj_t* thing) int blockx; int blocky; mobj_t** link; + + + ss = R_PointInSubsector (thing->x,thing->y); thing->subsector = ss; + if ( ! (thing->flags & MF_NOSECTOR) ) { + sec = ss->sector; + thing->sprev = NULL; thing->snext = sec->thinglist; + if (sec->thinglist) sec->thinglist->sprev = thing; + sec->thinglist = thing; } + + + if ( ! (thing->flags & MF_NOBLOCKMAP) ) { + blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; + if (blockx>=0 && blockx < bmapwidth && blocky>=0 @@ -270,14 +385,36 @@ P_SetThingPosition (mobj_t* thing) thing->bnext = *link; if (*link) (*link)->bprev = thing; + *link = thing; } else { + thing->bnext = thing->bprev = NULL; } } } + + + + + + + + + + + + + + + + + + + + boolean P_BlockLinesIterator ( int x, @@ -287,6 +424,7 @@ P_BlockLinesIterator int offset; short* list; line_t* ld; + if (x<0 || y<0 || x>=bmapwidth @@ -294,19 +432,30 @@ P_BlockLinesIterator { return true; } + offset = y*bmapwidth+x; + offset = *(blockmap+offset); + for ( list = blockmaplump+offset ; *list != -1 ; list++) { ld = &lines[*list]; + if (ld->validcount == validcount) continue; + ld->validcount = validcount; + if ( !func(ld) ) return false; } return true; } + + + + + boolean P_BlockThingsIterator ( int x, @@ -314,6 +463,7 @@ P_BlockThingsIterator boolean(*func)(mobj_t*) ) { mobj_t* mobj; + if ( x<0 || y<0 || x>=bmapwidth @@ -321,6 +471,8 @@ P_BlockThingsIterator { return true; } + + for (mobj = blocklinks[y*bmapwidth+x] ; mobj ; mobj = mobj->bnext) @@ -330,11 +482,29 @@ P_BlockThingsIterator } return true; } -intercept_t intercepts[MAXINTERCEPTS]; + + + + + + +intercept_t intercepts[INT_MAXERCEPTS]; intercept_t* intercept_p; + divline_t trace; boolean earlyout; int ptflags; + + + + + + + + + + + boolean PIT_AddLineIntercepts (line_t* ld) { @@ -342,6 +512,8 @@ PIT_AddLineIntercepts (line_t* ld) int s2; fixed_t frac; divline_t dl; + + if ( trace.dx > FRACUNIT*16 || trace.dy > FRACUNIT*16 || trace.dx < -FRACUNIT*16 @@ -355,40 +527,63 @@ PIT_AddLineIntercepts (line_t* ld) s1 = P_PointOnLineSide (trace.x, trace.y, ld); s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld); } + if (s1 == s2) return true; + + P_MakeDivline (ld, &dl); frac = P_InterceptVector (&trace, &dl); + if (frac < 0) return true; + + if (earlyout && frac < FRACUNIT && !ld->backsector) { return false; } + + intercept_p->frac = frac; intercept_p->isaline = true; intercept_p->d.line = ld; intercept_p++; + return true; } + + + + + + boolean PIT_AddThingIntercepts (mobj_t* thing) { fixed_t x1; fixed_t y1; fixed_t x2; fixed_t y2; + int s1; int s2; + boolean tracepositive; + divline_t dl; + fixed_t frac; + tracepositive = (trace.dx ^ trace.dy)>0; + + if (tracepositive) { x1 = thing->x - thing->radius; y1 = thing->y + thing->radius; + x2 = thing->x + thing->radius; y2 = thing->y - thing->radius; } @@ -396,26 +591,41 @@ boolean PIT_AddThingIntercepts (mobj_t* thing) { x1 = thing->x - thing->radius; y1 = thing->y - thing->radius; + x2 = thing->x + thing->radius; y2 = thing->y + thing->radius; } + s1 = P_PointOnDivlineSide (x1, y1, &trace); s2 = P_PointOnDivlineSide (x2, y2, &trace); + if (s1 == s2) return true; + dl.x = x1; dl.y = y1; dl.dx = x2-x1; dl.dy = y2-y1; + frac = P_InterceptVector (&trace, &dl); + if (frac < 0) return true; + intercept_p->frac = frac; intercept_p->isaline = false; intercept_p->d.thing = thing; intercept_p++; + return true; } + + + + + + + boolean P_TraverseIntercepts ( traverser_t func, @@ -425,11 +635,14 @@ P_TraverseIntercepts fixed_t dist; intercept_t* scan; intercept_t* in; + count = intercept_p - intercepts; + in = 0; + while (count--) { - dist = MAXINT; + dist = INT_MAX; for (scan = intercepts ; scan<intercept_p ; scan++) { if (scan->frac < dist) @@ -438,10 +651,13 @@ P_TraverseIntercepts in = scan; } } + if (dist > maxfrac) return true; + #if 0 { + in = scan = intercepts; for ( scan = intercepts ; scan<intercept_p ; scan++) if (scan->frac > maxfrac) @@ -450,12 +666,26 @@ P_TraverseIntercepts return false; } #endif + if ( !func (in) ) return false; - in->frac = MAXINT; + + in->frac = INT_MAX; } + return true; } + + + + + + + + + + + boolean P_PathTraverse ( fixed_t x1, @@ -469,35 +699,49 @@ P_PathTraverse fixed_t yt1; fixed_t xt2; fixed_t yt2; + fixed_t xstep; fixed_t ystep; + fixed_t partial; + fixed_t xintercept; fixed_t yintercept; + int mapx; int mapy; + int mapxstep; int mapystep; + int count; + earlyout = flags & PT_EARLYOUT; + validcount++; intercept_p = intercepts; + if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) x1 += FRACUNIT; + if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) y1 += FRACUNIT; + trace.x = x1; trace.y = y1; trace.dx = x2 - x1; trace.dy = y2 - y1; + x1 -= bmaporgx; y1 -= bmaporgy; xt1 = x1>>MAPBLOCKSHIFT; yt1 = y1>>MAPBLOCKSHIFT; + x2 -= bmaporgx; y2 -= bmaporgy; xt2 = x2>>MAPBLOCKSHIFT; yt2 = y2>>MAPBLOCKSHIFT; + if (xt2 > xt1) { mapxstep = 1; @@ -516,7 +760,10 @@ P_PathTraverse partial = FRACUNIT; ystep = 256*FRACUNIT; } + yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep); + + if (yt2 > yt1) { mapystep = 1; @@ -536,8 +783,13 @@ P_PathTraverse xstep = 256*FRACUNIT; } xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep); + + + + mapx = xt1; mapy = yt1; + for (count = 0 ; count < 64 ; count++) { if (flags & PT_ADDLINES) @@ -545,16 +797,19 @@ P_PathTraverse if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts)) return false; } + if (flags & PT_ADDTHINGS) { if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts)) return false; } + if (mapx == xt2 && mapy == yt2) { break; } + if ( (yintercept >> FRACBITS) == mapy) { yintercept += ystep; @@ -565,6 +820,11 @@ P_PathTraverse xintercept += xstep; mapy += mapystep; } + } + return P_TraverseIntercepts ( trav, FRACUNIT ); } + + + diff --git a/src/p_mobj.c b/src/p_mobj.c @@ -1,22 +1,36 @@ #include "i_system.h" #include "z_zone.h" #include "m_random.h" + #include "doomdef.h" #include "p_local.h" #include "sounds.h" + #include "st_stuff.h" #include "hu_stuff.h" + #include "s_sound.h" + #include "doomstat.h" + + void G_PlayerReborn (int player); void P_SpawnMapThing (mapthing_t* mthing); + + + + + + int test; + boolean P_SetMobjState ( mobj_t* mobj, statenum_t state ) { state_t* st; + do { if (state == S_NULL) @@ -25,30 +39,52 @@ P_SetMobjState P_RemoveMobj (mobj); return false; } + st = &states[state]; mobj->state = st; mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; + + + if (st->action.acp1) st->action.acp1(mobj); + state = st->nextstate; } while (!mobj->tics); + return true; } + + + + + void P_ExplodeMissile (mobj_t* mo) { mo->momx = mo->momy = mo->momz = 0; + P_SetMobjState (mo, mobjinfo[mo->type].deathstate); + mo->tics -= P_Random()&3; + if (mo->tics < 1) mo->tics = 1; + mo->flags &= ~MF_MISSILE; + if (mo->info->deathsound) S_StartSound (mo, mo->info->deathsound); } + + + + + #define STOPSPEED 0x1000 #define FRICTION 0xe800 + void P_XYMovement (mobj_t* mo) { fixed_t ptryx; @@ -56,27 +92,35 @@ void P_XYMovement (mobj_t* mo) player_t* player; fixed_t xmove; fixed_t ymove; + if (!mo->momx && !mo->momy) { if (mo->flags & MF_SKULLFLY) { + mo->flags &= ~MF_SKULLFLY; mo->momx = mo->momy = mo->momz = 0; + P_SetMobjState (mo, mo->info->spawnstate); } return; } + player = mo->player; + if (mo->momx > MAXMOVE) mo->momx = MAXMOVE; else if (mo->momx < -MAXMOVE) mo->momx = -MAXMOVE; + if (mo->momy > MAXMOVE) mo->momy = MAXMOVE; else if (mo->momy < -MAXMOVE) mo->momy = -MAXMOVE; + xmove = mo->momx; ymove = mo->momy; + do { if (xmove > MAXMOVE/2 || ymove > MAXMOVE/2) @@ -92,18 +136,24 @@ void P_XYMovement (mobj_t* mo) ptryy = mo->y + ymove; xmove = ymove = 0; } + if (!P_TryMove (mo, ptryx, ptryy)) { + if (mo->player) { P_SlideMove (mo); } else if (mo->flags & MF_MISSILE) { + if (ceilingline && ceilingline->backsector && ceilingline->backsector->ceilingpic == skyflatnum) { + + + P_RemoveMobj (mo); return; } @@ -113,17 +163,25 @@ void P_XYMovement (mobj_t* mo) mo->momx = mo->momy = 0; } } while (xmove || ymove); + + if (player && player->cheats & CF_NOMOMENTUM) { + mo->momx = mo->momy = 0; return; } + if (mo->flags & (MF_MISSILE | MF_SKULLFLY) ) return; + if (mo->z > mo->floorz) return; + if (mo->flags & MF_CORPSE) { + + if (mo->momx > FRACUNIT/4 || mo->momx < -FRACUNIT/4 || mo->momy > FRACUNIT/4 @@ -133,6 +191,7 @@ void P_XYMovement (mobj_t* mo) return; } } + if (mo->momx > -STOPSPEED && mo->momx < STOPSPEED && mo->momy > -STOPSPEED @@ -141,8 +200,10 @@ void P_XYMovement (mobj_t* mo) || (player->cmd.forwardmove== 0 && player->cmd.sidemove == 0 ) ) ) { + if ( player&&(unsigned)((player->mo->state - states)- S_PLAY_RUN1) < 4) P_SetMobjState (player->mo, S_PLAY); + mo->momx = 0; mo->momy = 0; } @@ -152,49 +213,77 @@ void P_XYMovement (mobj_t* mo) mo->momy = FixedMul (mo->momy, FRICTION); } } + + + + void P_ZMovement (mobj_t* mo) { fixed_t dist; fixed_t delta; + + if (mo->player && mo->z < mo->floorz) { mo->player->viewheight -= mo->floorz-mo->z; + mo->player->deltaviewheight = (VIEWHEIGHT - mo->player->viewheight)>>3; } + + mo->z += mo->momz; + if ( mo->flags & MF_FLOAT && mo->target) { + if ( !(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT) ) { dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); + delta =(mo->target->z + (mo->height>>1)) - mo->z; + if (delta<0 && dist < -(delta*3) ) mo->z -= FLOATSPEED; else if (delta>0 && dist < (delta*3) ) mo->z += FLOATSPEED; } + } + + if (mo->z <= mo->floorz) { + + + + + if (mo->flags & MF_SKULLFLY) { + mo->momz = -mo->momz; } + if (mo->momz < 0) { if (mo->player && mo->momz < -GRAVITY*8) { + + + + mo->player->deltaviewheight = mo->momz>>3; S_StartSound (mo, sfx_oof); } mo->momz = 0; } mo->z = mo->floorz; + if ( (mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP) ) { @@ -209,17 +298,21 @@ void P_ZMovement (mobj_t* mo) else mo->momz -= GRAVITY; } + if (mo->z + mo->height > mo->ceilingz) { + if (mo->momz > 0) mo->momz = 0; { mo->z = mo->ceilingz - mo->height; } + if (mo->flags & MF_SKULLFLY) { mo->momz = -mo->momz; } + if ( (mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP) ) { @@ -228,6 +321,12 @@ void P_ZMovement (mobj_t* mo) } } } + + + + + + void P_NightmareRespawn (mobj_t* mobj) { @@ -237,37 +336,66 @@ P_NightmareRespawn (mobj_t* mobj) subsector_t* ss; mobj_t* mo; mapthing_t* mthing; + x = mobj->spawnpoint.x << FRACBITS; y = mobj->spawnpoint.y << FRACBITS; + + if (!P_CheckPosition (mobj, x, y) ) return; + + + mo = P_SpawnMobj (mobj->x, mobj->y, mobj->subsector->sector->floorheight , MT_TFOG); + S_StartSound (mo, sfx_telept); + + ss = R_PointInSubsector (x,y); + mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_TFOG); + S_StartSound (mo, sfx_telept); + + mthing = &mobj->spawnpoint; + + if (mobj->info->flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; + + mo = P_SpawnMobj (x,y,z, mobj->type); mo->spawnpoint = mobj->spawnpoint; mo->angle = ANG45 * (mthing->angle/45); + if (mthing->options & MTF_AMBUSH) mo->flags |= MF_AMBUSH; + mo->reactiontime = 18; + + P_RemoveMobj (mobj); } + + + + + void P_MobjThinker (mobj_t* mobj) { + if (mobj->momx || mobj->momy || (mobj->flags&MF_SKULLFLY) ) { P_XYMovement (mobj); + + if (mobj->thinker.function.acv == (actionf_v) (-1)) return; } @@ -275,32 +403,53 @@ void P_MobjThinker (mobj_t* mobj) || mobj->momz ) { P_ZMovement (mobj); + + if (mobj->thinker.function.acv == (actionf_v) (-1)) return; } + + + + if (mobj->tics != -1) { mobj->tics--; + + if (!mobj->tics) if (!P_SetMobjState (mobj, mobj->state->nextstate) ) return; } else { + if (! (mobj->flags & MF_COUNTKILL) ) return; + if (!respawnmonsters) return; + mobj->movecount++; + if (mobj->movecount < 12*35) return; + if ( leveltime&31 ) return; + if (P_Random () > 4) return; + P_NightmareRespawn (mobj); } + } + + + + + mobj_t* P_SpawnMobj ( fixed_t x, @@ -311,9 +460,11 @@ P_SpawnMobj mobj_t* mobj; state_t* st; mobjinfo_t* info; + mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); memset (mobj, 0, sizeof (*mobj)); info = &mobjinfo[type]; + mobj->type = type; mobj->info = info; mobj->x = x; @@ -322,31 +473,50 @@ P_SpawnMobj mobj->height = info->height; mobj->flags = info->flags; mobj->health = info->spawnhealth; + if (gameskill != sk_nightmare) mobj->reactiontime = info->reactiontime; + mobj->lastlook = P_Random () % MAXPLAYERS; + + st = &states[info->spawnstate]; + mobj->state = st; mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; + + P_SetThingPosition (mobj); + mobj->floorz = mobj->subsector->sector->floorheight; mobj->ceilingz = mobj->subsector->sector->ceilingheight; + if (z == ONFLOORZ) mobj->z = mobj->floorz; else if (z == ONCEILINGZ) mobj->z = mobj->ceilingz - mobj->info->height; else mobj->z = z; + mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; + P_AddThinker (&mobj->thinker); + return mobj; } + + + + + mapthing_t itemrespawnque[ITEMQUESIZE]; int itemrespawntime[ITEMQUESIZE]; int iquehead; int iquetail; + + void P_RemoveMobj (mobj_t* mobj) { if ((mobj->flags & MF_SPECIAL) @@ -357,70 +527,125 @@ void P_RemoveMobj (mobj_t* mobj) itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; iquehead = (iquehead+1)&(ITEMQUESIZE-1); + + if (iquehead == iquetail) iquetail = (iquetail+1)&(ITEMQUESIZE-1); } + + P_UnsetThingPosition (mobj); + + S_StopSound (mobj); + + P_RemoveThinker ((thinker_t*)mobj); } + + + + + + + void P_RespawnSpecials (void) { fixed_t x; fixed_t y; fixed_t z; + subsector_t* ss; mobj_t* mo; mapthing_t* mthing; + int i; + + if (deathmatch != 2) return; + + if (iquehead == iquetail) return; + + if (leveltime - itemrespawntime[iquetail] < 30*35) return; + mthing = &itemrespawnque[iquetail]; + x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; + + ss = R_PointInSubsector (x,y); mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_IFOG); S_StartSound (mo, sfx_itmbk); + + for (i=0 ; i< NUMMOBJTYPES ; i++) { if (mthing->type == mobjinfo[i].doomednum) break; } + + if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; + mo = P_SpawnMobj (x,y,z, i); mo->spawnpoint = *mthing; mo->angle = ANG45 * (mthing->angle/45); + + iquetail = (iquetail+1)&(ITEMQUESIZE-1); } + + + + + + + + + + void P_SpawnPlayer (mapthing_t* mthing) { player_t* p; fixed_t x; fixed_t y; fixed_t z; + mobj_t* mobj; + int i; + + if (!playeringame[mthing->type-1]) return; + p = &players[mthing->type-1]; + if (p->playerstate == PST_REBORN) G_PlayerReborn (mthing->type-1); + x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; z = ONFLOORZ; mobj = P_SpawnMobj (x,y,z, MT_PLAYER); + + if (mthing->type > 1) mobj->flags |= (mthing->type-1)<<MF_TRANSSHIFT; + mobj->angle = ANG45 * (mthing->angle/45); mobj->player = p; mobj->health = p->health; + p->mo = mobj; p->playerstate = PST_LIVE; p->refire = 0; @@ -430,16 +655,30 @@ void P_SpawnPlayer (mapthing_t* mthing) p->extralight = 0; p->fixedcolormap = 0; p->viewheight = VIEWHEIGHT; + + P_SetupPsprites (p); + + if (deathmatch) for (i=0 ; i<NUMCARDS ; i++) p->cards[i] = true; + if (mthing->type-1 == consoleplayer) { + ST_Start (); + HU_Start (); } } + + + + + + + void P_SpawnMapThing (mapthing_t* mthing) { int i; @@ -448,6 +687,8 @@ void P_SpawnMapThing (mapthing_t* mthing) fixed_t x; fixed_t y; fixed_t z; + + if (mthing->type == 11) { if (deathmatch_p < &deathmatchstarts[10]) @@ -457,57 +698,90 @@ void P_SpawnMapThing (mapthing_t* mthing) } return; } + + if (mthing->type <= 4) { + playerstarts[mthing->type-1] = *mthing; if (!deathmatch) P_SpawnPlayer (mthing); + return; } + + if (!netgame && (mthing->options & 16) ) return; + if (gameskill == sk_baby) bit = 1; else if (gameskill == sk_nightmare) bit = 4; else bit = 1<<(gameskill-1); + if (!(mthing->options & bit) ) return; + + for (i=0 ; i< NUMMOBJTYPES ; i++) if (mthing->type == mobjinfo[i].doomednum) break; + if (i==NUMMOBJTYPES) I_Error ("P_SpawnMapThing: Unknown type %i at (%i, %i)", mthing->type, mthing->x, mthing->y); + + if (deathmatch && mobjinfo[i].flags & MF_NOTDMATCH) return; + + if (nomonsters && ( i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL)) ) { return; } + + x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; + if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; + mobj = P_SpawnMobj (x,y,z, i); mobj->spawnpoint = *mthing; + if (mobj->tics > 0) mobj->tics = 1 + (P_Random () % mobj->tics); if (mobj->flags & MF_COUNTKILL) totalkills++; if (mobj->flags & MF_COUNTITEM) totalitems++; + mobj->angle = ANG45 * (mthing->angle/45); if (mthing->options & MTF_AMBUSH) mobj->flags |= MF_AMBUSH; } + + + + + + + + + + + extern fixed_t attackrange; + void P_SpawnPuff ( fixed_t x, @@ -515,15 +789,26 @@ P_SpawnPuff fixed_t z ) { mobj_t* th; + z += ((P_Random()-P_Random())<<10); + th = P_SpawnMobj (x,y,z, MT_PUFF); th->momz = FRACUNIT; th->tics -= P_Random()&3; + if (th->tics < 1) th->tics = 1; + + if (attackrange == MELEERANGE) P_SetMobjState (th, S_PUFF3); } + + + + + + void P_SpawnBlood ( fixed_t x, @@ -532,28 +817,48 @@ P_SpawnBlood int damage ) { mobj_t* th; + z += ((P_Random()-P_Random())<<10); th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; th->tics -= P_Random()&3; + if (th->tics < 1) th->tics = 1; + if (damage <= 12 && damage >= 9) P_SetMobjState (th,S_BLOOD2); else if (damage < 9) P_SetMobjState (th,S_BLOOD3); } + + + + + + + + void P_CheckMissileSpawn (mobj_t* th) { th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1; + + + th->x += (th->momx>>1); th->y += (th->momy>>1); th->z += (th->momz>>1); + if (!P_TryMove (th, th->x, th->y)) P_ExplodeMissile (th); } + + + + + mobj_t* P_SpawnMissile ( mobj_t* source, @@ -563,27 +868,43 @@ P_SpawnMissile mobj_t* th; angle_t an; int dist; + th = P_SpawnMobj (source->x, source->y, source->z + 4*8*FRACUNIT, type); + if (th->info->seesound) S_StartSound (th, th->info->seesound); + th->target = source; an = R_PointToAngle2 (source->x, source->y, dest->x, dest->y); + + if (dest->flags & MF_SHADOW) an += (P_Random()-P_Random())<<20; + th->angle = an; an >>= ANGLETOFINESHIFT; th->momx = FixedMul (th->info->speed, finecosine[an]); th->momy = FixedMul (th->info->speed, finesine[an]); + dist = P_AproxDistance (dest->x - source->x, dest->y - source->y); dist = dist / th->info->speed; + if (dist < 1) dist = 1; + th->momz = (dest->z - source->z) / dist; P_CheckMissileSpawn (th); + return th; } + + + + + + void P_SpawnPlayerMissile ( mobj_t* source, @@ -591,33 +912,43 @@ P_SpawnPlayerMissile { mobj_t* th; angle_t an; + fixed_t x; fixed_t y; fixed_t z; fixed_t slope; + + an = source->angle; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); + if (!linetarget) { an += 1<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); + if (!linetarget) { an -= 2<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); } + if (!linetarget) { an = source->angle; slope = 0; } } + x = source->x; y = source->y; z = source->z + 4*8*FRACUNIT; + th = P_SpawnMobj (x,y,z, type); + if (th->info->seesound) S_StartSound (th, th->info->seesound); + th->target = source; th->angle = an; th->momx = FixedMul( th->info->speed, @@ -625,5 +956,7 @@ P_SpawnPlayerMissile th->momy = FixedMul( th->info->speed, finesine[an>>ANGLETOFINESHIFT]); th->momz = FixedMul( th->info->speed, slope); + P_CheckMissileSpawn (th); } + diff --git a/src/p_mobj.h b/src/p_mobj.h @@ -1,80 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __P_MOBJ__ #define __P_MOBJ__ + + #include "tables.h" #include "m_fixed.h" + + #include "d_think.h" + + + #include "doomdata.h" + + + + #include "info.h" + + + #ifdef __GNUG__ #pragma interface #endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + typedef enum { + MF_SPECIAL = 1, + MF_SOLID = 2, + MF_SHOOTABLE = 4, + MF_NOSECTOR = 8, + MF_NOBLOCKMAP = 16, + + MF_AMBUSH = 32, + MF_JUSTHIT = 64, + MF_JUSTATTACKED = 128, + + MF_SPAWNCEILING = 256, + + + MF_NOGRAVITY = 512, + + + MF_DROPOFF = 0x400, + MF_PICKUP = 0x800, + MF_NOCLIP = 0x1000, + MF_SLIDE = 0x2000, + + MF_FLOAT = 0x4000, + + MF_TELEPORT = 0x8000, + + MF_MISSILE = 0x10000, + + MF_DROPPED = 0x20000, + + MF_SHADOW = 0x40000, + + MF_NOBLOOD = 0x80000, + + MF_CORPSE = 0x100000, + + MF_INFLOAT = 0x200000, + + + + MF_COUNTKILL = 0x400000, + + + MF_COUNTITEM = 0x800000, + + + MF_SKULLFLY = 0x1000000, + + + MF_NOTDMATCH = 0x2000000, + + + + + MF_TRANSLATION = 0xc000000, + MF_TRANSSHIFT = 26 + } mobjflag_t; + + + typedef struct mobj_s { + thinker_t thinker; + + fixed_t x; fixed_t y; fixed_t z; + + struct mobj_s* snext; struct mobj_s* sprev; + + angle_t angle; spritenum_t sprite; int frame; + + + struct mobj_s* bnext; struct mobj_s* bprev; + struct subsector_s* subsector; + + fixed_t floorz; fixed_t ceilingz; + + fixed_t radius; fixed_t height; + + fixed_t momx; fixed_t momy; fixed_t momz; + + int validcount; + mobjtype_t type; mobjinfo_t* info; + int tics; state_t* state; int flags; int health; + + int movedir; int movecount; + + + struct mobj_s* target; + + + int reactiontime; + + + int threshold; + + + struct player_s* player; + + int lastlook; + + mapthing_t spawnpoint; + + struct mobj_s* tracer; + } mobj_t; + + + #endif + + + + + diff --git a/src/p_plats.c b/src/p_plats.c @@ -1,16 +1,31 @@ #include "i_system.h" #include "z_zone.h" #include "m_random.h" + #include "doomdef.h" #include "p_local.h" + #include "s_sound.h" + + #include "doomstat.h" #include "r_state.h" + + #include "sounds.h" + + plat_t* activeplats[MAXPLATS]; + + + + + + void T_PlatRaise(plat_t* plat) { result_e res; + switch(plat->status) { case up: @@ -18,6 +33,7 @@ void T_PlatRaise(plat_t* plat) plat->speed, plat->high, plat->crush,0,1); + if (plat->type == raiseAndChange || plat->type == raiseToNearestAndChange) { @@ -25,6 +41,8 @@ void T_PlatRaise(plat_t* plat) S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov); } + + if (res == crushed && (!plat->crush)) { plat->count = plat->wait; @@ -40,24 +58,29 @@ void T_PlatRaise(plat_t* plat) plat->status = waiting; S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_pstop); + switch(plat->type) { case blazeDWUS: case downWaitUpStay: P_RemoveActivePlat(plat); break; + case raiseAndChange: case raiseToNearestAndChange: P_RemoveActivePlat(plat); break; + default: break; } } } break; + case down: res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); + if (res == pastdest) { plat->count = plat->wait; @@ -65,6 +88,7 @@ void T_PlatRaise(plat_t* plat) S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstop); } break; + case waiting: if (!--plat->count) { @@ -78,6 +102,12 @@ void T_PlatRaise(plat_t* plat) break; } } + + + + + + int EV_DoPlat ( line_t* line, @@ -88,30 +118,41 @@ EV_DoPlat int secnum; int rtn; sector_t* sec; + secnum = -1; rtn = 0; + + + switch(type) { case perpetualRaise: P_ActivateInStasis(line->tag); break; + default: break; } + while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; + if (sec->specialdata) continue; + + rtn = 1; plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); P_AddThinker(&plat->thinker); + plat->type = type; plat->sector = sec; plat->sector->specialdata = plat; plat->thinker.function.acp1 = (actionf_p1) T_PlatRaise; plat->crush = false; plat->tag = line->tag; + switch(type) { case raiseToNearestAndChange: @@ -120,47 +161,63 @@ EV_DoPlat plat->high = P_FindNextHighestFloor(sec,sec->floorheight); plat->wait = 0; plat->status = up; + sec->special = 0; + S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); break; + case raiseAndChange: plat->speed = PLATSPEED/2; sec->floorpic = sides[line->sidenum[0]].sector->floorpic; plat->high = sec->floorheight + amount*FRACUNIT; plat->wait = 0; plat->status = up; + S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); break; + case downWaitUpStay: plat->speed = PLATSPEED * 4; plat->low = P_FindLowestFloorSurrounding(sec); + if (plat->low > sec->floorheight) plat->low = sec->floorheight; + plat->high = sec->floorheight; plat->wait = 35*PLATWAIT; plat->status = down; S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; + case blazeDWUS: plat->speed = PLATSPEED * 8; plat->low = P_FindLowestFloorSurrounding(sec); + if (plat->low > sec->floorheight) plat->low = sec->floorheight; + plat->high = sec->floorheight; plat->wait = 35*PLATWAIT; plat->status = down; S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; + case perpetualRaise: plat->speed = PLATSPEED; plat->low = P_FindLowestFloorSurrounding(sec); + if (plat->low > sec->floorheight) plat->low = sec->floorheight; + plat->high = P_FindHighestFloorSurrounding(sec); + if (plat->high < sec->floorheight) plat->high = sec->floorheight; + plat->wait = 35*PLATWAIT; plat->status = P_Random()&1; + S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; } @@ -168,9 +225,13 @@ EV_DoPlat } return rtn; } + + + void P_ActivateInStasis(int tag) { int i; + for (i = 0;i < MAXPLATS;i++) if (activeplats[i] && (activeplats[i])->tag == tag @@ -181,9 +242,11 @@ void P_ActivateInStasis(int tag) = (actionf_p1) T_PlatRaise; } } + void EV_StopPlat(line_t* line) { int j; + for (j = 0;j < MAXPLATS;j++) if (activeplats[j] && ((activeplats[j])->status != in_stasis) @@ -194,9 +257,11 @@ void EV_StopPlat(line_t* line) (activeplats[j])->thinker.function.acv = (actionf_v)NULL; } } + void P_AddActivePlat(plat_t* plat) { int i; + for (i = 0;i < MAXPLATS;i++) if (activeplats[i] == NULL) { @@ -205,6 +270,7 @@ void P_AddActivePlat(plat_t* plat) } I_Error ("P_AddActivePlat: no more plats!"); } + void P_RemoveActivePlat(plat_t* plat) { int i; @@ -214,6 +280,7 @@ void P_RemoveActivePlat(plat_t* plat) (activeplats[i])->sector->specialdata = NULL; P_RemoveThinker(&(activeplats[i])->thinker); activeplats[i] = NULL; + return; } I_Error ("P_RemoveActivePlat: can't find plat!"); diff --git a/src/p_pspr.c b/src/p_pspr.c @@ -6,520 +6,412 @@ #include "doomstat.h" #include "sounds.h" #include "p_pspr.h" + #define LOWERSPEED FRACUNIT*6 #define RAISESPEED FRACUNIT*6 #define WEAPONBOTTOM 128*FRACUNIT #define WEAPONTOP 32*FRACUNIT -#define BFGCELLS 40 +#define BFGCELLS 40 + +fixed_t swingx; +fixed_t swingy; +fixed_t bulletslope; + void -P_SetPsprite -( player_t* player, - int position, - statenum_t stnum ) +P_SetPsprite(player_t* player, int position, statenum_t stnum) { - pspdef_t* psp; - state_t* state; - psp = &player->psprites[position]; - do - { - if (!stnum) - { - psp->state = NULL; - break; - } - state = &states[stnum]; - psp->state = state; - psp->tics = state->tics; - if (state->misc1) - { - psp->sx = state->misc1 << FRACBITS; - psp->sy = state->misc2 << FRACBITS; - } - if (state->action.acp2) - { - state->action.acp2(player, psp); - if (!psp->state) - break; - } - stnum = psp->state->nextstate; - } while (!psp->tics); + pspdef_t* psp; + state_t* state; + + psp = &player->psprites[position]; + do { + if (!stnum) { + psp->state = NULL; + break; + } + state = &states[stnum]; + psp->state = state; + psp->tics = state->tics; + if (state->misc1) { + psp->sx = state->misc1 << FRACBITS; + psp->sy = state->misc2 << FRACBITS; + } + if (state->action.acp2) { + state->action.acp2(player, psp); + if (!psp->state) + break; + } + stnum = psp->state->nextstate; + } while (!psp->tics); } -fixed_t swingx; -fixed_t swingy; -void P_CalcSwing (player_t* player) + +void +P_CalcSwing(player_t* player) { - fixed_t swing; - int angle; - swing = player->bob; - angle = (FINEANGLES/70*leveltime)&FINEMASK; - swingx = FixedMul ( swing, finesine[angle]); - angle = (FINEANGLES/70*leveltime+FINEANGLES/2)&FINEMASK; - swingy = -FixedMul ( swingx, finesine[angle]); + fixed_t swing; + int angle; + + swing = player->bob; + angle = (FINEANGLES/70*leveltime)&FINEMASK; + swingx = FixedMul ( swing, finesine[angle]); + angle = (FINEANGLES/70*leveltime+FINEANGLES/2)&FINEMASK; + swingy = -FixedMul ( swingx, finesine[angle]); } -void P_BringUpWeapon (player_t* player) + +void +P_BringUpWeapon(player_t* player) { - statenum_t newstate; - if (player->pendingweapon == wp_nochange) - player->pendingweapon = player->readyweapon; - if (player->pendingweapon == wp_chainsaw) - S_StartSound (player->mo, sfx_sawup); - newstate = weaponinfo[player->pendingweapon].upstate; - player->pendingweapon = wp_nochange; - player->psprites[ps_weapon].sy = WEAPONBOTTOM; - P_SetPsprite (player, ps_weapon, newstate); + statenum_t newstate; + + if (player->pendingweapon == wp_nochange) player->pendingweapon = player->readyweapon; + if (player->pendingweapon == wp_chainsaw) S_StartSound (player->mo, sfx_sawup); + newstate = weaponinfo[player->pendingweapon].upstate; + player->pendingweapon = wp_nochange; + player->psprites[ps_weapon].sy = WEAPONBOTTOM; + P_SetPsprite (player, ps_weapon, newstate); } -boolean P_CheckAmmo (player_t* player) + +boolean +P_CheckAmmo(player_t* player) { - ammotype_t ammo; - int count; - ammo = weaponinfo[player->readyweapon].ammo; - if (player->readyweapon == wp_bfg) - count = BFGCELLS; - else if (player->readyweapon == wp_supershotgun) - count = 2; - else - count = 1; - if (ammo == am_noammo || player->ammo[ammo] >= count) - return true; - do - { - if (player->weaponowned[wp_plasma] - && player->ammo[am_cell] - && (gamemode != shareware) ) - { - player->pendingweapon = wp_plasma; - } - else if (player->weaponowned[wp_supershotgun] - && player->ammo[am_shell]>2 - && (gamemode == commercial) ) - { - player->pendingweapon = wp_supershotgun; - } - else if (player->weaponowned[wp_chaingun] - && player->ammo[am_clip]) - { - player->pendingweapon = wp_chaingun; - } - else if (player->weaponowned[wp_shotgun] - && player->ammo[am_shell]) - { - player->pendingweapon = wp_shotgun; - } - else if (player->ammo[am_clip]) - { - player->pendingweapon = wp_pistol; - } - else if (player->weaponowned[wp_chainsaw]) - { - player->pendingweapon = wp_chainsaw; - } - else if (player->weaponowned[wp_missile] - && player->ammo[am_misl]) - { - player->pendingweapon = wp_missile; - } - else if (player->weaponowned[wp_bfg] - && player->ammo[am_cell]>40 - && (gamemode != shareware) ) - { - player->pendingweapon = wp_bfg; - } - else - { - player->pendingweapon = wp_fist; - } - } while (player->pendingweapon == wp_nochange); - P_SetPsprite (player, - ps_weapon, - weaponinfo[player->readyweapon].downstate); - return false; + ammotype_t ammo; + int count; + + ammo = weaponinfo[player->readyweapon].ammo; + if (player->readyweapon == wp_bfg) count = BFGCELLS; + else if (player->readyweapon == wp_supershotgun) count = 2; + else count = 1; + if (ammo == am_noammo || player->ammo[ammo] >= count) return true; + do { + player->pendingweapon = wp_plasma; + if (player->weaponowned[wp_chaingun] && player->ammo[am_clip]) player->pendingweapon = wp_chaingun; + else if (player->weaponowned[wp_shotgun] && player->ammo[am_shell]) player->pendingweapon = wp_shotgun; + else if (player->ammo[am_clip]) player->pendingweapon = wp_pistol; + else if (player->weaponowned[wp_chainsaw]) player->pendingweapon = wp_chainsaw; + else if (player->weaponowned[wp_missile] && player->ammo[am_misl]) player->pendingweapon = wp_missile; + else player->pendingweapon = wp_fist; + } while (player->pendingweapon == wp_nochange); + P_SetPsprite (player, ps_weapon, weaponinfo[player->readyweapon].downstate); + return false; } -void P_FireWeapon (player_t* player) + +void +P_FireWeapon(player_t* player) { - statenum_t newstate; - if (!P_CheckAmmo (player)) - return; - P_SetMobjState (player->mo, S_PLAY_ATK1); - newstate = weaponinfo[player->readyweapon].atkstate; - P_SetPsprite (player, ps_weapon, newstate); - P_NoiseAlert (player->mo, player->mo); + statenum_t newstate; + + if (!P_CheckAmmo(player)) return; + P_SetMobjState (player->mo, S_PLAY_ATK1); + newstate = weaponinfo[player->readyweapon].atkstate; + P_SetPsprite (player, ps_weapon, newstate); + P_NoiseAlert (player->mo, player->mo); } -void P_DropWeapon (player_t* player) + +void +P_DropWeapon(player_t* player) { - P_SetPsprite (player, - ps_weapon, - weaponinfo[player->readyweapon].downstate); + P_SetPsprite (player, ps_weapon, weaponinfo[player->readyweapon].downstate); } + void -A_WeaponReady -( player_t* player, - pspdef_t* psp ) -{ - statenum_t newstate; - int angle; - if (player->mo->state == &states[S_PLAY_ATK1] - || player->mo->state == &states[S_PLAY_ATK2] ) - { - P_SetMobjState (player->mo, S_PLAY); - } - if (player->readyweapon == wp_chainsaw - && psp->state == &states[S_SAW]) - { - S_StartSound (player->mo, sfx_sawidl); - } - if (player->pendingweapon != wp_nochange || !player->health) - { - newstate = weaponinfo[player->readyweapon].downstate; - P_SetPsprite (player, ps_weapon, newstate); - return; - } - if (player->cmd.buttons & BT_ATTACK) - { - if ( !player->attackdown - || (player->readyweapon != wp_missile - && player->readyweapon != wp_bfg) ) - { - player->attackdown = true; - P_FireWeapon (player); - return; +A_WeaponReady(player_t* player, pspdef_t* psp) +{ + statenum_t newstate; + int angle; + + if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2]) P_SetMobjState (player->mo, S_PLAY); + if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) S_StartSound (player->mo, sfx_sawidl); + if (player->pendingweapon != wp_nochange || !player->health) { + newstate = weaponinfo[player->readyweapon].downstate; + P_SetPsprite (player, ps_weapon, newstate); + return; } - } - else - player->attackdown = false; - angle = (128*leveltime)&FINEMASK; - psp->sx = FRACUNIT + FixedMul (player->bob, finecosine[angle]); - angle &= FINEANGLES/2-1; - psp->sy = WEAPONTOP + FixedMul (player->bob, finesine[angle]); + if (player->cmd.buttons & BT_ATTACK) { + if (!player->attackdown || (player->readyweapon != wp_missile && player->readyweapon != wp_bfg)) { + player->attackdown = true; + P_FireWeapon (player); + return; + } + } else player->attackdown = false; + angle = (128*leveltime)&FINEMASK; + psp->sx = FRACUNIT + FixedMul (player->bob, finecosine[angle]); + angle &= FINEANGLES/2-1; + psp->sy = WEAPONTOP + FixedMul (player->bob, finesine[angle]); } -void A_ReFire -( player_t* player, - pspdef_t* psp ) + +void +A_ReFire(player_t* player, pspdef_t* psp) { - if ( (player->cmd.buttons & BT_ATTACK) - && player->pendingweapon == wp_nochange - && player->health) - { - player->refire++; - P_FireWeapon (player); - } - else - { - player->refire = 0; - P_CheckAmmo (player); - } + if ((player->cmd.buttons & BT_ATTACK) && player->pendingweapon == wp_nochange && player->health) { + player->refire++; + P_FireWeapon (player); + } else { + player->refire = 0; + P_CheckAmmo (player); + } } + void -A_CheckReload -( player_t* player, - pspdef_t* psp ) +A_CheckReload(player_t* player, pspdef_t* psp) { - P_CheckAmmo (player); -#if 0 - if (player->ammo[am_shell]<2) - P_SetPsprite (player, ps_weapon, S_DSNR1); -#endif + P_CheckAmmo(player); } + void -A_Lower -( player_t* player, - pspdef_t* psp ) -{ - psp->sy += LOWERSPEED; - if (psp->sy < WEAPONBOTTOM ) - return; - if (player->playerstate == PST_DEAD) - { - psp->sy = WEAPONBOTTOM; - return; - } - if (!player->health) - { - P_SetPsprite (player, ps_weapon, S_NULL); - return; - } - player->readyweapon = player->pendingweapon; - P_BringUpWeapon (player); +A_Lower(player_t* player, pspdef_t* psp) +{ + psp->sy += LOWERSPEED; + if (psp->sy < WEAPONBOTTOM) return; + if (player->playerstate == PST_DEAD) { + psp->sy = WEAPONBOTTOM; + return; + } + if (!player->health) { + P_SetPsprite(player, ps_weapon, S_NULL); + return; + } + player->readyweapon = player->pendingweapon; + P_BringUpWeapon (player); } + void -A_Raise -( player_t* player, - pspdef_t* psp ) +A_Raise(player_t* player, pspdef_t* psp) { - statenum_t newstate; - psp->sy -= RAISESPEED; - if (psp->sy > WEAPONTOP ) - return; - psp->sy = WEAPONTOP; - newstate = weaponinfo[player->readyweapon].readystate; - P_SetPsprite (player, ps_weapon, newstate); + statenum_t newstate; + + psp->sy -= RAISESPEED; + if (psp->sy > WEAPONTOP) return; + psp->sy = WEAPONTOP; + newstate = weaponinfo[player->readyweapon].readystate; + P_SetPsprite (player, ps_weapon, newstate); } + void -A_GunFlash -( player_t* player, - pspdef_t* psp ) +A_GunFlash(player_t* player, pspdef_t* psp) { - P_SetMobjState (player->mo, S_PLAY_ATK2); - P_SetPsprite (player,ps_flash,weaponinfo[player->readyweapon].flashstate); + P_SetMobjState(player->mo, S_PLAY_ATK2); + P_SetPsprite(player,ps_flash,weaponinfo[player->readyweapon].flashstate); } + void -A_Punch -( player_t* player, - pspdef_t* psp ) +A_Punch(player_t* player, pspdef_t* psp) { - angle_t angle; - int damage; - int slope; - damage = (P_Random ()%10+1)<<1; - if (player->powers[pw_strength]) - damage *= 10; - angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); - P_LineAttack (player->mo, angle, MELEERANGE, slope, damage); - if (linetarget) - { - S_StartSound (player->mo, sfx_punch); - player->mo->angle = R_PointToAngle2 (player->mo->x, - player->mo->y, - linetarget->x, - linetarget->y); - } + angle_t angle; + int damage, slope; + + damage = (P_Random() % 10 + 1) << 1; + if (player->powers[pw_strength]) damage *= 10; + angle = player->mo->angle; + angle += (P_Random()-P_Random())<<18; + slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + P_LineAttack (player->mo, angle, MELEERANGE, slope, damage); + if (linetarget) { + S_StartSound (player->mo, sfx_punch); + player->mo->angle = R_PointToAngle2 (player->mo->x, player->mo->y, linetarget->x, linetarget->y); + } } + void -A_Saw -( player_t* player, - pspdef_t* psp ) +A_Saw(player_t* player, pspdef_t* psp) { - angle_t angle; - int damage; - int slope; - damage = 2*(P_Random ()%10+1); - angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1); - P_LineAttack (player->mo, angle, MELEERANGE+1, slope, damage); - if (!linetarget) - { - S_StartSound (player->mo, sfx_sawful); - return; - } - S_StartSound (player->mo, sfx_sawhit); - angle = R_PointToAngle2 (player->mo->x, player->mo->y, - linetarget->x, linetarget->y); - if (angle - player->mo->angle > ANG180) - { - if (angle - player->mo->angle < -ANG90/20) - player->mo->angle = angle + ANG90/21; - else - player->mo->angle -= ANG90/20; - } - else - { - if (angle - player->mo->angle > ANG90/20) - player->mo->angle = angle - ANG90/21; - else - player->mo->angle += ANG90/20; - } - player->mo->flags |= MF_JUSTATTACKED; + angle_t angle; + int damage, slope; + + damage = 2 * (P_Random() % 10 + 1); + angle = player->mo->angle; + angle += (P_Random() - P_Random()) << 18; + slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1); + P_LineAttack(player->mo, angle, MELEERANGE+1, slope, damage); + if (!linetarget) { + S_StartSound (player->mo, sfx_sawful); + return; + } + S_StartSound(player->mo, sfx_sawhit); + angle = R_PointToAngle2(player->mo->x, player->mo->y, linetarget->x, linetarget->y); + if (angle - player->mo->angle > ANG180) { + if (angle - player->mo->angle < -ANG90/20) player->mo->angle = angle + ANG90/21; + else player->mo->angle -= ANG90/20; + } else { + if (angle - player->mo->angle > ANG90/20) player->mo->angle = angle - ANG90/21; + else player->mo->angle += ANG90/20; + } + player->mo->flags |= MF_JUSTATTACKED; } + void -A_FireMissile -( player_t* player, - pspdef_t* psp ) +A_FireMissile(player_t* player, pspdef_t* psp) { - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SpawnPlayerMissile (player->mo, MT_ROCKET); + --player->ammo[weaponinfo[player->readyweapon].ammo]; + P_SpawnPlayerMissile (player->mo, MT_ROCKET); } + void -A_FireBFG -( player_t* player, - pspdef_t* psp ) +A_FireBFG(player_t* player, pspdef_t* psp) { - player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS; - P_SpawnPlayerMissile (player->mo, MT_BFG); + player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS; + P_SpawnPlayerMissile (player->mo, MT_BFG); } + void -A_FirePlasma -( player_t* player, - pspdef_t* psp ) +A_FirePlasma(player_t* player, pspdef_t* psp) { - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, - ps_flash, - weaponinfo[player->readyweapon].flashstate+(P_Random ()&1) ); - P_SpawnPlayerMissile (player->mo, MT_PLASMA); + --player->ammo[weaponinfo[player->readyweapon].ammo]; + P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate + (P_Random() & 1)); + P_SpawnPlayerMissile (player->mo, MT_PLASMA); } -fixed_t bulletslope; -void P_BulletSlope (mobj_t* mo) + + +void +P_BulletSlope (mobj_t* mo) { - angle_t an; - an = mo->angle; - bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); - if (!linetarget) - { - an += 1<<26; + angle_t an; + + an = mo->angle; bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); - if (!linetarget) - { - an -= 2<<26; - bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + if (!linetarget) { + an += 1<<26; + bulletslope = P_AimLineAttack(mo, an, 16*64*FRACUNIT); + if (!linetarget) { + an -= 2<<26; + bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + } } - } } + void -P_GunShot -( mobj_t* mo, - boolean accurate ) +P_GunShot(mobj_t* mo, boolean accurate) { - angle_t angle; - int damage; - damage = 5*(P_Random ()%3+1); - angle = mo->angle; - if (!accurate) - angle += (P_Random()-P_Random())<<18; - P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage); + angle_t angle; + int damage; + + damage = 5 * (P_Random() % 3 + 1); + angle = mo->angle; + if (!accurate) angle += (P_Random()-P_Random())<<18; + P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); } + void -A_FirePistol -( player_t* player, - pspdef_t* psp ) +A_FirePistol(player_t* player, pspdef_t* psp) { - S_StartSound (player->mo, sfx_pistol); - P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, - ps_flash, - weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); - P_GunShot (player->mo, !player->refire); + S_StartSound(player->mo, sfx_pistol); + P_SetMobjState (player->mo, S_PLAY_ATK2); + --player->ammo[weaponinfo[player->readyweapon].ammo]; + P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate); + P_BulletSlope (player->mo); + P_GunShot (player->mo, !player->refire); } + void -A_FireShotgun -( player_t* player, - pspdef_t* psp ) +A_FireShotgun(player_t* player, pspdef_t* psp) { - int i; - S_StartSound (player->mo, sfx_shotgn); - P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, - ps_flash, - weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); - for (i=0 ; i<7 ; i++) - P_GunShot (player->mo, false); + int i; + + S_StartSound(player->mo, sfx_shotgn); + P_SetMobjState(player->mo, S_PLAY_ATK2); + --player->ammo[weaponinfo[player->readyweapon].ammo]; + P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate); + P_BulletSlope (player->mo); + for (i = 0; i < 7; ++i) P_GunShot(player->mo, false); } + void -A_FireShotgun2 -( player_t* player, - pspdef_t* psp ) +A_FireShotgun2(player_t* player, pspdef_t* psp) { - int i; - angle_t angle; - int damage; - S_StartSound (player->mo, sfx_dshtgn); - P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]-=2; - P_SetPsprite (player, - ps_flash, - weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); - for (i=0 ; i<20 ; i++) - { - damage = 5*(P_Random ()%3+1); - angle = player->mo->angle; - angle += (P_Random()-P_Random())<<19; - P_LineAttack (player->mo, - angle, - MISSILERANGE, - bulletslope + ((P_Random()-P_Random())<<5), damage); - } + angle_t angle; + int i, damage; + + S_StartSound(player->mo, sfx_dshtgn); + P_SetMobjState(player->mo, S_PLAY_ATK2); + player->ammo[weaponinfo[player->readyweapon].ammo]-=2; + P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate); + P_BulletSlope(player->mo); + for (i = 0; i < 20; ++i) { + damage = 5 * (P_Random() % 3 + 1); + angle = player->mo->angle; + angle += (P_Random() - P_Random()) << 19; + P_LineAttack (player->mo, angle, MISSILERANGE, bulletslope + ((P_Random()-P_Random())<<5), damage); + } } + void -A_FireCGun -( player_t* player, - pspdef_t* psp ) +A_FireCGun(player_t* player, pspdef_t* psp) { - S_StartSound (player->mo, sfx_pistol); - if (!player->ammo[weaponinfo[player->readyweapon].ammo]) - return; - P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, - ps_flash, - weaponinfo[player->readyweapon].flashstate - + psp->state - - &states[S_CHAIN1] ); - P_BulletSlope (player->mo); - P_GunShot (player->mo, !player->refire); + S_StartSound(player->mo, sfx_pistol); + if (!player->ammo[weaponinfo[player->readyweapon].ammo]) return; + P_SetMobjState(player->mo, S_PLAY_ATK2); + --player->ammo[weaponinfo[player->readyweapon].ammo]; + P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate + psp->state - &states[S_CHAIN1]); + P_BulletSlope(player->mo); + P_GunShot(player->mo, !player->refire); } -void A_Light0 (player_t *player, pspdef_t *psp) + +void +A_Light0(player_t *player, pspdef_t *psp) { - player->extralight = 0; + player->extralight = 0; } -void A_Light1 (player_t *player, pspdef_t *psp) + +void +A_Light1(player_t *player, pspdef_t *psp) { - player->extralight = 1; + player->extralight = 1; } -void A_Light2 (player_t *player, pspdef_t *psp) + +void +A_Light2(player_t *player, pspdef_t *psp) { - player->extralight = 2; + player->extralight = 2; } -void A_BFGSpray (mobj_t* mo) + +void +A_BFGSpray(mobj_t* mo) { - int i; - int j; - int damage; - angle_t an; - for (i=0 ; i<40 ; i++) - { - an = mo->angle - ANG90/2 + ANG90/40*i; - P_AimLineAttack (mo->target, an, 16*64*FRACUNIT); - if (!linetarget) - continue; - P_SpawnMobj (linetarget->x, - linetarget->y, - linetarget->z + (linetarget->height>>2), - MT_EXTRABFG); - damage = 0; - for (j=0;j<15;j++) - damage += (P_Random()&7) + 1; - P_DamageMobj (linetarget, mo->target,mo->target, damage); - } + angle_t an; + int i, j, damage; + + for (i = 0; i < 40; ++i) { + an = mo->angle - ANG90/2 + ANG90/40 * i; + P_AimLineAttack(mo->target, an, 16*64*FRACUNIT); + if (!linetarget) continue; + P_SpawnMobj(linetarget->x, linetarget->y, linetarget->z + (linetarget->height>>2), MT_EXTRABFG); + damage = 0; + for (j = 0; j < 15; ++j) damage += (P_Random()&7) + 1; + P_DamageMobj(linetarget, mo->target,mo->target, damage); + } } + void -A_BFGsound -( player_t* player, - pspdef_t* psp ) +A_BFGsound(player_t* player, pspdef_t* psp) { - S_StartSound (player->mo, sfx_bfg); + S_StartSound(player->mo, sfx_bfg); } -void P_SetupPsprites (player_t* player) + +void +P_SetupPsprites(player_t* player) { - int i; - for (i=0 ; i<NUMPSPRITES ; i++) - player->psprites[i].state = NULL; - player->pendingweapon = player->readyweapon; - P_BringUpWeapon (player); + int i; + + for (i = 0; i < NUMPSPRITES; ++i) player->psprites[i].state = NULL; + player->pendingweapon = player->readyweapon; + P_BringUpWeapon(player); } -void P_MovePsprites (player_t* player) + +void +P_MovePsprites(player_t* player) { - int i; - pspdef_t* psp; - state_t* state; - psp = &player->psprites[0]; - for (i=0 ; i<NUMPSPRITES ; i++, psp++) - { - if ( (state = psp->state) ) - { - if (psp->tics != -1) - { - psp->tics--; - if (!psp->tics) - P_SetPsprite (player, i, psp->state->nextstate); - } + pspdef_t* psp; + state_t* state; + int i; + + psp = &player->psprites[0]; + for (i = 0; i < NUMPSPRITES; ++i, ++psp) { + if ((state = psp->state)) { + if (psp->tics != -1) { + --psp->tics; + if (!psp->tics) P_SetPsprite(player, i, psp->state->nextstate); + } + } } - } - player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; - player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; + player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; + player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; } diff --git a/src/p_pspr.h b/src/p_pspr.h @@ -1,24 +1,51 @@ #ifndef __P_PSPR__ #define __P_PSPR__ + #include "m_fixed.h" #include "tables.h" + + #include "info.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + + #define FF_FULLBRIGHT 0x8000 #define FF_FRAMEMASK 0x7fff + + + + + + + + typedef enum { ps_weapon, ps_flash, NUMPSPRITES + } psprnum_t; + typedef struct { state_t* state; int tics; fixed_t sx; fixed_t sy; + } pspdef_t; + #endif + + + + + diff --git a/src/p_saveg.c b/src/p_saveg.c @@ -1,20 +1,36 @@ #include "i_system.h" #include "z_zone.h" #include "p_local.h" + + #include "doomstat.h" #include "r_state.h" + byte* save_p; -#define PADSAVEP() save_p += (4 - ((long)save_p & 3)) & 3 + + + + +#define PADSAVEP() save_p += (4 - ((long) save_p & 3)) & 3 + + + + + + void P_ArchivePlayers (void) { int i; int j; player_t* dest; + for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; + PADSAVEP(); + dest = (player_t *)save_p; memcpy (dest,&players[i],sizeof(player_t)); save_p += sizeof(player_t); @@ -28,29 +44,46 @@ void P_ArchivePlayers (void) } } } + + + + + + void P_UnArchivePlayers (void) { int i; int j; + for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; + PADSAVEP(); + memcpy (&players[i],save_p, sizeof(player_t)); save_p += sizeof(player_t); + + players[i].mo = NULL; players[i].message = NULL; players[i].attacker = NULL; + for (j=0 ; j<NUMPSPRITES ; j++) { if (players[i]. psprites[j].state) { - players[i]. psprites[j].state = &states[(long)players[i].psprites[j].state]; + players[i].psprites[j].state = &states[(long)players[i].psprites[j].state]; } } } } + + + + + void P_ArchiveWorld (void) { int i; @@ -59,7 +92,10 @@ void P_ArchiveWorld (void) line_t* li; side_t* si; short* put; + put = (short *)save_p; + + for (i=0, sec = sectors ; i<numsectors ; i++,sec++) { *put++ = sec->floorheight >> FRACBITS; @@ -70,6 +106,9 @@ void P_ArchiveWorld (void) *put++ = sec->special; *put++ = sec->tag; } + + + for (i=0, li = lines ; i<numlines ; i++,li++) { *put++ = li->flags; @@ -79,7 +118,9 @@ void P_ArchiveWorld (void) { if (li->sidenum[j] == -1) continue; + si = &sides[li->sidenum[j]]; + *put++ = si->textureoffset >> FRACBITS; *put++ = si->rowoffset >> FRACBITS; *put++ = si->toptexture; @@ -87,8 +128,15 @@ void P_ArchiveWorld (void) *put++ = si->midtexture; } } + save_p = (byte *)put; } + + + + + + void P_UnArchiveWorld (void) { int i; @@ -97,7 +145,10 @@ void P_UnArchiveWorld (void) line_t* li; side_t* si; short* get; + get = (short *)save_p; + + for (i=0, sec = sectors ; i<numsectors ; i++,sec++) { sec->floorheight = *get++ << FRACBITS; @@ -110,6 +161,8 @@ void P_UnArchiveWorld (void) sec->specialdata = 0; sec->soundtarget = 0; } + + for (i=0, li = lines ; i<numlines ; i++,li++) { li->flags = *get++; @@ -129,15 +182,32 @@ void P_UnArchiveWorld (void) } save_p = (byte *)get; } + + + + + + + + typedef enum { tc_end, tc_mobj + } thinkerclass_t; + + + + + + void P_ArchiveThinkers (void) { thinker_t* th; mobj_t* mobj; + + for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -148,30 +218,47 @@ void P_ArchiveThinkers (void) memcpy (mobj, th, sizeof(*mobj)); save_p += sizeof(*mobj); mobj->state = (state_t *)(mobj->state - states); + if (mobj->player) mobj->player = (player_t *)((mobj->player-players) + 1); continue; } + + } + + *save_p++ = tc_end; } + + + + + + void P_UnArchiveThinkers (void) { byte tclass; thinker_t* currentthinker; thinker_t* next; mobj_t* mobj; + + currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { next = currentthinker->next; + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) P_RemoveMobj ((mobj_t *)currentthinker); else Z_Free (currentthinker); + currentthinker = next; } P_InitThinkers (); + + while (1) { tclass = *save_p++; @@ -179,6 +266,7 @@ void P_UnArchiveThinkers (void) { case tc_end: return; + case tc_mobj: PADSAVEP(); mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); @@ -198,11 +286,19 @@ void P_UnArchiveThinkers (void) mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; P_AddThinker (&mobj->thinker); break; + default: I_Error ("Unknown tclass %i in savegame",tclass); } + } + } + + + + + enum { tc_ceiling, @@ -213,7 +309,22 @@ enum tc_strobe, tc_glow, tc_endspecials + } specials_e; + + + + + + + + + + + + + + void P_ArchiveSpecials (void) { thinker_t* th; @@ -225,6 +336,8 @@ void P_ArchiveSpecials (void) strobe_t* strobe; glow_t* glow; int i; + + for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acv == (actionf_v)NULL) @@ -232,6 +345,7 @@ void P_ArchiveSpecials (void) for (i = 0; i < MAXCEILINGS;i++) if (activeceilings[i] == (ceiling_t *)th) break; + if (i<MAXCEILINGS) { *save_p++ = tc_ceiling; @@ -243,6 +357,7 @@ void P_ArchiveSpecials (void) } continue; } + if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { *save_p++ = tc_ceiling; @@ -253,6 +368,7 @@ void P_ArchiveSpecials (void) ceiling->sector = (sector_t *)(ceiling->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_VerticalDoor) { *save_p++ = tc_door; @@ -263,6 +379,7 @@ void P_ArchiveSpecials (void) door->sector = (sector_t *)(door->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_MoveFloor) { *save_p++ = tc_floor; @@ -273,6 +390,7 @@ void P_ArchiveSpecials (void) floor->sector = (sector_t *)(floor->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_PlatRaise) { *save_p++ = tc_plat; @@ -283,6 +401,7 @@ void P_ArchiveSpecials (void) plat->sector = (sector_t *)(plat->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_LightFlash) { *save_p++ = tc_flash; @@ -293,6 +412,7 @@ void P_ArchiveSpecials (void) flash->sector = (sector_t *)(flash->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_StrobeFlash) { *save_p++ = tc_strobe; @@ -303,6 +423,7 @@ void P_ArchiveSpecials (void) strobe->sector = (sector_t *)(strobe->sector - sectors); continue; } + if (th->function.acp1 == (actionf_p1)T_Glow) { *save_p++ = tc_glow; @@ -314,8 +435,16 @@ void P_ArchiveSpecials (void) continue; } } + + *save_p++ = tc_endspecials; + } + + + + + void P_UnArchiveSpecials (void) { byte tclass; @@ -326,6 +455,9 @@ void P_UnArchiveSpecials (void) lightflash_t* flash; strobe_t* strobe; glow_t* glow; + + + while (1) { tclass = *save_p++; @@ -333,6 +465,7 @@ void P_UnArchiveSpecials (void) { case tc_endspecials: return; + case tc_ceiling: PADSAVEP(); ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); @@ -340,11 +473,14 @@ void P_UnArchiveSpecials (void) save_p += sizeof(*ceiling); ceiling->sector = &sectors[(long)ceiling->sector]; ceiling->sector->specialdata = ceiling; + if (ceiling->thinker.function.acp1) ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; + P_AddThinker (&ceiling->thinker); P_AddActiveCeiling(ceiling); break; + case tc_door: PADSAVEP(); door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); @@ -355,6 +491,7 @@ void P_UnArchiveSpecials (void) door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; P_AddThinker (&door->thinker); break; + case tc_floor: PADSAVEP(); floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); @@ -365,6 +502,7 @@ void P_UnArchiveSpecials (void) floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor; P_AddThinker (&floor->thinker); break; + case tc_plat: PADSAVEP(); plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); @@ -372,11 +510,14 @@ void P_UnArchiveSpecials (void) save_p += sizeof(*plat); plat->sector = &sectors[(long)plat->sector]; plat->sector->specialdata = plat; + if (plat->thinker.function.acp1) plat->thinker.function.acp1 = (actionf_p1)T_PlatRaise; + P_AddThinker (&plat->thinker); P_AddActivePlat(plat); break; + case tc_flash: PADSAVEP(); flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); @@ -386,6 +527,7 @@ void P_UnArchiveSpecials (void) flash->thinker.function.acp1 = (actionf_p1)T_LightFlash; P_AddThinker (&flash->thinker); break; + case tc_strobe: PADSAVEP(); strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); @@ -395,6 +537,7 @@ void P_UnArchiveSpecials (void) strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash; P_AddThinker (&strobe->thinker); break; + case tc_glow: PADSAVEP(); glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); @@ -404,9 +547,13 @@ void P_UnArchiveSpecials (void) glow->thinker.function.acp1 = (actionf_p1)T_Glow; P_AddThinker (&glow->thinker); break; + default: I_Error ("P_UnarchiveSpecials:Unknown tclass %i " "in savegame",tclass); } + } + } + diff --git a/src/p_saveg.h b/src/p_saveg.h @@ -1,8 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __P_SAVEG__ #define __P_SAVEG__ + + #ifdef __GNUG__ #pragma interface #endif + + + + void P_ArchivePlayers (void); void P_UnArchivePlayers (void); void P_ArchiveWorld (void); @@ -11,5 +39,13 @@ void P_ArchiveThinkers (void); void P_UnArchiveThinkers (void); void P_ArchiveSpecials (void); void P_UnArchiveSpecials (void); + extern byte* save_p; + + #endif + + + + + diff --git a/src/p_setup.h b/src/p_setup.h @@ -1,13 +1,7 @@ #ifndef __P_SETUP__ #define __P_SETUP__ -#ifdef __GNUG__ -#pragma interface -#endif -void -P_SetupLevel -( int episode, - int map, - int playermask, - skill_t skill); -void P_Init (void); + +void P_SetupLevel(int episode, int map, int playermask, skill_t skill); +void P_Init(); + #endif diff --git a/src/p_sight.c b/src/p_sight.c @@ -1,14 +1,29 @@ #include "doomdef.h" + #include "i_system.h" #include "p_local.h" + + #include "r_state.h" + + + + fixed_t sightzstart; fixed_t topslope; fixed_t bottomslope; + divline_t strace; fixed_t t2x; fixed_t t2y; + int sightcounts[2]; + + + + + + int P_DivlineSide ( fixed_t x, @@ -19,32 +34,50 @@ P_DivlineSide fixed_t dy; fixed_t left; fixed_t right; + if (!node->dx) { if (x==node->x) return 2; + if (x <= node->x) return node->dy > 0; + return node->dy < 0; } + if (!node->dy) { if (x==node->y) return 2; + if (y <= node->y) return node->dx < 0; + return node->dx > 0; } + dx = (x - node->x); dy = (y - node->y); + left = (node->dy>>FRACBITS) * (dx>>FRACBITS); right = (dy>>FRACBITS) * (node->dx>>FRACBITS); + if (right < left) return 0; + if (left == right) return 2; return 1; } + + + + + + + + fixed_t P_InterceptVector2 ( divline_t* v2, @@ -53,14 +86,25 @@ P_InterceptVector2 fixed_t frac; fixed_t num; fixed_t den; + den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy); + if (den == 0) return 0; + + num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy) + FixedMul ( (v2->y - v1->y)>>8 , v1->dx); frac = FixedDiv (num , den); + return frac; } + + + + + + boolean P_CrossSubsector (int num) { seg_t* seg; @@ -78,74 +122,116 @@ boolean P_CrossSubsector (int num) vertex_t* v2; fixed_t frac; fixed_t slope; + #ifdef RANGECHECK if (num>=numsubsectors) I_Error ("P_CrossSubsector: ss %i with numss = %i", num, numsubsectors); #endif + sub = &subsectors[num]; + + count = sub->numlines; seg = &segs[sub->firstline]; + for ( ; count ; seg++, count--) { line = seg->linedef; + + if (line->validcount == validcount) continue; + line->validcount = validcount; + v1 = line->v1; v2 = line->v2; s1 = P_DivlineSide (v1->x,v1->y, &strace); s2 = P_DivlineSide (v2->x, v2->y, &strace); + + if (s1 == s2) continue; + divl.x = v1->x; divl.y = v1->y; divl.dx = v2->x - v1->x; divl.dy = v2->y - v1->y; s1 = P_DivlineSide (strace.x, strace.y, &divl); s2 = P_DivlineSide (t2x, t2y, &divl); + + if (s1 == s2) continue; + + + if ( !(line->flags & ML_TWOSIDED) ) return false; + + front = seg->frontsector; back = seg->backsector; + + if (front->floorheight == back->floorheight && front->ceilingheight == back->ceilingheight) continue; + + + if (front->ceilingheight < back->ceilingheight) opentop = front->ceilingheight; else opentop = back->ceilingheight; + + if (front->floorheight > back->floorheight) openbottom = front->floorheight; else openbottom = back->floorheight; + + if (openbottom >= opentop) return false; + frac = P_InterceptVector2 (&strace, &divl); + if (front->floorheight != back->floorheight) { slope = FixedDiv (openbottom - sightzstart , frac); if (slope > bottomslope) bottomslope = slope; } + if (front->ceilingheight != back->ceilingheight) { slope = FixedDiv (opentop - sightzstart , frac); if (slope < topslope) topslope = slope; } + if (topslope <= bottomslope) return false; } + return true; } + + + + + + + + boolean P_CrossBSPNode (int bspnum) { node_t* bsp; int side; + if (bspnum & NF_SUBSECTOR) { if (bspnum == -1) @@ -153,18 +239,36 @@ boolean P_CrossBSPNode (int bspnum) else return P_CrossSubsector (bspnum&(~NF_SUBSECTOR)); } + bsp = &nodes[bspnum]; + + side = P_DivlineSide (strace.x, strace.y, (divline_t *)bsp); if (side == 2) side = 0; + + if (!P_CrossBSPNode (bsp->children[side]) ) return false; + + if (side == P_DivlineSide (t2x, t2y,(divline_t *)bsp)) { + return true; } + + return P_CrossBSPNode (bsp->children[side^1]); } + + + + + + + + boolean P_CheckSight ( mobj_t* t1, @@ -175,26 +279,44 @@ P_CheckSight int pnum; int bytenum; int bitnum; + + + + s1 = (t1->subsector->sector - sectors); s2 = (t2->subsector->sector - sectors); pnum = s1*numsectors + s2; bytenum = pnum>>3; bitnum = 1 << (pnum&7); + + if (rejectmatrix[bytenum]&bitnum) { sightcounts[0]++; + + return false; } + + + sightcounts[1]++; + validcount++; + sightzstart = t1->z + t1->height - (t1->height>>2); topslope = (t2->z+t2->height) - sightzstart; bottomslope = (t2->z) - sightzstart; + strace.x = t1->x; strace.y = t1->y; t2x = t2->x; t2y = t2->y; strace.dx = t2->x - t1->x; strace.dy = t2->y - t1->y; + + return P_CrossBSPNode (numnodes-1); } + + diff --git a/src/p_spec.c b/src/p_spec.c @@ -1,4 +1,12 @@ +/* + * + * + * P_ShootSpecialLine funny + * + * + */ #include <stdlib.h> + #include "doomdef.h" #include "doomstat.h" #include "i_system.h" @@ -12,673 +20,630 @@ #include "s_sound.h" #include "r_state.h" #include "sounds.h" -typedef struct -{ - boolean istexture; - int picnum; - int basepic; - int numpics; - int speed; + +typedef struct { + boolean istexture; + int picnum; + int basepic; + int numpics; + int speed; } anim_t; -typedef struct -{ - boolean istexture; - char endname[9]; - char startname[9]; - int speed; + +typedef struct { + boolean istexture; + char endname[9]; + char startname[9]; + int speed; } animdef_t; -#define MAXANIMS 32 -extern anim_t anims[MAXANIMS]; -extern anim_t* lastanim; -animdef_t animdefs[] = -{ - {false, "NUKAGE3", "NUKAGE1", 8}, - {false, "FWATER4", "FWATER1", 8}, - {false, "SWATER4", "SWATER1", 8}, - {false, "LAVA4", "LAVA1", 8}, - {false, "BLOOD3", "BLOOD1", 8}, - {false, "RROCK08", "RROCK05", 8}, - {false, "SLIME04", "SLIME01", 8}, - {false, "SLIME08", "SLIME05", 8}, - {false, "SLIME12", "SLIME09", 8}, - {true, "BLODGR4", "BLODGR1", 8}, - {true, "SLADRIP3", "SLADRIP1", 8}, - {true, "BLODRIP4", "BLODRIP1", 8}, - {true, "FIREWALL", "FIREWALA", 8}, - {true, "GSTFONT3", "GSTFONT1", 8}, - {true, "FIRELAVA", "FIRELAV3", 8}, - {true, "FIREMAG3", "FIREMAG1", 8}, - {true, "FIREBLU2", "FIREBLU1", 8}, - {true, "ROCKRED3", "ROCKRED1", 8}, - {true, "BFALL4", "BFALL1", 8}, - {true, "SFALL4", "SFALL1", 8}, - {true, "WFALL4", "WFALL1", 8}, - {true, "DBRAIN4", "DBRAIN1", 8}, - {-1} + +#define MAXANIMS 32 + +extern anim_t anims[MAXANIMS]; +extern anim_t* lastanim; + +animdef_t animdefs[] = { + {false, "NUKAGE3", "NUKAGE1", 8}, + {false, "FWATER4", "FWATER1", 8}, + {false, "SWATER4", "SWATER1", 8}, + {false, "LAVA4", "LAVA1", 8}, + {false, "BLOOD3", "BLOOD1", 8}, + {false, "RROCK08", "RROCK05", 8}, + {false, "SLIME04", "SLIME01", 8}, + {false, "SLIME08", "SLIME05", 8}, + {false, "SLIME12", "SLIME09", 8}, + {true, "BLODGR4", "BLODGR1", 8}, + {true, "SLADRIP3", "SLADRIP1", 8}, + {true, "BLODRIP4", "BLODRIP1", 8}, + {true, "FIREWALL", "FIREWALA", 8}, + {true, "GSTFONT3", "GSTFONT1", 8}, + {true, "FIRELAVA", "FIRELAV3", 8}, + {true, "FIREMAG3", "FIREMAG1", 8}, + {true, "FIREBLU2", "FIREBLU1", 8}, + {true, "ROCKRED3", "ROCKRED1", 8}, + {true, "BFALL4", "BFALL1", 8}, + {true, "SFALL4", "SFALL1", 8}, + {true, "WFALL4", "WFALL1", 8}, + {true, "DBRAIN4", "DBRAIN1", 8}, + {-1} }; -anim_t anims[MAXANIMS]; -anim_t* lastanim; -#define MAXLINEANIMS 64 -extern short numlinespecials; -extern line_t* linespeciallist[MAXLINEANIMS]; -void P_InitPicAnims (void) + +anim_t anims[MAXANIMS]; +anim_t* lastanim; + +#define MAXLINEANIMS 64 + +extern short numlinespecials; +extern line_t* linespeciallist[MAXLINEANIMS]; + +void +P_InitPicAnims() { - int i; - lastanim = anims; - for (i=0 ; animdefs[i].istexture != -1 ; i++) - { - if (animdefs[i].istexture) - { - if (R_CheckTextureNumForName(animdefs[i].startname) == -1) - continue; - lastanim->picnum = R_TextureNumForName (animdefs[i].endname); - lastanim->basepic = R_TextureNumForName (animdefs[i].startname); - } - else - { - if (W_CheckNumForName(animdefs[i].startname) == -1) - continue; - lastanim->picnum = R_FlatNumForName (animdefs[i].endname); - lastanim->basepic = R_FlatNumForName (animdefs[i].startname); + int i; + + lastanim = anims; + for (i = 0; animdefs[i].istexture != -1 ; ++i) { + if (animdefs[i].istexture) { + if (R_CheckTextureNumForName(animdefs[i].startname) == -1) + continue; + lastanim->picnum = R_TextureNumForName (animdefs[i].endname); + lastanim->basepic = R_TextureNumForName (animdefs[i].startname); + } else { + if (W_CheckNumForName(animdefs[i].startname) == -1) + continue; + lastanim->picnum = R_FlatNumForName (animdefs[i].endname); + lastanim->basepic = R_FlatNumForName (animdefs[i].startname); + } + lastanim->istexture = animdefs[i].istexture; + lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; + if (lastanim->numpics < 2) + I_Error ("P_InitPicAnims: bad cycle from %s to %s", animdefs[i].startname, animdefs[i].endname); + lastanim->speed = animdefs[i].speed; + ++lastanim; } - lastanim->istexture = animdefs[i].istexture; - lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; - if (lastanim->numpics < 2) - I_Error ("P_InitPicAnims: bad cycle from %s to %s", - animdefs[i].startname, - animdefs[i].endname); - lastanim->speed = animdefs[i].speed; - lastanim++; - } } + side_t* -getSide -( int currentSector, - int line, - int side ) +getSide(int currentSector, int line, int side) { - return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ]; + return &sides[(sectors[currentSector].lines[line])->sidenum[side]]; } + sector_t* -getSector -( int currentSector, - int line, - int side ) +getSector(int currentSector, int line, int side) { - return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector; + return sides[(sectors[currentSector].lines[line])->sidenum[side]].sector; } + int -twoSided -( int sector, - int line ) +twoSided(int sector, int line) { - return (sectors[sector].lines[line])->flags & ML_TWOSIDED; + return (sectors[sector].lines[line])->flags & ML_TWOSIDED; } + sector_t* -getNextSector -( line_t* line, - sector_t* sec ) +getNextSector(line_t* line, sector_t* sec) { - if (!(line->flags & ML_TWOSIDED)) - return NULL; - if (line->frontsector == sec) - return line->backsector; - return line->frontsector; + if (!(line->flags & ML_TWOSIDED)) + return NULL; + if (line->frontsector == sec) + return line->backsector; + return line->frontsector; } -fixed_t P_FindLowestFloorSurrounding(sector_t* sec) + +fixed_t +P_FindLowestFloorSurrounding(sector_t* sec) { - int i; - line_t* check; - sector_t* other; - fixed_t floor = sec->floorheight; - for (i=0 ;i < sec->linecount ; i++) - { - check = sec->lines[i]; - other = getNextSector(check,sec); - if (!other) - continue; - if (other->floorheight < floor) - floor = other->floorheight; - } - return floor; + line_t* check; + sector_t* other; + fixed_t floor; + int i; + + floor = sec->floorheight; + for (i = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + other = getNextSector(check,sec); + if (!other) + continue; + if (other->floorheight < floor) + floor = other->floorheight; + } + return floor; } -fixed_t P_FindHighestFloorSurrounding(sector_t *sec) + +fixed_t +P_FindHighestFloorSurrounding(sector_t *sec) { - int i; - line_t* check; - sector_t* other; - fixed_t floor = -500*FRACUNIT; - for (i=0 ;i < sec->linecount ; i++) - { - check = sec->lines[i]; - other = getNextSector(check,sec); - if (!other) - continue; - if (other->floorheight > floor) - floor = other->floorheight; - } - return floor; + line_t* check; + sector_t* other; + fixed_t floor; + int i; + + floor = -500 * FRACUNIT; + for (i = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + other = getNextSector(check,sec); + if (!other) + continue; + if (other->floorheight > floor) + floor = other->floorheight; + } + return floor; } -#define MAX_ADJOINING_SECTORS 20 + +#define MAX_ADJOINING_SECTORS 20 + fixed_t -P_FindNextHighestFloor -( sector_t* sec, - int currentheight ) +P_FindNextHighestFloor(sector_t* sec, int currentheight) { - int i; - int h; - int min; - line_t* check; - sector_t* other; - fixed_t height = currentheight; - fixed_t heightlist[MAX_ADJOINING_SECTORS]; - for (i=0, h=0 ;i < sec->linecount ; i++) - { - check = sec->lines[i]; - other = getNextSector(check,sec); - if (!other) - continue; - if (other->floorheight > height) - heightlist[h++] = other->floorheight; - if ( h >= MAX_ADJOINING_SECTORS ) - { - fprintf( stderr, - "Sector with more than 20 adjoining sectors\n" ); - break; + line_t* check; + sector_t* other; + fixed_t height, heightlist[MAX_ADJOINING_SECTORS]; + int i, h, min; + + height = currentheight; + for (i = 0, h = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + other = getNextSector(check,sec); + if (!other) + continue; + if (other->floorheight > height) + heightlist[h++] = other->floorheight; + if (h >= MAX_ADJOINING_SECTORS) { + fprintf(stderr, "Sector with more than 20 adjoining sectors\n"); + break; + } } - } - if (!h) - return currentheight; - min = heightlist[0]; - for (i = 1;i < h;i++) - if (heightlist[i] < min) - min = heightlist[i]; - return min; + if (!h) + return currentheight; + min = heightlist[0]; + for (i = 1; i < h; ++i) + if (heightlist[i] < min) + min = heightlist[i]; + return min; } + fixed_t P_FindLowestCeilingSurrounding(sector_t* sec) { - int i; - line_t* check; - sector_t* other; - fixed_t height = MAXINT; - for (i=0 ;i < sec->linecount ; i++) - { - check = sec->lines[i]; - other = getNextSector(check,sec); - if (!other) - continue; - if (other->ceilingheight < height) - height = other->ceilingheight; - } - return height; + line_t* check; + sector_t* other; + fixed_t height; + int i; + + height = INT_MAX; + for (i = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + other = getNextSector(check,sec); + if (!other) + continue; + if (other->ceilingheight < height) + height = other->ceilingheight; + } + return height; } -fixed_t P_FindHighestCeilingSurrounding(sector_t* sec) + +fixed_t +P_FindHighestCeilingSurrounding(sector_t* sec) { - int i; - line_t* check; - sector_t* other; - fixed_t height = 0; - for (i=0 ;i < sec->linecount ; i++) - { - check = sec->lines[i]; - other = getNextSector(check,sec); - if (!other) - continue; - if (other->ceilingheight > height) - height = other->ceilingheight; - } - return height; + line_t* check; + sector_t* other; + fixed_t height; + int i; + + height = 0; + for (i = 0; i < sec->linecount; ++i) { + check = sec->lines[i]; + other = getNextSector(check,sec); + if (!other) + continue; + if (other->ceilingheight > height) + height = other->ceilingheight; + } + return height; } + int -P_FindSectorFromLineTag -( line_t* line, - int start ) +P_FindSectorFromLineTag(line_t* line, int start) { - int i; - for (i=start+1;i<numsectors;i++) - if (sectors[i].tag == line->tag) - return i; - return -1; + int i; + + for (i = start + 1; i < numsectors; ++i) + if (sectors[i].tag == line->tag) + return i; + return -1; } + int -P_FindMinSurroundingLight -( sector_t* sector, - int max ) +P_FindMinSurroundingLight(sector_t* sector, int max) { - int i; - int min; - line_t* line; - sector_t* check; - min = max; - for (i=0 ; i < sector->linecount ; i++) - { - line = sector->lines[i]; - check = getNextSector(line,sector); - if (!check) - continue; - if (check->lightlevel < min) - min = check->lightlevel; - } - return min; + line_t* line; + sector_t* check; + int i, min; + + min = max; + for (i = 0; i < sector->linecount; ++i) { + line = sector->lines[i]; + check = getNextSector(line,sector); + if (!check) + continue; + if (check->lightlevel < min) + min = check->lightlevel; + } + return min; } + void -P_CrossSpecialLine -( int linenum, - int side, - mobj_t* thing ) +P_CrossSpecialLine(int linenum, int side, mobj_t* thing) { - line_t* line; - int ok; - line = &lines[linenum]; - if (!thing->player) - { - switch(thing->type) - { - case MT_ROCKET: - case MT_PLASMA: - case MT_BFG: - case MT_TROOPSHOT: - case MT_HEADSHOT: - case MT_BRUISERSHOT: - return; - break; - default: break; - } - ok = 0; - switch(line->special) - { - case 39: - case 97: - case 125: - case 126: - case 4: - case 10: - case 88: - ok = 1; - break; + line_t* line; + int ok; + + line = &lines[linenum]; + if (!thing->player) { + switch (thing->type) { + case MT_ROCKET: + case MT_PLASMA: + case MT_BFG: + case MT_TROOPSHOT: + case MT_HEADSHOT: + case MT_BRUISERSHOT: + return; + default: break; + } + ok = 0; + switch (line->special) { + case 39: + case 97: + case 125: + case 126: + case 4: + case 10: + case 88: + ok = 1; + break; + } + if (!ok) + return; } - if (!ok) - return; - } - switch (line->special) - { - case 2: - EV_DoDoor(line,open); - line->special = 0; - break; - case 3: - EV_DoDoor(line,close); - line->special = 0; - break; - case 4: - EV_DoDoor(line,normal); - line->special = 0; - break; - case 5: - EV_DoFloor(line,raiseFloor); - line->special = 0; - break; - case 6: - EV_DoCeiling(line,fastCrushAndRaise); - line->special = 0; - break; - case 8: - EV_BuildStairs(line,build8); - line->special = 0; - break; - case 10: - EV_DoPlat(line,downWaitUpStay,0); - line->special = 0; - break; - case 12: - EV_LightTurnOn(line,0); - line->special = 0; - break; - case 13: - EV_LightTurnOn(line,255); - line->special = 0; - break; - case 16: - EV_DoDoor(line,close30ThenOpen); - line->special = 0; - break; - case 17: - EV_StartLightStrobing(line); - line->special = 0; - break; - case 19: - EV_DoFloor(line,lowerFloor); - line->special = 0; - break; - case 22: - EV_DoPlat(line,raiseToNearestAndChange,0); - line->special = 0; - break; - case 25: - EV_DoCeiling(line,crushAndRaise); - line->special = 0; - break; - case 30: - EV_DoFloor(line,raiseToTexture); - line->special = 0; - break; - case 35: - EV_LightTurnOn(line,35); - line->special = 0; - break; - case 36: - EV_DoFloor(line,turboLower); - line->special = 0; - break; - case 37: - EV_DoFloor(line,lowerAndChange); - line->special = 0; - break; - case 38: - EV_DoFloor( line, lowerFloorToLowest ); - line->special = 0; - break; - case 39: - EV_Teleport( line, side, thing ); - line->special = 0; - break; - case 40: - EV_DoCeiling( line, raiseToHighest ); - EV_DoFloor( line, lowerFloorToLowest ); - line->special = 0; - break; - case 44: - EV_DoCeiling( line, lowerAndCrush ); - line->special = 0; - break; - case 52: - G_ExitLevel (); - break; - case 53: - EV_DoPlat(line,perpetualRaise,0); - line->special = 0; - break; - case 54: - EV_StopPlat(line); - line->special = 0; - break; - case 56: - EV_DoFloor(line,raiseFloorCrush); - line->special = 0; - break; - case 57: - EV_CeilingCrushStop(line); - line->special = 0; - break; - case 58: - EV_DoFloor(line,raiseFloor24); - line->special = 0; - break; - case 59: - EV_DoFloor(line,raiseFloor24AndChange); - line->special = 0; - break; - case 104: - EV_TurnTagLightsOff(line); - line->special = 0; - break; - case 108: - EV_DoDoor (line,blazeRaise); - line->special = 0; - break; - case 109: - EV_DoDoor (line,blazeOpen); - line->special = 0; - break; - case 100: - EV_BuildStairs(line,turbo16); - line->special = 0; - break; - case 110: - EV_DoDoor (line,blazeClose); - line->special = 0; - break; - case 119: - EV_DoFloor(line,raiseFloorToNearest); - line->special = 0; - break; - case 121: - EV_DoPlat(line,blazeDWUS,0); - line->special = 0; - break; - case 124: - G_SecretExitLevel (); - break; - case 125: - if (!thing->player) - { - EV_Teleport( line, side, thing ); - line->special = 0; + switch (line->special) { + case 2: + EV_DoDoor(line,open); + line->special = 0; + break; + + case 3: + EV_DoDoor(line,close); + line->special = 0; + break; + case 4: + EV_DoDoor(line,normal); + line->special = 0; + break; + case 5: + EV_DoFloor(line,raiseFloor); + line->special = 0; + break; + case 6: + EV_DoCeiling(line,fastCrushAndRaise); + line->special = 0; + break; + case 8: + EV_BuildStairs(line,build8); + line->special = 0; + break; + case 10: + EV_DoPlat(line,downWaitUpStay,0); + line->special = 0; + break; + case 12: + EV_LightTurnOn(line,0); + line->special = 0; + break; + case 13: + EV_LightTurnOn(line,255); + line->special = 0; + break; + case 16: + EV_DoDoor(line,close30ThenOpen); + line->special = 0; + break; + case 17: + EV_StartLightStrobing(line); + line->special = 0; + break; + case 19: + EV_DoFloor(line,lowerFloor); + line->special = 0; + break; + case 22: + EV_DoPlat(line,raiseToNearestAndChange,0); + line->special = 0; + break; + case 25: + EV_DoCeiling(line,crushAndRaise); + line->special = 0; + break; + case 30: + EV_DoFloor(line,raiseToTexture); + line->special = 0; + break; + case 35: + EV_LightTurnOn(line,35); + line->special = 0; + break; + case 36: + EV_DoFloor(line,turboLower); + line->special = 0; + break; + case 37: + EV_DoFloor(line,lowerAndChange); + line->special = 0; + break; + case 38: + EV_DoFloor(line, lowerFloorToLowest); + line->special = 0; + break; + case 39: + EV_Teleport(line, side, thing); + line->special = 0; + break; + case 40: + EV_DoCeiling(line, raiseToHighest); + EV_DoFloor(line, lowerFloorToLowest); + line->special = 0; + break; + case 44: + EV_DoCeiling(line, lowerAndCrush); + line->special = 0; + break; + case 52: G_ExitLevel(); break; + case 53: + EV_DoPlat(line,perpetualRaise,0); + line->special = 0; + break; + case 54: + EV_StopPlat(line); + line->special = 0; + break; + case 56: + EV_DoFloor(line,raiseFloorCrush); + line->special = 0; + break; + case 57: + EV_CeilingCrushStop(line); + line->special = 0; + break; + case 58: + EV_DoFloor(line,raiseFloor24); + line->special = 0; + break; + case 59: + EV_DoFloor(line,raiseFloor24AndChange); + line->special = 0; + break; + case 104: + EV_TurnTagLightsOff(line); + line->special = 0; + break; + case 108: + EV_DoDoor (line,blazeRaise); + line->special = 0; + break; + case 109: + EV_DoDoor (line,blazeOpen); + line->special = 0; + break; + case 100: + EV_BuildStairs(line,turbo16); + line->special = 0; + break; + case 110: + EV_DoDoor (line,blazeClose); + line->special = 0; + break; + case 119: + EV_DoFloor(line,raiseFloorToNearest); + line->special = 0; + break; + case 121: + EV_DoPlat(line,blazeDWUS,0); + line->special = 0; + break; + case 124: G_SecretExitLevel (); break; + case 125: + if (!thing->player) { + EV_Teleport(line, side, thing); + line->special = 0; + } + break; + case 130: + EV_DoFloor(line,raiseFloorTurbo); + line->special = 0; + break; + case 141: + EV_DoCeiling(line,silentCrushAndRaise); + line->special = 0; + break; + case 72: EV_DoCeiling(line, lowerAndCrush); break; + case 73: EV_DoCeiling(line,crushAndRaise); break; + case 74: EV_CeilingCrushStop(line); break; + case 75: EV_DoDoor(line,close); break; + case 76: EV_DoDoor(line,close30ThenOpen); break; + case 77: EV_DoCeiling(line,fastCrushAndRaise); break; + case 79: EV_LightTurnOn(line,35); break; + case 80: EV_LightTurnOn(line,0); break; + case 81: EV_LightTurnOn(line,255); break; + case 82: EV_DoFloor(line, lowerFloorToLowest); break; + case 83: EV_DoFloor(line,lowerFloor); break; + case 84: EV_DoFloor(line,lowerAndChange); break; + case 86: EV_DoDoor(line,open); break; + case 87: EV_DoPlat(line,perpetualRaise,0); break; + case 88: EV_DoPlat(line,downWaitUpStay,0); break; + case 89: EV_StopPlat(line); break; + case 90: EV_DoDoor(line,normal); break; + case 91: EV_DoFloor(line,raiseFloor); break; + case 92: EV_DoFloor(line,raiseFloor24); break; + case 93: EV_DoFloor(line,raiseFloor24AndChange); break; + case 94: EV_DoFloor(line,raiseFloorCrush); break; + case 95: EV_DoPlat(line,raiseToNearestAndChange,0); break; + case 96: EV_DoFloor(line,raiseToTexture); break; + case 97: EV_Teleport(line, side, thing); break; + case 98: EV_DoFloor(line,turboLower); break; + case 105: EV_DoDoor(line,blazeRaise); break; + case 106: EV_DoDoor(line,blazeOpen); break; + case 107: EV_DoDoor(line,blazeClose); break; + case 120: EV_DoPlat(line,blazeDWUS,0); break; + case 126: + if (!thing->player) + EV_Teleport(line, side, thing); + break; + case 128: EV_DoFloor(line,raiseFloorToNearest); break; + case 129: EV_DoFloor(line,raiseFloorTurbo); break; } - break; - case 130: - EV_DoFloor(line,raiseFloorTurbo); - line->special = 0; - break; - case 141: - EV_DoCeiling(line,silentCrushAndRaise); - line->special = 0; - break; - case 72: - EV_DoCeiling( line, lowerAndCrush ); - break; - case 73: - EV_DoCeiling(line,crushAndRaise); - break; - case 74: - EV_CeilingCrushStop(line); - break; - case 75: - EV_DoDoor(line,close); - break; - case 76: - EV_DoDoor(line,close30ThenOpen); - break; - case 77: - EV_DoCeiling(line,fastCrushAndRaise); - break; - case 79: - EV_LightTurnOn(line,35); - break; - case 80: - EV_LightTurnOn(line,0); - break; - case 81: - EV_LightTurnOn(line,255); - break; - case 82: - EV_DoFloor( line, lowerFloorToLowest ); - break; - case 83: - EV_DoFloor(line,lowerFloor); - break; - case 84: - EV_DoFloor(line,lowerAndChange); - break; - case 86: - EV_DoDoor(line,open); - break; - case 87: - EV_DoPlat(line,perpetualRaise,0); - break; - case 88: - EV_DoPlat(line,downWaitUpStay,0); - break; - case 89: - EV_StopPlat(line); - break; - case 90: - EV_DoDoor(line,normal); - break; - case 91: - EV_DoFloor(line,raiseFloor); - break; - case 92: - EV_DoFloor(line,raiseFloor24); - break; - case 93: - EV_DoFloor(line,raiseFloor24AndChange); - break; - case 94: - EV_DoFloor(line,raiseFloorCrush); - break; - case 95: - EV_DoPlat(line,raiseToNearestAndChange,0); - break; - case 96: - EV_DoFloor(line,raiseToTexture); - break; - case 97: - EV_Teleport( line, side, thing ); - break; - case 98: - EV_DoFloor(line,turboLower); - break; - case 105: - EV_DoDoor (line,blazeRaise); - break; - case 106: - EV_DoDoor (line,blazeOpen); - break; - case 107: - EV_DoDoor (line,blazeClose); - break; - case 120: - EV_DoPlat(line,blazeDWUS,0); - break; - case 126: - if (!thing->player) - EV_Teleport( line, side, thing ); - break; - case 128: - EV_DoFloor(line,raiseFloorToNearest); - break; - case 129: - EV_DoFloor(line,raiseFloorTurbo); - break; - } } + void -P_ShootSpecialLine -( mobj_t* thing, - line_t* line ) +P_ShootSpecialLine(mobj_t* thing, line_t* line) { - int ok; - if (!thing->player) - { - ok = 0; - switch(line->special) - { - case 46: - ok = 1; - break; + if (!thing->player && line->special != 46) + return; + switch (line->special) { + case 24: + EV_DoFloor(line,raiseFloor); + P_ChangeSwitchTexture(line,0); + break; + case 46: + EV_DoDoor(line,open); + P_ChangeSwitchTexture(line,1); + break; + case 47: + EV_DoPlat(line,raiseToNearestAndChange,0); + P_ChangeSwitchTexture(line,0); + break; } - if (!ok) - return; - } - switch(line->special) - { - case 24: - EV_DoFloor(line,raiseFloor); - P_ChangeSwitchTexture(line,0); - break; - case 46: - EV_DoDoor(line,open); - P_ChangeSwitchTexture(line,1); - break; - case 47: - EV_DoPlat(line,raiseToNearestAndChange,0); - P_ChangeSwitchTexture(line,0); - break; - } } -void P_PlayerInSpecialSector (player_t* player) + +void +P_PlayerInSpecialSector(player_t* player) { - sector_t* sector; - sector = player->mo->subsector->sector; - if (player->mo->z != sector->floorheight) + sector_t* sector; + + sector = player->mo->subsector->sector; + + + if (player->mo->z != sector->floorheight) return; - switch (sector->special) - { - case 5: + + + switch (sector->special) + { + case 5: + if (!player->powers[pw_ironfeet]) if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 10); break; - case 7: + + case 7: + if (!player->powers[pw_ironfeet]) if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 5); break; - case 16: - case 4: + + case 16: + + case 4: + if (!player->powers[pw_ironfeet] - || (P_Random()<5) ) + || (P_Random()<5)) { if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 20); } break; - case 9: + + case 9: + player->secretcount++; sector->special = 0; break; - case 11: + + case 11: + player->cheats &= ~CF_GODMODE; + if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 20); + if (player->health <= 10) G_ExitLevel(); break; - default: + + default: I_Error ("P_PlayerInSpecialSector: " "unknown special %i", sector->special); break; - }; + }; } + + + + + + + + boolean levelTimer; int levelTimeCount; + void P_UpdateSpecials (void) { - anim_t* anim; - int pic; - int i; - line_t* line; - if (levelTimer == true) - { + anim_t* anim; + int pic; + int i; + line_t* line; + + + + if (levelTimer == true) + { levelTimeCount--; if (!levelTimeCount) G_ExitLevel(); - } - for (anim = anims ; anim < lastanim ; anim++) - { + } + + + for (anim = anims ; anim < lastanim ; anim++) + { for (i=anim->basepic ; i<anim->basepic+anim->numpics ; i++) { - pic = anim->basepic + ( (leveltime/anim->speed + i)%anim->numpics ); + pic = anim->basepic + ((leveltime/anim->speed + i)%anim->numpics); if (anim->istexture) texturetranslation[i] = pic; else flattranslation[i] = pic; } - } - for (i = 0; i < numlinespecials; i++) - { + } + + + + for (i = 0; i < numlinespecials; i++) + { line = linespeciallist[i]; switch(line->special) { - case 48: + case 48: + sides[line->sidenum[0]].textureoffset += FRACUNIT; break; } - } - for (i = 0; i < MAXBUTTONS; i++) + } + + + + for (i = 0; i < MAXBUTTONS; i++) if (buttonlist[i].btimer) { buttonlist[i].btimer--; @@ -686,15 +651,17 @@ void P_UpdateSpecials (void) { switch(buttonlist[i].where) { - case top: + case top: sides[buttonlist[i].line->sidenum[0]].toptexture = buttonlist[i].btexture; break; - case middle: + + case middle: sides[buttonlist[i].line->sidenum[0]].midtexture = buttonlist[i].btexture; break; - case bottom: + + case bottom: sides[buttonlist[i].line->sidenum[0]].bottomtexture = buttonlist[i].btexture; break; @@ -703,31 +670,42 @@ void P_UpdateSpecials (void) memset(&buttonlist[i],0,sizeof(button_t)); } } + } + + + + + + int EV_DoDonut(line_t* line) { - sector_t* s1; - sector_t* s2; - sector_t* s3; - int secnum; - int rtn; - int i; - floormove_t* floor; - secnum = -1; - rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) - { + sector_t* s1; + sector_t* s2; + sector_t* s3; + int secnum; + int rtn; + int i; + floormove_t* floor; + + secnum = -1; + rtn = 0; + while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + { s1 = &sectors[secnum]; + + if (s1->specialdata) continue; + rtn = 1; s2 = getNextSector(s1->lines[0],s1); for (i = 0;i < s2->linecount;i++) { - if (((!s2->lines[i]->flags) & ML_TWOSIDED) || - (s2->lines[i]->backsector == s1)) - continue; + if (((!s2->lines[i]->flags) & ML_TWOSIDED) || (s2->lines[i]->backsector == s1)) continue; s3 = s2->lines[i]->backsector; + + floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); s2->specialdata = floor; @@ -740,6 +718,8 @@ int EV_DoDonut(line_t* line) floor->texture = s3->floorpic; floor->newspecial = 0; floor->floordestheight = s3->floorheight; + + floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); s1->specialdata = floor; @@ -752,89 +732,124 @@ int EV_DoDonut(line_t* line) floor->floordestheight = s3->floorheight; break; } - } - return rtn; + } + return rtn; } + + + + + + + + + + + + short numlinespecials; line_t* linespeciallist[MAXLINEANIMS]; + + + void P_SpawnSpecials (void) { - sector_t* sector; - int i; - if (W_CheckNumForName("texture2") >= 0) - levelTimer = false; - i = M_CheckParm("-avg"); - if (i && deathmatch) - { + sector_t* sector; + int i; + + if (W_CheckNumForName("texture2") >= 0) + + + + levelTimer = false; + + i = M_CheckParm("-avg"); + if (i && deathmatch) + { levelTimer = true; levelTimeCount = 20 * 60 * 35; - } - i = M_CheckParm("-timer"); - if (i && deathmatch) - { + } + + i = M_CheckParm("-timer"); + if (i && deathmatch) + { int time; time = atoi(myargv[i+1]) * 60 * 35; levelTimer = true; levelTimeCount = time; - } - sector = sectors; - for (i=0 ; i<numsectors ; i++, sector++) - { + } + + + sector = sectors; + for (i=0 ; i<numsectors ; i++, sector++) + { if (!sector->special) continue; - switch (sector->special) - { - case 1: - P_SpawnLightFlash (sector); - break; - case 2: - P_SpawnStrobeFlash(sector,FASTDARK,0); - break; - case 3: - P_SpawnStrobeFlash(sector,SLOWDARK,0); - break; - case 4: - P_SpawnStrobeFlash(sector,FASTDARK,0); - sector->special = 4; - break; - case 8: - P_SpawnGlowingLight(sector); - break; - case 9: - totalsecret++; - break; - case 10: - P_SpawnDoorCloseIn30 (sector); - break; - case 12: - P_SpawnStrobeFlash (sector, SLOWDARK, 1); - break; - case 13: - P_SpawnStrobeFlash (sector, FASTDARK, 1); - break; - case 14: - P_SpawnDoorRaiseIn5Mins (sector, i); - break; - case 17: - P_SpawnFireFlicker(sector); - break; + + switch (sector->special) { + case 1: + P_SpawnLightFlash (sector); + break; + case 2: + P_SpawnStrobeFlash(sector,FASTDARK,0); + break; + case 3: + P_SpawnStrobeFlash(sector,SLOWDARK,0); + break; + case 4: + P_SpawnStrobeFlash(sector,FASTDARK,0); + sector->special = 4; + break; + case 8: + P_SpawnGlowingLight(sector); + break; + case 9: + totalsecret++; + break; + case 10: + P_SpawnDoorCloseIn30(sector); + break; + case 12: + P_SpawnStrobeFlash(sector, SLOWDARK, 1); + break; + case 13: + P_SpawnStrobeFlash(sector, FASTDARK, 1); + break; + case 14: + P_SpawnDoorRaiseIn5Mins(sector, i); + break; + case 17: + P_SpawnFireFlicker(sector); + break; + } } - } - numlinespecials = 0; - for (i = 0;i < numlines; i++) - { + + + + numlinespecials = 0; + for (i = 0;i < numlines; i++) + { switch(lines[i].special) { - case 48: + case 48: + linespeciallist[numlinespecials] = &lines[i]; numlinespecials++; break; } - } - for (i = 0;i < MAXCEILINGS;i++) + } + + + + for (i = 0;i < MAXCEILINGS;i++) activeceilings[i] = NULL; - for (i = 0;i < MAXPLATS;i++) + + for (i = 0;i < MAXPLATS;i++) activeplats[i] = NULL; - for (i = 0;i < MAXBUTTONS;i++) + + for (i = 0;i < MAXBUTTONS;i++) memset(&buttonlist[i],0,sizeof(button_t)); + + + } diff --git a/src/p_spec.h b/src/p_spec.h @@ -1,61 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + #ifndef __P_SPEC__ #define __P_SPEC__ + + + + + extern boolean levelTimer; extern int levelTimeCount; + + + #define MO_TELEPORTMAN 14 + + + void P_InitPicAnims (void); + + void P_SpawnSpecials (void); + + void P_UpdateSpecials (void); + + boolean P_UseSpecialLine ( mobj_t* thing, line_t* line, int side ); + void P_ShootSpecialLine ( mobj_t* thing, line_t* line ); + void P_CrossSpecialLine ( int linenum, int side, mobj_t* thing ); + void P_PlayerInSpecialSector (player_t* player); + int twoSided ( int sector, int line ); + sector_t* getSector ( int currentSector, int line, int side ); + side_t* getSide ( int currentSector, int line, int side ); + fixed_t P_FindLowestFloorSurrounding(sector_t* sec); fixed_t P_FindHighestFloorSurrounding(sector_t* sec); + fixed_t P_FindNextHighestFloor ( sector_t* sec, int currentheight ); + fixed_t P_FindLowestCeilingSurrounding(sector_t* sec); fixed_t P_FindHighestCeilingSurrounding(sector_t* sec); + int P_FindSectorFromLineTag ( line_t* line, int start ); + int P_FindMinSurroundingLight ( sector_t* sector, int max ); + sector_t* getNextSector ( line_t* line, sector_t* sec ); + + + + + int EV_DoDonut(line_t* line); + + + + + + typedef struct { thinker_t thinker; @@ -63,7 +128,11 @@ typedef struct int count; int maxlight; int minlight; + } fireflicker_t; + + + typedef struct { thinker_t thinker; @@ -73,7 +142,11 @@ typedef struct int minlight; int maxtime; int mintime; + } lightflash_t; + + + typedef struct { thinker_t thinker; @@ -83,7 +156,12 @@ typedef struct int maxlight; int darktime; int brighttime; + } strobe_t; + + + + typedef struct { thinker_t thinker; @@ -91,40 +169,61 @@ typedef struct int minlight; int maxlight; int direction; + } glow_t; + + #define GLOWSPEED 8 #define STROBEBRIGHT 5 #define FASTDARK 15 #define SLOWDARK 35 + void P_SpawnFireFlicker (sector_t* sector); void T_LightFlash (lightflash_t* flash); void P_SpawnLightFlash (sector_t* sector); void T_StrobeFlash (strobe_t* flash); + void P_SpawnStrobeFlash ( sector_t* sector, int fastOrSlow, int inSync ); + void EV_StartLightStrobing(line_t* line); void EV_TurnTagLightsOff(line_t* line); + void EV_LightTurnOn ( line_t* line, int bright ); + void T_Glow(glow_t* g); void P_SpawnGlowingLight(sector_t* sector); + + + + + + + typedef struct { char name1[9]; char name2[9]; short episode; + } switchlist_t; + + typedef enum { top, middle, bottom + } bwhere_e; + + typedef struct { line_t* line; @@ -132,23 +231,45 @@ typedef struct int btexture; int btimer; mobj_t* soundorg; + } button_t; + + + + + #define MAXSWITCHES 50 + + #define MAXBUTTONS 16 + + #define BUTTONTIME 35 + extern button_t buttonlist[MAXBUTTONS]; + void P_ChangeSwitchTexture ( line_t* line, int useAgain ); + void P_InitSwitchList(void); + + + + + typedef enum { up, down, waiting, in_stasis + } plat_e; + + + typedef enum { perpetualRaise, @@ -156,7 +277,11 @@ typedef enum raiseAndChange, raiseToNearestAndChange, blazeDWUS + } plattype_e; + + + typedef struct { thinker_t thinker; @@ -171,21 +296,35 @@ typedef struct boolean crush; int tag; plattype_e type; + } plat_t; + + + #define PLATWAIT 3 #define PLATSPEED FRACUNIT #define MAXPLATS 30 + + extern plat_t* activeplats[MAXPLATS]; + void T_PlatRaise(plat_t* plat); + int EV_DoPlat ( line_t* line, plattype_e type, int amount ); + void P_AddActivePlat(plat_t* plat); void P_RemoveActivePlat(plat_t* plat); void EV_StopPlat(line_t* line); void P_ActivateInStasis(int tag); + + + + + typedef enum { normal, @@ -196,7 +335,11 @@ typedef enum blazeRaise, blazeOpen, blazeClose + } vldoor_e; + + + typedef struct { thinker_t thinker; @@ -204,44 +347,74 @@ typedef struct sector_t* sector; fixed_t topheight; fixed_t speed; + + int direction; + + int topwait; + + int topcountdown; + } vldoor_t; + + + #define VDOORSPEED FRACUNIT*2 #define VDOORWAIT 150 + void EV_VerticalDoor ( line_t* line, mobj_t* thing ); + int EV_DoDoor ( line_t* line, vldoor_e type ); + int EV_DoLockedDoor ( line_t* line, vldoor_e type, mobj_t* thing ); + void T_VerticalDoor (vldoor_t* door); void P_SpawnDoorCloseIn30 (sector_t* sec); + void P_SpawnDoorRaiseIn5Mins ( sector_t* sec, int secnum ); + + + #if 0 + + + typedef enum { sd_opening, sd_waiting, sd_closing + } sd_e; + + + typedef enum { sdt_openOnly, sdt_closeOnly, sdt_openAndClose + } sdt_e; + + + + typedef struct { thinker_t thinker; @@ -253,7 +426,11 @@ typedef struct sector_t* frontsector; sector_t* backsector; sd_e status; + } slidedoor_t; + + + typedef struct { char frontFrame1[9]; @@ -264,22 +441,42 @@ typedef struct char backFrame2[9]; char backFrame3[9]; char backFrame4[9]; + } slidename_t; + + + typedef struct { int frontFrames[4]; int backFrames[4]; + } slideframe_t; + + + + #define SNUMFRAMES 4 + #define SDOORWAIT 35*3 #define SWAITTICS 4 + + #define MAXSLIDEDOORS 5 + void P_InitSlidingDoorFrames(void); + void EV_SlidingDoor ( line_t* line, mobj_t* thing ); #endif + + + + + + typedef enum { lowerToFloor, @@ -288,7 +485,11 @@ typedef enum crushAndRaise, fastCrushAndRaise, silentCrushAndRaise + } ceiling_e; + + + typedef struct { thinker_t thinker; @@ -298,44 +499,88 @@ typedef struct fixed_t topheight; fixed_t speed; boolean crush; + + int direction; + + int tag; int olddirection; + } ceiling_t; + + + + + #define CEILSPEED FRACUNIT #define CEILWAIT 150 #define MAXCEILINGS 30 + extern ceiling_t* activeceilings[MAXCEILINGS]; + int EV_DoCeiling ( line_t* line, ceiling_e type ); + void T_MoveCeiling (ceiling_t* ceiling); void P_AddActiveCeiling(ceiling_t* c); void P_RemoveActiveCeiling(ceiling_t* c); int EV_CeilingCrushStop(line_t* line); void P_ActivateInStasisCeiling(line_t* line); + + + + + typedef enum { + lowerFloor, + + lowerFloorToLowest, + + turboLower, + + raiseFloor, + + raiseFloorToNearest, + + raiseToTexture, + + + lowerAndChange, + raiseFloor24, raiseFloor24AndChange, raiseFloorCrush, + + raiseFloorTurbo, donutRaise, raiseFloor512 + } floor_e; + + + + typedef enum { build8, turbo16 + } stair_e; + + + typedef struct { thinker_t thinker; @@ -347,14 +592,21 @@ typedef struct short texture; fixed_t floordestheight; fixed_t speed; + } floormove_t; + + + #define FLOORSPEED FRACUNIT + typedef enum { ok, crushed, pastdest + } result_e; + result_e T_MovePlane ( sector_t* sector, @@ -363,18 +615,31 @@ T_MovePlane boolean crush, int floorOrCeiling, int direction ); + int EV_BuildStairs ( line_t* line, stair_e type ); + int EV_DoFloor ( line_t* line, floor_e floortype ); + void T_MoveFloor( floormove_t* floor); + + + + int EV_Teleport ( line_t* line, int side, mobj_t* thing ); + #endif + + + + + diff --git a/src/p_switch.c b/src/p_switch.c @@ -6,418 +6,361 @@ #include "sounds.h" #include "doomstat.h" #include "r_state.h" -switchlist_t alphSwitchList[] = -{ - {"SW1BRCOM", "SW2BRCOM", 1}, - {"SW1BRN1", "SW2BRN1", 1}, - {"SW1BRN2", "SW2BRN2", 1}, - {"SW1BRNGN", "SW2BRNGN", 1}, - {"SW1BROWN", "SW2BROWN", 1}, - {"SW1COMM", "SW2COMM", 1}, - {"SW1COMP", "SW2COMP", 1}, - {"SW1DIRT", "SW2DIRT", 1}, - {"SW1EXIT", "SW2EXIT", 1}, - {"SW1GRAY", "SW2GRAY", 1}, - {"SW1GRAY1", "SW2GRAY1", 1}, - {"SW1METAL", "SW2METAL", 1}, - {"SW1PIPE", "SW2PIPE", 1}, - {"SW1SLAD", "SW2SLAD", 1}, - {"SW1STARG", "SW2STARG", 1}, - {"SW1STON1", "SW2STON1", 1}, - {"SW1STON2", "SW2STON2", 1}, - {"SW1STONE", "SW2STONE", 1}, - {"SW1STRTN", "SW2STRTN", 1}, - {"SW1BLUE", "SW2BLUE", 2}, - {"SW1CMT", "SW2CMT", 2}, - {"SW1GARG", "SW2GARG", 2}, - {"SW1GSTON", "SW2GSTON", 2}, - {"SW1HOT", "SW2HOT", 2}, - {"SW1LION", "SW2LION", 2}, - {"SW1SATYR", "SW2SATYR", 2}, - {"SW1SKIN", "SW2SKIN", 2}, - {"SW1VINE", "SW2VINE", 2}, - {"SW1WOOD", "SW2WOOD", 2}, - {"SW1PANEL", "SW2PANEL", 3}, - {"SW1ROCK", "SW2ROCK", 3}, - {"SW1MET2", "SW2MET2", 3}, - {"SW1WDMET", "SW2WDMET", 3}, - {"SW1BRIK", "SW2BRIK", 3}, - {"SW1MOD1", "SW2MOD1", 3}, - {"SW1ZIM", "SW2ZIM", 3}, - {"SW1STON6", "SW2STON6", 3}, - {"SW1TEK", "SW2TEK", 3}, - {"SW1MARB", "SW2MARB", 3}, - {"SW1SKULL", "SW2SKULL", 3}, - {"\0", "\0", 0} + +int switchlist[MAXSWITCHES * 2]; +int numswitches; +button_t buttonlist[MAXBUTTONS]; + +switchlist_t alphSwitchList[] = { + {"SW1BRCOM", "SW2BRCOM", 1}, + {"SW1BRN1", "SW2BRN1", 1}, + {"SW1BRN2", "SW2BRN2", 1}, + {"SW1BRNGN", "SW2BRNGN", 1}, + {"SW1BROWN", "SW2BROWN", 1}, + {"SW1COMM", "SW2COMM", 1}, + {"SW1COMP", "SW2COMP", 1}, + {"SW1DIRT", "SW2DIRT", 1}, + {"SW1EXIT", "SW2EXIT", 1}, + {"SW1GRAY", "SW2GRAY", 1}, + {"SW1GRAY1", "SW2GRAY1", 1}, + {"SW1METAL", "SW2METAL", 1}, + {"SW1PIPE", "SW2PIPE", 1}, + {"SW1SLAD", "SW2SLAD", 1}, + {"SW1STARG", "SW2STARG", 1}, + {"SW1STON1", "SW2STON1", 1}, + {"SW1STON2", "SW2STON2", 1}, + {"SW1STONE", "SW2STONE", 1}, + {"SW1STRTN", "SW2STRTN", 1}, + {"SW1BLUE", "SW2BLUE", 2}, + {"SW1CMT", "SW2CMT", 2}, + {"SW1GARG", "SW2GARG", 2}, + {"SW1GSTON", "SW2GSTON", 2}, + {"SW1HOT", "SW2HOT", 2}, + {"SW1LION", "SW2LION", 2}, + {"SW1SATYR", "SW2SATYR", 2}, + {"SW1SKIN", "SW2SKIN", 2}, + {"SW1VINE", "SW2VINE", 2}, + {"SW1WOOD", "SW2WOOD", 2}, + {"SW1PANEL", "SW2PANEL", 3}, + {"SW1ROCK", "SW2ROCK", 3}, + {"SW1MET2", "SW2MET2", 3}, + {"SW1WDMET", "SW2WDMET", 3}, + {"SW1BRIK", "SW2BRIK", 3}, + {"SW1MOD1", "SW2MOD1", 3}, + {"SW1ZIM", "SW2ZIM", 3}, + {"SW1STON6", "SW2STON6", 3}, + {"SW1TEK", "SW2TEK", 3}, + {"SW1MARB", "SW2MARB", 3}, + {"SW1SKULL", "SW2SKULL", 3}, + {"\0", "\0", 0} }; -int switchlist[MAXSWITCHES * 2]; -int numswitches; -button_t buttonlist[MAXBUTTONS]; -void P_InitSwitchList(void) + +void +P_InitSwitchList(void) { - int i; - int index; - int episode; - episode = 1; - if (gamemode == registered) - episode = 2; - else - if ( gamemode == commercial ) - episode = 3; - for (index = 0,i = 0;i < MAXSWITCHES;i++) - { - if (!alphSwitchList[i].episode) - { - numswitches = index/2; - switchlist[index] = -1; - break; - } - if (alphSwitchList[i].episode <= episode) - { -#if 0 - int value; - if (R_CheckTextureNumForName(alphSwitchList[i].name1) < 0) - { - I_Error("Can't find switch texture '%s'!", - alphSwitchList[i].name1); - continue; - } - value = R_TextureNumForName(alphSwitchList[i].name1); -#endif - switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); - switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2); + int i, j, episode; + + episode = 1; + for (i = 0, j = 0; i < MAXSWITCHES; ++i) { + if (!alphSwitchList[i].episode) { + numswitches = j/2; + switchlist[j] = -1; + break; + } + if (alphSwitchList[i].episode <= episode) { + switchlist[j++] = R_TextureNumForName(alphSwitchList[i].name1); + switchlist[j++] = R_TextureNumForName(alphSwitchList[i].name2); + } } - } } + void -P_StartButton -( line_t* line, - bwhere_e w, - int texture, - int time ) +P_StartButton(line_t* line, bwhere_e w, int texture, int time) { - int i; - for (i = 0;i < MAXBUTTONS;i++) - { - if (buttonlist[i].btimer - && buttonlist[i].line == line) - { - return; - } - } - for (i = 0;i < MAXBUTTONS;i++) - { - if (!buttonlist[i].btimer) - { - buttonlist[i].line = line; - buttonlist[i].where = w; - buttonlist[i].btexture = texture; - buttonlist[i].btimer = time; - buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; - return; + int i; + + for (i = 0; i < MAXBUTTONS; ++i) { + if (buttonlist[i].btimer && buttonlist[i].line == line) + return; + for (i = 0; i < MAXBUTTONS; ++i) { + if (!buttonlist[i].btimer) { + buttonlist[i].line = line; + buttonlist[i].where = w; + buttonlist[i].btexture = texture; + buttonlist[i].btimer = time; + buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; + return; + } + } + I_Error("P_StartButton: no button slots left!"); } - } - I_Error("P_StartButton: no button slots left!"); } + void -P_ChangeSwitchTexture -( line_t* line, - int useAgain ) +P_ChangeSwitchTexture(line_t* line, int useAgain) { - int texTop; - int texMid; - int texBot; - int i; - int sound; - if (!useAgain) - line->special = 0; - texTop = sides[line->sidenum[0]].toptexture; - texMid = sides[line->sidenum[0]].midtexture; - texBot = sides[line->sidenum[0]].bottomtexture; - sound = sfx_swtchn; - if (line->special == 11) - sound = sfx_swtchx; - for (i = 0;i < numswitches*2;i++) - { - if (switchlist[i] == texTop) - { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].toptexture = switchlist[i^1]; - if (useAgain) - P_StartButton(line,top,switchlist[i],BUTTONTIME); - return; - } - else - { - if (switchlist[i] == texMid) - { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].midtexture = switchlist[i^1]; - if (useAgain) - P_StartButton(line, middle,switchlist[i],BUTTONTIME); - return; - } - else - { - if (switchlist[i] == texBot) - { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].bottomtexture = switchlist[i^1]; - if (useAgain) - P_StartButton(line, bottom,switchlist[i],BUTTONTIME); - return; + int texTop, texMid, texBot, i, sound; + + if (!useAgain) line->special = 0; + texTop = sides[line->sidenum[0]].toptexture; + texMid = sides[line->sidenum[0]].midtexture; + texBot = sides[line->sidenum[0]].bottomtexture; + sound = sfx_swtchn; + if (line->special == 11) sound = sfx_swtchx; + for (i = 0; i < numswitches * 2; ++i) { + if (switchlist[i] == texTop) { + S_StartSound(buttonlist->soundorg,sound); + sides[line->sidenum[0]].toptexture = switchlist[i^1]; + if (useAgain) P_StartButton(line,top,switchlist[i],BUTTONTIME); + return; + } else { + if (switchlist[i] == texMid) { + S_StartSound(buttonlist->soundorg,sound); + sides[line->sidenum[0]].midtexture = switchlist[i^1]; + if (useAgain) P_StartButton(line, middle,switchlist[i],BUTTONTIME); + return; + } else { + if (switchlist[i] == texBot) { + S_StartSound(buttonlist->soundorg,sound); + sides[line->sidenum[0]].bottomtexture = switchlist[i^1]; + if (useAgain) P_StartButton(line, bottom,switchlist[i],BUTTONTIME); + return; + } + } } - } } - } } + boolean -P_UseSpecialLine -( mobj_t* thing, - line_t* line, - int side ) -{ - if (side) - { - switch(line->special) - { - case 124: - break; - default: - return false; - break; +P_UseSpecialLine(mobj_t* thing, line_t* line, int side) +{ + if (side && line->special != 124) return false; + if (!thing->player) { + if (line->flags & ML_SECRET) return false; + switch (line->special) { + case 1: + case 32: + case 33: + case 34: + break; + default: + return false; + } } - } - if (!thing->player) - { - if (line->flags & ML_SECRET) - return false; - switch(line->special) - { - case 1: - case 32: - case 33: - case 34: - break; - default: - return false; - break; + switch (line->special) { + case 1: + case 26: + case 27: + case 28: + case 31: + case 32: + case 33: + case 34: + case 117: + case 118: + EV_VerticalDoor(line, thing); + break; + case 7: + if (EV_BuildStairs(line,build8)) + P_ChangeSwitchTexture(line,0); + break; + case 9: + if (EV_DoDonut(line)) + P_ChangeSwitchTexture(line,0); + break; + case 11: + P_ChangeSwitchTexture(line,0); + G_ExitLevel(); + break; + case 14: + if(EV_DoPlat(line,raiseAndChange,32)) + P_ChangeSwitchTexture(line,0); + break; + case 15: + if (EV_DoPlat(line,raiseAndChange,24)) + P_ChangeSwitchTexture(line,0); + break; + case 18: + if (EV_DoFloor(line, raiseFloorToNearest)) + P_ChangeSwitchTexture(line,0); + break; + case 20: + if (EV_DoPlat(line,raiseToNearestAndChange,0)) + P_ChangeSwitchTexture(line,0); + break; + case 21: + if (EV_DoPlat(line,downWaitUpStay,0)) + P_ChangeSwitchTexture(line,0); + break; + case 23: + if (EV_DoFloor(line,lowerFloorToLowest)) + P_ChangeSwitchTexture(line,0); + break; + case 29: + if (EV_DoDoor(line,normal)) + P_ChangeSwitchTexture(line,0); + break; + case 41: + if (EV_DoCeiling(line,lowerToFloor)) + P_ChangeSwitchTexture(line,0); + break; + case 71: + if (EV_DoFloor(line,turboLower)) + P_ChangeSwitchTexture(line,0); + break; + case 49: + if (EV_DoCeiling(line,crushAndRaise)) + P_ChangeSwitchTexture(line,0); + break; + case 50: + if (EV_DoDoor(line,close)) + P_ChangeSwitchTexture(line,0); + break; + case 51: + P_ChangeSwitchTexture(line,0); + G_SecretExitLevel(); + break; + case 55: + if (EV_DoFloor(line,raiseFloorCrush)) + P_ChangeSwitchTexture(line,0); + break; + case 101: + if (EV_DoFloor(line,raiseFloor)) + P_ChangeSwitchTexture(line,0); + break; + case 102: + if (EV_DoFloor(line,lowerFloor)) + P_ChangeSwitchTexture(line,0); + break; + case 103: + if (EV_DoDoor(line,open)) + P_ChangeSwitchTexture(line,0); + break; + case 111: + if (EV_DoDoor (line,blazeRaise)) + P_ChangeSwitchTexture(line,0); + break; + case 112: + if (EV_DoDoor (line,blazeOpen)) + P_ChangeSwitchTexture(line,0); + break; + case 113: + if (EV_DoDoor (line,blazeClose)) + P_ChangeSwitchTexture(line,0); + break; + case 122: + if (EV_DoPlat(line,blazeDWUS,0)) + P_ChangeSwitchTexture(line,0); + break; + case 127: + if (EV_BuildStairs(line,turbo16)) + P_ChangeSwitchTexture(line,0); + break; + case 131: + if (EV_DoFloor(line,raiseFloorTurbo)) + P_ChangeSwitchTexture(line,0); + break; + case 133: + case 135: + case 137: + if (EV_DoLockedDoor(line,blazeOpen,thing)) + P_ChangeSwitchTexture(line,0); + break; + case 140: + if (EV_DoFloor(line,raiseFloor512)) + P_ChangeSwitchTexture(line,0); + break; + case 42: + if (EV_DoDoor(line,close)) + P_ChangeSwitchTexture(line,1); + break; + case 43: + if (EV_DoCeiling(line,lowerToFloor)) + P_ChangeSwitchTexture(line,1); + break; + case 45: + if (EV_DoFloor(line,lowerFloor)) + P_ChangeSwitchTexture(line,1); + break; + case 60: + if (EV_DoFloor(line,lowerFloorToLowest)) + P_ChangeSwitchTexture(line,1); + break; + case 61: + if (EV_DoDoor(line,open)) + P_ChangeSwitchTexture(line,1); + break; + case 62: + if (EV_DoPlat(line,downWaitUpStay,1)) + P_ChangeSwitchTexture(line,1); + break; + case 63: + if (EV_DoDoor(line,normal)) + P_ChangeSwitchTexture(line,1); + break; + case 64: + if (EV_DoFloor(line,raiseFloor)) + P_ChangeSwitchTexture(line,1); + break; + case 66: + if (EV_DoPlat(line,raiseAndChange,24)) + P_ChangeSwitchTexture(line,1); + break; + case 67: + if (EV_DoPlat(line,raiseAndChange,32)) + P_ChangeSwitchTexture(line,1); + break; + case 65: + if (EV_DoFloor(line,raiseFloorCrush)) + P_ChangeSwitchTexture(line,1); + break; + case 68: + if (EV_DoPlat(line,raiseToNearestAndChange,0)) + P_ChangeSwitchTexture(line,1); + break; + case 69: + if (EV_DoFloor(line, raiseFloorToNearest)) + P_ChangeSwitchTexture(line,1); + break; + case 70: + if (EV_DoFloor(line,turboLower)) + P_ChangeSwitchTexture(line,1); + break; + case 114: + if (EV_DoDoor(line,blazeRaise)) + P_ChangeSwitchTexture(line,1); + break; + case 115: + if (EV_DoDoor(line,blazeOpen)) + P_ChangeSwitchTexture(line,1); + break; + case 116: + if (EV_DoDoor(line,blazeClose)) + P_ChangeSwitchTexture(line,1); + break; + case 123: + if (EV_DoPlat(line,blazeDWUS,0)) + P_ChangeSwitchTexture(line,1); + break; + case 132: + if (EV_DoFloor(line,raiseFloorTurbo)) + P_ChangeSwitchTexture(line,1); + break; + case 99: + case 134: + case 136: + if (EV_DoLockedDoor (line,blazeOpen,thing)) + P_ChangeSwitchTexture(line,1); + break; + case 138: + EV_LightTurnOn(line,255); + P_ChangeSwitchTexture(line,1); + break; + case 139: + EV_LightTurnOn(line,35); + P_ChangeSwitchTexture(line,1); + break; } - } - switch (line->special) - { - case 1: - case 26: - case 27: - case 28: - case 31: - case 32: - case 33: - case 34: - case 117: - case 118: - EV_VerticalDoor (line, thing); - break; - case 7: - if (EV_BuildStairs(line,build8)) - P_ChangeSwitchTexture(line,0); - break; - case 9: - if (EV_DoDonut(line)) - P_ChangeSwitchTexture(line,0); - break; - case 11: - P_ChangeSwitchTexture(line,0); - G_ExitLevel (); - break; - case 14: - if (EV_DoPlat(line,raiseAndChange,32)) - P_ChangeSwitchTexture(line,0); - break; - case 15: - if (EV_DoPlat(line,raiseAndChange,24)) - P_ChangeSwitchTexture(line,0); - break; - case 18: - if (EV_DoFloor(line, raiseFloorToNearest)) - P_ChangeSwitchTexture(line,0); - break; - case 20: - if (EV_DoPlat(line,raiseToNearestAndChange,0)) - P_ChangeSwitchTexture(line,0); - break; - case 21: - if (EV_DoPlat(line,downWaitUpStay,0)) - P_ChangeSwitchTexture(line,0); - break; - case 23: - if (EV_DoFloor(line,lowerFloorToLowest)) - P_ChangeSwitchTexture(line,0); - break; - case 29: - if (EV_DoDoor(line,normal)) - P_ChangeSwitchTexture(line,0); - break; - case 41: - if (EV_DoCeiling(line,lowerToFloor)) - P_ChangeSwitchTexture(line,0); - break; - case 71: - if (EV_DoFloor(line,turboLower)) - P_ChangeSwitchTexture(line,0); - break; - case 49: - if (EV_DoCeiling(line,crushAndRaise)) - P_ChangeSwitchTexture(line,0); - break; - case 50: - if (EV_DoDoor(line,close)) - P_ChangeSwitchTexture(line,0); - break; - case 51: - P_ChangeSwitchTexture(line,0); - G_SecretExitLevel (); - break; - case 55: - if (EV_DoFloor(line,raiseFloorCrush)) - P_ChangeSwitchTexture(line,0); - break; - case 101: - if (EV_DoFloor(line,raiseFloor)) - P_ChangeSwitchTexture(line,0); - break; - case 102: - if (EV_DoFloor(line,lowerFloor)) - P_ChangeSwitchTexture(line,0); - break; - case 103: - if (EV_DoDoor(line,open)) - P_ChangeSwitchTexture(line,0); - break; - case 111: - if (EV_DoDoor (line,blazeRaise)) - P_ChangeSwitchTexture(line,0); - break; - case 112: - if (EV_DoDoor (line,blazeOpen)) - P_ChangeSwitchTexture(line,0); - break; - case 113: - if (EV_DoDoor (line,blazeClose)) - P_ChangeSwitchTexture(line,0); - break; - case 122: - if (EV_DoPlat(line,blazeDWUS,0)) - P_ChangeSwitchTexture(line,0); - break; - case 127: - if (EV_BuildStairs(line,turbo16)) - P_ChangeSwitchTexture(line,0); - break; - case 131: - if (EV_DoFloor(line,raiseFloorTurbo)) - P_ChangeSwitchTexture(line,0); - break; - case 133: - case 135: - case 137: - if (EV_DoLockedDoor (line,blazeOpen,thing)) - P_ChangeSwitchTexture(line,0); - break; - case 140: - if (EV_DoFloor(line,raiseFloor512)) - P_ChangeSwitchTexture(line,0); - break; - case 42: - if (EV_DoDoor(line,close)) - P_ChangeSwitchTexture(line,1); - break; - case 43: - if (EV_DoCeiling(line,lowerToFloor)) - P_ChangeSwitchTexture(line,1); - break; - case 45: - if (EV_DoFloor(line,lowerFloor)) - P_ChangeSwitchTexture(line,1); - break; - case 60: - if (EV_DoFloor(line,lowerFloorToLowest)) - P_ChangeSwitchTexture(line,1); - break; - case 61: - if (EV_DoDoor(line,open)) - P_ChangeSwitchTexture(line,1); - break; - case 62: - if (EV_DoPlat(line,downWaitUpStay,1)) - P_ChangeSwitchTexture(line,1); - break; - case 63: - if (EV_DoDoor(line,normal)) - P_ChangeSwitchTexture(line,1); - break; - case 64: - if (EV_DoFloor(line,raiseFloor)) - P_ChangeSwitchTexture(line,1); - break; - case 66: - if (EV_DoPlat(line,raiseAndChange,24)) - P_ChangeSwitchTexture(line,1); - break; - case 67: - if (EV_DoPlat(line,raiseAndChange,32)) - P_ChangeSwitchTexture(line,1); - break; - case 65: - if (EV_DoFloor(line,raiseFloorCrush)) - P_ChangeSwitchTexture(line,1); - break; - case 68: - if (EV_DoPlat(line,raiseToNearestAndChange,0)) - P_ChangeSwitchTexture(line,1); - break; - case 69: - if (EV_DoFloor(line, raiseFloorToNearest)) - P_ChangeSwitchTexture(line,1); - break; - case 70: - if (EV_DoFloor(line,turboLower)) - P_ChangeSwitchTexture(line,1); - break; - case 114: - if (EV_DoDoor (line,blazeRaise)) - P_ChangeSwitchTexture(line,1); - break; - case 115: - if (EV_DoDoor (line,blazeOpen)) - P_ChangeSwitchTexture(line,1); - break; - case 116: - if (EV_DoDoor (line,blazeClose)) - P_ChangeSwitchTexture(line,1); - break; - case 123: - if (EV_DoPlat(line,blazeDWUS,0)) - P_ChangeSwitchTexture(line,1); - break; - case 132: - if (EV_DoFloor(line,raiseFloorTurbo)) - P_ChangeSwitchTexture(line,1); - break; - case 99: - case 134: - case 136: - if (EV_DoLockedDoor (line,blazeOpen,thing)) - P_ChangeSwitchTexture(line,1); - break; - case 138: - EV_LightTurnOn(line,255); - P_ChangeSwitchTexture(line,1); - break; - case 139: - EV_LightTurnOn(line,35); - P_ChangeSwitchTexture(line,1); - break; - } - return true; + return true; } + diff --git a/src/p_telept.c b/src/p_telept.c @@ -1,8 +1,21 @@ #include "doomdef.h" + #include "s_sound.h" + #include "p_local.h" + + + #include "sounds.h" + + #include "r_state.h" + + + + + + int EV_Teleport ( line_t* line, @@ -19,10 +32,17 @@ EV_Teleport fixed_t oldx; fixed_t oldy; fixed_t oldz; + + if (thing->flags & MF_MISSILE) return 0; + + + if (side == 1) return 0; + + tag = line->tag; for (i = 0; i < numsectors; i++) { @@ -33,30 +53,46 @@ EV_Teleport thinker != &thinkercap; thinker = thinker->next) { + if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; + m = (mobj_t *)thinker; + + if (m->type != MT_TELEPORTMAN ) continue; + sector = m->subsector->sector; + if (sector-sectors != i ) continue; + oldx = thing->x; oldy = thing->y; oldz = thing->z; + if (!P_TeleportMove (thing, m->x, m->y)) return 0; + thing->z = thing->floorz; if (thing->player) thing->player->viewz = thing->z+thing->player->viewheight; + + fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); S_StartSound (fog, sfx_telept); an = m->angle >> ANGLETOFINESHIFT; fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] , thing->z, MT_TFOG); + + S_StartSound (fog, sfx_telept); + + if (thing->player) thing->reactiontime = 18; + thing->angle = m->angle; thing->momx = thing->momy = thing->momz = 0; return 1; @@ -65,3 +101,4 @@ EV_Teleport } return 0; } + diff --git a/src/p_tick.c b/src/p_tick.c @@ -1,12 +1,40 @@ #include "z_zone.h" #include "p_local.h" + #include "doomstat.h" + + int leveltime; + + + + + + + + + + + + thinker_t thinkercap; + + + + + void P_InitThinkers (void) { thinkercap.prev = thinkercap.next = &thinkercap; } + + + + + + + + void P_AddThinker (thinker_t* thinker) { thinkercap.prev->next = thinker; @@ -14,21 +42,45 @@ void P_AddThinker (thinker_t* thinker) thinker->prev = thinkercap.prev; thinkercap.prev = thinker; } + + + + + + + + void P_RemoveThinker (thinker_t* thinker) { + thinker->function.acv = (actionf_v)(-1); } + + + + + + + void P_AllocateThinker (thinker_t* thinker) { } + + + + + + void P_RunThinkers (void) { thinker_t* currentthinker; + currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { if ( currentthinker->function.acv == (actionf_v)(-1) ) { + currentthinker->next->prev = currentthinker->prev; currentthinker->prev->next = currentthinker->next; Z_Free (currentthinker); @@ -41,11 +93,22 @@ void P_RunThinkers (void) currentthinker = currentthinker->next; } } + + + + + + + void P_Ticker (void) { int i; + + if (paused) return; + + if ( !netgame && menuactive && !demoplayback @@ -53,11 +116,16 @@ void P_Ticker (void) { return; } + + for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i]) P_PlayerThink (&players[i]); + P_RunThinkers (); P_UpdateSpecials (); P_RespawnSpecials (); + + leveltime++; } diff --git a/src/p_tick.h b/src/p_tick.h @@ -1,7 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __P_TICK__ #define __P_TICK__ + + #ifdef __GNUG__ #pragma interface #endif + + + + + void P_Ticker (void); + + + #endif + + + + + diff --git a/src/p_user.c b/src/p_user.c @@ -2,218 +2,174 @@ #include "d_event.h" #include "p_local.h" #include "doomstat.h" + #define INVERSECOLORMAP 32 -#define MAXBOB 0x100000 +#define MAXBOB 0x100000 +#define ANG5 (ANG90/18) + boolean onground; + void -P_Thrust -( player_t* player, - angle_t angle, - fixed_t move ) +P_Thrust(player_t* player, angle_t angle, fixed_t move) { - angle >>= ANGLETOFINESHIFT; - player->mo->momx += FixedMul(move,finecosine[angle]); - player->mo->momy += FixedMul(move,finesine[angle]); + angle >>= ANGLETOFINESHIFT; + player->mo->momx += FixedMul(move,finecosine[angle]); + player->mo->momy += FixedMul(move,finesine[angle]); } -void P_CalcHeight (player_t* player) + +void +P_CalcHeight (player_t* player) { - int angle; - fixed_t bob; - player->bob = - FixedMul (player->mo->momx, player->mo->momx) - + FixedMul (player->mo->momy,player->mo->momy); - player->bob >>= 2; - if (player->bob>MAXBOB) - player->bob = MAXBOB; - if ((player->cheats & CF_NOMOMENTUM) || !onground) - { - player->viewz = player->mo->z + VIEWHEIGHT; - if (player->viewz > player->mo->ceilingz-4*FRACUNIT) - player->viewz = player->mo->ceilingz-4*FRACUNIT; - player->viewz = player->mo->z + player->viewheight; - return; - } - angle = (FINEANGLES/20*leveltime)&FINEMASK; - bob = FixedMul ( player->bob/2, finesine[angle]); - if (player->playerstate == PST_LIVE) - { - player->viewheight += player->deltaviewheight; - if (player->viewheight > VIEWHEIGHT) - { - player->viewheight = VIEWHEIGHT; - player->deltaviewheight = 0; - } - if (player->viewheight < VIEWHEIGHT/2) - { - player->viewheight = VIEWHEIGHT/2; - if (player->deltaviewheight <= 0) - player->deltaviewheight = 1; + fixed_t bob; + int angle; + + player->bob = FixedMul(player->mo->momx, player->mo->momx) + FixedMul(player->mo->momy,player->mo->momy); + player->bob >>= 2; + if (player->bob>MAXBOB) + player->bob = MAXBOB; + if ((player->cheats & CF_NOMOMENTUM) || !onground) { + player->viewz = player->mo->z + VIEWHEIGHT; + if (player->viewz > player->mo->ceilingz-4*FRACUNIT) + player->viewz = player->mo->ceilingz-4*FRACUNIT; + player->viewz = player->mo->z + player->viewheight; + return; } - if (player->deltaviewheight) - { - player->deltaviewheight += FRACUNIT/4; - if (!player->deltaviewheight) - player->deltaviewheight = 1; + angle = (FINEANGLES/20*leveltime)&FINEMASK; + bob = FixedMul( player->bob/2, finesine[angle]); + if (player->playerstate == PST_LIVE) { + player->viewheight += player->deltaviewheight; + if (player->viewheight > VIEWHEIGHT) { + player->viewheight = VIEWHEIGHT; + player->deltaviewheight = 0; + } + if (player->viewheight < VIEWHEIGHT/2) { + player->viewheight = VIEWHEIGHT/2; + if (player->deltaviewheight <= 0) + player->deltaviewheight = 1; + } + if (player->deltaviewheight) { + player->deltaviewheight += FRACUNIT/4; + if (!player->deltaviewheight) + player->deltaviewheight = 1; + } } - } - player->viewz = player->mo->z + player->viewheight + bob; - if (player->viewz > player->mo->ceilingz-4*FRACUNIT) - player->viewz = player->mo->ceilingz-4*FRACUNIT; + player->viewz = player->mo->z + player->viewheight + bob; + if (player->viewz > player->mo->ceilingz-4*FRACUNIT) + player->viewz = player->mo->ceilingz-4*FRACUNIT; } -void P_MovePlayer (player_t* player) + +void +P_MovePlayer(player_t* player) { - ticcmd_t* cmd; - cmd = &player->cmd; - player->mo->angle += (cmd->angleturn<<16); - onground = (player->mo->z <= player->mo->floorz); - if (cmd->forwardmove && onground) - P_Thrust (player, player->mo->angle, cmd->forwardmove*2048); - if (cmd->sidemove && onground) - P_Thrust (player, player->mo->angle-ANG90, cmd->sidemove*2048); - if ( (cmd->forwardmove || cmd->sidemove) - && player->mo->state == &states[S_PLAY] ) - { - P_SetMobjState (player->mo, S_PLAY_RUN1); - } -} -#define ANG5 (ANG90/18) -void P_DeathThink (player_t* player) + ticcmd_t* cmd; + + cmd = &player->cmd; + player->mo->angle += (cmd->angleturn<<16); + onground = (player->mo->z <= player->mo->floorz); + if (cmd->forwardmove && onground) P_Thrust(player, player->mo->angle, cmd->forwardmove*2048); + if (cmd->sidemove && onground) P_Thrust(player, player->mo->angle-ANG90, cmd->sidemove*2048); + if ((cmd->forwardmove || cmd->sidemove) && player->mo->state == &states[S_PLAY]) + P_SetMobjState(player->mo, S_PLAY_RUN1); +} + +void P_DeathThink(player_t* player) { - angle_t angle; - angle_t delta; - P_MovePsprites (player); - if (player->viewheight > 6*FRACUNIT) - player->viewheight -= FRACUNIT; - if (player->viewheight < 6*FRACUNIT) - player->viewheight = 6*FRACUNIT; - player->deltaviewheight = 0; - onground = (player->mo->z <= player->mo->floorz); - P_CalcHeight (player); - if (player->attacker && player->attacker != player->mo) - { - angle = R_PointToAngle2 (player->mo->x, - player->mo->y, - player->attacker->x, - player->attacker->y); - delta = angle - player->mo->angle; - if (delta < ANG5 || delta > (unsigned)-ANG5) - { - player->mo->angle = angle; - if (player->damagecount) - player->damagecount--; + angle_t angle, delta; + + P_MovePsprites(player); + if (player->viewheight > 6*FRACUNIT) player->viewheight -= FRACUNIT; + if (player->viewheight < 6*FRACUNIT) player->viewheight = 6*FRACUNIT; + player->deltaviewheight = 0; + onground = (player->mo->z <= player->mo->floorz); + P_CalcHeight(player); + if (player->attacker && player->attacker != player->mo) { + angle = R_PointToAngle2(player->mo->x, player->mo->y, player->attacker->x, player->attacker->y); + delta = angle - player->mo->angle; + if (delta < ANG5 || delta > (unsigned)-ANG5) { + player->mo->angle = angle; + if (player->damagecount) + --player->damagecount; + } + else if (delta < ANG180) player->mo->angle += ANG5; + else player->mo->angle -= ANG5; } - else if (delta < ANG180) - player->mo->angle += ANG5; - else - player->mo->angle -= ANG5; - } - else if (player->damagecount) - player->damagecount--; - if (player->cmd.buttons & BT_USE) - player->playerstate = PST_REBORN; + if (player->damagecount) + --player->damagecount; + if (player->cmd.buttons & BT_USE) + player->playerstate = PST_REBORN; } -void P_PlayerThink (player_t* player) + +void +P_PlayerThink(player_t* player) { - ticcmd_t* cmd; - weapontype_t newweapon; - if (player->cheats & CF_NOCLIP) - player->mo->flags |= MF_NOCLIP; - else - player->mo->flags &= ~MF_NOCLIP; - cmd = &player->cmd; - if (player->mo->flags & MF_JUSTATTACKED) - { - cmd->angleturn = 0; - cmd->forwardmove = 0xc800/512; - cmd->sidemove = 0; - player->mo->flags &= ~MF_JUSTATTACKED; - } - if (player->playerstate == PST_DEAD) - { - P_DeathThink (player); - return; - } - if (player->mo->reactiontime) - player->mo->reactiontime--; - else - P_MovePlayer (player); - P_CalcHeight (player); - if (player->mo->subsector->sector->special) - P_PlayerInSpecialSector (player); - if (cmd->buttons & BT_SPECIAL) - cmd->buttons = 0; - if (cmd->buttons & BT_CHANGE) - { - newweapon = (cmd->buttons&BT_WEAPONMASK)>>BT_WEAPONSHIFT; - if (newweapon == wp_fist - && player->weaponowned[wp_chainsaw] - && !(player->readyweapon == wp_chainsaw - && player->powers[pw_strength])) - { - newweapon = wp_chainsaw; - } - if ( (gamemode == commercial) - && newweapon == wp_shotgun - && player->weaponowned[wp_supershotgun] - && player->readyweapon != wp_supershotgun) - { - newweapon = wp_supershotgun; - } - if (player->weaponowned[newweapon] - && newweapon != player->readyweapon) - { - if ((newweapon != wp_plasma - && newweapon != wp_bfg) - || (gamemode != shareware) ) - { - player->pendingweapon = newweapon; - } + ticcmd_t* cmd; + weapontype_t newweapon; + + if (player->cheats & CF_NOCLIP) + player->mo->flags |= MF_NOCLIP; + else + player->mo->flags &= ~MF_NOCLIP; + cmd = &player->cmd; + if (player->mo->flags & MF_JUSTATTACKED) { + cmd->angleturn = 0; + cmd->forwardmove = 0xc800/512; + cmd->sidemove = 0; + player->mo->flags &= ~MF_JUSTATTACKED; } - } - if (cmd->buttons & BT_USE) - { - if (!player->usedown) - { - P_UseLines (player); - player->usedown = true; + if (player->playerstate == PST_DEAD) { + P_DeathThink (player); + return; } - } - else - player->usedown = false; - P_MovePsprites (player); - if (player->powers[pw_strength]) - player->powers[pw_strength]++; - if (player->powers[pw_invulnerability]) - player->powers[pw_invulnerability]--; - if (player->powers[pw_invisibility]) - if (! --player->powers[pw_invisibility] ) - player->mo->flags &= ~MF_SHADOW; - if (player->powers[pw_infrared]) - player->powers[pw_infrared]--; - if (player->powers[pw_ironfeet]) - player->powers[pw_ironfeet]--; - if (player->damagecount) - player->damagecount--; - if (player->bonuscount) - player->bonuscount--; - if (player->powers[pw_invulnerability]) - { - if (player->powers[pw_invulnerability] > 4*32 - || (player->powers[pw_invulnerability]&8) ) - player->fixedcolormap = INVERSECOLORMAP; + if (player->mo->reactiontime) + --player->mo->reactiontime; else - player->fixedcolormap = 0; - } - else if (player->powers[pw_infrared]) - { - if (player->powers[pw_infrared] > 4*32 - || (player->powers[pw_infrared]&8) ) - { - player->fixedcolormap = 1; + P_MovePlayer(player); + P_CalcHeight(player); + if (player->mo->subsector->sector->special) + P_PlayerInSpecialSector(player); + if (cmd->buttons & BT_SPECIAL) + cmd->buttons = 0; + if (cmd->buttons & BT_CHANGE) { + newweapon = (cmd->buttons&BT_WEAPONMASK)>>BT_WEAPONSHIFT; + if (newweapon == wp_fist && player->weaponowned[wp_chainsaw] && !(player->readyweapon == wp_chainsaw && player->powers[pw_strength])) + newweapon = wp_chainsaw; + if (player->weaponowned[newweapon] && newweapon != player->readyweapon) { + if (newweapon != wp_plasma && newweapon != wp_bfg) + player->pendingweapon = newweapon; + } } - else - player->fixedcolormap = 0; - } - else - player->fixedcolormap = 0; + if (cmd->buttons & BT_USE) { + if (!player->usedown) { + P_UseLines(player); + player->usedown = true; + } + } else player->usedown = false; + P_MovePsprites(player); + if (player->powers[pw_strength]) + player->powers[pw_strength]++; + if (player->powers[pw_invulnerability]) + --player->powers[pw_invulnerability]; + if (player->powers[pw_invisibility]) + if (!--player->powers[pw_invisibility]) + player->mo->flags &= ~MF_SHADOW; + if (player->powers[pw_infrared]) + --player->powers[pw_infrared]; + if (player->powers[pw_ironfeet]) + --player->powers[pw_ironfeet]; + if (player->damagecount) + --player->damagecount; + if (player->bonuscount) + --player->bonuscount; + if (player->powers[pw_invulnerability]) { + if (player->powers[pw_invulnerability] > 4*32 || (player->powers[pw_invulnerability]&8)) + player->fixedcolormap = INVERSECOLORMAP; + else + player->fixedcolormap = 0; + } + else if (player->powers[pw_infrared]) { + if (player->powers[pw_infrared] > 4*32 || (player->powers[pw_infrared]&8)) + player->fixedcolormap = 1; + else + player->fixedcolormap = 0; + } else player->fixedcolormap = 0; } diff --git a/src/parameters b/src/parameters @@ -0,0 +1,38 @@ +-2 /*screen multiplier*/ +-3 /*screen multiplier*/ +-4 /*screen multiplier*/ +-altdeath +-avg +-cdrom +-comdev +-config +-deathmatch +-debugfile +-devparm +-disp +-dup +-episode +-extratic +-fast +-file +-geom +-grabmouse +-loadgame +-maxdemo +-net +-noblit +-nodraw +-nomonsters +-playdemo +-port +-record +-regdev +-respawn +-shdev +-skill +-statcopy +-timedemo +-timer +-turbo +-warp +-wart diff --git a/src/r_bsp.c b/src/r_bsp.c @@ -1,34 +1,77 @@ #include "doomdef.h" + #include "m_bbox.h" + #include "i_system.h" + #include "r_main.h" #include "r_plane.h" #include "r_things.h" + + #include "doomstat.h" #include "r_state.h" + + + + + seg_t* curline; side_t* sidedef; line_t* linedef; sector_t* frontsector; sector_t* backsector; + drawseg_t drawsegs[MAXDRAWSEGS]; drawseg_t* ds_p; + + void R_StoreWallRange ( int start, int stop ); + + + + + + + void R_ClearDrawSegs (void) { ds_p = drawsegs; } + + + + + + + + typedef struct { int first; int last; + } cliprange_t; + + #define MAXSEGS 32 + + cliprange_t* newend; cliprange_t solidsegs[MAXSEGS]; + + + + + + + + + + void R_ClipSolidWallSegment ( int first, @@ -36,16 +79,23 @@ R_ClipSolidWallSegment { cliprange_t* next; cliprange_t* start; + + + start = solidsegs; while (start->last < first-1) start++; + if (first < start->first) { if (last < start->first-1) { + + R_StoreWallRange (first, last); next = newend; newend++; + while (next != start) { *next = *(next-1); @@ -55,64 +105,115 @@ R_ClipSolidWallSegment next->last = last; return; } + + R_StoreWallRange (first, start->first - 1); + start->first = first; } + + if (last <= start->last) return; + next = start; while (last >= (next+1)->first-1) { + R_StoreWallRange (next->last + 1, (next+1)->first - 1); next++; + if (last <= next->last) { + + start->last = next->last; goto crunch; } } + + R_StoreWallRange (next->last + 1, last); + start->last = last; + + + crunch: if (next == start) { + return; } + + while (next++ != newend) { + *++start = *next; } + newend = start+1; } + + + + + + + + + + void R_ClipPassWallSegment ( int first, int last ) { cliprange_t* start; + + + start = solidsegs; while (start->last < first-1) start++; + if (first < start->first) { if (last < start->first-1) { + R_StoreWallRange (first, last); return; } + + R_StoreWallRange (first, start->first - 1); } + + if (last <= start->last) return; + while (last >= (start+1)->first-1) { + R_StoreWallRange (start->last + 1, (start+1)->first - 1); start++; + if (last <= start->last) return; } + + R_StoreWallRange (start->last + 1, last); } + + + + + + void R_ClearClipSegs (void) { solidsegs[0].first = -0x7fffffff; @@ -121,6 +222,12 @@ void R_ClearClipSegs (void) solidsegs[1].last = 0x7fffffff; newend = solidsegs+2; } + + + + + + void R_AddLine (seg_t* line) { int x1; @@ -129,46 +236,80 @@ void R_AddLine (seg_t* line) angle_t angle2; angle_t span; angle_t tspan; + curline = line; + + angle1 = R_PointToAngle (line->v1->x, line->v1->y); angle2 = R_PointToAngle (line->v2->x, line->v2->y); + + + span = angle1 - angle2; + + if (span >= ANG180) return; + + rw_angle1 = angle1; angle1 -= viewangle; angle2 -= viewangle; + tspan = angle1 + clipangle; if (tspan > 2*clipangle) { tspan -= 2*clipangle; + + if (tspan >= span) return; + angle1 = clipangle; } tspan = clipangle - angle2; if (tspan > 2*clipangle) { tspan -= 2*clipangle; + + if (tspan >= span) return; angle2 = -clipangle; } + + + angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; + + if (x1 == x2) return; + backsector = line->backsector; + + if (!backsector) goto clipsolid; + + if (backsector->ceilingheight <= frontsector->floorheight || backsector->floorheight >= frontsector->ceilingheight) goto clipsolid; + + if (backsector->ceilingheight != frontsector->ceilingheight || backsector->floorheight != frontsector->floorheight) goto clippass; + + + + + + if (backsector->ceilingpic == frontsector->ceilingpic && backsector->floorpic == frontsector->floorpic && backsector->lightlevel == frontsector->lightlevel @@ -176,12 +317,23 @@ void R_AddLine (seg_t* line) { return; } + + clippass: R_ClipPassWallSegment (x1, x2-1); return; + clipsolid: R_ClipSolidWallSegment (x1, x2-1); } + + + + + + + + int checkcoord[12][4] = { {3,0,2,1}, @@ -196,95 +348,143 @@ int checkcoord[12][4] = {2,1,3,1}, {2,1,3,0} }; + + boolean R_CheckBBox (fixed_t* bspcoord) { int boxx; int boxy; int boxpos; + fixed_t x1; fixed_t y1; fixed_t x2; fixed_t y2; + angle_t angle1; angle_t angle2; angle_t span; angle_t tspan; + cliprange_t* start; + int sx1; int sx2; + + + if (viewx <= bspcoord[BOXLEFT]) boxx = 0; else if (viewx < bspcoord[BOXRIGHT]) boxx = 1; else boxx = 2; + if (viewy >= bspcoord[BOXTOP]) boxy = 0; else if (viewy > bspcoord[BOXBOTTOM]) boxy = 1; else boxy = 2; + boxpos = (boxy<<2)+boxx; if (boxpos == 5) return true; + x1 = bspcoord[checkcoord[boxpos][0]]; y1 = bspcoord[checkcoord[boxpos][1]]; x2 = bspcoord[checkcoord[boxpos][2]]; y2 = bspcoord[checkcoord[boxpos][3]]; + + angle1 = R_PointToAngle (x1, y1) - viewangle; angle2 = R_PointToAngle (x2, y2) - viewangle; + span = angle1 - angle2; + + if (span >= ANG180) return true; + tspan = angle1 + clipangle; + if (tspan > 2*clipangle) { tspan -= 2*clipangle; + + if (tspan >= span) return false; + angle1 = clipangle; } tspan = clipangle - angle2; if (tspan > 2*clipangle) { tspan -= 2*clipangle; + + if (tspan >= span) return false; + angle2 = -clipangle; } + + + + + angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; sx1 = viewangletox[angle1]; sx2 = viewangletox[angle2]; + + if (sx1 == sx2) return false; sx2--; + start = solidsegs; while (start->last < sx2) start++; + if (sx1 >= start->first && sx2 <= start->last) { + return false; } + return true; } + + + + + + + + + void R_Subsector (int num) { int count; seg_t* line; subsector_t* sub; + #ifdef RANGECHECK if (num>=numsubsectors) I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors); #endif + sscount++; sub = &subsectors[num]; frontsector = sub->sector; count = sub->numlines; line = &segs[sub->firstline]; + if (frontsector->floorheight < viewz) { floorplane = R_FindPlane (frontsector->floorheight, @@ -293,6 +493,7 @@ void R_Subsector (int num) } else floorplane = NULL; + if (frontsector->ceilingheight > viewz || frontsector->ceilingpic == skyflatnum) { @@ -302,17 +503,30 @@ void R_Subsector (int num) } else ceilingplane = NULL; + R_AddSprites (frontsector); + while (count--) { R_AddLine (line); line++; } } + + + + + + + + + void R_RenderBSPNode (int bspnum) { node_t* bsp; int side; + + if (bspnum & NF_SUBSECTOR) { if (bspnum == -1) @@ -321,9 +535,18 @@ void R_RenderBSPNode (int bspnum) R_Subsector (bspnum&(~NF_SUBSECTOR)); return; } + bsp = &nodes[bspnum]; + + side = R_PointOnSide (viewx, viewy, bsp); + + R_RenderBSPNode (bsp->children[side]); + + if (R_CheckBBox (bsp->bbox[side^1])) R_RenderBSPNode (bsp->children[side^1]); } + + diff --git a/src/r_bsp.h b/src/r_bsp.h @@ -1,26 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __R_BSP__ #define __R_BSP__ + #ifdef __GNUG__ #pragma interface #endif + + extern seg_t* curline; extern side_t* sidedef; extern line_t* linedef; extern sector_t* frontsector; extern sector_t* backsector; + extern int rw_x; extern int rw_stopx; + extern boolean segtextured; + + extern boolean markfloor; extern boolean markceiling; + extern boolean skymap; + extern drawseg_t drawsegs[MAXDRAWSEGS]; extern drawseg_t* ds_p; + extern lighttable_t** hscalelight; extern lighttable_t** vscalelight; extern lighttable_t** dscalelight; + + typedef void (*drawfunc_t) (int start, int stop); + + + void R_ClearClipSegs (void); void R_ClearDrawSegs (void); + + void R_RenderBSPNode (int bspnum); + + #endif + + + + + diff --git a/src/r_data.c b/src/r_data.c @@ -9,7 +9,6 @@ #include "r_local.h" #include "p_local.h" #include "doomstat.h" -#include "r_sky.h" #include "r_data.h" typedef struct { diff --git a/src/r_data.h b/src/r_data.h @@ -1,17 +1,14 @@ #ifndef __R_DATA__ #define __R_DATA__ + #include "r_defs.h" #include "r_state.h" -#ifdef __GNUG__ -#pragma interface -#endif -byte* -R_GetColumn -( int tex, - int col ); -void R_InitData (void); -void R_PrecacheLevel (void); -int R_FlatNumForName (char* name); -int R_TextureNumForName (char *name); -int R_CheckTextureNumForName (char *name); + +byte* R_GetColumn(int tex, int col); +void R_InitData(void); +void R_PrecacheLevel(void); +int R_FlatNumForName (char* name); +int R_TextureNumForName (char *name); +int R_CheckTextureNumForName (char *name); + #endif diff --git a/src/r_defs.h b/src/r_defs.h @@ -1,51 +1,51 @@ #ifndef __R_DEFS__ #define __R_DEFS__ + #include "doomdef.h" #include "m_fixed.h" #include "d_think.h" #include "p_mobj.h" -#ifdef __GNUG__ -#pragma interface -#endif + #define SIL_NONE 0 #define SIL_BOTTOM 1 #define SIL_TOP 2 #define SIL_BOTH 3 #define MAXDRAWSEGS 256 -typedef struct -{ + +typedef struct { fixed_t x; fixed_t y; } vertex_t; + struct line_s; -typedef struct -{ - thinker_t thinker; - fixed_t x; - fixed_t y; - fixed_t z; + +typedef struct { + thinker_t thinker; + fixed_t x; + fixed_t y; + fixed_t z; } degenmobj_t; -typedef struct -{ - fixed_t floorheight; - fixed_t ceilingheight; - short floorpic; - short ceilingpic; - short lightlevel; - short special; - short tag; - int soundtraversed; - mobj_t* soundtarget; - int blockbox[4]; - degenmobj_t soundorg; - int validcount; - mobj_t* thinglist; - void* specialdata; - int linecount; - struct line_s** lines; + +typedef struct { + fixed_t floorheight; + fixed_t ceilingheight; + short floorpic; + short ceilingpic; + short lightlevel; + short special; + short tag; + int soundtraversed; + mobj_t* soundtarget; + int blockbox[4]; + degenmobj_t soundorg; + int validcount; + mobj_t* thinglist; + void* specialdata; + int linecount; + struct line_s** lines; } sector_t; -typedef struct -{ + +typedef struct { fixed_t textureoffset; fixed_t rowoffset; short toptexture; @@ -53,15 +53,15 @@ typedef struct short midtexture; sector_t* sector; } side_t; -typedef enum -{ + +typedef enum { ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE } slopetype_t; -typedef struct line_s -{ + +typedef struct line_s { vertex_t* v1; vertex_t* v2; fixed_t dx; @@ -77,14 +77,14 @@ typedef struct line_s int validcount; void* specialdata; } line_t; -typedef struct subsector_s -{ + +typedef struct subsector_s { sector_t* sector; short numlines; short firstline; } subsector_t; -typedef struct -{ + +typedef struct { vertex_t* v1; vertex_t* v2; fixed_t offset; @@ -94,8 +94,8 @@ typedef struct sector_t* frontsector; sector_t* backsector; } seg_t; -typedef struct -{ + +typedef struct { fixed_t x; fixed_t y; fixed_t dx; @@ -103,15 +103,16 @@ typedef struct fixed_t bbox[2][4]; unsigned short children[2]; } node_t; -typedef struct -{ - byte topdelta; - byte length; + +typedef struct { + byte topdelta; + byte length; } post_t; -typedef post_t column_t; + +typedef post_t column_t; typedef byte lighttable_t; -typedef struct drawseg_s -{ + +typedef struct drawseg_s { seg_t* curline; int x1; int x2; @@ -125,16 +126,16 @@ typedef struct drawseg_s short* sprbottomclip; short* maskedtexturecol; } drawseg_t; -typedef struct -{ - short width; - short height; - short leftoffset; - short topoffset; - int columnofs[8]; + +typedef struct { + short width; + short height; + short leftoffset; + short topoffset; + int columnofs[8]; } patch_t; -typedef struct vissprite_s -{ + +typedef struct vissprite_s { struct vissprite_s* prev; struct vissprite_s* next; int x1; @@ -151,24 +152,24 @@ typedef struct vissprite_s lighttable_t* colormap; int mobjflags; } vissprite_t; -typedef struct -{ + +typedef struct { boolean rotate; short lump[8]; byte flip[8]; } spriteframe_t; -typedef struct -{ - int numframes; - spriteframe_t* spriteframes; + +typedef struct { + int numframes; + spriteframe_t* spriteframes; } spritedef_t; -typedef struct -{ - fixed_t height; - int picnum; - int lightlevel; - int minx; - int maxx; + +typedef struct { + fixed_t height; + int picnum; + int lightlevel; + int minx; + int maxx; byte pad1; byte top[SCREENWIDTH]; byte pad2; @@ -176,4 +177,5 @@ typedef struct byte bottom[SCREENWIDTH]; byte pad4; } visplane_t; + #endif diff --git a/src/r_draw.c b/src/r_draw.c @@ -5,497 +5,277 @@ #include "r_local.h" #include "v_video.h" #include "doomstat.h" + #define MAXWIDTH 1120 #define MAXHEIGHT 832 #define SBARHEIGHT 32 -byte* viewimage; +#define FUZZTABLE 50 +#define FUZZOFF (SCREENWIDTH) + +lighttable_t* dc_colormap; +lighttable_t* ds_colormap; +byte* ds_source; +byte* viewimage; +byte* ylookup[MAXHEIGHT]; +byte* dc_source; +byte* dc_translation; +byte* translationtables; int viewwidth; int scaledviewwidth; int viewheight; int viewwindowx; -int viewwindowy; -byte* ylookup[MAXHEIGHT]; -int columnofs[MAXWIDTH]; -byte translations[3][256]; -lighttable_t* dc_colormap; -int dc_x; -int dc_yl; -int dc_yh; -fixed_t dc_iscale; +int viewwindowy; +int columnofs[MAXWIDTH]; +byte translations[3][256]; +int dc_x; +int dc_yl; +int dc_yh; +fixed_t dc_iscale; fixed_t dc_texturemid; -byte* dc_source; int dccount; -void R_DrawColumn (void) -{ - int count; - byte* dest; - fixed_t frac; - fixed_t fracstep; - count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK - if ((unsigned)dc_x >= SCREENWIDTH - || dc_yl < 0 - || dc_yh >= SCREENHEIGHT) - I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); -#endif - dest = ylookup[dc_yl] + columnofs[dc_x]; - fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; - do - { - *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; - dest += SCREENWIDTH; - frac += fracstep; - } while (count--); -} -#if 0 -void R_DrawColumn (void) -{ - int count; - byte* source; - byte* dest; - byte* colormap; - unsigned frac; - unsigned fracstep; - unsigned fracstep2; - unsigned fracstep3; - unsigned fracstep4; - count = dc_yh - dc_yl + 1; - source = dc_source; - colormap = dc_colormap; - dest = ylookup[dc_yl] + columnofs[dc_x]; - fracstep = dc_iscale<<9; - frac = (dc_texturemid + (dc_yl-centery)*dc_iscale)<<9; - fracstep2 = fracstep+fracstep; - fracstep3 = fracstep2+fracstep; - fracstep4 = fracstep3+fracstep; - while (count >= 8) - { - dest[0] = colormap[source[frac>>25]]; - dest[SCREENWIDTH] = colormap[source[(frac+fracstep)>>25]]; - dest[SCREENWIDTH*2] = colormap[source[(frac+fracstep2)>>25]]; - dest[SCREENWIDTH*3] = colormap[source[(frac+fracstep3)>>25]]; - frac += fracstep4; - dest[SCREENWIDTH*4] = colormap[source[frac>>25]]; - dest[SCREENWIDTH*5] = colormap[source[(frac+fracstep)>>25]]; - dest[SCREENWIDTH*6] = colormap[source[(frac+fracstep2)>>25]]; - dest[SCREENWIDTH*7] = colormap[source[(frac+fracstep3)>>25]]; - frac += fracstep4; - dest += SCREENWIDTH*8; - count -= 8; - } - while (count > 0) - { - *dest = colormap[source[frac>>25]]; - dest += SCREENWIDTH; - frac += fracstep; - count--; - } +int ds_y; +int ds_x1; +int ds_x2; +fixed_t ds_xfrac; +fixed_t ds_yfrac; +fixed_t ds_xstep; +fixed_t ds_ystep; +int dscount; +int fuzzpos = 0; +int fuzzoffset[FUZZTABLE] = { + FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF, + FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, + FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF, + FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, + FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF +}; + +void +R_DrawColumn() +{ + int count; + byte* dest; + fixed_t frac, fracstep; + + count = dc_yh - dc_yl; + if (count < 0) + return; + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = dc_iscale; + frac = dc_texturemid + (dc_yl-centery)*fracstep; + do { + *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; + dest += SCREENWIDTH; + frac += fracstep; + } while (count--); } -#endif -void R_DrawColumnLow (void) -{ - int count; - byte* dest; - byte* dest2; - fixed_t frac; - fixed_t fracstep; - count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK - if ((unsigned)dc_x >= SCREENWIDTH - || dc_yl < 0 - || dc_yh >= SCREENHEIGHT) - { - I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); - } -#endif - dc_x <<= 1; - dest = ylookup[dc_yl] + columnofs[dc_x]; - dest2 = ylookup[dc_yl] + columnofs[dc_x+1]; - fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; - do - { - *dest2 = *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; - dest += SCREENWIDTH; - dest2 += SCREENWIDTH; - frac += fracstep; - } while (count--); + +void +R_DrawColumnLow() +{ + byte* dest, *dest2; + fixed_t frac, fracstep; + int count; + + count = dc_yh - dc_yl; + if (count < 0) + return; + dc_x <<= 1; + dest = ylookup[dc_yl] + columnofs[dc_x]; + dest2 = ylookup[dc_yl] + columnofs[dc_x+1]; + fracstep = dc_iscale; + frac = dc_texturemid + (dc_yl-centery)*fracstep; + do { + *dest2 = *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; + dest += SCREENWIDTH; + dest2 += SCREENWIDTH; + frac += fracstep; + } while (count--); } -#define FUZZTABLE 50 -#define FUZZOFF (SCREENWIDTH) -int fuzzoffset[FUZZTABLE] = + +void +R_DrawFuzzColumn() { - FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF, - FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, - FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF, - FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, - FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF -}; -int fuzzpos = 0; -void R_DrawFuzzColumn (void) -{ - int count; - byte* dest; - fixed_t frac; - fixed_t fracstep; - if (!dc_yl) - dc_yl = 1; - if (dc_yh == viewheight-1) - dc_yh = viewheight - 2; - count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK - if ((unsigned)dc_x >= SCREENWIDTH - || dc_yl < 0 || dc_yh >= SCREENHEIGHT) - { - I_Error ("R_DrawFuzzColumn: %i to %i at %i", - dc_yl, dc_yh, dc_x); - } -#endif - /* WATCOM code - if (detailshift) - { - if (dc_x & 1) - { - outpw (GC_INDEX,GC_READMAP+(2<<8) ); - outp (SC_INDEX+1,12); - } - else - { - outpw (GC_INDEX,GC_READMAP); - outp (SC_INDEX+1,3); - } - dest = destview + dc_yl*80 + (dc_x>>1); - } - else - { - outpw (GC_INDEX,GC_READMAP+((dc_x&3)<<8) ); - outp (SC_INDEX+1,1<<(dc_x&3)); - dest = destview + dc_yl*80 + (dc_x>>2); - }*/ - dest = ylookup[dc_yl] + columnofs[dc_x]; - fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; - do - { - *dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]]; - if (++fuzzpos == FUZZTABLE) - fuzzpos = 0; - dest += SCREENWIDTH; - frac += fracstep; - } while (count--); -} -byte* dc_translation; -byte* translationtables; -void R_DrawTranslatedColumn (void) -{ - int count; - byte* dest; - fixed_t frac; - fixed_t fracstep; - count = dc_yh - dc_yl; - if (count < 0) - return; -#ifdef RANGECHECK - if ((unsigned)dc_x >= SCREENWIDTH - || dc_yl < 0 - || dc_yh >= SCREENHEIGHT) - { - I_Error ( "R_DrawColumn: %i to %i at %i", - dc_yl, dc_yh, dc_x); - } -#endif - /* Keep for fixing. - if (detailshift) - { - if (dc_x & 1) - outp (SC_INDEX+1,12); - else - outp (SC_INDEX+1,3); - dest = destview + dc_yl*80 + (dc_x>>1); - } - else - { - outp (SC_INDEX+1,1<<(dc_x&3)); - dest = destview + dc_yl*80 + (dc_x>>2); - }*/ - dest = ylookup[dc_yl] + columnofs[dc_x]; - fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; - do - { - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; - dest += SCREENWIDTH; - frac += fracstep; - } while (count--); -} -void R_InitTranslationTables (void) + byte* dest; + fixed_t frac, fracstep; + int count; + + if (!dc_yl) dc_yl = 1; + if (dc_yh == viewheight-1) dc_yh = viewheight - 2; + count = dc_yh - dc_yl; + if (count < 0) + return; + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = dc_iscale; + frac = dc_texturemid + (dc_yl-centery)*fracstep; + do { + *dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]]; + if (++fuzzpos == FUZZTABLE) + fuzzpos = 0; + dest += SCREENWIDTH; + frac += fracstep; + } while (count--); +} + +void +R_DrawTranslatedColumn() { - int i; - translationtables = Z_Malloc (256*3+255, PU_STATIC, 0); - translationtables = (byte*)(((long)translationtables + 255 )& ~255); - for (i=0 ; i<256 ; i++) - { - if (i >= 0x70 && i<= 0x7f) - { - translationtables[i] = 0x60 + (i&0xf); - translationtables [i+256] = 0x40 + (i&0xf); - translationtables [i+512] = 0x20 + (i&0xf); - } - else - { - translationtables[i] = translationtables[i+256] - = translationtables[i+512] = i; + byte* dest; + fixed_t frac, fracstep; + int count; + + count = dc_yh - dc_yl; + if (count < 0) + return; + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = dc_iscale; + frac = dc_texturemid + (dc_yl-centery)*fracstep; + do { + *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; + dest += SCREENWIDTH; + frac += fracstep; + } while (count--); +} + +void +R_InitTranslationTables() +{ + int i; + + translationtables = Z_Malloc (256*3+255, PU_STATIC, 0); + translationtables = (byte*)(((long)translationtables + 255 )& ~255); + for (i = 0; i < 256; ++i) { + if (i >= 0x70 && i<= 0x7f) { + translationtables[i] = 0x60 + (i&0xf); + translationtables [i+256] = 0x40 + (i&0xf); + translationtables [i+512] = 0x20 + (i&0xf); + } else translationtables[i] = translationtables[i+256] = translationtables[i+512] = i; } - } } -int ds_y; -int ds_x1; -int ds_x2; -lighttable_t* ds_colormap; -fixed_t ds_xfrac; -fixed_t ds_yfrac; -fixed_t ds_xstep; -fixed_t ds_ystep; -byte* ds_source; -int dscount; -void R_DrawSpan (void) -{ - fixed_t xfrac; - fixed_t yfrac; - byte* dest; - int count; - int spot; -#ifdef RANGECHECK - if (ds_x2 < ds_x1 - || ds_x1<0 - || ds_x2>=SCREENWIDTH - || (unsigned)ds_y>SCREENHEIGHT) - { - I_Error( "R_DrawSpan: %i to %i at %i", - ds_x1,ds_x2,ds_y); - } -#endif - xfrac = ds_xfrac; - yfrac = ds_yfrac; - dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1; - do - { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); - *dest++ = ds_colormap[ds_source[spot]]; - xfrac += ds_xstep; - yfrac += ds_ystep; - } while (count--); -} -#if 0 -void R_DrawSpan (void) -{ - unsigned position, step; - byte* source; - byte* colormap; - byte* dest; - unsigned count; - usingned spot; - unsigned value; - unsigned temp; - unsigned xtemp; - unsigned ytemp; - position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff); - step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff); - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; - while (count >= 4) - { - ytemp = position>>4; - ytemp = ytemp & 4032; - xtemp = position>>26; - spot = xtemp | ytemp; - position += step; - dest[0] = colormap[source[spot]]; - ytemp = position>>4; - ytemp = ytemp & 4032; - xtemp = position>>26; - spot = xtemp | ytemp; - position += step; - dest[1] = colormap[source[spot]]; - ytemp = position>>4; - ytemp = ytemp & 4032; - xtemp = position>>26; - spot = xtemp | ytemp; - position += step; - dest[2] = colormap[source[spot]]; - ytemp = position>>4; - ytemp = ytemp & 4032; - xtemp = position>>26; - spot = xtemp | ytemp; - position += step; - dest[3] = colormap[source[spot]]; - count -= 4; - dest += 4; - } - while (count > 0) - { - ytemp = position>>4; - ytemp = ytemp & 4032; - xtemp = position>>26; - spot = xtemp | ytemp; - position += step; - *dest++ = colormap[source[spot]]; - count--; - } -} -#endif -void R_DrawSpanLow (void) -{ - fixed_t xfrac; - fixed_t yfrac; - byte* dest; - int count; - int spot; -#ifdef RANGECHECK - if (ds_x2 < ds_x1 - || ds_x1<0 - || ds_x2>=SCREENWIDTH - || (unsigned)ds_y>SCREENHEIGHT) - { - I_Error( "R_DrawSpan: %i to %i at %i", - ds_x1,ds_x2,ds_y); - } -#endif - xfrac = ds_xfrac; - yfrac = ds_yfrac; - ds_x1 <<= 1; - ds_x2 <<= 1; - dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1; - do - { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); - *dest++ = ds_colormap[ds_source[spot]]; - *dest++ = ds_colormap[ds_source[spot]]; - xfrac += ds_xstep; - yfrac += ds_ystep; - } while (count--); + + +void +R_DrawSpan() +{ + byte* dest; + fixed_t xfrac, yfrac; + int count, spot; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + dest = ylookup[ds_y] + columnofs[ds_x1]; + count = ds_x2 - ds_x1; + do { + spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + *dest++ = ds_colormap[ds_source[spot]]; + xfrac += ds_xstep; + yfrac += ds_ystep; + } while (count--); +} + +void +R_DrawSpanLow() +{ + byte* dest; + fixed_t xfrac, yfrac; + int count, spot; + + xfrac = ds_xfrac; + yfrac = ds_yfrac; + ds_x1 <<= 1; + ds_x2 <<= 1; + dest = ylookup[ds_y] + columnofs[ds_x1]; + count = ds_x2 - ds_x1; + do { + spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + *dest++ = ds_colormap[ds_source[spot]]; + *dest++ = ds_colormap[ds_source[spot]]; + xfrac += ds_xstep; + yfrac += ds_ystep; + } while (count--); +} + +void +R_InitBuffer(int width, int height) +{ + int i; + + viewwindowx = (SCREENWIDTH-width) >> 1; + for (i = 0; i < width; ++i) + columnofs[i] = viewwindowx + i; + if (width == SCREENWIDTH) + viewwindowy = 0; + else + viewwindowy = (SCREENHEIGHT-SBARHEIGHT-height) >> 1; + for (i=0 ; i<height ; i++) + ylookup[i] = screens[0] + (i+viewwindowy)*SCREENWIDTH; } + void -R_InitBuffer -( int width, - int height ) -{ - int i; - viewwindowx = (SCREENWIDTH-width) >> 1; - for (i=0 ; i<width ; i++) - columnofs[i] = viewwindowx + i; - if (width == SCREENWIDTH) - viewwindowy = 0; - else - viewwindowy = (SCREENHEIGHT-SBARHEIGHT-height) >> 1; - for (i=0 ; i<height ; i++) - ylookup[i] = screens[0] + (i+viewwindowy)*SCREENWIDTH; -} -void R_FillBackScreen (void) -{ - byte* src; - byte* dest; - int x; - int y; - patch_t* patch; - char name1[] = "FLOOR7_2"; - char name2[] = "GRNROCK"; - char* name; - if (scaledviewwidth == 320) - return; - if ( gamemode == commercial) - name = name2; - else +R_FillBackScreen() +{ + patch_t* patch; + byte* src, *dest; + char* name; + int x, y; + char name1[] = "FLOOR7_2"; + + if (scaledviewwidth == 320) + return; name = name1; - src = W_CacheLumpName (name, PU_CACHE); - dest = screens[1]; - for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) - { - for (x=0 ; x<SCREENWIDTH/64 ; x++) - { - memcpy (dest, src+((y&63)<<6), 64); - dest += 64; - } - if (SCREENWIDTH&63) - { - memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); - dest += (SCREENWIDTH&63); - } - } - patch = W_CacheLumpName ("brdr_t",PU_CACHE); - for (x=0 ; x<scaledviewwidth ; x+=8) - V_DrawPatch (viewwindowx+x,viewwindowy-8,1,patch); - patch = W_CacheLumpName ("brdr_b",PU_CACHE); - for (x=0 ; x<scaledviewwidth ; x+=8) - V_DrawPatch (viewwindowx+x,viewwindowy+viewheight,1,patch); - patch = W_CacheLumpName ("brdr_l",PU_CACHE); - for (y=0 ; y<viewheight ; y+=8) - V_DrawPatch (viewwindowx-8,viewwindowy+y,1,patch); - patch = W_CacheLumpName ("brdr_r",PU_CACHE); - for (y=0 ; y<viewheight ; y+=8) - V_DrawPatch (viewwindowx+scaledviewwidth,viewwindowy+y,1,patch); - V_DrawPatch (viewwindowx-8, - viewwindowy-8, - 1, - W_CacheLumpName ("brdr_tl",PU_CACHE)); - V_DrawPatch (viewwindowx+scaledviewwidth, - viewwindowy-8, - 1, - W_CacheLumpName ("brdr_tr",PU_CACHE)); - V_DrawPatch (viewwindowx-8, - viewwindowy+viewheight, - 1, - W_CacheLumpName ("brdr_bl",PU_CACHE)); - V_DrawPatch (viewwindowx+scaledviewwidth, - viewwindowy+viewheight, - 1, - W_CacheLumpName ("brdr_br",PU_CACHE)); -} + src = W_CacheLumpName (name, PU_CACHE); + dest = screens[1]; + for (y = 0; y < SCREENHEIGHT-SBARHEIGHT; ++y) { + for (x = 0; x < SCREENWIDTH/64; ++x) { + memcpy(dest, src+((y&63)<<6), 64); + dest += 64; + } + if (SCREENWIDTH&63) { + memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); + dest += (SCREENWIDTH&63); + } + } + patch = W_CacheLumpName("brdr_t",PU_CACHE); + for (x = 0; x < scaledviewwidth; x += 8) V_DrawPatch(viewwindowx+x,viewwindowy-8,1,patch); + patch = W_CacheLumpName ("brdr_b",PU_CACHE); + for (x = 0; x < scaledviewwidth; x += 8) V_DrawPatch(viewwindowx+x,viewwindowy+viewheight,1,patch); + patch = W_CacheLumpName ("brdr_l",PU_CACHE); + for (y = 0; y < viewheight; y += 8) V_DrawPatch(viewwindowx-8,viewwindowy+y,1,patch); + patch = W_CacheLumpName ("brdr_r",PU_CACHE); + for (y = 0; y < viewheight; y += 8) V_DrawPatch(viewwindowx+scaledviewwidth,viewwindowy+y,1,patch); + V_DrawPatch(viewwindowx-8, viewwindowy-8, 1, W_CacheLumpName("brdr_tl",PU_CACHE)); + V_DrawPatch(viewwindowx+scaledviewwidth, viewwindowy-8, 1, W_CacheLumpName("brdr_tr",PU_CACHE)); + V_DrawPatch(viewwindowx-8, viewwindowy + viewheight, 1, W_CacheLumpName("brdr_bl",PU_CACHE)); + V_DrawPatch(viewwindowx+scaledviewwidth, viewwindowy+viewheight, 1, W_CacheLumpName("brdr_br",PU_CACHE)); +} + void -R_VideoErase -( unsigned ofs, - int count ) -{ - memcpy (screens[0]+ofs, screens[1]+ofs, count); -} +R_VideoErase(unsigned ofs, int count) +{ + memcpy(screens[0]+ofs, screens[1]+ofs, count); +} + +void V_MarkRect(int x, int y, int width, int height); + void -V_MarkRect -( int x, - int y, - int width, - int height ); -void R_DrawViewBorder (void) -{ - int top; - int side; - int ofs; - int i; - if (scaledviewwidth == SCREENWIDTH) - return; - top = ((SCREENHEIGHT-SBARHEIGHT)-viewheight)/2; - side = (SCREENWIDTH-scaledviewwidth)/2; - R_VideoErase (0, top*SCREENWIDTH+side); - ofs = (viewheight+top)*SCREENWIDTH-side; - R_VideoErase (ofs, top*SCREENWIDTH+side); - ofs = top*SCREENWIDTH + SCREENWIDTH-side; - side <<= 1; - for (i=1 ; i<viewheight ; i++) - { - R_VideoErase (ofs, side); - ofs += SCREENWIDTH; - } - V_MarkRect (0,0,SCREENWIDTH, SCREENHEIGHT-SBARHEIGHT); -} +R_DrawViewBorder() +{ + int top, side, ofs, i; + + if (scaledviewwidth == SCREENWIDTH) + return; + top = ((SCREENHEIGHT-SBARHEIGHT)-viewheight)/2; + side = (SCREENWIDTH-scaledviewwidth)/2; + R_VideoErase(0, top*SCREENWIDTH+side); + ofs = (viewheight+top)*SCREENWIDTH-side; + R_VideoErase(ofs, top*SCREENWIDTH+side); + ofs = top*SCREENWIDTH + SCREENWIDTH-side; + side <<= 1; + for (i = 1; i < viewheight; ++i) { + R_VideoErase(ofs, side); + ofs += SCREENWIDTH; + } + V_MarkRect(0, 0, SCREENWIDTH, SCREENHEIGHT - SBARHEIGHT); +} diff --git a/src/r_draw.h b/src/r_draw.h @@ -1,43 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __R_DRAW__ #define __R_DRAW__ + + #ifdef __GNUG__ #pragma interface #endif + + extern lighttable_t* dc_colormap; extern int dc_x; extern int dc_yl; extern int dc_yh; extern fixed_t dc_iscale; extern fixed_t dc_texturemid; + + extern byte* dc_source; + + + + + void R_DrawColumn (void); void R_DrawColumnLow (void); + + void R_DrawFuzzColumn (void); void R_DrawFuzzColumnLow (void); + + + + void R_DrawTranslatedColumn (void); void R_DrawTranslatedColumnLow (void); + void R_VideoErase ( unsigned ofs, int count ); + extern int ds_y; extern int ds_x1; extern int ds_x2; + extern lighttable_t* ds_colormap; + extern fixed_t ds_xfrac; extern fixed_t ds_yfrac; extern fixed_t ds_xstep; extern fixed_t ds_ystep; + + extern byte* ds_source; + extern byte* translationtables; extern byte* dc_translation; + + + + void R_DrawSpan (void); + + void R_DrawSpanLow (void); + + void R_InitBuffer ( int width, int height ); + + + + void R_InitTranslationTables (void); + + + + void R_FillBackScreen (void); + + void R_DrawViewBorder (void); + + + #endif + + + + + diff --git a/src/r_local.h b/src/r_local.h @@ -1,5 +1,6 @@ #ifndef __R_LOCAL__ #define __R_LOCAL__ + #include "tables.h" #include "doomdef.h" #include "r_data.h" @@ -10,4 +11,8 @@ #include "r_data.h" #include "r_things.h" #include "r_draw.h" + +extern int skytexture; +extern int skytexturemid; + #endif diff --git a/src/r_main.c b/src/r_main.c @@ -1,21 +1,27 @@ #include <stdlib.h> #include <math.h> + #include "doomdef.h" #include "d_net.h" #include "m_bbox.h" #include "r_local.h" -#include "r_sky.h" -#define FIELDOFVIEW 2048 + +#define FIELDOFVIEW 2048 +#define DISTMAP 2 + +extern lighttable_t** walllights; +extern int detailLevel; +extern int screenblocks; + int viewangleoffset; -int validcount = 1; +int validcount = 1; lighttable_t* fixedcolormap; -extern lighttable_t** walllights; int centerx; int centery; fixed_t centerxfrac; fixed_t centeryfrac; fixed_t projection; -int framecount; +int framecount; int sscount; int linecount; int loopcount; @@ -26,7 +32,7 @@ angle_t viewangle; fixed_t viewcos; fixed_t viewsin; player_t* viewplayer; -int detailshift; +int detailshift; angle_t clipangle; int viewangletox[FINEANGLES/2]; angle_t xtoviewangle[SCREENWIDTH+1]; @@ -34,517 +40,365 @@ fixed_t* finecosine = &finesine[FINEANGLES/4]; lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t* scalelightfixed[MAXLIGHTSCALE]; lighttable_t* zlight[LIGHTLEVELS][MAXLIGHTZ]; -int extralight; -void (*colfunc) (void); -void (*basecolfunc) (void); -void (*fuzzcolfunc) (void); -void (*transcolfunc) (void); -void (*spanfunc) (void); +int extralight; +boolean setsizeneeded; +int setblocks; +int setdetail; +int skyflatnum; +int skytexture; +int skytexturemid; + +void (*colfunc) (); +void (*basecolfunc) (); +void (*fuzzcolfunc) (); +void (*transcolfunc) (); +void (*spanfunc) (); + void -R_AddPointToBox -( int x, - int y, - fixed_t* box ) +R_AddPointToBox(int x, int y, fixed_t* box) { - if (x< box[BOXLEFT]) - box[BOXLEFT] = x; - if (x> box[BOXRIGHT]) - box[BOXRIGHT] = x; - if (y< box[BOXBOTTOM]) - box[BOXBOTTOM] = y; - if (y> box[BOXTOP]) - box[BOXTOP] = y; + if (x< box[BOXLEFT]) box[BOXLEFT] = x; + if (x> box[BOXRIGHT]) box[BOXRIGHT] = x; + if (y< box[BOXBOTTOM]) box[BOXBOTTOM] = y; + if (y> box[BOXTOP]) box[BOXTOP] = y; } int -R_PointOnSide -( fixed_t x, - fixed_t y, - node_t* node ) +R_PointOnSide(fixed_t x, fixed_t y, node_t* node) { - fixed_t dx; - fixed_t dy; - fixed_t left; - fixed_t right; - if (!node->dx) - { - if (x <= node->x) - return node->dy > 0; - return node->dy < 0; - } - if (!node->dy) - { - if (y <= node->y) - return node->dx < 0; - return node->dx > 0; - } - dx = (x - node->x); - dy = (y - node->y); - if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) - { - if ( (node->dy ^ dx) & 0x80000000 ) - { - return 1; + fixed_t dx, dy, left, right; + + if (!node->dx) { + if (x <= node->x) + return node->dy > 0; + return node->dy < 0; } - return 0; - } - left = FixedMul ( node->dy>>FRACBITS , dx ); - right = FixedMul ( dy , node->dx>>FRACBITS ); - if (right < left) - { - return 0; - } - return 1; + if (!node->dy) { + if (y <= node->y) + return node->dx < 0; + return node->dx > 0; + } + dx = (x - node->x); + dy = (y - node->y); + if ((node->dy ^ node->dx ^ dx ^ dy)&0x80000000) { + if ((node->dy ^ dx) & 0x80000000) + return 1; + return 0; + } + left = FixedMul(node->dy>>FRACBITS , dx); + right = FixedMul(dy , node->dx>>FRACBITS); + if (right < left) + return 0; + return 1; } + int -R_PointOnSegSide -( fixed_t x, - fixed_t y, - seg_t* line ) +R_PointOnSegSide(fixed_t x, fixed_t y, seg_t* line) { - fixed_t lx; - fixed_t ly; - fixed_t ldx; - fixed_t ldy; - fixed_t dx; - fixed_t dy; - fixed_t left; - fixed_t right; - lx = line->v1->x; - ly = line->v1->y; - ldx = line->v2->x - lx; - ldy = line->v2->y - ly; - if (!ldx) - { - if (x <= lx) - return ldy > 0; - return ldy < 0; - } - if (!ldy) - { - if (y <= ly) - return ldx < 0; - return ldx > 0; - } - dx = (x - lx); - dy = (y - ly); - if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) - { - if ( (ldy ^ dx) & 0x80000000 ) - { - return 1; - } - return 0; - } - left = FixedMul ( ldy>>FRACBITS , dx ); - right = FixedMul ( dy , ldx>>FRACBITS ); - if (right < left) - { - return 0; - } - return 1; -} -angle_t -R_PointToAngle -( fixed_t x, - fixed_t y ) -{ - x -= viewx; - y -= viewy; - if ( (!x) && (!y) ) - return 0; - if (x>= 0) - { - if (y>= 0) - { - if (x>y) - { - return tantoangle[ SlopeDiv(y,x)]; - } - else - { - return ANG90-1-tantoangle[ SlopeDiv(x,y)]; - } - } - else - { - y = -y; - if (x>y) - { - return -tantoangle[SlopeDiv(y,x)]; - } - else - { - return ANG270+tantoangle[ SlopeDiv(x,y)]; - } + fixed_t lx, ly, ldx, ldy, dx, dy, left, right; + + lx = line->v1->x; + ly = line->v1->y; + ldx = line->v2->x - lx; + ldy = line->v2->y - ly; + if (!ldx) { + if (x <= lx) + return ldy > 0; + return ldy < 0; } - } - else - { - x = -x; - if (y>= 0) - { - if (x>y) - { - return ANG180-1-tantoangle[ SlopeDiv(y,x)]; - } - else - { - return ANG90+ tantoangle[ SlopeDiv(x,y)]; - } + if (!ldy) { + if (y <= ly) + return ldx < 0; + return ldx > 0; } - else - { - y = -y; - if (x>y) - { - return ANG180+tantoangle[ SlopeDiv(y,x)]; - } - else - { - return ANG270-1-tantoangle[ SlopeDiv(x,y)]; - } + dx = (x - lx); + dy = (y - ly); + if ((ldy ^ ldx ^ dx ^ dy)&0x80000000) { + if ((ldy ^ dx) & 0x80000000) + return 1; + return 0; } - } - return 0; + left = FixedMul(ldy>>FRACBITS , dx); + right = FixedMul(dy , ldx>>FRACBITS); + if (right < left) + return 0; + return 1; } + angle_t -R_PointToAngle2 -( fixed_t x1, - fixed_t y1, - fixed_t x2, - fixed_t y2 ) -{ - viewx = x1; - viewy = y1; - return R_PointToAngle (x2, y2); -} -fixed_t -R_PointToDist -( fixed_t x, - fixed_t y ) +R_PointToAngle(fixed_t x, fixed_t y) { - int angle; - fixed_t dx; - fixed_t dy; - fixed_t temp; - fixed_t dist; - dx = abs(x - viewx); - dy = abs(y - viewy); - if (dy>dx) - { - temp = dx; - dx = dy; - dy = temp; - } - angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT; - dist = FixedDiv (dx, finesine[angle] ); - return dist; + x -= viewx; + y -= viewy; + if ((!x) && (!y)) + return 0; + if (x>= 0) { + if (y>= 0) { + if (x>y) + return tantoangle[ SlopeDiv(y,x)]; + else return ANG90-1-tantoangle[ SlopeDiv(x,y)]; + } + else { + y = -y; + if (x>y) + return -tantoangle[SlopeDiv(y,x)]; + else return ANG270+tantoangle[ SlopeDiv(x,y)]; + } + } else { + x = -x; + if (y>= 0) { + if (x > y) + return ANG180-1-tantoangle[ SlopeDiv(y,x)]; + else return ANG90+ tantoangle[ SlopeDiv(x,y)]; + } else { + y = -y; + if (x > y) + return ANG180+tantoangle[ SlopeDiv(y,x)]; + else return ANG270-1-tantoangle[ SlopeDiv(x,y)]; + } + } + return 0; } -void R_InitPointToAngle (void) + +angle_t +R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) { -#if 0 - int i; - long t; - float f; - for (i=0 ; i<=SLOPERANGE ; i++) - { - f = atan( (float)i/SLOPERANGE )/(3.141592657*2); - t = 0xffffffff*f; - tantoangle[i] = t; - } -#endif + viewx = x1; + viewy = y1; + return R_PointToAngle(x2, y2); } -fixed_t R_ScaleFromGlobalAngle (angle_t visangle) -{ - fixed_t scale; - int anglea; - int angleb; - int sinea; - int sineb; - fixed_t num; - int den; -#if 0 + +fixed_t +R_PointToDist(fixed_t x, fixed_t y) { - fixed_t dist; - fixed_t z; - fixed_t sinv; - fixed_t cosv; - sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; - dist = FixedDiv (rw_distance, sinv); - cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; - z = abs(FixedMul (dist, cosv)); - scale = FixedDiv(projection, z); - return scale; -} -#endif - anglea = ANG90 + (visangle-viewangle); - angleb = ANG90 + (visangle-rw_normalangle); - sinea = finesine[anglea>>ANGLETOFINESHIFT]; - sineb = finesine[angleb>>ANGLETOFINESHIFT]; - num = FixedMul(projection,sineb)<<detailshift; - den = FixedMul(rw_distance,sinea); - if (den > num>>16) - { - scale = FixedDiv (num, den); - if (scale > 64*FRACUNIT) - scale = 64*FRACUNIT; - else if (scale < 256) - scale = 256; - } - else - scale = 64*FRACUNIT; - return scale; + fixed_t dx, dy, temp, dist; + int angle; + + dx = abs(x - viewx); + dy = abs(y - viewy); + if (dy > dx) { + temp = dx; + dx = dy; + dy = temp; + } + angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT; + dist = FixedDiv (dx, finesine[angle] ); + return dist; } -void R_InitTables (void) + +fixed_t +R_ScaleFromGlobalAngle(angle_t visangle) { -#if 0 - int i; - float a; - float fv; - int t; - for (i=0 ; i<FINEANGLES/2 ; i++) - { - a = (i-FINEANGLES/4+0.5)*PI*2/FINEANGLES; - fv = FRACUNIT*tan (a); - t = fv; - finetangent[i] = t; - } - for (i=0 ; i<5*FINEANGLES/4 ; i++) - { - a = (i+0.5)*PI*2/FINEANGLES; - t = FRACUNIT*sin (a); - finesine[i] = t; - } -#endif + fixed_t scale, num; + int anglea, angleb, sinea, sineb, den; + anglea = ANG90 + (visangle-viewangle); + angleb = ANG90 + (visangle-rw_normalangle); + sinea = finesine[anglea>>ANGLETOFINESHIFT]; + sineb = finesine[angleb>>ANGLETOFINESHIFT]; + num = FixedMul(projection,sineb)<<detailshift; + den = FixedMul(rw_distance,sinea); + if (den > num>>16) { + scale = FixedDiv(num, den); + if (scale > 64*FRACUNIT) scale = 64*FRACUNIT; + if (scale < 256) scale = 256; + } + else scale = 64*FRACUNIT; + return scale; } -void R_InitTextureMapping (void) + +void +R_InitTextureMapping() { - int i; - int x; - int t; - fixed_t focallength; - focallength = FixedDiv (centerxfrac, - finetangent[FINEANGLES/4+FIELDOFVIEW/2] ); - for (i=0 ; i<FINEANGLES/2 ; i++) - { - if (finetangent[i] > FRACUNIT*2) - t = -1; - else if (finetangent[i] < -FRACUNIT*2) - t = viewwidth+1; - else - { - t = FixedMul (finetangent[i], focallength); - t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; - if (t < -1) - t = -1; - else if (t>viewwidth+1) - t = viewwidth+1; + fixed_t focallength; + int i, x, t; + + focallength = FixedDiv(centerxfrac, finetangent[FINEANGLES/4+FIELDOFVIEW/2]); + for (i = 0; i < FINEANGLES/2; ++i) { + if (finetangent[i] > FRACUNIT * 2) + t = -1; + else if + (finetangent[i] < -FRACUNIT*2) t = viewwidth+1; + else { + t = FixedMul (finetangent[i], focallength); + t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; + if (t < -1) + t = -1; + if (t>viewwidth+1) + t = viewwidth+1; + } + viewangletox[i] = t; + } + for (x = 0; x <= viewwidth; ++x) { + i = 0; + while (viewangletox[i]>x) + ++i; + xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90; + } + for (i = 0; i < FINEANGLES/2; ++i) { + t = centerx - FixedMul(finetangent[i], focallength);; + if (viewangletox[i] == -1) + viewangletox[i] = 0; + if (viewangletox[i] == viewwidth+1) + viewangletox[i] = viewwidth; } - viewangletox[i] = t; - } - for (x=0;x<=viewwidth;x++) - { - i = 0; - while (viewangletox[i]>x) - i++; - xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90; - } - for (i=0 ; i<FINEANGLES/2 ; i++) - { - t = FixedMul (finetangent[i], focallength); - t = centerx - t; - if (viewangletox[i] == -1) - viewangletox[i] = 0; - else if (viewangletox[i] == viewwidth+1) - viewangletox[i] = viewwidth; - } - clipangle = xtoviewangle[0]; + clipangle = xtoviewangle[0]; } -#define DISTMAP 2 -void R_InitLightTables (void) + +void +R_InitLightTables() { - int i; - int j; - int level; - int startmap; - int scale; - for (i=0 ; i< LIGHTLEVELS ; i++) - { - startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; - for (j=0 ; j<MAXLIGHTZ ; j++) - { - scale = FixedDiv ((SCREENWIDTH/2*FRACUNIT), (j+1)<<LIGHTZSHIFT); - scale >>= LIGHTSCALESHIFT; - level = startmap - scale/DISTMAP; - if (level < 0) - level = 0; - if (level >= NUMCOLORMAPS) - level = NUMCOLORMAPS-1; - zlight[i][j] = colormaps + level*256; + int i, j, level, startmap, scale; + + for (i = 0; i < LIGHTLEVELS; ++i) { + startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; + for (j = 0; j < MAXLIGHTZ; ++j) { + scale = FixedDiv ((SCREENWIDTH/2*FRACUNIT), (j+1)<<LIGHTZSHIFT); + scale >>= LIGHTSCALESHIFT; + level = startmap - scale/DISTMAP; + if (level < 0) + level = 0; + if (level >= NUMCOLORMAPS) + level = NUMCOLORMAPS-1; + zlight[i][j] = colormaps + level*256; + } } - } } -boolean setsizeneeded; -int setblocks; -int setdetail; + void -R_SetViewSize -( int blocks, - int detail ) +R_SetViewSize(int blocks, int detail) { - setsizeneeded = true; - setblocks = blocks; - setdetail = detail; + setsizeneeded = true; + setblocks = blocks; + setdetail = detail; } -void R_ExecuteSetViewSize (void) + +void +R_ExecuteSetViewSize() { - fixed_t cosadj; - fixed_t dy; - int i; - int j; - int level; - int startmap; - setsizeneeded = false; - if (setblocks == 11) - { - scaledviewwidth = SCREENWIDTH; - viewheight = SCREENHEIGHT; - } - else - { - scaledviewwidth = setblocks*32; - viewheight = (setblocks*168/10)&~7; - } - detailshift = setdetail; - viewwidth = scaledviewwidth>>detailshift; - centery = viewheight/2; - centerx = viewwidth/2; - centerxfrac = centerx<<FRACBITS; - centeryfrac = centery<<FRACBITS; - projection = centerxfrac; - if (!detailshift) - { - colfunc = basecolfunc = R_DrawColumn; - fuzzcolfunc = R_DrawFuzzColumn; - transcolfunc = R_DrawTranslatedColumn; - spanfunc = R_DrawSpan; - } - else - { - colfunc = basecolfunc = R_DrawColumnLow; - fuzzcolfunc = R_DrawFuzzColumn; - transcolfunc = R_DrawTranslatedColumn; - spanfunc = R_DrawSpanLow; - } - R_InitBuffer (scaledviewwidth, viewheight); - R_InitTextureMapping (); - pspritescale = FRACUNIT*viewwidth/SCREENWIDTH; - pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth; - for (i=0 ; i<viewwidth ; i++) - screenheightarray[i] = viewheight; - for (i=0 ; i<viewheight ; i++) - { - dy = ((i-viewheight/2)<<FRACBITS)+FRACUNIT/2; - dy = abs(dy); - yslope[i] = FixedDiv ( (viewwidth<<detailshift)/2*FRACUNIT, dy); - } - for (i=0 ; i<viewwidth ; i++) - { - cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]); - distscale[i] = FixedDiv (FRACUNIT,cosadj); - } - for (i=0 ; i< LIGHTLEVELS ; i++) - { - startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; - for (j=0 ; j<MAXLIGHTSCALE ; j++) - { - level = startmap - j*SCREENWIDTH/(viewwidth<<detailshift)/DISTMAP; - if (level < 0) - level = 0; - if (level >= NUMCOLORMAPS) - level = NUMCOLORMAPS-1; - scalelight[i][j] = colormaps + level*256; + fixed_t cosadj, dy; + int i, j, level, startmap; + + setsizeneeded = false; + if (setblocks == 11) { + scaledviewwidth = SCREENWIDTH; + viewheight = SCREENHEIGHT; + } else { + scaledviewwidth = setblocks * 32; + viewheight = (setblocks * 168/10) & ~7; + } + detailshift = setdetail; + viewwidth = scaledviewwidth>>detailshift; + centery = viewheight/2; + centerx = viewwidth/2; + centerxfrac = centerx<<FRACBITS; + centeryfrac = centery<<FRACBITS; + projection = centerxfrac; + if (!detailshift) { + colfunc = basecolfunc = R_DrawColumn; + fuzzcolfunc = R_DrawFuzzColumn; + transcolfunc = R_DrawTranslatedColumn; + spanfunc = R_DrawSpan; + } else { + colfunc = basecolfunc = R_DrawColumnLow; + fuzzcolfunc = R_DrawFuzzColumn; + transcolfunc = R_DrawTranslatedColumn; + spanfunc = R_DrawSpanLow; + } + R_InitBuffer(scaledviewwidth, viewheight); + R_InitTextureMapping(); + pspritescale = FRACUNIT*viewwidth/SCREENWIDTH; + pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth; + for (i = 0; i < viewwidth; ++i) + screenheightarray[i] = viewheight; + for (i = 0; i < viewheight; ++i) { + dy = ((i-viewheight/2)<<FRACBITS)+FRACUNIT/2; + dy = abs(dy); + yslope[i] = FixedDiv ( (viewwidth<<detailshift)/2*FRACUNIT, dy); + } + for (i = 0; i < viewwidth; ++i) { + cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]); + distscale[i] = FixedDiv (FRACUNIT,cosadj); + } + for (i = 0; i < LIGHTLEVELS; ++i) { + startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; + for (j = 0; j <MAXLIGHTSCALE; ++j) { + level = startmap - j*SCREENWIDTH/(viewwidth<<detailshift)/DISTMAP; + if (level < 0) + level = 0; + if (level >= NUMCOLORMAPS) + level = NUMCOLORMAPS-1; + scalelight[i][j] = colormaps + level*256; + } } - } } -extern int detailLevel; -extern int screenblocks; -void R_Init (void) + +void +R_Init() { - R_InitData (); - printf ("\nR_InitData"); - R_InitPointToAngle (); - printf ("\nR_InitPointToAngle"); - R_InitTables (); - printf ("\nR_InitTables"); - R_SetViewSize (screenblocks, detailLevel); - R_InitPlanes (); - printf ("\nR_InitPlanes"); - R_InitLightTables (); - printf ("\nR_InitLightTables"); - R_InitSkyMap (); - printf ("\nR_InitSkyMap"); - R_InitTranslationTables (); - printf ("\nR_InitTranslationsTables"); - framecount = 0; + R_InitData(); + R_SetViewSize(screenblocks, detailLevel); + R_InitPlanes(); + R_InitLightTables(); + skytexturemid = 100 * FRACUNIT; + R_InitTranslationTables(); + framecount = 0; } + subsector_t* -R_PointInSubsector -( fixed_t x, - fixed_t y ) +R_PointInSubsector(fixed_t x, fixed_t y) { - node_t* node; - int side; - int nodenum; - if (!numnodes) - return subsectors; - nodenum = numnodes-1; - while (! (nodenum & NF_SUBSECTOR) ) - { - node = &nodes[nodenum]; - side = R_PointOnSide (x, y, node); - nodenum = node->children[side]; - } - return &subsectors[nodenum & ~NF_SUBSECTOR]; + node_t* node; + int side, nodenum; + + if (!numnodes) + return subsectors; + nodenum = numnodes-1; + while (!(nodenum & NF_SUBSECTOR)) { + node = &nodes[nodenum]; + side = R_PointOnSide (x, y, node); + nodenum = node->children[side]; + } + return &subsectors[nodenum & ~NF_SUBSECTOR]; } -void R_SetupFrame (player_t* player) -{ - int i; - viewplayer = player; - viewx = player->mo->x; - viewy = player->mo->y; - viewangle = player->mo->angle + viewangleoffset; - extralight = player->extralight; - viewz = player->viewz; - viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; - viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; - sscount = 0; - if (player->fixedcolormap) - { - fixedcolormap = - colormaps - + player->fixedcolormap*256*sizeof(lighttable_t); - walllights = scalelightfixed; - for (i=0 ; i<MAXLIGHTSCALE ; i++) - scalelightfixed[i] = fixedcolormap; - } - else - fixedcolormap = 0; - framecount++; - validcount++; + +void +R_SetupFrame(player_t* player) +{ + int i; + + viewplayer = player; + viewx = player->mo->x; + viewy = player->mo->y; + viewangle = player->mo->angle + viewangleoffset; + extralight = player->extralight; + viewz = player->viewz; + viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; + viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; + sscount = 0; + if (player->fixedcolormap) { + fixedcolormap = colormaps + player->fixedcolormap*256*sizeof(lighttable_t); + walllights = scalelightfixed; + for (i = 0; i < MAXLIGHTSCALE; ++i) + scalelightfixed[i] = fixedcolormap; + } else { + fixedcolormap = 0; + } + ++framecount; + ++validcount; } -void R_RenderPlayerView (player_t* player) -{ - R_SetupFrame (player); - R_ClearClipSegs (); - R_ClearDrawSegs (); - R_ClearPlanes (); - R_ClearSprites (); - NetUpdate (); - R_RenderBSPNode (numnodes-1); - NetUpdate (); - R_DrawPlanes (); - NetUpdate (); - R_DrawMasked (); - NetUpdate (); + +void +R_RenderPlayerView(player_t* player) +{ + R_SetupFrame(player); + R_ClearClipSegs(); + R_ClearDrawSegs(); + R_ClearPlanes(); + R_ClearSprites(); + NetUpdate(); + R_RenderBSPNode(numnodes-1); + NetUpdate(); + R_DrawPlanes(); + NetUpdate(); + R_DrawMasked(); + NetUpdate(); } diff --git a/src/r_main.h b/src/r_main.h @@ -1,76 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __R_MAIN__ #define __R_MAIN__ + #include "d_player.h" #include "r_data.h" + + #ifdef __GNUG__ #pragma interface #endif + + + + + extern fixed_t viewcos; extern fixed_t viewsin; + extern int viewwidth; extern int viewheight; extern int viewwindowx; extern int viewwindowy; + + + extern int centerx; extern int centery; + extern fixed_t centerxfrac; extern fixed_t centeryfrac; extern fixed_t projection; + extern int validcount; + extern int linecount; extern int loopcount; + + + + + + + + + + #define LIGHTLEVELS 16 #define LIGHTSEGSHIFT 4 + #define MAXLIGHTSCALE 48 #define LIGHTSCALESHIFT 12 #define MAXLIGHTZ 128 #define LIGHTZSHIFT 20 + extern lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; extern lighttable_t* scalelightfixed[MAXLIGHTSCALE]; extern lighttable_t* zlight[LIGHTLEVELS][MAXLIGHTZ]; + extern int extralight; extern lighttable_t* fixedcolormap; + + + + #define NUMCOLORMAPS 32 + + + + + extern int detailshift; + + + + + + extern void (*colfunc) (void); extern void (*basecolfunc) (void); extern void (*fuzzcolfunc) (void); + extern void (*spanfunc) (void); + + + + int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ); + int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ); + angle_t R_PointToAngle ( fixed_t x, fixed_t y ); + angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ); + fixed_t R_PointToDist ( fixed_t x, fixed_t y ); + + fixed_t R_ScaleFromGlobalAngle (angle_t visangle); + subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ); + void R_AddPointToBox ( int x, int y, fixed_t* box ); + + + + + + + + void R_RenderPlayerView (player_t *player); + + void R_Init (void); + + void R_SetViewSize (int blocks, int detail); + #endif + + + + + diff --git a/src/r_plane.c b/src/r_plane.c @@ -1,11 +1,12 @@ #include <stdlib.h> + #include "i_system.h" #include "z_zone.h" #include "w_wad.h" #include "doomdef.h" #include "doomstat.h" #include "r_local.h" -#include "r_sky.h" + planefunction_t floorfunc; planefunction_t ceilingfunc; #define MAXVISPLANES 128 @@ -30,75 +31,80 @@ fixed_t cachedheight[SCREENHEIGHT]; fixed_t cacheddistance[SCREENHEIGHT]; fixed_t cachedxstep[SCREENHEIGHT]; fixed_t cachedystep[SCREENHEIGHT]; -void R_InitPlanes (void) + +void +R_InitPlanes() { } + void -R_MapPlane -( int y, - int x1, - int x2 ) +R_MapPlane(int y, int x1, int x2) { - angle_t angle; - fixed_t distance; - fixed_t length; - unsigned index; -#ifdef RANGECHECK - if (x2 < x1 - || x1<0 - || x2>=viewwidth - || (unsigned)y>viewheight) - { - I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); - } -#endif - if (planeheight != cachedheight[y]) - { - cachedheight[y] = planeheight; - distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]); - ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale); - ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale); - } - else - { - distance = cacheddistance[y]; - ds_xstep = cachedxstep[y]; - ds_ystep = cachedystep[y]; + angle_t angle; + fixed_t distance, length; + uint index; + + if (planeheight != cachedheight[y]) { + cachedheight[y] = planeheight; + distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]); + ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale); + ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale); + } else { + distance = cacheddistance[y]; + ds_xstep = cachedxstep[y]; + ds_ystep = cachedystep[y]; } length = FixedMul (distance,distscale[x1]); angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; ds_xfrac = viewx + FixedMul(finecosine[angle], length); ds_yfrac = -viewy - FixedMul(finesine[angle], length); - if (fixedcolormap) - ds_colormap = fixedcolormap; - else - { - index = distance >> LIGHTZSHIFT; - if (index >= MAXLIGHTZ ) - index = MAXLIGHTZ-1; - ds_colormap = planezlight[index]; + if (fixedcolormap) { + ds_colormap = fixedcolormap; + } else { + index = distance >> LIGHTZSHIFT; + if (index >= MAXLIGHTZ ) + index = MAXLIGHTZ-1; + ds_colormap = planezlight[index]; } ds_y = y; ds_x1 = x1; ds_x2 = x2; - spanfunc (); + spanfunc(); } -void R_ClearPlanes (void) + +void +R_ClearPlanes (void) { int i; angle_t angle; + + for (i=0 ; i<viewwidth ; i++) { floorclip[i] = viewheight; ceilingclip[i] = -1; } + lastvisplane = visplanes; lastopening = openings; + + memset (cachedheight, 0, sizeof(cachedheight)); + + angle = (viewangle-ANG90)>>ANGLETOFINESHIFT; + + basexscale = FixedDiv (finecosine[angle],centerxfrac); baseyscale = -FixedDiv (finesine[angle],centerxfrac); } + + + + + + + visplane_t* R_FindPlane ( fixed_t height, @@ -106,11 +112,13 @@ R_FindPlane int lightlevel ) { visplane_t* check; + if (picnum == skyflatnum) { height = 0; lightlevel = 0; } + for (check=visplanes; check<lastvisplane; check++) { if (height == check->height @@ -120,19 +128,31 @@ R_FindPlane break; } } + + if (check < lastvisplane) return check; + if (lastvisplane - visplanes == MAXVISPLANES) I_Error ("R_FindPlane: no more visplanes"); + lastvisplane++; + check->height = height; check->picnum = picnum; check->lightlevel = lightlevel; check->minx = SCREENWIDTH; check->maxx = -1; + memset (check->top,0xff,sizeof(check->top)); + return check; } + + + + + visplane_t* R_CheckPlane ( visplane_t* pl, @@ -144,6 +164,7 @@ R_CheckPlane int unionl; int unionh; int x; + if (start < pl->minx) { intrl = pl->minx; @@ -154,6 +175,7 @@ R_CheckPlane unionl = pl->minx; intrl = start; } + if (stop > pl->maxx) { intrh = pl->maxx; @@ -164,24 +186,38 @@ R_CheckPlane unionh = pl->maxx; intrh = stop; } + for (x=intrl ; x<= intrh ; x++) if (pl->top[x] != 0xff) break; + if (x > intrh) { pl->minx = unionl; pl->maxx = unionh; + + return pl; } + + lastvisplane->height = pl->height; lastvisplane->picnum = pl->picnum; lastvisplane->lightlevel = pl->lightlevel; + pl = lastvisplane++; pl->minx = start; pl->maxx = stop; + memset (pl->top,0xff,sizeof(pl->top)); + return pl; } + + + + + void R_MakeSpans ( int x, @@ -200,6 +236,7 @@ R_MakeSpans R_MapPlane (b1,spanstart[b1],x-1); b1--; } + while (t2 < t1 && t2<=b2) { spanstart[t2] = x; @@ -211,6 +248,13 @@ R_MakeSpans b2--; } } + + + + + + + void R_DrawPlanes (void) { visplane_t* pl; @@ -218,30 +262,43 @@ void R_DrawPlanes (void) int x; int stop; int angle; + #ifdef RANGECHECK if (ds_p - drawsegs > MAXDRAWSEGS) I_Error ("R_DrawPlanes: drawsegs overflow (%i)", ds_p - drawsegs); + if (lastvisplane - visplanes > MAXVISPLANES) I_Error ("R_DrawPlanes: visplane overflow (%i)", lastvisplane - visplanes); + if (lastopening - openings > MAXOPENINGS) I_Error ("R_DrawPlanes: opening overflow (%i)", lastopening - openings); #endif + for (pl = visplanes ; pl < lastvisplane ; pl++) { if (pl->minx > pl->maxx) continue; + + + if (pl->picnum == skyflatnum) { dc_iscale = pspriteiscale>>detailshift; + + + + + dc_colormap = colormaps; dc_texturemid = skytexturemid; for (x=pl->minx ; x <= pl->maxx ; x++) { dc_yl = pl->top[x]; dc_yh = pl->bottom[x]; + if (dc_yl <= dc_yh) { angle = (viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; @@ -252,19 +309,28 @@ void R_DrawPlanes (void) } continue; } + + ds_source = W_CacheLumpNum(firstflat + flattranslation[pl->picnum], PU_STATIC); + planeheight = abs(pl->height-viewz); light = (pl->lightlevel >> LIGHTSEGSHIFT)+extralight; + if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; + if (light < 0) light = 0; + planezlight = zlight[light]; + pl->top[pl->maxx+1] = 0xff; pl->top[pl->minx-1] = 0xff; + stop = pl->maxx + 1; + for (x=pl->minx ; x<= stop ; x++) { R_MakeSpans(x,pl->top[x-1], @@ -272,6 +338,7 @@ void R_DrawPlanes (void) pl->top[x], pl->bottom[x]); } + Z_ChangeTag (ds_source, PU_CACHE); } } diff --git a/src/r_plane.h b/src/r_plane.h @@ -1,24 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __R_PLANE__ #define __R_PLANE__ + + #include "r_data.h" + #ifdef __GNUG__ #pragma interface #endif + + + extern short* lastopening; + + typedef void (*planefunction_t) (int top, int bottom); + extern planefunction_t floorfunc; extern planefunction_t ceilingfunc_t; + extern short floorclip[SCREENWIDTH]; extern short ceilingclip[SCREENWIDTH]; + extern fixed_t yslope[SCREENHEIGHT]; extern fixed_t distscale[SCREENWIDTH]; + void R_InitPlanes (void); void R_ClearPlanes (void); + void R_MapPlane ( int y, int x1, int x2 ); + void R_MakeSpans ( int x, @@ -26,15 +62,26 @@ R_MakeSpans int b1, int t2, int b2 ); + void R_DrawPlanes (void); + visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ); + visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ); + + + #endif + + + + + diff --git a/src/r_segs.c b/src/r_segs.c @@ -1,20 +1,22 @@ #include <stdlib.h> + #include "i_system.h" #include "doomdef.h" #include "doomstat.h" #include "r_local.h" -#include "r_sky.h" +#include "r_things.h" + boolean segtextured; boolean markfloor; boolean markceiling; boolean maskedtexture; -int toptexture; -int bottomtexture; -int midtexture; +int toptexture; +int bottomtexture; +int midtexture; angle_t rw_normalangle; -int rw_angle1; -int rw_x; -int rw_stopx; +int rw_angle1; +int rw_x; +int rw_stopx; angle_t rw_centerangle; fixed_t rw_offset; fixed_t rw_distance; @@ -23,10 +25,10 @@ fixed_t rw_scalestep; fixed_t rw_midtexturemid; fixed_t rw_toptexturemid; fixed_t rw_bottomtexturemid; -int worldtop; -int worldbottom; -int worldhigh; -int worldlow; +int worldtop; +int worldbottom; +int worldhigh; +int worldlow; fixed_t pixhigh; fixed_t pixlow; fixed_t pixhighstep; @@ -35,468 +37,525 @@ fixed_t topfrac; fixed_t topstep; fixed_t bottomfrac; fixed_t bottomstep; -lighttable_t** walllights; -short* maskedtexturecol; +lighttable_t** walllights; +short* maskedtexturecol; + void -R_RenderMaskedSegRange -( drawseg_t* ds, - int x1, - int x2 ) +R_RenderMaskedSegRange(drawseg_t* ds, int x1, int x2) { - unsigned index; - column_t* col; - int lightnum; - int texnum; - curline = ds->curline; - frontsector = curline->frontsector; - backsector = curline->backsector; - texnum = texturetranslation[curline->sidedef->midtexture]; - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; - if (lightnum < 0) - walllights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - walllights = scalelight[LIGHTLEVELS-1]; - else - walllights = scalelight[lightnum]; - maskedtexturecol = ds->maskedtexturecol; - rw_scalestep = ds->scalestep; - spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; - mfloorclip = ds->sprbottomclip; - mceilingclip = ds->sprtopclip; - if (curline->linedef->flags & ML_DONTPEGBOTTOM) - { - dc_texturemid = frontsector->floorheight > backsector->floorheight - ? frontsector->floorheight : backsector->floorheight; - dc_texturemid = dc_texturemid + textureheight_g[texnum] - viewz; - } - else - { - dc_texturemid =frontsector->ceilingheight<backsector->ceilingheight - ? frontsector->ceilingheight : backsector->ceilingheight; - dc_texturemid = dc_texturemid - viewz; - } - dc_texturemid += curline->sidedef->rowoffset; - if (fixedcolormap) - dc_colormap = fixedcolormap; - for (dc_x = x1 ; dc_x <= x2 ; dc_x++) - { - if (maskedtexturecol[dc_x] != MAXSHORT) - { - if (!fixedcolormap) - { - index = spryscale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) - index = MAXLIGHTSCALE-1; - dc_colormap = walllights[index]; - } - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - dc_iscale = 0xffffffffu / (unsigned)spryscale; - col = (column_t *)( - (byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3); - R_DrawMaskedColumn (col); - maskedtexturecol[dc_x] = MAXSHORT; - } - spryscale += rw_scalestep; - } + column_t* col; + uint index; + int lightnum, texnum; + + curline = ds->curline; + frontsector = curline->frontsector; + backsector = curline->backsector; + texnum = texturetranslation[curline->sidedef->midtexture]; + lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; + if (curline->v1->y == curline->v2->y) + --lightnum; + if (curline->v1->x == curline->v2->x) + ++lightnum; + if (lightnum < 0) + walllights = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + walllights = scalelight[LIGHTLEVELS-1]; + else + walllights = scalelight[lightnum]; + maskedtexturecol = ds->maskedtexturecol; + rw_scalestep = ds->scalestep; + spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; + mfloorclip = ds->sprbottomclip; + mceilingclip = ds->sprtopclip; + if (curline->linedef->flags & ML_DONTPEGBOTTOM) { + dc_texturemid = + frontsector->floorheight > backsector->floorheight + ? frontsector->floorheight + : backsector->floorheight; + dc_texturemid = dc_texturemid + textureheight_g[texnum] - viewz; + } else { + dc_texturemid = + frontsector->ceilingheight<backsector->ceilingheight + ? frontsector->ceilingheight + : backsector->ceilingheight; + dc_texturemid = dc_texturemid - viewz; + } + dc_texturemid += curline->sidedef->rowoffset; + if (fixedcolormap) + dc_colormap = fixedcolormap; + for (dc_x = x1; dc_x <= x2; ++dc_x) { + if (maskedtexturecol[dc_x] != SHRT_MAX) { + if (!fixedcolormap) { + index = spryscale >> LIGHTSCALESHIFT; + if (index >= MAXLIGHTSCALE ) + index = MAXLIGHTSCALE-1; + dc_colormap = walllights[index]; + } + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); + dc_iscale = 0xffffffffu / (unsigned)spryscale; + col = (column_t*)((byte*)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3); + R_DrawMaskedColumn(col); + maskedtexturecol[dc_x] = SHRT_MAX; + } + spryscale += rw_scalestep; + } } -#define HEIGHTBITS 12 -#define HEIGHTUNIT (1<<HEIGHTBITS) -void R_RenderSegLoop (void) + +#define HEIGHTBITS 12 +#define HEIGHTUNIT (1<<HEIGHTBITS) + +void +R_RenderSegLoop() { - angle_t angle; - unsigned index; - int yl; - int yh; - int mid; - fixed_t texturecolumn; - int top; - int bottom; - for ( ; rw_x < rw_stopx ; rw_x++) - { + angle_t angle; + fixed_t texturecolumn; + uint index; + int yl, yh, mid, top, bottom; + + texturecolumn = 0; + for (; rw_x < rw_stopx; ++rw_x) { yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; if (yl < ceilingclip[rw_x]+1) - yl = ceilingclip[rw_x]+1; - if (markceiling) - { - top = ceilingclip[rw_x]+1; - bottom = yl-1; - if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; - if (top <= bottom) - { - ceilingplane->top[rw_x] = top; - ceilingplane->bottom[rw_x] = bottom; - } + yl = ceilingclip[rw_x]+1; + if (markceiling) { + top = ceilingclip[rw_x] + 1; + bottom = yl - 1; + if (bottom >= floorclip[rw_x]) + bottom = floorclip[rw_x]-1; + if (top <= bottom) { + ceilingplane->top[rw_x] = top; + ceilingplane->bottom[rw_x] = bottom; + } } yh = bottomfrac>>HEIGHTBITS; if (yh >= floorclip[rw_x]) - yh = floorclip[rw_x]-1; - if (markfloor) - { - top = yh+1; - bottom = floorclip[rw_x]-1; - if (top <= ceilingclip[rw_x]) - top = ceilingclip[rw_x]+1; - if (top <= bottom) - { - floorplane->top[rw_x] = top; - floorplane->bottom[rw_x] = bottom; - } + yh = floorclip[rw_x]-1; + if (markfloor) { + top = yh + 1; + bottom = floorclip[rw_x] - 1; + if (top <= ceilingclip[rw_x]) + top = ceilingclip[rw_x] + 1; + if (top <= bottom) { + floorplane->top[rw_x] = top; + floorplane->bottom[rw_x] = bottom; + } } - if (segtextured) - { - angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); - texturecolumn >>= FRACBITS; - index = rw_scale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) - index = MAXLIGHTSCALE-1; - dc_colormap = walllights[index]; - dc_x = rw_x; - dc_iscale = 0xffffffffu / (unsigned)rw_scale; - } - if (midtexture) - { - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); - colfunc (); - ceilingclip[rw_x] = viewheight; - floorclip[rw_x] = -1; + if (segtextured) { + angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; + texturecolumn = rw_offset - FixedMul(finetangent[angle], rw_distance); + texturecolumn >>= FRACBITS; + index = rw_scale>>LIGHTSCALESHIFT; + if (index >= MAXLIGHTSCALE) + index = MAXLIGHTSCALE-1; + dc_colormap = walllights[index]; + dc_x = rw_x; + dc_iscale = 0xffffffffu / (unsigned)rw_scale; } - else - { - if (toptexture) - { - mid = pixhigh>>HEIGHTBITS; - pixhigh += pixhighstep; - if (mid >= floorclip[rw_x]) - mid = floorclip[rw_x]-1; - if (mid >= yl) - { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); - colfunc (); - ceilingclip[rw_x] = mid; + if (midtexture) { + dc_yl = yl; + dc_yh = yh; + dc_texturemid = rw_midtexturemid; + dc_source = R_GetColumn(midtexture,texturecolumn); + colfunc (); + ceilingclip[rw_x] = viewheight; + floorclip[rw_x] = -1; + } else { + if (toptexture) { + mid = pixhigh>>HEIGHTBITS; + pixhigh += pixhighstep; + if (mid >= floorclip[rw_x]) + mid = floorclip[rw_x]-1; + if (mid >= yl) { + dc_yl = yl; + dc_yh = mid; + dc_texturemid = rw_toptexturemid; + dc_source = R_GetColumn(toptexture, texturecolumn); + colfunc(); + ceilingclip[rw_x] = mid; + } else + ceilingclip[rw_x] = yl-1; + } else { + if (markceiling) + ceilingclip[rw_x] = yl-1; } - else - ceilingclip[rw_x] = yl-1; - } - else - { - if (markceiling) - ceilingclip[rw_x] = yl-1; - } - if (bottomtexture) - { - mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; - pixlow += pixlowstep; - if (mid <= ceilingclip[rw_x]) - mid = ceilingclip[rw_x]+1; - if (mid <= yh) - { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); - colfunc (); - floorclip[rw_x] = mid; + if (bottomtexture) { + mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; + pixlow += pixlowstep; + if (mid <= ceilingclip[rw_x]) + mid = ceilingclip[rw_x]+1; + if (mid <= yh) { + dc_yl = mid; + dc_yh = yh; + dc_texturemid = rw_bottomtexturemid; + dc_source = R_GetColumn(bottomtexture, + texturecolumn); + colfunc(); + floorclip[rw_x] = mid; + } else + floorclip[rw_x] = yh+1; + } else { + if (markfloor) + floorclip[rw_x] = yh+1; } - else - floorclip[rw_x] = yh+1; - } - else - { - if (markfloor) - floorclip[rw_x] = yh+1; - } - if (maskedtexture) - { - maskedtexturecol[rw_x] = texturecolumn; - } + if (maskedtexture) + maskedtexturecol[rw_x] = texturecolumn; } rw_scale += rw_scalestep; topfrac += topstep; bottomfrac += bottomstep; - } + } } + void -R_StoreWallRange -( int start, - int stop ) +R_StoreWallRange(int start, int stop) { - fixed_t hyp; - fixed_t sineval; - angle_t distangle, offsetangle; - fixed_t vtop; - int lightnum; - if (ds_p == &drawsegs[MAXDRAWSEGS]) - return; + fixed_t hyp, sineval, vtop; + angle_t distangle, offsetangle; + int lightnum; + + if (ds_p == &drawsegs[MAXDRAWSEGS]) + return; #ifdef RANGECHECK - if (start >=viewwidth || start > stop) - I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); + if (start >=viewwidth || start > stop) + I_Error("Bad R_RenderWallRange: %i to %i", start , stop); #endif - sidedef = curline->sidedef; - linedef = curline->linedef; - linedef->flags |= ML_MAPPED; - rw_normalangle = curline->angle + ANG90; - offsetangle = abs(rw_normalangle-rw_angle1); - if (offsetangle > ANG90) - offsetangle = ANG90; - distangle = ANG90 - offsetangle; - hyp = R_PointToDist (curline->v1->x, curline->v1->y); - sineval = finesine[distangle>>ANGLETOFINESHIFT]; - rw_distance = FixedMul (hyp, sineval); - ds_p->x1 = rw_x = start; - ds_p->x2 = stop; - ds_p->curline = curline; - rw_stopx = stop+1; - ds_p->scale1 = rw_scale = - R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]); - if (stop > start ) - { + sidedef = curline->sidedef; + linedef = curline->linedef; + linedef->flags |= ML_MAPPED; + rw_normalangle = curline->angle + ANG90; + offsetangle = abs(rw_normalangle-rw_angle1); + if (offsetangle > ANG90) + offsetangle = ANG90; + distangle = ANG90 - offsetangle; + hyp = R_PointToDist (curline->v1->x, curline->v1->y); + sineval = finesine[distangle>>ANGLETOFINESHIFT]; + rw_distance = FixedMul (hyp, sineval); + ds_p->x1 = rw_x = start; + ds_p->x2 = stop; + ds_p->curline = curline; + rw_stopx = stop+1; + ds_p->scale1 = rw_scale = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[start]); + if (stop > start) { ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]); ds_p->scalestep = rw_scalestep = - (ds_p->scale2 - rw_scale) / (stop-start); - } - else - { + (ds_p->scale2 - rw_scale) / (stop-start); + } + else + { + #if 0 if (rw_distance < FRACUNIT/2) { - fixed_t trx,try; - fixed_t gxt,gyt; - trx = curline->v1->x - viewx; - try = curline->v1->y - viewy; - gxt = FixedMul(trx,viewcos); - gyt = -FixedMul(try,viewsin); - ds_p->scale1 = FixedDiv(projection, gxt-gyt)<<detailshift; + fixed_t trx,try; + fixed_t gxt,gyt; + + trx = curline->v1->x - viewx; + try = curline->v1->y - viewy; + + gxt = FixedMul(trx,viewcos); + gyt = -FixedMul(try,viewsin); + ds_p->scale1 = FixedDiv(projection, gxt-gyt)<<detailshift; } #endif ds_p->scale2 = ds_p->scale1; - } - worldtop = frontsector->ceilingheight - viewz; - worldbottom = frontsector->floorheight - viewz; - midtexture = toptexture = bottomtexture = maskedtexture = 0; - ds_p->maskedtexturecol = NULL; - if (!backsector) - { + } + + + + worldtop = frontsector->ceilingheight - viewz; + worldbottom = frontsector->floorheight - viewz; + + midtexture = toptexture = bottomtexture = maskedtexture = 0; + ds_p->maskedtexturecol = NULL; + + if (!backsector) + { + midtexture = texturetranslation[sidedef->midtexture]; + markfloor = markceiling = true; if (linedef->flags & ML_DONTPEGBOTTOM) { - vtop = frontsector->floorheight + + vtop = frontsector->floorheight + textureheight_g[sidedef->midtexture]; - rw_midtexturemid = vtop - viewz; + + rw_midtexturemid = vtop - viewz; } else { - rw_midtexturemid = worldtop; + + rw_midtexturemid = worldtop; } rw_midtexturemid += sidedef->rowoffset; + ds_p->silhouette = SIL_BOTH; ds_p->sprtopclip = screenheightarray; ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = MAXINT; - ds_p->tsilheight = MININT; - } - else - { + ds_p->bsilheight = INT_MAX; + ds_p->tsilheight = INT_MIN; + } + else + { + ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; + if (frontsector->floorheight > backsector->floorheight) { - ds_p->silhouette = SIL_BOTTOM; - ds_p->bsilheight = frontsector->floorheight; + ds_p->silhouette = SIL_BOTTOM; + ds_p->bsilheight = frontsector->floorheight; } else if (backsector->floorheight > viewz) { - ds_p->silhouette = SIL_BOTTOM; - ds_p->bsilheight = MAXINT; + ds_p->silhouette = SIL_BOTTOM; + ds_p->bsilheight = INT_MAX; + } + if (frontsector->ceilingheight < backsector->ceilingheight) { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = frontsector->ceilingheight; + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = frontsector->ceilingheight; } else if (backsector->ceilingheight < viewz) { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = MININT; + ds_p->silhouette |= SIL_TOP; + ds_p->tsilheight = INT_MIN; + } + if (backsector->ceilingheight <= frontsector->floorheight) { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = MAXINT; - ds_p->silhouette |= SIL_BOTTOM; + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT_MAX; + ds_p->silhouette |= SIL_BOTTOM; } + if (backsector->floorheight >= frontsector->ceilingheight) { - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = MININT; - ds_p->silhouette |= SIL_TOP; + ds_p->sprtopclip = screenheightarray; + ds_p->tsilheight = INT_MIN; + ds_p->silhouette |= SIL_TOP; } + worldhigh = backsector->ceilingheight - viewz; worldlow = backsector->floorheight - viewz; + + if (frontsector->ceilingpic == skyflatnum - && backsector->ceilingpic == skyflatnum) + && backsector->ceilingpic == skyflatnum) { - worldtop = worldhigh; + worldtop = worldhigh; } + + if (worldlow != worldbottom - || backsector->floorpic != frontsector->floorpic - || backsector->lightlevel != frontsector->lightlevel) + || backsector->floorpic != frontsector->floorpic + || backsector->lightlevel != frontsector->lightlevel) { - markfloor = true; + markfloor = true; } else { - markfloor = false; + + markfloor = false; } + + if (worldhigh != worldtop - || backsector->ceilingpic != frontsector->ceilingpic - || backsector->lightlevel != frontsector->lightlevel) + || backsector->ceilingpic != frontsector->ceilingpic + || backsector->lightlevel != frontsector->lightlevel) { - markceiling = true; + markceiling = true; } else { - markceiling = false; + + markceiling = false; } + if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) + || backsector->floorheight >= frontsector->ceilingheight) { - markceiling = markfloor = true; + + markceiling = markfloor = true; } + + if (worldhigh < worldtop) { - toptexture = texturetranslation[sidedef->toptexture]; - if (linedef->flags & ML_DONTPEGTOP) - { + + toptexture = texturetranslation[sidedef->toptexture]; + if (linedef->flags & ML_DONTPEGTOP) + { + rw_toptexturemid = worldtop; - } - else - { + } + else + { vtop = - backsector->ceilingheight - + textureheight_g[sidedef->toptexture]; + backsector->ceilingheight + + textureheight_g[sidedef->toptexture]; + + rw_toptexturemid = vtop - viewz; - } + } } if (worldlow > worldbottom) { - bottomtexture = texturetranslation[sidedef->bottomtexture]; - if (linedef->flags & ML_DONTPEGBOTTOM ) - { + + bottomtexture = texturetranslation[sidedef->bottomtexture]; + + if (linedef->flags & ML_DONTPEGBOTTOM ) + { + + rw_bottomtexturemid = worldtop; - } - else + } + else rw_bottomtexturemid = worldlow; } rw_toptexturemid += sidedef->rowoffset; rw_bottomtexturemid += sidedef->rowoffset; + + if (sidedef->midtexture) { - maskedtexture = true; - ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; - lastopening += rw_stopx - rw_x; - } - } - segtextured = midtexture | toptexture | bottomtexture | maskedtexture; - if (segtextured) - { + + maskedtexture = true; + ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; + lastopening += rw_stopx - rw_x; + } + } + + + segtextured = midtexture | toptexture | bottomtexture | maskedtexture; + + if (segtextured) + { offsetangle = rw_normalangle-rw_angle1; + if (offsetangle > ANG180) - offsetangle = -offsetangle; + offsetangle = -offsetangle; + if (offsetangle > ANG90) - offsetangle = ANG90; + offsetangle = ANG90; + sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; rw_offset = FixedMul (hyp, sineval); + if (rw_normalangle-rw_angle1 < ANG180) - rw_offset = -rw_offset; + rw_offset = -rw_offset; + rw_offset += sidedef->textureoffset + curline->offset; rw_centerangle = ANG90 + viewangle - rw_normalangle; + + + + + if (!fixedcolormap) { - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (curline->v1->y == curline->v2->y) + lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; + + if (curline->v1->y == curline->v2->y) lightnum--; - else if (curline->v1->x == curline->v2->x) + else if (curline->v1->x == curline->v2->x) lightnum++; - if (lightnum < 0) + + if (lightnum < 0) walllights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) + else if (lightnum >= LIGHTLEVELS) walllights = scalelight[LIGHTLEVELS-1]; - else + else walllights = scalelight[lightnum]; } - } - if (frontsector->floorheight >= viewz) - { + } + + + + + + + if (frontsector->floorheight >= viewz) + { + markfloor = false; - } - if (frontsector->ceilingheight <= viewz + } + + if (frontsector->ceilingheight <= viewz && frontsector->ceilingpic != skyflatnum) - { + { + markceiling = false; - } - worldtop >>= 4; - worldbottom >>= 4; - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); - bottomstep = -FixedMul (rw_scalestep,worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - if (backsector) - { + } + + + + worldtop >>= 4; + worldbottom >>= 4; + + topstep = -FixedMul (rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + + bottomstep = -FixedMul (rw_scalestep,worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + + if (backsector) + { worldhigh >>= 4; worldlow >>= 4; + if (worldhigh < worldtop) { - pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); - pixhighstep = -FixedMul (rw_scalestep,worldhigh); + pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); + pixhighstep = -FixedMul (rw_scalestep,worldhigh); } + if (worldlow > worldbottom) { - pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); - pixlowstep = -FixedMul (rw_scalestep,worldlow); + pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); + pixlowstep = -FixedMul (rw_scalestep,worldlow); + } } - } - if (markceiling) + + + if (markceiling) ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); - if (markfloor) + + if (markfloor) floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); - R_RenderSegLoop (); - if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) + + R_RenderSegLoop (); + + + + if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) - { + { memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start)); ds_p->sprtopclip = lastopening - start; lastopening += rw_stopx - start; - } - if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) + } + + if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) - { + { memcpy (lastopening, floorclip+start, 2*(rw_stopx-start)); ds_p->sprbottomclip = lastopening - start; lastopening += rw_stopx - start; - } - if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) - { + } + + if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) + { ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = MININT; - } - if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM)) - { + ds_p->tsilheight = INT_MIN; + } + if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM)) + { ds_p->silhouette |= SIL_BOTTOM; - ds_p->bsilheight = MAXINT; - } - ds_p++; + ds_p->bsilheight = INT_MAX; + } + ds_p++; } + diff --git a/src/r_segs.h b/src/r_segs.h @@ -1,11 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __R_SEGS__ #define __R_SEGS__ + + #ifdef __GNUG__ #pragma interface #endif + + void R_RenderMaskedSegRange ( drawseg_t* ds, int x1, int x2 ); + + #endif + + + + + diff --git a/src/r_sky.c b/src/r_sky.c @@ -1,13 +0,0 @@ -#include "m_fixed.h" -#include "r_data.h" -#ifdef __GNUG__ -#pragma implementation "r_sky.h" -#endif -#include "r_sky.h" -int skyflatnum; -int skytexture; -int skytexturemid; -void R_InitSkyMap (void) -{ - skytexturemid = 100*FRACUNIT; -} diff --git a/src/r_sky.h b/src/r_sky.h @@ -1,11 +0,0 @@ -#ifndef __R_SKY__ -#define __R_SKY__ -#ifdef __GNUG__ -#pragma interface -#endif -#define SKYFLATNAME "F_SKY1" -#define ANGLETOSKYSHIFT 22 -extern int skytexture; -extern int skytexturemid; -void R_InitSkyMap (void); -#endif diff --git a/src/r_state.h b/src/r_state.h @@ -1,10 +1,9 @@ #ifndef __R_STATE__ #define __R_STATE__ + #include "d_player.h" #include "r_data.h" -#ifdef __GNUG__ -#pragma interface -#endif + extern fixed_t* textureheight_g; extern fixed_t* spritewidth; extern fixed_t* spriteoffset; @@ -49,4 +48,10 @@ extern int rw_angle1; extern int sscount; extern visplane_t* floorplane; extern visplane_t* ceilingplane; + #endif + + + + + diff --git a/src/r_things.c b/src/r_things.c @@ -1,605 +1,521 @@ #include <stdio.h> #include <stdlib.h> + #include "doomdef.h" -#include "m_swap.h" #include "i_system.h" #include "z_zone.h" #include "w_wad.h" +#include "m_swap.h" #include "r_local.h" #include "doomstat.h" -#define MINZ (FRACUNIT*4) -#define BASEYCENTER 100 -typedef struct -{ - int x1; - int x2; - int column; - int topclip; - int bottomclip; + +#define MINZ (FRACUNIT*4) +#define BASEYCENTER 100 + +typedef struct { + int x1; + int x2; + int column; + int topclip; + int bottomclip; } maskdraw_t; -fixed_t pspritescale; -fixed_t pspriteiscale; -lighttable_t** spritelights; -short negonearray[SCREENWIDTH]; -short screenheightarray[SCREENWIDTH]; -spritedef_t* sprites; -int numsprites; -spriteframe_t sprtemp[29]; -int maxframe; -char* spritename; + +fixed_t pspritescale; +fixed_t pspriteiscale; +lighttable_t** spritelights; +short negonearray[SCREENWIDTH]; +short screenheightarray[SCREENWIDTH]; +spritedef_t* sprites; +int numsprites; +spriteframe_t sprtemp[29]; +int maxframe; +char* spritename; + void -R_InstallSpriteLump -( int lump, - unsigned frame, - unsigned rotation, - boolean flipped ) +R_InstallSpriteLump(int lump, unsigned frame, unsigned rotation, boolean flipped) { - int r; - if (frame >= 29 || rotation > 8) - I_Error("R_InstallSpriteLump: " - "Bad frame characters in lump %i", lump); - if ((int)frame > maxframe) - maxframe = frame; - if (rotation == 0) - { - if (sprtemp[frame].rotate == false) - I_Error ("R_InitSprites: Sprite %s frame %c has " - "multip rot=0 lump", spritename, 'A'+frame); - if (sprtemp[frame].rotate == true) - I_Error ("R_InitSprites: Sprite %s frame %c has rotations " - "and a rot=0 lump", spritename, 'A'+frame); - sprtemp[frame].rotate = false; - for (r=0 ; r<8 ; r++) - { - sprtemp[frame].lump[r] = lump - firstspritelump; - sprtemp[frame].flip[r] = (byte)flipped; + int r; + + if (frame >= 29 || rotation > 8) + I_Error("R_InstallSpriteLump: Bad frame characters in lump %i", lump); + if ((int)frame > maxframe) + maxframe = frame; + if (rotation == 0) { + if (sprtemp[frame].rotate == false) + I_Error ("R_InitSprites: Sprite %s frame %c has multip rot=0 lump", spritename, 'A'+frame); + if (sprtemp[frame].rotate == true) + I_Error ("R_InitSprites: Sprite %s frame %c has rotations and a rot=0 lump", spritename, 'A'+frame); + sprtemp[frame].rotate = false; + for (r = 0; r < 8; ++r) { + sprtemp[frame].lump[r] = lump - firstspritelump; + sprtemp[frame].flip[r] = (byte)flipped; + } + return; } - return; - } - if (sprtemp[frame].rotate == false) - I_Error ("R_InitSprites: Sprite %s frame %c has rotations " - "and a rot=0 lump", spritename, 'A'+frame); - sprtemp[frame].rotate = true; - rotation--; - if (sprtemp[frame].lump[rotation] != -1) - I_Error ("R_InitSprites: Sprite %s : %c : %c " - "has two lumps mapped to it", - spritename, 'A'+frame, '1'+rotation); - sprtemp[frame].lump[rotation] = lump - firstspritelump; - sprtemp[frame].flip[rotation] = (byte)flipped; + if (sprtemp[frame].rotate == false) + I_Error ("R_InitSprites: Sprite %s frame %c has rotations and a rot=0 lump", spritename, 'A'+frame); + sprtemp[frame].rotate = true; + --rotation; + if (sprtemp[frame].lump[rotation] != -1) + I_Error("R_InitSprites: Sprite %s : %c : %c has two lumps mapped to it", spritename, 'A'+frame, '1'+rotation); + sprtemp[frame].lump[rotation] = lump - firstspritelump; + sprtemp[frame].flip[rotation] = (byte)flipped; } -void R_InitSpriteDefs (char** namelist) + +void +R_InitSpriteDefs(char** namelist) { - char** check; - int i; - int l; - int intname; - int frame; - int rotation; - int start; - int end; - int patched; - check = namelist; - while (*check != NULL) - check++; - numsprites = check-namelist; - if (!numsprites) - return; - sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); - start = firstspritelump-1; - end = lastspritelump+1; - for (i=0 ; i<numsprites ; i++) - { - spritename = namelist[i]; - memset (sprtemp,-1, sizeof(sprtemp)); - maxframe = -1; - intname = *(int *)namelist[i]; - for (l=start+1 ; l<end ; l++) - { - if (*(int *)lumpinfo_g[l].name == intname) - { - frame = lumpinfo_g[l].name[4] - 'A'; - rotation = lumpinfo_g[l].name[5] - '0'; - if (modifiedgame) - patched = W_GetNumForName (lumpinfo_g[l].name); - else - patched = l; - R_InstallSpriteLump (patched, frame, rotation, false); - if (lumpinfo_g[l].name[6]) - { - frame = lumpinfo_g[l].name[6] - 'A'; - rotation = lumpinfo_g[l].name[7] - '0'; - R_InstallSpriteLump (l, frame, rotation, true); + int i, l, intname, frame, rotation, start, end, patched; + + numsprites = LENGTH(sprnames); + if (!numsprites) + return; + sprites = Z_Malloc(numsprites * sizeof(*sprites), PU_STATIC, NULL); + start = firstspritelump - 1; + end = lastspritelump + 1; + for (i = 0; i < numsprites; ++i) { + spritename = namelist[i]; + memset(sprtemp, -1, sizeof(sprtemp)); + maxframe = -1; + intname = *(int*)namelist[i]; + for (l = start + 1; l < end; ++l) { + if (*(int*)lumpinfo_g[l].name == intname) { + frame = lumpinfo_g[l].name[4] - 'A'; + rotation = lumpinfo_g[l].name[5] - '0'; + if (modifiedgame) + patched = W_GetNumForName(lumpinfo_g[l].name); + else + patched = l; + R_InstallSpriteLump(patched, frame, rotation, false); + if (lumpinfo_g[l].name[6]) { + frame = lumpinfo_g[l].name[6] - 'A'; + rotation = lumpinfo_g[l].name[7] - '0'; + R_InstallSpriteLump(l, frame, rotation, true); + } + } } - } - } - if (maxframe == -1) - { - sprites[i].numframes = 0; - continue; - } - maxframe++; - for (frame = 0 ; frame < maxframe ; frame++) - { - switch ((int)sprtemp[frame].rotate) - { - case -1: - I_Error ("R_InitSprites: No patches found " - "for %s frame %c", namelist[i], frame+'A'); - break; - case 0: - break; - case 1: - for (rotation=0 ; rotation<8 ; rotation++) - if (sprtemp[frame].lump[rotation] == -1) - I_Error ("R_InitSprites: Sprite %s frame %c " - "is missing rotations", - namelist[i], frame+'A'); - break; - } + if (maxframe == -1) { + sprites[i].numframes = 0; + continue; + } + ++maxframe; + + for (frame = 0; frame < maxframe; ++frame) { + switch ((int)sprtemp[frame].rotate) { + case -1: + I_Error ("R_InitSprites: No patches found for %s frame %c", namelist[i], frame+'A'); + break; + case 0: + break; + case 1: + for (rotation = 0; rotation < 8; ++rotation) + if (sprtemp[frame].lump[rotation] == -1) + I_Error("R_InitSprites: Sprite %s frame %c is missing rotations", namelist[i], frame+'A'); + break; + } + } + sprites[i].numframes = maxframe; + sprites[i].spriteframes = Z_Malloc(maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); + memcpy(sprites[i].spriteframes, sprtemp, maxframe*sizeof(spriteframe_t)); } - sprites[i].numframes = maxframe; - sprites[i].spriteframes = - Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); - memcpy (sprites[i].spriteframes, sprtemp, maxframe*sizeof(spriteframe_t)); - } } -vissprite_t vissprites[MAXVISSPRITES]; -vissprite_t* vissprite_p; -int newvissprite; -void R_InitSprites (char** namelist) + +vissprite_t vissprites[MAXVISSPRITES]; +vissprite_t* vissprite_p; +int newvissprite; + +void +R_InitSprites(char** namelist) { - int i; - for (i=0 ; i<SCREENWIDTH ; i++) - { - negonearray[i] = -1; - } - R_InitSpriteDefs (namelist); + int i; + + for (i = 0; i < SCREENWIDTH; ++i) + negonearray[i] = -1; + R_InitSpriteDefs(namelist); } -void R_ClearSprites (void) + +void +R_ClearSprites() { - vissprite_p = vissprites; + vissprite_p = vissprites; } -vissprite_t overflowsprite; -vissprite_t* R_NewVisSprite (void) + +vissprite_t overflowsprite; + +vissprite_t* +R_NewVisSprite() { - if (vissprite_p == &vissprites[MAXVISSPRITES]) - return &overflowsprite; - vissprite_p++; - return vissprite_p-1; + if (vissprite_p == &vissprites[MAXVISSPRITES]) + return &overflowsprite; + ++vissprite_p; + return vissprite_p - 1; } -short* mfloorclip; -short* mceilingclip; -fixed_t spryscale; -fixed_t sprtopscreen; -void R_DrawMaskedColumn (column_t* column) + + +short* mfloorclip; +short* mceilingclip; +fixed_t spryscale; +fixed_t sprtopscreen; + +void +R_DrawMaskedColumn(column_t* column) { - int topscreen; - int bottomscreen; - fixed_t basetexturemid; - basetexturemid = dc_texturemid; - for ( ; column->topdelta != 0xff ; ) - { - topscreen = sprtopscreen + spryscale*column->topdelta; - bottomscreen = topscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; - if (dc_yh >= mfloorclip[dc_x]) - dc_yh = mfloorclip[dc_x]-1; - if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x]+1; - if (dc_yl <= dc_yh) - { - dc_source = (byte *)column + 3; - dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS); - colfunc (); + fixed_t basetexturemid; + int topscreen, bottomscreen; + + basetexturemid = dc_texturemid; + for (; column->topdelta != 0xff;) { + topscreen = sprtopscreen + spryscale*column->topdelta; + bottomscreen = topscreen + spryscale*column->length; + dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; + dc_yh = (bottomscreen-1)>>FRACBITS; + if (dc_yh >= mfloorclip[dc_x]) + dc_yh = mfloorclip[dc_x]-1; + if (dc_yl <= mceilingclip[dc_x]) + dc_yl = mceilingclip[dc_x]+1; + if (dc_yl <= dc_yh) { + dc_source = (byte *)column + 3; + dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS); + colfunc (); + } + column = (column_t *)( (byte *)column + column->length + 4); } - column = (column_t *)( (byte *)column + column->length + 4); - } - dc_texturemid = basetexturemid; + dc_texturemid = basetexturemid; } + void -R_DrawVisSprite -( vissprite_t* vis, - int x1, - int x2 ) +R_DrawVisSprite(vissprite_t* vis, int x1, int x2) { - column_t* column; - int texturecolumn; - fixed_t frac; - patch_t* patch; - patch = W_CacheLumpNum (vis->patch+firstspritelump, PU_CACHE); - dc_colormap = vis->colormap; - if (!dc_colormap) - { - colfunc = fuzzcolfunc; - } - else if (vis->mobjflags & MF_TRANSLATION) - { - colfunc = R_DrawTranslatedColumn; - dc_translation = translationtables - 256 + - ( (vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) ); - } - dc_iscale = abs(vis->xiscale)>>detailshift; - dc_texturemid = vis->texturemid; - frac = vis->startfrac; - spryscale = vis->scale; - sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); - for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale) - { - texturecolumn = frac>>FRACBITS; + column_t* column; + patch_t* patch; + fixed_t frac; + int texturecolumn; + + patch = W_CacheLumpNum(vis->patch + firstspritelump, PU_CACHE); + dc_colormap = vis->colormap; + if (!dc_colormap) + colfunc = fuzzcolfunc; + if (vis->mobjflags & MF_TRANSLATION) { + colfunc = R_DrawTranslatedColumn; + dc_translation = translationtables - 256 + ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8)); + } + dc_iscale = abs(vis->xiscale)>>detailshift; + dc_texturemid = vis->texturemid; + frac = vis->startfrac; + spryscale = vis->scale; + sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); + for (dc_x = vis->x1; dc_x <= vis->x2; ++dc_x, frac += vis->xiscale) { + texturecolumn = frac>>FRACBITS; #ifdef RANGECHECK - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - I_Error ("R_DrawSpriteRange: bad texturecolumn"); + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + I_Error ("R_DrawSpriteRange: bad texturecolumn"); #endif - column = (column_t *) ((byte *)patch + - LONG(patch->columnofs[texturecolumn])); - R_DrawMaskedColumn (column); - } - colfunc = basecolfunc; + column = (column_t*)((byte*)patch + LONG(patch->columnofs[texturecolumn])); + R_DrawMaskedColumn (column); + } + colfunc = basecolfunc; } -void R_ProjectSprite (mobj_t* thing) + +void +R_ProjectSprite(mobj_t* thing) { - fixed_t tr_x; - fixed_t tr_y; - fixed_t gxt; - fixed_t gyt; - fixed_t tx; - fixed_t tz; - fixed_t xscale; - int x1; - int x2; - spritedef_t* sprdef; - spriteframe_t* sprframe; - int lump; - unsigned rot; - boolean flip; - int index; - vissprite_t* vis; - angle_t ang; - fixed_t iscale; - tr_x = thing->x - viewx; - tr_y = thing->y - viewy; - gxt = FixedMul(tr_x,viewcos); - gyt = -FixedMul(tr_y,viewsin); - tz = gxt-gyt; - if (tz < MINZ) - return; - xscale = FixedDiv(projection, tz); - gxt = -FixedMul(tr_x,viewsin); - gyt = FixedMul(tr_y,viewcos); - tx = -(gyt+gxt); - if (abs(tx)>(tz<<2)) - return; + spriteframe_t* sprframe; + spritedef_t* sprdef; + vissprite_t* vis; + angle_t ang; + fixed_t tr_x, tr_y, gxt, gyt, tx, tz, xscale, iscale; + int x1, x2, lump, index; + uint rot; + boolean flip; + + tr_x = thing->x - viewx; + tr_y = thing->y - viewy; + gxt = FixedMul(tr_x,viewcos); + gyt = -FixedMul(tr_y,viewsin); + tz = gxt - gyt; + if (tz < MINZ) + return; + xscale = FixedDiv(projection, tz); + gxt = -FixedMul(tr_x,viewsin); + gyt = FixedMul(tr_y,viewcos); + tx = -(gyt+gxt); + if (abs(tx)>(tz<<2)) + return; #ifdef RANGECHECK - if ((unsigned)thing->sprite >= numsprites) - I_Error ("R_ProjectSprite: invalid sprite number %i ", - thing->sprite); + if ((unsigned)thing->sprite >= numsprites) + I_Error ("R_ProjectSprite: invalid sprite number %i ", thing->sprite); #endif - sprdef = &sprites[thing->sprite]; + sprdef = &sprites[thing->sprite]; #ifdef RANGECHECK - if ( (thing->frame&FF_FRAMEMASK) >= sprdef->numframes ) - I_Error ("R_ProjectSprite: invalid sprite frame %i : %i ", - thing->sprite, thing->frame); + if ((thing->frame&FF_FRAMEMASK) >= sprdef->numframes) + I_Error ("R_ProjectSprite: invalid sprite frame %i : %i ", thing->sprite, thing->frame); #endif - sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; - if (sprframe->rotate) - { - ang = R_PointToAngle (thing->x, thing->y); - rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29; - lump = sprframe->lump[rot]; - flip = (boolean)sprframe->flip[rot]; - } - else - { - lump = sprframe->lump[0]; - flip = (boolean)sprframe->flip[0]; - } - tx -= spriteoffset[lump]; - x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS; - if (x1 > viewwidth) - return; - tx += spritewidth[lump]; - x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1; - if (x2 < 0) - return; - vis = R_NewVisSprite (); - vis->mobjflags = thing->flags; - vis->scale = xscale<<detailshift; - vis->gx = thing->x; - vis->gy = thing->y; - vis->gz = thing->z; - vis->gzt = thing->z + spritetopoffset[lump]; - vis->texturemid = vis->gzt - viewz; - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - iscale = FixedDiv (FRACUNIT, xscale); - if (flip) - { - vis->startfrac = spritewidth[lump]-1; - vis->xiscale = -iscale; - } - else - { - vis->startfrac = 0; - vis->xiscale = iscale; - } - if (vis->x1 > x1) - vis->startfrac += vis->xiscale*(vis->x1-x1); - vis->patch = lump; - if (thing->flags & MF_SHADOW) - { - vis->colormap = NULL; - } - else if (fixedcolormap) - { - vis->colormap = fixedcolormap; - } - else if (thing->frame & FF_FULLBRIGHT) - { - vis->colormap = colormaps; - } - else - { - index = xscale>>(LIGHTSCALESHIFT-detailshift); - if (index >= MAXLIGHTSCALE) - index = MAXLIGHTSCALE-1; - vis->colormap = spritelights[index]; - } + sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; + if (sprframe->rotate) { + ang = R_PointToAngle (thing->x, thing->y); + rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29; + lump = sprframe->lump[rot]; + flip = (boolean)sprframe->flip[rot]; + } else { + lump = sprframe->lump[0]; + flip = (boolean)sprframe->flip[0]; + } + tx -= spriteoffset[lump]; + x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS; + if (x1 > viewwidth) + return; + tx += spritewidth[lump]; + x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1; + if (x2 < 0) + return; + vis = R_NewVisSprite(); + vis->mobjflags = thing->flags; + vis->scale = xscale<<detailshift; + vis->gx = thing->x; + vis->gy = thing->y; + vis->gz = thing->z; + vis->gzt = thing->z + spritetopoffset[lump]; + vis->texturemid = vis->gzt - viewz; + vis->x1 = x1 < 0 ? 0 : x1; + vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + iscale = FixedDiv(FRACUNIT, xscale); + if (flip) { + vis->startfrac = spritewidth[lump]-1; + vis->xiscale = -iscale; + } else { + vis->startfrac = 0; + vis->xiscale = iscale; + } + if (vis->x1 > x1) + vis->startfrac += vis->xiscale*(vis->x1-x1); + vis->patch = lump; + if (thing->flags & MF_SHADOW) + vis->colormap = NULL; + else if (fixedcolormap) + vis->colormap = fixedcolormap; + else if (thing->frame & FF_FULLBRIGHT) + vis->colormap = colormaps; + else { + index = xscale>>(LIGHTSCALESHIFT-detailshift); + if (index >= MAXLIGHTSCALE) + index = MAXLIGHTSCALE-1; + vis->colormap = spritelights[index]; + } } -void R_AddSprites (sector_t* sec) + +void +R_AddSprites(sector_t* sec) { - mobj_t* thing; - int lightnum; - if (sec->validcount == validcount) - return; - sec->validcount = validcount; - lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (lightnum < 0) - spritelights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - spritelights = scalelight[LIGHTLEVELS-1]; - else - spritelights = scalelight[lightnum]; - for (thing = sec->thinglist ; thing ; thing = thing->snext) - R_ProjectSprite (thing); + mobj_t* thing; + int lightnum; + + if (sec->validcount == validcount) + return; + sec->validcount = validcount; + lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight; + if (lightnum < 0) + spritelights = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + spritelights = scalelight[LIGHTLEVELS-1]; + else + spritelights = scalelight[lightnum]; + for (thing = sec->thinglist; thing; thing = thing->snext) + R_ProjectSprite (thing); } -void R_DrawPSprite (pspdef_t* psp) + +void +R_DrawPSprite(pspdef_t* psp) { - fixed_t tx; - int x1; - int x2; - spritedef_t* sprdef; - spriteframe_t* sprframe; - int lump; - boolean flip; - vissprite_t* vis; - vissprite_t avis; + spriteframe_t* sprframe; + spritedef_t* sprdef; + vissprite_t avis, *vis; + fixed_t tx; + int x1, x2, lump; + boolean flip; #ifdef RANGECHECK - if ( (unsigned)psp->state->sprite >= numsprites) - I_Error ("R_ProjectSprite: invalid sprite number %i ", - psp->state->sprite); + if ( (unsigned)psp->state->sprite >= numsprites) + I_Error ("R_ProjectSprite: invalid sprite number %i ", psp->state->sprite); #endif - sprdef = &sprites[psp->state->sprite]; + sprdef = &sprites[psp->state->sprite]; #ifdef RANGECHECK - if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) - I_Error ("R_ProjectSprite: invalid sprite frame %i : %i ", - psp->state->sprite, psp->state->frame); + if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) + I_Error ("R_ProjectSprite: invalid sprite frame %i : %i ", psp->state->sprite, psp->state->frame); #endif - sprframe = &sprdef->spriteframes[ psp->state->frame & FF_FRAMEMASK ]; - lump = sprframe->lump[0]; - flip = (boolean)sprframe->flip[0]; - tx = psp->sx-160*FRACUNIT; - tx -= spriteoffset[lump]; - x1 = (centerxfrac + FixedMul (tx,pspritescale) ) >>FRACBITS; - if (x1 > viewwidth) - return; - tx += spritewidth[lump]; - x2 = ((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1; - if (x2 < 0) - return; - vis = &avis; - vis->mobjflags = 0; - vis->texturemid = (BASEYCENTER<<FRACBITS)+FRACUNIT/2-(psp->sy-spritetopoffset[lump]); - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - vis->scale = pspritescale<<detailshift; - if (flip) - { - vis->xiscale = -pspriteiscale; - vis->startfrac = spritewidth[lump]-1; - } - else - { - vis->xiscale = pspriteiscale; - vis->startfrac = 0; - } - if (vis->x1 > x1) - vis->startfrac += vis->xiscale*(vis->x1-x1); - vis->patch = lump; - if (viewplayer->powers[pw_invisibility] > 4*32 - || viewplayer->powers[pw_invisibility] & 8) - { - vis->colormap = NULL; - } - else if (fixedcolormap) - { - vis->colormap = fixedcolormap; - } - else if (psp->state->frame & FF_FULLBRIGHT) - { - vis->colormap = colormaps; - } - else - { - vis->colormap = spritelights[MAXLIGHTSCALE-1]; - } - R_DrawVisSprite (vis, vis->x1, vis->x2); + sprframe = &sprdef->spriteframes[psp->state->frame & FF_FRAMEMASK]; + lump = sprframe->lump[0]; + flip = (boolean)sprframe->flip[0]; + tx = psp->sx-160*FRACUNIT; + tx -= spriteoffset[lump]; + x1 = (centerxfrac + FixedMul (tx,pspritescale) ) >>FRACBITS; + if (x1 > viewwidth) + return; + tx += spritewidth[lump]; + x2 = ((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1; + if (x2 < 0) + return; + vis = &avis; + vis->mobjflags = 0; + vis->texturemid = (BASEYCENTER<<FRACBITS)+FRACUNIT/2-(psp->sy-spritetopoffset[lump]); + vis->x1 = x1 < 0 ? 0 : x1; + vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + vis->scale = pspritescale<<detailshift; + if (flip) { + vis->xiscale = -pspriteiscale; + vis->startfrac = spritewidth[lump]-1; + } else { + vis->xiscale = pspriteiscale; + vis->startfrac = 0; + } + if (vis->x1 > x1) + vis->startfrac += vis->xiscale*(vis->x1-x1); + vis->patch = lump; + if (viewplayer->powers[pw_invisibility] > 4*32 || viewplayer->powers[pw_invisibility] & 8) + vis->colormap = NULL; + else if (fixedcolormap) + vis->colormap = fixedcolormap; + else if (psp->state->frame & FF_FULLBRIGHT) + vis->colormap = colormaps; + else + vis->colormap = spritelights[MAXLIGHTSCALE-1]; + R_DrawVisSprite (vis, vis->x1, vis->x2); } -void R_DrawPlayerSprites (void) + +void +R_DrawPlayerSprites() { - int i; - int lightnum; - pspdef_t* psp; - lightnum = - (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) - +extralight; - if (lightnum < 0) - spritelights = scalelight[0]; - else if (lightnum >= LIGHTLEVELS) - spritelights = scalelight[LIGHTLEVELS-1]; - else - spritelights = scalelight[lightnum]; - mfloorclip = screenheightarray; - mceilingclip = negonearray; - for (i=0, psp=viewplayer->psprites; - i<NUMPSPRITES; - i++,psp++) - { - if (psp->state) - R_DrawPSprite (psp); - } + int i, lightnum; + pspdef_t* psp; + + lightnum = (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) + extralight; + if (lightnum < 0) + spritelights = scalelight[0]; + else if (lightnum >= LIGHTLEVELS) + spritelights = scalelight[LIGHTLEVELS-1]; + else + spritelights = scalelight[lightnum]; + mfloorclip = screenheightarray; + mceilingclip = negonearray; + for (i = 0, psp = viewplayer->psprites; i < NUMPSPRITES; ++i, ++psp) + if (psp->state) + R_DrawPSprite(psp); } -vissprite_t vsprsortedhead; -void R_SortVisSprites (void) + +vissprite_t vsprsortedhead; + +void +R_SortVisSprites() { - int i; - int count; - vissprite_t* ds; - vissprite_t* best; - vissprite_t unsorted; - fixed_t bestscale; - count = vissprite_p - vissprites; - unsorted.next = unsorted.prev = &unsorted; - if (!count) - return; - for (ds=vissprites ; ds<vissprite_p ; ds++) - { - ds->next = ds+1; - ds->prev = ds-1; - } - vissprites[0].prev = &unsorted; - unsorted.next = &vissprites[0]; - (vissprite_p-1)->next = &unsorted; - unsorted.prev = vissprite_p-1; - vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; - for (i=0 ; i<count ; i++) - { - bestscale = MAXINT; - for (ds=unsorted.next ; ds!= &unsorted ; ds=ds->next) - { - if (ds->scale < bestscale) - { - bestscale = ds->scale; - best = ds; - } + vissprite_t* best, *ds; + vissprite_t unsorted; + fixed_t bestscale; + int i, count; + + count = vissprite_p - vissprites; + unsorted.next = unsorted.prev = &unsorted; + if (!count) + return; + for (ds = vissprites; ds < vissprite_p; ++ds) { + ds->next = ds+1; + ds->prev = ds-1; + } + vissprites[0].prev = &unsorted; + unsorted.next = &vissprites[0]; + (vissprite_p-1)->next = &unsorted; + unsorted.prev = vissprite_p-1; + vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; + for (i = 0; i < count; ++i) { + bestscale = INT_MAX; + for (best = ds = unsorted.next; ds != &unsorted; ds = ds->next) { + if (ds->scale < bestscale) { + bestscale = ds->scale; + best = ds; + } + } + best->next->prev = best->prev; + best->prev->next = best->next; + best->next = &vsprsortedhead; + best->prev = vsprsortedhead.prev; + vsprsortedhead.prev->next = best; + vsprsortedhead.prev = best; } - best->next->prev = best->prev; - best->prev->next = best->next; - best->next = &vsprsortedhead; - best->prev = vsprsortedhead.prev; - vsprsortedhead.prev->next = best; - vsprsortedhead.prev = best; - } } -void R_DrawSprite (vissprite_t* spr) + +void +R_DrawSprite(vissprite_t* spr) { - drawseg_t* ds; - short clipbot[SCREENWIDTH]; - short cliptop[SCREENWIDTH]; - int x; - int r1; - int r2; - fixed_t scale; - fixed_t lowscale; - int silhouette; - for (x = spr->x1 ; x<=spr->x2 ; x++) - clipbot[x] = cliptop[x] = -2; - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) - { - if (ds->x1 > spr->x2 - || ds->x2 < spr->x1 - || (!ds->silhouette - && !ds->maskedtexturecol) ) - { - continue; - } - r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; - r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; - if (ds->scale1 > ds->scale2) - { - lowscale = ds->scale2; - scale = ds->scale1; - } - else - { - lowscale = ds->scale1; - scale = ds->scale2; - } - if (scale < spr->scale - || ( lowscale < spr->scale - && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline) ) ) - { - if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, r1, r2); - continue; - } - silhouette = ds->silhouette; - if (spr->gz >= ds->bsilheight) - silhouette &= ~SIL_BOTTOM; - if (spr->gzt <= ds->tsilheight) - silhouette &= ~SIL_TOP; - if (silhouette == 1) - { - for (x=r1 ; x<=r2 ; x++) - if (clipbot[x] == -2) - clipbot[x] = ds->sprbottomclip[x]; - } - else if (silhouette == 2) - { - for (x=r1 ; x<=r2 ; x++) - if (cliptop[x] == -2) - cliptop[x] = ds->sprtopclip[x]; + drawseg_t* ds; + short clipbot[SCREENWIDTH], cliptop[SCREENWIDTH]; + fixed_t scale, lowscale; + int x, r1, r2, silhouette; + + for (x = spr->x1; x <= spr->x2; ++x) + clipbot[x] = cliptop[x] = -2; + for (ds = ds_p-1; ds >= drawsegs; --ds) { + if (ds->x1 > spr->x2 || ds->x2 < spr->x1 || (!ds->silhouette && !ds->maskedtexturecol) ) + continue; + r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; + r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; + if (ds->scale1 > ds->scale2) { + lowscale = ds->scale2; + scale = ds->scale1; + } else { + lowscale = ds->scale1; + scale = ds->scale2; + } + if (scale < spr->scale || ( lowscale < spr->scale && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) { + if (ds->maskedtexturecol) + R_RenderMaskedSegRange (ds, r1, r2); + continue; + } + silhouette = ds->silhouette; + if (spr->gz >= ds->bsilheight) + silhouette &= ~SIL_BOTTOM; + if (spr->gzt <= ds->tsilheight) + silhouette &= ~SIL_TOP; + if (silhouette == 1) { + for (x = r1; x <= r2; ++x) + if (clipbot[x] == -2) + clipbot[x] = ds->sprbottomclip[x]; + } + if (silhouette == 2) { + for (x = r1; x <= r2; ++x) + if (cliptop[x] == -2) + cliptop[x] = ds->sprtopclip[x]; + } + if (silhouette == 3) { + for (x = r1; x <= r2; ++x) { + if (clipbot[x] == -2) + clipbot[x] = ds->sprbottomclip[x]; + if (cliptop[x] == -2) + cliptop[x] = ds->sprtopclip[x]; + } + } } - else if (silhouette == 3) - { - for (x=r1 ; x<=r2 ; x++) - { - if (clipbot[x] == -2) - clipbot[x] = ds->sprbottomclip[x]; + for (x = spr->x1; x <= spr->x2; ++x) { + if (clipbot[x] == -2) + clipbot[x] = viewheight; if (cliptop[x] == -2) - cliptop[x] = ds->sprtopclip[x]; - } + cliptop[x] = -1; } - } - for (x = spr->x1 ; x<=spr->x2 ; x++) - { - if (clipbot[x] == -2) - clipbot[x] = viewheight; - if (cliptop[x] == -2) - cliptop[x] = -1; - } - mfloorclip = clipbot; - mceilingclip = cliptop; - R_DrawVisSprite (spr, spr->x1, spr->x2); + mfloorclip = clipbot; + mceilingclip = cliptop; + R_DrawVisSprite(spr, spr->x1, spr->x2); } -void R_DrawMasked (void) + +void +R_DrawMasked() { - vissprite_t* spr; - drawseg_t* ds; - R_SortVisSprites (); - if (vissprite_p > vissprites) - { - for (spr = vsprsortedhead.next ; - spr != &vsprsortedhead ; - spr=spr->next) - { - R_DrawSprite (spr); + vissprite_t* spr; + drawseg_t* ds; + + R_SortVisSprites(); + if (vissprite_p > vissprites) { + for (spr = vsprsortedhead.next; spr != &vsprsortedhead; spr=spr->next) + R_DrawSprite(spr); } - } - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) - if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, ds->x1, ds->x2); - if (!viewangleoffset) - R_DrawPlayerSprites (); + for (ds = ds_p-1; ds >= drawsegs; --ds) + if (ds->maskedtexturecol) + R_RenderMaskedSegRange(ds, ds->x1, ds->x2); + if (!viewangleoffset) + R_DrawPlayerSprites(); } diff --git a/src/r_things.h b/src/r_things.h @@ -1,31 +1,54 @@ #ifndef __R_THINGS__ #define __R_THINGS__ + + #ifdef __GNUG__ #pragma interface #endif + #define MAXVISSPRITES 128 + extern vissprite_t vissprites[MAXVISSPRITES]; extern vissprite_t* vissprite_p; extern vissprite_t vsprsortedhead; + + + extern short negonearray[SCREENWIDTH]; extern short screenheightarray[SCREENWIDTH]; + + extern short* mfloorclip; extern short* mceilingclip; extern fixed_t spryscale; extern fixed_t sprtopscreen; + extern fixed_t pspritescale; extern fixed_t pspriteiscale; + + void R_DrawMaskedColumn (column_t* column); + + void R_SortVisSprites (void); + void R_AddSprites (sector_t* sec); void R_AddPSprites (void); void R_DrawSprites (void); void R_InitSprites (char** namelist); void R_ClearSprites (void); void R_DrawMasked (void); + void R_ClipVisSprite ( vissprite_t* vis, int xl, int xh ); + + #endif + + + + + diff --git a/src/s_sound.c b/src/s_sound.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> + #include "i_system.h" #include "i_sound.h" #include "sounds.h" @@ -10,8 +11,9 @@ #include "doomdef.h" #include "p_local.h" #include "doomstat.h" -const char snd_prefixen[] -= { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' }; + +const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' }; + #define S_MAX_VOLUME 127 #define S_CLIPPING_DIST (1200*0x10000) #define S_CLOSE_DIST (160*0x10000) @@ -25,505 +27,333 @@ const char snd_prefixen[] #define S_IFRACVOL 30 #define NA 0 #define S_NUMCHANNELS 2 + +typedef struct { + sfxinfo_t* sfxinfo; + void* origin; + int handle; +} channel_t; + extern int snd_MusicDevice; extern int snd_SfxDevice; extern int snd_DesiredMusicDevice; extern int snd_DesiredSfxDevice; -typedef struct -{ - sfxinfo_t* sfxinfo; - void* origin; - int handle; -} channel_t; + static channel_t* channels; int snd_SfxVolume = 15; -int snd_MusicVolume = 15; -static boolean mus_paused; +int snd_MusicVolume = 15; +static boolean mus_paused; static musicinfo_t* mus_playing=0; -int numChannels; +int numChannels; static int nextcleanup; + int -S_getChannel -( void* origin, - sfxinfo_t* sfxinfo ); +S_getChannel(void* origin, sfxinfo_t* sfxinfo); + int -S_AdjustSoundParams -( mobj_t* listener, - mobj_t* source, - int* vol, - int* sep, - int* pitch ); +S_AdjustSoundParams(mobj_t* listener, mobj_t* source, int* vol, int* sep, int* pitch); void S_StopChannel(int cnum); -void S_Init -( int sfxVolume, - int musicVolume ) -{ - int i; - fprintf( stderr, "S_Init: default sfx volume %d\n", sfxVolume); - I_SetChannels(); - S_SetSfxVolume(sfxVolume); - S_SetMusicVolume(musicVolume); - channels = - (channel_t *) Z_Malloc(numChannels*sizeof(channel_t), PU_STATIC, 0); - for (i=0 ; i<numChannels ; i++) - channels[i].sfxinfo = 0; - mus_paused = 0; - for (i=1 ; i<NUMSFX ; i++) - S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; -} -void S_Start(void) -{ - int cnum; - int mnum; - for (cnum=0 ; cnum<numChannels ; cnum++) - if (channels[cnum].sfxinfo) - S_StopChannel(cnum); - mus_paused = 0; - if (gamemode == commercial) - mnum = mus_runnin + gamemap - 1; - else - { - int spmus[]= - { - mus_e3m4, - mus_e3m2, - mus_e3m3, - mus_e1m5, - mus_e2m7, - mus_e2m4, - mus_e2m6, - mus_e2m5, - mus_e1m9 - }; - if (gameepisode < 4) - mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1; - else - mnum = spmus[gamemap-1]; - } - S_ChangeMusic(mnum, true); - nextcleanup = 15; -} + void -S_StartSoundAtVolume -( void* origin_p, - int sfx_id, - int volume ) +S_Init(int sfxVolume, int musicVolume) { - int rc; - int sep; - int pitch; - int priority; - sfxinfo_t* sfx; - int cnum; - mobj_t* origin = (mobj_t *) origin_p; - /*fprintf( stderr, - "S_StartSoundAtVolume: playing sound %d (%s)\n", - sfx_id, S_sfx[sfx_id].name );*/ - if (sfx_id < 1 || sfx_id > NUMSFX) - I_Error("Bad sfx #: %d", sfx_id); - sfx = &S_sfx[sfx_id]; - if (sfx->link) - { - pitch = sfx->pitch; - priority = sfx->priority; - volume += sfx->volume; - if (volume < 1) - return; - if (volume > snd_SfxVolume) - volume = snd_SfxVolume; - } - else - { - pitch = NORM_PITCH; - priority = NORM_PRIORITY; - } - if (origin && origin != players[consoleplayer].mo) - { - rc = S_AdjustSoundParams(players[consoleplayer].mo, - origin, - &volume, - &sep, - &pitch); - if ( origin->x == players[consoleplayer].mo->x - && origin->y == players[consoleplayer].mo->y) - { - sep = NORM_SEP; - } - if (!rc) - return; - } - else - { - sep = NORM_SEP; - } - if (sfx_id >= sfx_sawup - && sfx_id <= sfx_sawhit) - { - pitch += 8 - (M_Random()&15); - if (pitch<0) - pitch = 0; - else if (pitch>255) - pitch = 255; - } - else if (sfx_id != sfx_itemup - && sfx_id != sfx_tink) - { - pitch += 16 - (M_Random()&31); - if (pitch<0) - pitch = 0; - else if (pitch>255) - pitch = 255; - } - S_StopSound(origin); - cnum = S_getChannel(origin, sfx); - if (cnum<0) - return; - if (sfx->lumpnum < 0) - sfx->lumpnum = I_GetSfxLumpNum(sfx); -#ifndef SNDSRV - if (!sfx->data) - { - fprintf( stderr, - "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n"); - } -#endif - if (sfx->usefulness++ < 0) - sfx->usefulness = 1; - channels[cnum].handle = I_StartSound(sfx_id, - /*sfx->data,*/ - volume, - sep, - pitch, - priority); -} + int i; + + fprintf(stderr, "S_Init: default sfx volume %d\n", sfxVolume); + I_SetChannels(); + S_SetSfxVolume(sfxVolume); + S_SetMusicVolume(musicVolume); + channels = (channel_t*)Z_Malloc(numChannels*sizeof(channel_t), PU_STATIC, 0); + for (i = 0; i < numChannels; ++i) + channels[i].sfxinfo = 0; + mus_paused = 0; + for (i = 1; i < NUMSFX; ++i) + S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; +} + void -S_StartSound -( void* origin, - int sfx_id ) +S_Start() { -#ifdef SAWDEBUG -#endif - S_StartSoundAtVolume(origin, sfx_id, snd_SfxVolume); -#ifdef SAWDEBUG + int cnum, mnum; + int spmus[] = { + mus_e3m4, + mus_e3m2, + mus_e3m3, + mus_e1m5, + mus_e2m7, + mus_e2m4, + mus_e2m6, + mus_e2m5, + mus_e1m9 + }; + + for (cnum = 0; cnum < numChannels; ++cnum) + if (channels[cnum].sfxinfo) + S_StopChannel(cnum); + mus_paused = 0; + if (gameepisode < 4) + mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1; + else + mnum = spmus[gamemap-1]; + S_ChangeMusic(mnum, true); + nextcleanup = 15; +} + +void +S_StartSoundAtVolume(void* origin_p, int sfx_id, int volume) { - int i; - int n; - static mobj_t* last_saw_origins[10] = {1,1,1,1,1,1,1,1,1,1}; - static int first_saw=0; - static int next_saw=0; - if (sfx_id == sfx_sawidl - || sfx_id == sfx_sawful - || sfx_id == sfx_sawhit) - { - for (i=first_saw;i!=next_saw;i=(i+1)%10) - if (last_saw_origins[i] != origin) - fprintf(stderr, "old origin 0x%lx != " - "origin 0x%lx for sfx %d\n", - last_saw_origins[i], - origin, - sfx_id); - last_saw_origins[next_saw] = origin; - next_saw = (next_saw + 1) % 10; - if (next_saw == first_saw) - first_saw = (first_saw + 1) % 10; - for (n=i=0; i<numChannels ; i++) - { - if (channels[i].sfxinfo == &S_sfx[sfx_sawidl] - || channels[i].sfxinfo == &S_sfx[sfx_sawful] - || channels[i].sfxinfo == &S_sfx[sfx_sawhit]) n++; + sfxinfo_t* sfx; + mobj_t* origin; + int rc, sep, pitch, priority, cnum; + origin = (mobj_t *) origin_p; + if (sfx_id < 1 || sfx_id > NUMSFX) + I_Error("Bad sfx #: %d", sfx_id); + sfx = &S_sfx[sfx_id]; + if (sfx->link) { + pitch = sfx->pitch; + priority = sfx->priority; + volume += sfx->volume; + if (volume < 1) + return; + if (volume > snd_SfxVolume) + volume = snd_SfxVolume; + } else { + pitch = NORM_PITCH; + priority = NORM_PRIORITY; } - if (n>1) - { - for (i=0; i<numChannels ; i++) - { - if (channels[i].sfxinfo == &S_sfx[sfx_sawidl] - || channels[i].sfxinfo == &S_sfx[sfx_sawful] - || channels[i].sfxinfo == &S_sfx[sfx_sawhit]) - { - fprintf(stderr, - "chn: sfxinfo=0x%lx, origin=0x%lx, " - "handle=%d\n", - channels[i].sfxinfo, - channels[i].origin, - channels[i].handle); - } - } - fprintf(stderr, "\n"); + if (origin && origin != players[consoleplayer].mo) { + rc = S_AdjustSoundParams(players[consoleplayer].mo, origin, &volume, &sep, &pitch); + if (origin->x == players[consoleplayer].mo->x && origin->y == players[consoleplayer].mo->y) + sep = NORM_SEP; + if (!rc) + return; + } else sep = NORM_SEP; + if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit) { + pitch += 8 - (M_Random()&15); + if (pitch<0) + pitch = 0; + if (pitch>255) + pitch = 255; } - } -} -#endif + if (sfx_id != sfx_itemup && sfx_id != sfx_tink) { + pitch += 16 - (M_Random()&31); + if (pitch < 0) + pitch = 0; + if (pitch > 255) + pitch = 255; + } + S_StopSound(origin); + cnum = S_getChannel(origin, sfx); + if (cnum<0) return; + if (sfx->lumpnum < 0) sfx->lumpnum = I_GetSfxLumpNum(sfx); + if (!sfx->data) fprintf(stderr, "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n"); + if (sfx->usefulness++ < 0) sfx->usefulness = 1; + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority); } -void S_StopSound(void *origin) + +void +S_StartSound(void* origin, int sfx_id) { - int cnum; - for (cnum=0 ; cnum<numChannels ; cnum++) - { - if (channels[cnum].sfxinfo && channels[cnum].origin == origin) - { - S_StopChannel(cnum); - break; - } - } + S_StartSoundAtVolume(origin, sfx_id, snd_SfxVolume); } -void S_PauseSound(void) + +void +S_StopSound(void *origin) { - if (mus_playing && !mus_paused) - { - I_PauseSong(mus_playing->handle); - mus_paused = true; - } + int cnum; + + for (cnum = 0; cnum < numChannels; ++cnum) + if (channels[cnum].sfxinfo && channels[cnum].origin == origin) { + S_StopChannel(cnum); + break; + } } -void S_ResumeSound(void) + +void +S_PauseSound() { - if (mus_playing && mus_paused) - { - I_ResumeSong(mus_playing->handle); - mus_paused = false; - } + if (mus_playing && !mus_paused) { + I_PauseSong(mus_playing->handle); + mus_paused = true; + } } -void S_UpdateSounds(void* listener_p) + +void +S_ResumeSound() { - int audible; - int cnum; - int volume; - int sep; - int pitch; - sfxinfo_t* sfx; - channel_t* c; - mobj_t* listener = (mobj_t*)listener_p; - /*if (gametic > nextcleanup) - { - for (i=1 ; i<NUMSFX ; i++) - { - if (S_sfx[i].usefulness < 1 - && S_sfx[i].usefulness > -1) - { - if (--S_sfx[i].usefulness == -1) - { - Z_ChangeTag(S_sfx[i].data, PU_CACHE); - S_sfx[i].data = 0; - } - } + if (mus_playing && mus_paused) { + I_ResumeSong(mus_playing->handle); + mus_paused = false; } - nextcleanup = gametic + 15; - }*/ - for (cnum=0 ; cnum<numChannels ; cnum++) - { - c = &channels[cnum]; - sfx = c->sfxinfo; - if (c->sfxinfo) - { - if (I_SoundIsPlaying(c->handle)) - { - volume = snd_SfxVolume; - pitch = NORM_PITCH; - sep = NORM_SEP; - if (sfx->link) - { - pitch = sfx->pitch; - volume += sfx->volume; - if (volume < 1) - { - S_StopChannel(cnum); - continue; - } - else if (volume > snd_SfxVolume) - { - volume = snd_SfxVolume; - } - } - if (c->origin && listener_p != c->origin) - { - audible = S_AdjustSoundParams(listener, - c->origin, - &volume, - &sep, - &pitch); - if (!audible) - { - S_StopChannel(cnum); - } - else - I_UpdateSoundParams(c->handle, volume, sep, pitch); +} + +void +S_UpdateSounds(void* listener_p) +{ + sfxinfo_t* sfx; + channel_t* c; + mobj_t* listener; + int audible, cnum, volume, sep, pitch; + + listener = (mobj_t*)listener_p; + for (cnum = 0; cnum < numChannels; ++cnum) { + c = &channels[cnum]; + sfx = c->sfxinfo; + if (c->sfxinfo) { + if (I_SoundIsPlaying(c->handle)) { + volume = snd_SfxVolume; + pitch = NORM_PITCH; + sep = NORM_SEP; + if (sfx->link) { + pitch = sfx->pitch; + volume += sfx->volume; + if (volume < 1) { + S_StopChannel(cnum); + continue; + } + if (volume > snd_SfxVolume) + volume = snd_SfxVolume; + } + if (c->origin && listener_p != c->origin) { + audible = S_AdjustSoundParams(listener, c->origin, &volume, &sep, &pitch); + if (!audible) + S_StopChannel(cnum); + else I_UpdateSoundParams(c->handle, volume, sep, pitch); + } + } + else S_StopChannel(cnum); } - } - else - { - S_StopChannel(cnum); - } } - } } -void S_SetMusicVolume(int volume) + +void +S_SetMusicVolume(int volume) { - if (volume < 0 || volume > 127) - { - I_Error("Attempt to set music volume at %d", - volume); - } - I_SetMusicVolume(127); - I_SetMusicVolume(volume); - snd_MusicVolume = volume; + if (volume < 0 || volume > 127) + I_Error("Attempt to set music volume at %d", volume); + I_SetMusicVolume(127); + I_SetMusicVolume(volume); + snd_MusicVolume = volume; } -void S_SetSfxVolume(int volume) + +void +S_SetSfxVolume(int volume) { - if (volume < 0 || volume > 127) - I_Error("Attempt to set sfx volume at %d", volume); - snd_SfxVolume = volume; + if (volume < 0 || volume > 127) + I_Error("Attempt to set sfx volume at %d", volume); + snd_SfxVolume = volume; } -void S_StartMusic(int m_id) + +void +S_StartMusic(int m_id) { - S_ChangeMusic(m_id, false); + S_ChangeMusic(m_id, false); } + void -S_ChangeMusic -( int musicnum, - int looping ) +S_ChangeMusic(int musicnum, int looping) { - musicinfo_t* music; - char namebuf[9]; - if ( (musicnum <= mus_None) - || (musicnum >= NUMMUSIC) ) - { - I_Error("Bad music number %d", musicnum); - } - else + musicinfo_t* music; + char namebuf[9]; + + if ((musicnum <= mus_None) || (musicnum >= NUMMUSIC)) + I_Error("Bad music number %d", musicnum); music = &S_music[musicnum]; - if (mus_playing == music) - return; - S_StopMusic(); - if (!music->lumpnum) - { - sprintf(namebuf, "d_%s", music->name); - music->lumpnum = W_GetNumForName(namebuf); - } - music->data = (void *) W_CacheLumpNum(music->lumpnum, PU_MUSIC); - music->handle = I_RegisterSong(music->data); - I_PlaySong(music->handle, looping); - mus_playing = music; + if (mus_playing == music) + return; + S_StopMusic(); + if (!music->lumpnum) { + sprintf(namebuf, "D_%s", music->name); + music->lumpnum = W_GetNumForName(namebuf); + } + music->data = (void *) W_CacheLumpNum(music->lumpnum, PU_MUSIC); + music->handle = I_RegisterSong(music->data); + I_PlaySong(music->handle, looping); + mus_playing = music; } -void S_StopMusic(void) + +void +S_StopMusic() { - if (mus_playing) - { - if (mus_paused) - I_ResumeSong(mus_playing->handle); - I_StopSong(mus_playing->handle); - I_UnRegisterSong(mus_playing->handle); - Z_ChangeTag(mus_playing->data, PU_CACHE); - mus_playing->data = 0; - mus_playing = 0; - } + if (mus_playing) { + if (mus_paused) + I_ResumeSong(mus_playing->handle); + I_StopSong(mus_playing->handle); + I_UnRegisterSong(mus_playing->handle); + Z_ChangeTag(mus_playing->data, PU_CACHE); + mus_playing->data = 0; + mus_playing = 0; + } } -void S_StopChannel(int cnum) + +void +S_StopChannel(int cnum) { - int i; - channel_t* c = &channels[cnum]; - if (c->sfxinfo) - { - if (I_SoundIsPlaying(c->handle)) - { -#ifdef SAWDEBUG - if (c->sfxinfo == &S_sfx[sfx_sawful]) - fprintf(stderr, "stopped\n"); -#endif - I_StopSound(c->handle); - } - for (i=0 ; i<numChannels ; i++) - { - if (cnum != i - && c->sfxinfo == channels[i].sfxinfo) - { - break; - } + channel_t* c; + int i; + + c = &channels[cnum]; + if (c->sfxinfo) { + if (I_SoundIsPlaying(c->handle)) + I_StopSound(c->handle); + for (i = 0; i < numChannels; ++i) + if (cnum != i && c->sfxinfo == channels[i].sfxinfo) + break; + c->sfxinfo->usefulness--; + c->sfxinfo = 0; } - c->sfxinfo->usefulness--; - c->sfxinfo = 0; - } } + int -S_AdjustSoundParams -( mobj_t* listener, - mobj_t* source, - int* vol, - int* sep, - int* pitch ) +S_AdjustSoundParams(mobj_t* listener, mobj_t* source, int* vol, int* sep, int* pitch) { - fixed_t approx_dist; - fixed_t adx; - fixed_t ady; - angle_t angle; - adx = abs(listener->x - source->x); - ady = abs(listener->y - source->y); - approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1); - if (gamemap != 8 - && approx_dist > S_CLIPPING_DIST) - { - return 0; - } - angle = R_PointToAngle2(listener->x, - listener->y, - source->x, - source->y); - if (angle > listener->angle) - angle = angle - listener->angle; - else - angle = angle + (0xffffffff - listener->angle); - angle >>= ANGLETOFINESHIFT; - *sep = 128 - (FixedMul(S_STEREO_SWING,finesine[angle])>>FRACBITS); - if (approx_dist < S_CLOSE_DIST) - { - *vol = snd_SfxVolume; - } - else if (gamemap == 8) - { - if (approx_dist > S_CLIPPING_DIST) - approx_dist = S_CLIPPING_DIST; - *vol = 15+ ((snd_SfxVolume-15) - *((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) - / S_ATTENUATOR; - } - else - { - *vol = (snd_SfxVolume - * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) - / S_ATTENUATOR; - } - return (*vol > 0); + fixed_t approx_dist, adx, ady; + angle_t angle; + + adx = abs(listener->x - source->x); + ady = abs(listener->y - source->y); + approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1); + if (gamemap != 8 && approx_dist > S_CLIPPING_DIST) + return 0; + angle = R_PointToAngle2(listener->x, listener->y, source->x, source->y); + if (angle > listener->angle) + angle = angle - listener->angle; + else angle = angle + (0xffffffff - listener->angle); + angle >>= ANGLETOFINESHIFT; + *sep = 128 - (FixedMul(S_STEREO_SWING,finesine[angle])>>FRACBITS); + if (approx_dist < S_CLOSE_DIST) + *vol = snd_SfxVolume; + else if (gamemap == 8) { + if (approx_dist > S_CLIPPING_DIST) + approx_dist = S_CLIPPING_DIST; + *vol = 15+ ((snd_SfxVolume-15) * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR; + } else *vol = (snd_SfxVolume * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR; + return (*vol > 0); } + int -S_getChannel -( void* origin, - sfxinfo_t* sfxinfo ) +S_getChannel(void* origin, sfxinfo_t* sfxinfo) { - int cnum; - channel_t* c; - for (cnum=0 ; cnum<numChannels ; cnum++) - { - if (!channels[cnum].sfxinfo) - break; - else if (origin && channels[cnum].origin == origin) - { - S_StopChannel(cnum); - break; + channel_t* c; + int cnum; + for (cnum = 0; cnum < numChannels; ++cnum) { + if (!channels[cnum].sfxinfo) + break; + if (origin && channels[cnum].origin == origin) { + S_StopChannel(cnum); + break; + } } - } - if (cnum == numChannels) - { - for (cnum=0 ; cnum<numChannels ; cnum++) - if (channels[cnum].sfxinfo->priority >= sfxinfo->priority) break; - if (cnum == numChannels) - { - return -1; + if (cnum == numChannels) { + for (cnum = 0; cnum < numChannels; ++cnum) + if (channels[cnum].sfxinfo->priority >= sfxinfo->priority) + break; + if (cnum == numChannels) + return -1; + else S_StopChannel(cnum); } - else - { - S_StopChannel(cnum); - } - } - c = &channels[cnum]; - c->sfxinfo = sfxinfo; - c->origin = origin; - return cnum; + c = &channels[cnum]; + c->sfxinfo = sfxinfo; + c->origin = origin; + return cnum; } diff --git a/src/s_sound.h b/src/s_sound.h @@ -1,32 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __S_SOUND__ #define __S_SOUND__ + + #ifdef __GNUG__ #pragma interface #endif + + + + + + + + void S_Init ( int sfxVolume, int musicVolume ); + + + + + + + + + void S_Start(void); + + + + + + void S_StartSound ( void* origin, int sound_id ); + + + + void S_StartSoundAtVolume ( void* origin, int sound_id, int volume ); + + + void S_StopSound(void* origin); + + + void S_StartMusic(int music_id); + + + void S_ChangeMusic ( int music_id, int looping ); + + void S_StopMusic(void); + + void S_PauseSound(void); void S_ResumeSound(void); + + + + + void S_UpdateSounds(void* listener); + void S_SetMusicVolume(int volume); void S_SetSfxVolume(int volume); + + #endif + + + + + diff --git a/src/sndserver b/src/sndserver Binary files differ. diff --git a/src/sounds.c b/src/sounds.c @@ -1,185 +1,187 @@ -#include "doomtype.h" +#include "doomdef.h" #include "sounds.h" + musicinfo_t S_music[] = { { 0 }, - { "e1m1", 0 }, - { "e1m2", 0 }, - { "e1m3", 0 }, - { "e1m4", 0 }, - { "e1m5", 0 }, - { "e1m6", 0 }, - { "e1m7", 0 }, - { "e1m8", 0 }, - { "e1m9", 0 }, - { "e2m1", 0 }, - { "e2m2", 0 }, - { "e2m3", 0 }, - { "e2m4", 0 }, - { "e2m5", 0 }, - { "e2m6", 0 }, - { "e2m7", 0 }, - { "e2m8", 0 }, - { "e2m9", 0 }, - { "e3m1", 0 }, - { "e3m2", 0 }, - { "e3m3", 0 }, - { "e3m4", 0 }, - { "e3m5", 0 }, - { "e3m6", 0 }, - { "e3m7", 0 }, - { "e3m8", 0 }, - { "e3m9", 0 }, - { "inter", 0 }, - { "intro", 0 }, - { "bunny", 0 }, - { "victor", 0 }, - { "introa", 0 }, - { "runnin", 0 }, - { "stalks", 0 }, - { "countd", 0 }, - { "betwee", 0 }, - { "doom", 0 }, - { "the_da", 0 }, - { "shawn", 0 }, - { "ddtblu", 0 }, - { "in_cit", 0 }, - { "dead", 0 }, - { "stlks2", 0 }, - { "theda2", 0 }, - { "doom2", 0 }, - { "ddtbl2", 0 }, - { "runni2", 0 }, - { "dead2", 0 }, - { "stlks3", 0 }, - { "romero", 0 }, - { "shawn2", 0 }, - { "messag", 0 }, - { "count2", 0 }, - { "ddtbl3", 0 }, - { "ampie", 0 }, - { "theda3", 0 }, - { "adrian", 0 }, - { "messg2", 0 }, - { "romer2", 0 }, - { "tense", 0 }, - { "shawn3", 0 }, - { "openin", 0 }, - { "evil", 0 }, - { "ultima", 0 }, - { "read_m", 0 }, - { "dm2ttl", 0 }, - { "dm2int", 0 } + { "E1M1", 0 }, + { "E1M2", 0 }, + { "E1M3", 0 }, + { "E1M4", 0 }, + { "E1M5", 0 }, + { "E1M6", 0 }, + { "E1M7", 0 }, + { "E1M8", 0 }, + { "E1M9", 0 }, + { "E2M1", 0 }, + { "E2M2", 0 }, + { "E2M3", 0 }, + { "E2M4", 0 }, + { "E2M5", 0 }, + { "E2M6", 0 }, + { "E2M7", 0 }, + { "E2M8", 0 }, + { "E2M9", 0 }, + { "E3M1", 0 }, + { "E3M2", 0 }, + { "E3M3", 0 }, + { "E3M4", 0 }, + { "E3M5", 0 }, + { "E3M6", 0 }, + { "E3M7", 0 }, + { "E3M8", 0 }, + { "E3M9", 0 }, + { "INTER", 0 }, + { "INTRO", 0 }, + { "BUNNY", 0 }, + { "VICTOR", 0 }, + { "INTROA", 0 }, + { "RUNNIN", 0 }, + { "STALKS", 0 }, + { "COUNTD", 0 }, + { "BETWEE", 0 }, + { "DOOM", 0 }, + { "THE_DA", 0 }, + { "SHAWN", 0 }, + { "DDTBLU", 0 }, + { "IN_CIT", 0 }, + { "DEAD", 0 }, + { "STLKS2", 0 }, + { "THEDA2", 0 }, + { "DOOM2", 0 }, + { "DDTBL2", 0 }, + { "RUNNI2", 0 }, + { "DEAD2", 0 }, + { "STLKS3", 0 }, + { "ROMERO", 0 }, + { "SHAWN2", 0 }, + { "MESSAG", 0 }, + { "COUNT2", 0 }, + { "DDTBL3", 0 }, + { "AMPIE", 0 }, + { "THEDA3", 0 }, + { "ADRIAN", 0 }, + { "MESSG2", 0 }, + { "ROMER2", 0 }, + { "TENSE", 0 }, + { "SHAWN3", 0 }, + { "OPENIN", 0 }, + { "EVIL", 0 }, + { "ULTIMA", 0 }, + { "READ_M", 0 }, + { "DM2TTL", 0 }, + { "DM2INT", 0 } }; + sfxinfo_t S_sfx[] = { - { "none", false, 0, 0, -1, -1, 0 }, - { "pistol", false, 64, 0, -1, -1, 0 }, - { "shotgn", false, 64, 0, -1, -1, 0 }, - { "sgcock", false, 64, 0, -1, -1, 0 }, - { "dshtgn", false, 64, 0, -1, -1, 0 }, - { "dbopn", false, 64, 0, -1, -1, 0 }, - { "dbcls", false, 64, 0, -1, -1, 0 }, - { "dbload", false, 64, 0, -1, -1, 0 }, - { "plasma", false, 64, 0, -1, -1, 0 }, - { "bfg", false, 64, 0, -1, -1, 0 }, - { "sawup", false, 64, 0, -1, -1, 0 }, - { "sawidl", false, 118, 0, -1, -1, 0 }, - { "sawful", false, 64, 0, -1, -1, 0 }, - { "sawhit", false, 64, 0, -1, -1, 0 }, - { "rlaunc", false, 64, 0, -1, -1, 0 }, - { "rxplod", false, 70, 0, -1, -1, 0 }, - { "firsht", false, 70, 0, -1, -1, 0 }, - { "firxpl", false, 70, 0, -1, -1, 0 }, - { "pstart", false, 100, 0, -1, -1, 0 }, - { "pstop", false, 100, 0, -1, -1, 0 }, - { "doropn", false, 100, 0, -1, -1, 0 }, - { "dorcls", false, 100, 0, -1, -1, 0 }, - { "stnmov", false, 119, 0, -1, -1, 0 }, - { "swtchn", false, 78, 0, -1, -1, 0 }, - { "swtchx", false, 78, 0, -1, -1, 0 }, - { "plpain", false, 96, 0, -1, -1, 0 }, - { "dmpain", false, 96, 0, -1, -1, 0 }, - { "popain", false, 96, 0, -1, -1, 0 }, - { "vipain", false, 96, 0, -1, -1, 0 }, - { "mnpain", false, 96, 0, -1, -1, 0 }, - { "pepain", false, 96, 0, -1, -1, 0 }, - { "slop", false, 78, 0, -1, -1, 0 }, - { "itemup", true, 78, 0, -1, -1, 0 }, - { "wpnup", true, 78, 0, -1, -1, 0 }, - { "oof", false, 96, 0, -1, -1, 0 }, - { "telept", false, 32, 0, -1, -1, 0 }, - { "posit1", true, 98, 0, -1, -1, 0 }, - { "posit2", true, 98, 0, -1, -1, 0 }, - { "posit3", true, 98, 0, -1, -1, 0 }, - { "bgsit1", true, 98, 0, -1, -1, 0 }, - { "bgsit2", true, 98, 0, -1, -1, 0 }, - { "sgtsit", true, 98, 0, -1, -1, 0 }, - { "cacsit", true, 98, 0, -1, -1, 0 }, - { "brssit", true, 94, 0, -1, -1, 0 }, - { "cybsit", true, 92, 0, -1, -1, 0 }, - { "spisit", true, 90, 0, -1, -1, 0 }, - { "bspsit", true, 90, 0, -1, -1, 0 }, - { "kntsit", true, 90, 0, -1, -1, 0 }, - { "vilsit", true, 90, 0, -1, -1, 0 }, - { "mansit", true, 90, 0, -1, -1, 0 }, - { "pesit", true, 90, 0, -1, -1, 0 }, - { "sklatk", false, 70, 0, -1, -1, 0 }, - { "sgtatk", false, 70, 0, -1, -1, 0 }, - { "skepch", false, 70, 0, -1, -1, 0 }, - { "vilatk", false, 70, 0, -1, -1, 0 }, - { "claw", false, 70, 0, -1, -1, 0 }, - { "skeswg", false, 70, 0, -1, -1, 0 }, - { "pldeth", false, 32, 0, -1, -1, 0 }, - { "pdiehi", false, 32, 0, -1, -1, 0 }, - { "podth1", false, 70, 0, -1, -1, 0 }, - { "podth2", false, 70, 0, -1, -1, 0 }, - { "podth3", false, 70, 0, -1, -1, 0 }, - { "bgdth1", false, 70, 0, -1, -1, 0 }, - { "bgdth2", false, 70, 0, -1, -1, 0 }, - { "sgtdth", false, 70, 0, -1, -1, 0 }, - { "cacdth", false, 70, 0, -1, -1, 0 }, - { "skldth", false, 70, 0, -1, -1, 0 }, - { "brsdth", false, 32, 0, -1, -1, 0 }, - { "cybdth", false, 32, 0, -1, -1, 0 }, - { "spidth", false, 32, 0, -1, -1, 0 }, - { "bspdth", false, 32, 0, -1, -1, 0 }, - { "vildth", false, 32, 0, -1, -1, 0 }, - { "kntdth", false, 32, 0, -1, -1, 0 }, - { "pedth", false, 32, 0, -1, -1, 0 }, - { "skedth", false, 32, 0, -1, -1, 0 }, - { "posact", true, 120, 0, -1, -1, 0 }, - { "bgact", true, 120, 0, -1, -1, 0 }, - { "dmact", true, 120, 0, -1, -1, 0 }, - { "bspact", true, 100, 0, -1, -1, 0 }, - { "bspwlk", true, 100, 0, -1, -1, 0 }, - { "vilact", true, 100, 0, -1, -1, 0 }, - { "noway", false, 78, 0, -1, -1, 0 }, - { "barexp", false, 60, 0, -1, -1, 0 }, - { "punch", false, 64, 0, -1, -1, 0 }, - { "hoof", false, 70, 0, -1, -1, 0 }, - { "metal", false, 70, 0, -1, -1, 0 }, - { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, - { "tink", false, 60, 0, -1, -1, 0 }, - { "bdopn", false, 100, 0, -1, -1, 0 }, - { "bdcls", false, 100, 0, -1, -1, 0 }, - { "itmbk", false, 100, 0, -1, -1, 0 }, - { "flame", false, 32, 0, -1, -1, 0 }, - { "flamst", false, 32, 0, -1, -1, 0 }, - { "getpow", false, 60, 0, -1, -1, 0 }, - { "bospit", false, 70, 0, -1, -1, 0 }, - { "boscub", false, 70, 0, -1, -1, 0 }, - { "bossit", false, 70, 0, -1, -1, 0 }, - { "bospn", false, 70, 0, -1, -1, 0 }, - { "bosdth", false, 70, 0, -1, -1, 0 }, - { "manatk", false, 70, 0, -1, -1, 0 }, - { "mandth", false, 70, 0, -1, -1, 0 }, - { "sssit", false, 70, 0, -1, -1, 0 }, - { "ssdth", false, 70, 0, -1, -1, 0 }, - { "keenpn", false, 70, 0, -1, -1, 0 }, - { "keendt", false, 70, 0, -1, -1, 0 }, - { "skeact", false, 70, 0, -1, -1, 0 }, - { "skesit", false, 70, 0, -1, -1, 0 }, - { "skeatk", false, 70, 0, -1, -1, 0 }, - { "radio", false, 60, 0, -1, -1, 0 } + { "NONE", false, 0, 0, -1, -1, 0 }, + { "PISTOL", false, 64, 0, -1, -1, 0 }, + { "SHOTGN", false, 64, 0, -1, -1, 0 }, + { "SGCOCK", false, 64, 0, -1, -1, 0 }, + { "DSHTGN", false, 64, 0, -1, -1, 0 }, + { "DBOPN", false, 64, 0, -1, -1, 0 }, + { "DBCLS", false, 64, 0, -1, -1, 0 }, + { "DBLOAD", false, 64, 0, -1, -1, 0 }, + { "PLASMA", false, 64, 0, -1, -1, 0 }, + { "BFG", false, 64, 0, -1, -1, 0 }, + { "SAWUP", false, 64, 0, -1, -1, 0 }, + { "SAWIDL", false, 118, 0, -1, -1, 0 }, + { "SAWFUL", false, 64, 0, -1, -1, 0 }, + { "SAWHIT", false, 64, 0, -1, -1, 0 }, + { "RLAUNC", false, 64, 0, -1, -1, 0 }, + { "RXPLOD", false, 70, 0, -1, -1, 0 }, + { "FIRSHT", false, 70, 0, -1, -1, 0 }, + { "FIRXPL", false, 70, 0, -1, -1, 0 }, + { "PSTART", false, 100, 0, -1, -1, 0 }, + { "PSTOP", false, 100, 0, -1, -1, 0 }, + { "DOROPN", false, 100, 0, -1, -1, 0 }, + { "DORCLS", false, 100, 0, -1, -1, 0 }, + { "STNMOV", false, 119, 0, -1, -1, 0 }, + { "SWTCHN", false, 78, 0, -1, -1, 0 }, + { "SWTCHX", false, 78, 0, -1, -1, 0 }, + { "PLPAIN", false, 96, 0, -1, -1, 0 }, + { "DMPAIN", false, 96, 0, -1, -1, 0 }, + { "POPAIN", false, 96, 0, -1, -1, 0 }, + { "VIPAIN", false, 96, 0, -1, -1, 0 }, + { "MNPAIN", false, 96, 0, -1, -1, 0 }, + { "PEPAIN", false, 96, 0, -1, -1, 0 }, + { "SLOP", false, 78, 0, -1, -1, 0 }, + { "ITEMUP", true, 78, 0, -1, -1, 0 }, + { "WPNUP", true, 78, 0, -1, -1, 0 }, + { "OOF", false, 96, 0, -1, -1, 0 }, + { "TELEPT", false, 32, 0, -1, -1, 0 }, + { "POSIT1", true, 98, 0, -1, -1, 0 }, + { "POSIT2", true, 98, 0, -1, -1, 0 }, + { "POSIT3", true, 98, 0, -1, -1, 0 }, + { "BGSIT1", true, 98, 0, -1, -1, 0 }, + { "BGSIT2", true, 98, 0, -1, -1, 0 }, + { "SGTSIT", true, 98, 0, -1, -1, 0 }, + { "CACSIT", true, 98, 0, -1, -1, 0 }, + { "BRSSIT", true, 94, 0, -1, -1, 0 }, + { "CYBSIT", true, 92, 0, -1, -1, 0 }, + { "SPISIT", true, 90, 0, -1, -1, 0 }, + { "BSPSIT", true, 90, 0, -1, -1, 0 }, + { "KNTSIT", true, 90, 0, -1, -1, 0 }, + { "VILSIT", true, 90, 0, -1, -1, 0 }, + { "MANSIT", true, 90, 0, -1, -1, 0 }, + { "PESIT", true, 90, 0, -1, -1, 0 }, + { "SKLATK", false, 70, 0, -1, -1, 0 }, + { "SGTATK", false, 70, 0, -1, -1, 0 }, + { "SKEPCH", false, 70, 0, -1, -1, 0 }, + { "VILATK", false, 70, 0, -1, -1, 0 }, + { "CLAW", false, 70, 0, -1, -1, 0 }, + { "SKESWG", false, 70, 0, -1, -1, 0 }, + { "PLDETH", false, 32, 0, -1, -1, 0 }, + { "PDIEHI", false, 32, 0, -1, -1, 0 }, + { "PODTH1", false, 70, 0, -1, -1, 0 }, + { "PODTH2", false, 70, 0, -1, -1, 0 }, + { "PODTH3", false, 70, 0, -1, -1, 0 }, + { "BGDTH1", false, 70, 0, -1, -1, 0 }, + { "BGDTH2", false, 70, 0, -1, -1, 0 }, + { "SGTDTH", false, 70, 0, -1, -1, 0 }, + { "CACDTH", false, 70, 0, -1, -1, 0 }, + { "SKLDTH", false, 70, 0, -1, -1, 0 }, + { "BRSDTH", false, 32, 0, -1, -1, 0 }, + { "CYBDTH", false, 32, 0, -1, -1, 0 }, + { "SPIDTH", false, 32, 0, -1, -1, 0 }, + { "BSPDTH", false, 32, 0, -1, -1, 0 }, + { "VILDTH", false, 32, 0, -1, -1, 0 }, + { "KNTDTH", false, 32, 0, -1, -1, 0 }, + { "PEDTH", false, 32, 0, -1, -1, 0 }, + { "SKEDTH", false, 32, 0, -1, -1, 0 }, + { "POSACT", true, 120, 0, -1, -1, 0 }, + { "BGACT", true, 120, 0, -1, -1, 0 }, + { "DMACT", true, 120, 0, -1, -1, 0 }, + { "BSPACT", true, 100, 0, -1, -1, 0 }, + { "BSPWLK", true, 100, 0, -1, -1, 0 }, + { "VILACT", true, 100, 0, -1, -1, 0 }, + { "NOWAY", false, 78, 0, -1, -1, 0 }, + { "BAREXP", false, 60, 0, -1, -1, 0 }, + { "PUNCH", false, 64, 0, -1, -1, 0 }, + { "HOOF", false, 70, 0, -1, -1, 0 }, + { "METAL", false, 70, 0, -1, -1, 0 }, + { "CHGUN", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, + { "TINK", false, 60, 0, -1, -1, 0 }, + { "BDOPN", false, 100, 0, -1, -1, 0 }, + { "BDCLS", false, 100, 0, -1, -1, 0 }, + { "ITMBK", false, 100, 0, -1, -1, 0 }, + { "FLAME", false, 32, 0, -1, -1, 0 }, + { "FLAMST", false, 32, 0, -1, -1, 0 }, + { "GETPOW", false, 60, 0, -1, -1, 0 }, + { "BOSPIT", false, 70, 0, -1, -1, 0 }, + { "BOSCUB", false, 70, 0, -1, -1, 0 }, + { "BOSSIT", false, 70, 0, -1, -1, 0 }, + { "BOSPN", false, 70, 0, -1, -1, 0 }, + { "BOSDTH", false, 70, 0, -1, -1, 0 }, + { "MANATK", false, 70, 0, -1, -1, 0 }, + { "MANDTH", false, 70, 0, -1, -1, 0 }, + { "SSSIT", false, 70, 0, -1, -1, 0 }, + { "SSDTH", false, 70, 0, -1, -1, 0 }, + { "KEENPN", false, 70, 0, -1, -1, 0 }, + { "KEENDT", false, 70, 0, -1, -1, 0 }, + { "SKEACT", false, 70, 0, -1, -1, 0 }, + { "SKESIT", false, 70, 0, -1, -1, 0 }, + { "SKEATK", false, 70, 0, -1, -1, 0 }, + { "RADIO", false, 60, 0, -1, -1, 0 } }; diff --git a/src/sounds.h b/src/sounds.h @@ -1,27 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __SOUNDS__ #define __SOUNDS__ + + + + + typedef struct sfxinfo_struct sfxinfo_t; + struct sfxinfo_struct { + char* name; + + int singularity; + + int priority; + + sfxinfo_t* link; + + int pitch; + + int volume; + + void* data; + + + + int usefulness; + + int lumpnum; }; + + + + + + + typedef struct { + char* name; + + int lumpnum; + + void* data; + + int handle; + } musicinfo_t; + + + + + extern sfxinfo_t S_sfx[]; + + extern musicinfo_t S_music[]; + + + + + typedef enum { mus_None, @@ -94,6 +168,12 @@ typedef enum mus_dm2int, NUMMUSIC } musicenum_t; + + + + + + typedef enum { sfx_None, @@ -207,4 +287,11 @@ typedef enum sfx_radio, NUMSFX } sfxenum_t; + #endif + + + + + + diff --git a/src/st_lib.c b/src/st_lib.c @@ -1,19 +1,39 @@ #include <ctype.h> + #include "doomdef.h" + #include "z_zone.h" #include "v_video.h" #include "m_swap.h" + #include "i_system.h" + #include "w_wad.h" + #include "st_stuff.h" #include "st_lib.h" #include "r_local.h" + + + extern boolean automapactive; + + + + + + + + patch_t* sttminus; + void STlib_init(void) { sttminus = (patch_t *) W_CacheLumpName("STTMINUS", PU_STATIC); } + + + void STlib_initNum ( st_number_t* n, @@ -32,45 +52,75 @@ STlib_initNum n->on = on; n->p = pl; } + + + + + + + void STlib_drawNum ( st_number_t* n, boolean refresh ) { + int numdigits = n->width; int num = *n->num; + int w = SHORT(n->p[0]->width); int h = SHORT(n->p[0]->height); int x = n->x; + int neg; + n->oldnum = *n->num; + neg = num < 0; + if (neg) { if (numdigits == 2 && num < -9) num = -9; else if (numdigits == 3 && num < -99) num = -99; + num = -num; } + + x = n->x - numdigits*w; + if (n->y - ST_Y < 0) I_Error("drawNum: n->y - ST_Y < 0"); + V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG); + + if (num == 1994) return; + x = n->x; + + if (!num) V_DrawPatch(x - w, n->y, FG, n->p[ 0 ]); + + while (num && numdigits--) { x -= w; V_DrawPatch(x, n->y, FG, n->p[ num % 10 ]); num /= 10; } + + if (neg) V_DrawPatch(x - 8, n->y, FG, sttminus); } + + + void STlib_updateNum ( st_number_t* n, @@ -78,6 +128,9 @@ STlib_updateNum { if (*n->on) STlib_drawNum(n, refresh); } + + + void STlib_initPercent ( st_percent_t* p, @@ -91,6 +144,10 @@ STlib_initPercent STlib_initNum(&p->n, x, y, pl, num, on, 3); p->p = percent; } + + + + void STlib_updatePercent ( st_percent_t* per, @@ -98,8 +155,12 @@ STlib_updatePercent { if (refresh && *per->n.on) V_DrawPatch(per->n.x, per->n.y, FG, per->p); + STlib_updateNum(&per->n, refresh); } + + + void STlib_initMultIcon ( st_multicon_t* i, @@ -116,6 +177,9 @@ STlib_initMultIcon i->on = on; i->p = il; } + + + void STlib_updateMultIcon ( st_multicon_t* mi, @@ -125,6 +189,7 @@ STlib_updateMultIcon int h; int x; int y; + if (*mi->on && (mi->oldinum != *mi->inum || refresh) && (*mi->inum!=-1)) @@ -135,14 +200,19 @@ STlib_updateMultIcon y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset); w = SHORT(mi->p[mi->oldinum]->width); h = SHORT(mi->p[mi->oldinum]->height); + if (y - ST_Y < 0) I_Error("updateMultIcon: y - ST_Y < 0"); + V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); } V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]); mi->oldinum = *mi->inum; } } + + + void STlib_initBinIcon ( st_binicon_t* b, @@ -159,6 +229,9 @@ STlib_initBinIcon b->on = on; b->p = i; } + + + void STlib_updateBinIcon ( st_binicon_t* bi, @@ -168,6 +241,7 @@ STlib_updateBinIcon int y; int w; int h; + if (*bi->on && (bi->oldval != *bi->val || refresh)) { @@ -175,12 +249,17 @@ STlib_updateBinIcon y = bi->y - SHORT(bi->p->topoffset); w = SHORT(bi->p->width); h = SHORT(bi->p->height); + if (y - ST_Y < 0) I_Error("updateBinIcon: y - ST_Y < 0"); + if (*bi->val) V_DrawPatch(bi->x, bi->y, FG, bi->p); else V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); + bi->oldval = *bi->val; } + } + diff --git a/src/st_lib.h b/src/st_lib.h @@ -1,45 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + #ifndef __STLIB__ #define __STLIB__ + + + #include "r_defs.h" + + + + + #define BG 4 #define FG 0 + + + + + + + + + typedef struct { + + int x; int y; + + int width; + + int oldnum; + + int* num; + + + boolean* on; + + patch_t** p; + + int data; + } st_number_t; + + + + + typedef struct { + st_number_t n; + + patch_t* p; + } st_percent_t; + + + + typedef struct { + int x; int y; + + int oldinum; + + int* inum; + + + boolean* on; + + patch_t** p; + + int data; + } st_multicon_t; + + + + + + typedef struct { + int x; int y; + + int oldval; + + boolean* val; + + + boolean* on; + + patch_t* p; int data; + } st_binicon_t; + + + + + + + + + + + void STlib_init(void); + + + + void STlib_initNum ( st_number_t* n, @@ -49,10 +161,14 @@ STlib_initNum int* num, boolean* on, int width ); + void STlib_updateNum ( st_number_t* n, boolean refresh ); + + + void STlib_initPercent ( st_percent_t* p, @@ -62,10 +178,15 @@ STlib_initPercent int* num, boolean* on, patch_t* percent ); + + void STlib_updatePercent ( st_percent_t* per, int refresh ); + + + void STlib_initMultIcon ( st_multicon_t* mi, @@ -74,10 +195,15 @@ STlib_initMultIcon patch_t** il, int* inum, boolean* on ); + + void STlib_updateMultIcon ( st_multicon_t* mi, boolean refresh ); + + + void STlib_initBinIcon ( st_binicon_t* b, @@ -86,8 +212,15 @@ STlib_initBinIcon patch_t* i, boolean* val, boolean* on ); + void STlib_updateBinIcon ( st_binicon_t* bi, boolean refresh ); + #endif + + + + + diff --git a/src/st_stuff.c b/src/st_stuff.c @@ -1,4 +1,5 @@ #include <stdio.h> + #include "i_system.h" #include "i_video.h" #include "z_zone.h" @@ -34,11 +35,9 @@ #define ST_NUMSTRAIGHTFACES 3 #define ST_NUMTURNFACES 2 #define ST_NUMSPECIALFACES 3 -#define ST_FACESTRIDE \ - (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES) +#define ST_FACESTRIDE (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES) #define ST_NUMEXTRAFACES 2 -#define ST_NUMFACES \ - (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES) +#define ST_NUMFACES (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES) #define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES) #define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES) #define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1) @@ -53,10 +52,10 @@ #define ST_OUCHCOUNT (1*TICRATE) #define ST_RAMPAGEDELAY (2*TICRATE) #define ST_MUCHPAIN 20 -#define ST_AMMOWIDTH 3 +#define ST_AMMOWIDTH 3 #define ST_AMMOX 44 #define ST_AMMOY 171 -#define ST_HEALTHWIDTH 3 +#define ST_HEALTHWIDTH 3 #define ST_HEALTHX 90 #define ST_HEALTHY 171 #define ST_ARMSX 111 @@ -66,7 +65,7 @@ #define ST_ARMSXSPACE 12 #define ST_ARMSYSPACE 10 #define ST_FRAGSX 138 -#define ST_FRAGSY 171 +#define ST_FRAGSY 171 #define ST_FRAGSWIDTH 2 #define ST_ARMORWIDTH 3 #define ST_ARMORX 221 @@ -107,19 +106,19 @@ #define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH #define ST_MAXAMMO3X 314 #define ST_MAXAMMO3Y 185 -#define ST_WEAPON0X 110 +#define ST_WEAPON0X 110 #define ST_WEAPON0Y 172 -#define ST_WEAPON1X 122 +#define ST_WEAPON1X 122 #define ST_WEAPON1Y 172 -#define ST_WEAPON2X 134 +#define ST_WEAPON2X 134 #define ST_WEAPON2Y 172 -#define ST_WEAPON3X 110 +#define ST_WEAPON3X 110 #define ST_WEAPON3Y 181 -#define ST_WEAPON4X 122 +#define ST_WEAPON4X 122 #define ST_WEAPON4Y 181 #define ST_WEAPON5X 134 #define ST_WEAPON5Y 181 -#define ST_WPNSX 109 +#define ST_WPNSX 109 #define ST_WPNSY 191 #define ST_DETHX 109 #define ST_DETHY 191 @@ -129,15 +128,14 @@ #define ST_MSGHEIGHT 1 #define ST_OUTTEXTX 0 #define ST_OUTTEXTY 6 -#define ST_OUTWIDTH 52 +#define ST_OUTWIDTH 52 #define ST_OUTHEIGHT 1 -#define ST_MAPWIDTH \ - (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)])) -#define ST_MAPTITLEX \ - (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH) +#define ST_MAPWIDTH (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)])) +#define ST_MAPTITLEX (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH) #define ST_MAPTITLEY 0 #define ST_MAPHEIGHT 1 -static player_t* plyr; + +static player_t* plyr; static boolean st_firsttime; static int veryfirsttime = 1; static int lu_palette; @@ -149,782 +147,531 @@ static boolean st_statusbaron; static boolean st_chat; static boolean st_oldchat; static boolean st_cursoron; -static boolean st_notdeathmatch; +static boolean st_notdeathmatch; static boolean st_armson; -static boolean st_fragson; +static boolean st_fragson; static patch_t* sbar; static patch_t* tallnum[10]; static patch_t* tallpercent; static patch_t* shortnum[10]; -static patch_t* keys[NUMCARDS]; +static patch_t* keys[NUMCARDS]; static patch_t* faces[ST_NUMFACES]; static patch_t* faceback; static patch_t* armsbg; -static patch_t* arms[6][2]; +static patch_t* arms[6][2]; static st_number_t w_ready; static st_number_t w_frags; static st_percent_t w_health; -static st_binicon_t w_armsbg; +static st_binicon_t w_armsbg; static st_multicon_t w_arms[6]; -static st_multicon_t w_faces; +static st_multicon_t w_faces; static st_multicon_t w_keyboxes[3]; static st_percent_t w_armor; static st_number_t w_ammo[4]; -static st_number_t w_maxammo[4]; +static st_number_t w_maxammo[4]; static int st_fragscount; static int st_oldhealth = -1; -static boolean oldweaponsowned[NUMWEAPONS]; +static boolean oldweaponsowned[NUMWEAPONS]; static int st_facecount = 0; static int st_faceindex = 0; -static int keyboxes[3]; -static int st_randomnumber; -unsigned char cheat_mus_seq[] = -{ - 0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff -}; -unsigned char cheat_choppers_seq[] = -{ - 0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff -}; -unsigned char cheat_god_seq[] = -{ - 0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff -}; -unsigned char cheat_ammo_seq[] = -{ - 0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff -}; -unsigned char cheat_ammonokey_seq[] = -{ - 0xb2, 0x26, 0x66, 0xa2, 0xff -}; -unsigned char cheat_noclip_seq[] = -{ - 0xb2, 0x26, 0xea, 0x2a, 0xb2, - 0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff -}; -unsigned char cheat_commercial_noclip_seq[] = -{ - 0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff -}; -unsigned char cheat_powerup_seq[7][10] = -{ - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, - { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff } +static int keyboxes[3]; +static int st_randomnumber; +static int st_palette = 0; +static boolean st_stopped = true; + +unsigned char cheat_mus_seq[] = { 0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff }; +unsigned char cheat_choppers_seq[] = { 0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff }; +unsigned char cheat_god_seq[] = { 0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff }; +unsigned char cheat_ammo_seq[] = { 0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff }; +unsigned char cheat_ammonokey_seq[] = { 0xb2, 0x26, 0x66, 0xa2, 0xff }; +unsigned char cheat_noclip_seq[] = { + 0xb2, 0x26, 0xea, 0x2a, 0xb2, + 0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff }; -unsigned char cheat_clev_seq[] = -{ - 0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff +unsigned char cheat_commercial_noclip_seq[] = { 0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff }; +unsigned char cheat_powerup_seq[7][10] = { + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, + { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff } }; -unsigned char cheat_mypos_seq[] = -{ - 0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff -}; +unsigned char cheat_clev_seq[] = { 0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff }; +unsigned char cheat_mypos_seq[] = { 0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff }; cheatseq_t cheat_mus = { cheat_mus_seq, 0 }; cheatseq_t cheat_god = { cheat_god_seq, 0 }; cheatseq_t cheat_ammo = { cheat_ammo_seq, 0 }; cheatseq_t cheat_ammonokey = { cheat_ammonokey_seq, 0 }; cheatseq_t cheat_noclip = { cheat_noclip_seq, 0 }; cheatseq_t cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 }; -cheatseq_t cheat_powerup[7] = -{ - { cheat_powerup_seq[0], 0 }, - { cheat_powerup_seq[1], 0 }, - { cheat_powerup_seq[2], 0 }, - { cheat_powerup_seq[3], 0 }, - { cheat_powerup_seq[4], 0 }, - { cheat_powerup_seq[5], 0 }, - { cheat_powerup_seq[6], 0 } +cheatseq_t cheat_powerup[7] = { + { cheat_powerup_seq[0], 0 }, + { cheat_powerup_seq[1], 0 }, + { cheat_powerup_seq[2], 0 }, + { cheat_powerup_seq[3], 0 }, + { cheat_powerup_seq[4], 0 }, + { cheat_powerup_seq[5], 0 }, + { cheat_powerup_seq[6], 0 } }; cheatseq_t cheat_choppers = { cheat_choppers_seq, 0 }; cheatseq_t cheat_clev = { cheat_clev_seq, 0 }; cheatseq_t cheat_mypos = { cheat_mypos_seq, 0 }; extern char* mapnames[]; -void ST_Stop(void); -void ST_refreshBackground(void) + +void +ST_refreshBackground() { - if (st_statusbaron) - { - V_DrawPatch(ST_X, 0, BG, sbar); - if (netgame) - V_DrawPatch(ST_FX, 0, BG, faceback); - V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG); - } + if (st_statusbaron) { + V_DrawPatch(ST_X, 0, BG, sbar); + if (netgame) V_DrawPatch(ST_FX, 0, BG, faceback); + V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG); + } } + boolean -ST_Responder (event_t* ev) +ST_Responder(event_t* ev) { - int i; - if (ev->type == ev_keyup - && ((ev->data1 & 0xffff0000) == AM_MSGHEADER)) - { - switch(ev->data1) - { - case AM_MSGENTERED: - st_gamestate = AutomapState; - st_firsttime = true; - break; - case AM_MSGEXITED: - st_gamestate = FirstPersonState; - break; - } - } - else if (ev->type == ev_keydown) - { - if (!netgame) - { - if (cht_CheckCheat(&cheat_god, ev->data1)) - { - plyr->cheats ^= CF_GODMODE; - if (plyr->cheats & CF_GODMODE) - { - if (plyr->mo) - plyr->mo->health = 100; - plyr->health = 100; - plyr->message = STSTR_DQDON; - } - else - plyr->message = STSTR_DQDOFF; - } - else if (cht_CheckCheat(&cheat_ammonokey, ev->data1)) - { - plyr->armorpoints = 200; - plyr->armortype = 2; - for (i=0;i<NUMWEAPONS;i++) - plyr->weaponowned[i] = true; - for (i=0;i<NUMAMMO;i++) - plyr->ammo[i] = plyr->maxammo[i]; - plyr->message = STSTR_FAADDED; - } - else if (cht_CheckCheat(&cheat_ammo, ev->data1)) - { - plyr->armorpoints = 200; - plyr->armortype = 2; - for (i=0;i<NUMWEAPONS;i++) - plyr->weaponowned[i] = true; - for (i=0;i<NUMAMMO;i++) - plyr->ammo[i] = plyr->maxammo[i]; - for (i=0;i<NUMCARDS;i++) - plyr->cards[i] = true; - plyr->message = STSTR_KFAADDED; - } - else if (cht_CheckCheat(&cheat_mus, ev->data1)) - { - char buf[3]; - int musnum; - plyr->message = STSTR_MUS; - cht_GetParam(&cheat_mus, buf); - if (gamemode == commercial) - { - musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1; - if (((buf[0]-'0')*10 + buf[1]-'0') > 35) - plyr->message = STSTR_NOMUS; - else - S_ChangeMusic(musnum, 1); - } - else - { - musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1'); - if (((buf[0]-'1')*9 + buf[1]-'1') > 31) - plyr->message = STSTR_NOMUS; - else - S_ChangeMusic(musnum, 1); + char msg[ST_MSGWIDTH], buf[3]; + int i, musnum, epsd, map; + + if (ev->type == ev_keyup && ((ev->data1 & 0xffff0000) == AM_MSGHEADER)) { + switch (ev->data1) { + case AM_MSGENTERED: + st_gamestate = AutomapState; + st_firsttime = true; + break; + case AM_MSGEXITED: + st_gamestate = FirstPersonState; + break; + } } - } - else if ( cht_CheckCheat(&cheat_noclip, ev->data1) - || cht_CheckCheat(&cheat_commercial_noclip,ev->data1) ) - { - plyr->cheats ^= CF_NOCLIP; - if (plyr->cheats & CF_NOCLIP) - plyr->message = STSTR_NCON; - else - plyr->message = STSTR_NCOFF; - } - for (i=0;i<6;i++) - { - if (cht_CheckCheat(&cheat_powerup[i], ev->data1)) - { - if (!plyr->powers[i]) - P_GivePower( plyr, i); - else if (i!=pw_strength) - plyr->powers[i] = 1; - else - plyr->powers[i] = 0; - plyr->message = STSTR_BEHOLDX; + if (ev->type == ev_keydown) { + if (!netgame) { + if (cht_CheckCheat(&cheat_god, ev->data1)) { + plyr->cheats ^= CF_GODMODE; + if (plyr->cheats & CF_GODMODE) { + if (plyr->mo) plyr->mo->health = 100; + plyr->health = 100; + plyr->message = lang[STSTR_DQDON]; + } + else plyr->message = lang[STSTR_DQDOFF]; + } + if (cht_CheckCheat(&cheat_ammonokey, ev->data1)) { + plyr->armorpoints = 200; + plyr->armortype = 2; + for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; + for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; + plyr->message = lang[STSTR_FAADDED]; + } + if (cht_CheckCheat(&cheat_ammo, ev->data1)) { + plyr->armorpoints = 200; + plyr->armortype = 2; + for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; + for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; + for (i=0;i<NUMCARDS;i++) plyr->cards[i] = true; + plyr->message = lang[STSTR_KFAADDED]; + } + if (cht_CheckCheat(&cheat_mus, ev->data1)) { + plyr->message = lang[STSTR_MUS]; + cht_GetParam(&cheat_mus, buf); + musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1'); + if (((buf[0]-'1')*9 + buf[1]-'1') > 31) plyr->message = lang[STSTR_NOMUS]; + else S_ChangeMusic(musnum, 1); + } + if (cht_CheckCheat(&cheat_noclip, ev->data1) || cht_CheckCheat(&cheat_commercial_noclip,ev->data1)) { + plyr->cheats ^= CF_NOCLIP; + if (plyr->cheats & CF_NOCLIP) plyr->message = lang[STSTR_NCON]; + else plyr->message = lang[STSTR_NCOFF]; + } + for (i = 0; i < 6; ++i) { + if (cht_CheckCheat(&cheat_powerup[i], ev->data1)) { + if (!plyr->powers[i]) P_GivePower( plyr, i); + else if (i!=pw_strength) plyr->powers[i] = 1; + else plyr->powers[i] = 0; + plyr->message = lang[STSTR_BEHOLDX]; + } + } + if (cht_CheckCheat(&cheat_powerup[6], ev->data1)) plyr->message = lang[STSTR_BEHOLD]; + if (cht_CheckCheat(&cheat_choppers, ev->data1)) { + plyr->weaponowned[wp_chainsaw] = true; + plyr->powers[pw_invulnerability] = true; + plyr->message = lang[STSTR_CHOPPERS]; + } + if (cht_CheckCheat(&cheat_mypos, ev->data1)) { + sprintf(msg, "ang=0x%x;x,y=(0x%x,0x%x)", + players[consoleplayer].mo->angle, + players[consoleplayer].mo->x, + players[consoleplayer].mo->y); + plyr->message = msg; + } + } + if (cht_CheckCheat(&cheat_clev, ev->data1)) { + cht_GetParam(&cheat_clev, buf); + epsd = buf[0] - '0'; + map = buf[1] - '0'; + if (epsd < 1) return false; + if (map < 1) return false; + if ((epsd > 1) || (map > 9)) return false; + plyr->message = lang[STSTR_CLEV]; + G_DeferedInitNew(gameskill, epsd, map); + } } - } - if (cht_CheckCheat(&cheat_powerup[6], ev->data1)) - { - plyr->message = STSTR_BEHOLD; - } - else if (cht_CheckCheat(&cheat_choppers, ev->data1)) - { - plyr->weaponowned[wp_chainsaw] = true; - plyr->powers[pw_invulnerability] = true; - plyr->message = STSTR_CHOPPERS; - } - else if (cht_CheckCheat(&cheat_mypos, ev->data1)) - { - static char buf[ST_MSGWIDTH]; - sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)", - players[consoleplayer].mo->angle, - players[consoleplayer].mo->x, - players[consoleplayer].mo->y); - plyr->message = buf; - } - } - if (cht_CheckCheat(&cheat_clev, ev->data1)) - { - char buf[3]; - int epsd; - int map; - cht_GetParam(&cheat_clev, buf); - if (gamemode == commercial) - { - epsd = 0; - map = (buf[0] - '0')*10 + buf[1] - '0'; - } - else - { - epsd = buf[0] - '0'; - map = buf[1] - '0'; - } - if (epsd < 1) - return false; - if (map < 1) - return false; - if ((gamemode == retail) - && ((epsd > 4) || (map > 9))) return false; - if ((gamemode == registered) - && ((epsd > 3) || (map > 9))) - return false; - if ((gamemode == shareware) - && ((epsd > 1) || (map > 9))) - return false; - if ((gamemode == commercial) - && (( epsd > 1) || (map > 34))) - return false; - plyr->message = STSTR_CLEV; - G_DeferedInitNew(gameskill, epsd, map); - } - } - return false; } -int ST_calcPainOffset(void) + +int +ST_calcPainOffset() { - int health; - static int lastcalc; - static int oldhealth = -1; - health = plyr->health > 100 ? 100 : plyr->health; - if (health != oldhealth) - { - lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); - oldhealth = health; - } - return lastcalc; + static int lastcalc, oldhealth = -1; + int health; + + health = plyr->health > 100 ? 100 : plyr->health; + if (health != oldhealth) { + lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); + oldhealth = health; + } + return lastcalc; } -void ST_updateFaceWidget(void) + +void +ST_updateFaceWidget() { - int i; - angle_t badguyangle; - angle_t diffang; - static int lastattackdown = -1; - static int priority = 0; - boolean doevilgrin; - if (priority < 10) - { - if (!plyr->health) - { - priority = 9; - st_faceindex = ST_DEADFACE; - st_facecount = 1; - } - } - if (priority < 9) - { - if (plyr->bonuscount) - { - doevilgrin = false; - for (i=0;i<NUMWEAPONS;i++) - { - if (oldweaponsowned[i] != plyr->weaponowned[i]) - { - doevilgrin = true; - oldweaponsowned[i] = plyr->weaponowned[i]; - } - } - if (doevilgrin) - { - priority = 8; - st_facecount = ST_EVILGRINCOUNT; - st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; - } + static int lastattackdown = -1; + static int priority = 0; + angle_t badguyangle; + angle_t diffang; + int i; + boolean doevilgrin; + + if (priority < 10 && !plyr->health) { + priority = 9; + st_faceindex = ST_DEADFACE; + st_facecount = 1; } - } - if (priority < 8) - { - if (plyr->damagecount - && plyr->attacker - && plyr->attacker != plyr->mo) - { - priority = 7; - if (plyr->health - st_oldhealth > ST_MUCHPAIN) - { - st_facecount = ST_TURNCOUNT; - st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; - } - else - { - badguyangle = R_PointToAngle2(plyr->mo->x, - plyr->mo->y, - plyr->attacker->x, - plyr->attacker->y); - if (badguyangle > plyr->mo->angle) - { - diffang = badguyangle - plyr->mo->angle; - i = diffang > ANG180; - } - else - { - diffang = plyr->mo->angle - badguyangle; - i = diffang <= ANG180; - } - st_facecount = ST_TURNCOUNT; - st_faceindex = ST_calcPainOffset(); - if (diffang < ANG45) - { - st_faceindex += ST_RAMPAGEOFFSET; - } - else if (i) - { - st_faceindex += ST_TURNOFFSET; + + if (priority < 9 && plyr->bonuscount) { + doevilgrin = false; + for (i = 0; i < NUMWEAPONS; ++i) { + if (oldweaponsowned[i] != plyr->weaponowned[i]) { + doevilgrin = true; + oldweaponsowned[i] = plyr->weaponowned[i]; + } } - else - { - st_faceindex += ST_TURNOFFSET+1; + if (doevilgrin) { + priority = 8; + st_facecount = ST_EVILGRINCOUNT; + st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; } - } } - } - if (priority < 7) - { - if (plyr->damagecount) - { - if (plyr->health - st_oldhealth > ST_MUCHPAIN) - { + + if (priority < 8 && plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) { priority = 7; - st_facecount = ST_TURNCOUNT; - st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; - } - else - { - priority = 6; - st_facecount = ST_TURNCOUNT; - st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; + if (plyr->health - st_oldhealth > ST_MUCHPAIN) { + st_facecount = ST_TURNCOUNT; + st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; + } else { + badguyangle = R_PointToAngle2(plyr->mo->x, plyr->mo->y, plyr->attacker->x, plyr->attacker->y); + if (badguyangle > plyr->mo->angle) { + diffang = badguyangle - plyr->mo->angle; + i = diffang > ANG180; + } else { + diffang = plyr->mo->angle - badguyangle; + i = diffang <= ANG180; + } + st_facecount = ST_TURNCOUNT; + st_faceindex = ST_calcPainOffset(); + if (diffang < ANG45) st_faceindex += ST_RAMPAGEOFFSET; + else if (i) st_faceindex += ST_TURNOFFSET; + else st_faceindex += ST_TURNOFFSET+1; + } + } + if (priority < 7 && plyr->damagecount) { + if (plyr->health - st_oldhealth > ST_MUCHPAIN) { + priority = 7; + st_facecount = ST_TURNCOUNT; + st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; + } else { + priority = 6; + st_facecount = ST_TURNCOUNT; + st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; } } - } - if (priority < 6) - { - if (plyr->attackdown) - { - if (lastattackdown==-1) - lastattackdown = ST_RAMPAGEDELAY; - else if (!--lastattackdown) - { - priority = 5; - st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; + if (priority < 6) { + if (plyr->attackdown) { + if (lastattackdown==-1) lastattackdown = ST_RAMPAGEDELAY; + if (!--lastattackdown) { + priority = 5; + st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; + st_facecount = 1; + lastattackdown = 1; + } + } else lastattackdown = -1; + } + if (priority < 5 && ((plyr->cheats & CF_GODMODE) || (plyr->powers[pw_invulnerability]))) { + priority = 4; + st_faceindex = ST_GODFACE; st_facecount = 1; - lastattackdown = 1; - } } - else - lastattackdown = -1; - } - if (priority < 5) - { - if ((plyr->cheats & CF_GODMODE) - || plyr->powers[pw_invulnerability]) - { - priority = 4; - st_faceindex = ST_GODFACE; - st_facecount = 1; + if (!st_facecount) { + st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); + st_facecount = ST_STRAIGHTFACECOUNT; + priority = 0; } - } - if (!st_facecount) - { - st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); - st_facecount = ST_STRAIGHTFACECOUNT; - priority = 0; - } - st_facecount--; + --st_facecount; } -void ST_updateWidgets(void) + +void +ST_updateWidgets() { - static int largeammo = 1994; - int i; - if (weaponinfo[plyr->readyweapon].ammo == am_noammo) - w_ready.num = &largeammo; - else - w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; - w_ready.data = plyr->readyweapon; - for (i=0;i<3;i++) - { - keyboxes[i] = plyr->cards[i] ? i : -1; - if (plyr->cards[i+3]) - keyboxes[i] = i+3; - } - ST_updateFaceWidget(); - st_notdeathmatch = !deathmatch; - st_armson = st_statusbaron && !deathmatch; - st_fragson = deathmatch && st_statusbaron; - st_fragscount = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (i != consoleplayer) - st_fragscount += plyr->frags[i]; - else - st_fragscount -= plyr->frags[i]; - } - if (!--st_msgcounter) - st_chat = st_oldchat; + static int largeammo = 1994; + int i; + + if (weaponinfo[plyr->readyweapon].ammo == am_noammo) w_ready.num = &largeammo; + else w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; + w_ready.data = plyr->readyweapon; + for (i = 0; i < 3; ++i) { + keyboxes[i] = plyr->cards[i] ? i : -1; + if (plyr->cards[i+3]) keyboxes[i] = i+3; + } + ST_updateFaceWidget(); + st_notdeathmatch = !deathmatch; + st_armson = st_statusbaron && !deathmatch; + st_fragson = deathmatch && st_statusbaron; + st_fragscount = 0; + for (i = 0; i < MAXPLAYERS; ++i) { + if (i != consoleplayer) st_fragscount += plyr->frags[i]; + else st_fragscount -= plyr->frags[i]; + } + if (!--st_msgcounter) st_chat = st_oldchat; } -void ST_Ticker (void) + +void +ST_Ticker() { - st_clock++; - st_randomnumber = M_Random(); - ST_updateWidgets(); - st_oldhealth = plyr->health; + st_clock++; + st_randomnumber = M_Random(); + ST_updateWidgets(); + st_oldhealth = plyr->health; } -static int st_palette = 0; -void ST_doPaletteStuff(void) + + +void ST_doPaletteStuff() { - int palette; - byte* pal; - int cnt; - int bzc; - cnt = plyr->damagecount; - if (plyr->powers[pw_strength]) - { - bzc = 12 - (plyr->powers[pw_strength]>>6); - if (bzc > cnt) - cnt = bzc; - } - if (cnt) - { - palette = (cnt+7)>>3; - if (palette >= NUMREDPALS) - palette = NUMREDPALS-1; - palette += STARTREDPALS; - } - else if (plyr->bonuscount) - { - palette = (plyr->bonuscount+7)>>3; - if (palette >= NUMBONUSPALS) - palette = NUMBONUSPALS-1; - palette += STARTBONUSPALS; - } - else if ( plyr->powers[pw_ironfeet] > 4*32 - || plyr->powers[pw_ironfeet]&8) - palette = RADIATIONPAL; - else - palette = 0; - if (palette != st_palette) - { - st_palette = palette; - pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768; - I_SetPalette (pal); - } + byte* pal; + int palette, cnt, bzc; + + cnt = plyr->damagecount; + if (plyr->powers[pw_strength]) { + bzc = 12 - (plyr->powers[pw_strength]>>6); + if (bzc > cnt) cnt = bzc; + } + if (cnt) { + palette = (cnt+7)>>3; + if (palette >= NUMREDPALS) palette = NUMREDPALS-1; + palette += STARTREDPALS; + } + else if (plyr->bonuscount) { + palette = (plyr->bonuscount + 7 )>> 3; + if (palette >= NUMBONUSPALS) palette = NUMBONUSPALS-1; + palette += STARTBONUSPALS; + } + else if (plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet]&8) palette = RADIATIONPAL; + else palette = 0; + if (palette != st_palette) { + st_palette = palette; + pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768; + I_SetPalette (pal); + } } -void ST_drawWidgets(boolean refresh) + +void +ST_drawWidgets(boolean refresh) { - int i; - st_armson = st_statusbaron && !deathmatch; - st_fragson = deathmatch && st_statusbaron; - STlib_updateNum(&w_ready, refresh); - for (i=0;i<4;i++) - { - STlib_updateNum(&w_ammo[i], refresh); - STlib_updateNum(&w_maxammo[i], refresh); - } - STlib_updatePercent(&w_health, refresh); - STlib_updatePercent(&w_armor, refresh); - STlib_updateBinIcon(&w_armsbg, refresh); - for (i=0;i<6;i++) - STlib_updateMultIcon(&w_arms[i], refresh); - STlib_updateMultIcon(&w_faces, refresh); - for (i=0;i<3;i++) - STlib_updateMultIcon(&w_keyboxes[i], refresh); - STlib_updateNum(&w_frags, refresh); + int i; + + st_armson = st_statusbaron && !deathmatch; + st_fragson = deathmatch && st_statusbaron; + STlib_updateNum(&w_ready, refresh); + for (i = 0; i < 4; ++i) { + STlib_updateNum(&w_ammo[i], refresh); + STlib_updateNum(&w_maxammo[i], refresh); + } + STlib_updatePercent(&w_health, refresh); + STlib_updatePercent(&w_armor, refresh); + STlib_updateBinIcon(&w_armsbg, refresh); + for (i = 0; i < 6; ++i) STlib_updateMultIcon(&w_arms[i], refresh); + STlib_updateMultIcon(&w_faces, refresh); + for (i = 0; i < 3; ++i) STlib_updateMultIcon(&w_keyboxes[i], refresh); + STlib_updateNum(&w_frags, refresh); } -void ST_doRefresh(void) + +void +ST_doRefresh() { - st_firsttime = false; - ST_refreshBackground(); - ST_drawWidgets(true); + st_firsttime = false; + ST_refreshBackground(); + ST_drawWidgets(true); } -void ST_diffDraw(void) + +void +ST_diffDraw() { - ST_drawWidgets(false); + ST_drawWidgets(false); } -void ST_Drawer (boolean fullscreen, boolean refresh) + +void +ST_Drawer(boolean fullscreen, boolean refresh) { - st_statusbaron = (!fullscreen) || automapactive; - st_firsttime = st_firsttime || refresh; - ST_doPaletteStuff(); - if (st_firsttime) ST_doRefresh(); - else ST_diffDraw(); + st_statusbaron = (!fullscreen) || automapactive; + st_firsttime = st_firsttime || refresh; + ST_doPaletteStuff(); + if (st_firsttime) ST_doRefresh(); + else ST_diffDraw(); } -void ST_loadGraphics(void) + +void +ST_loadData() { - int i; - int j; - int facenum; - char namebuf[9]; - for (i=0;i<10;i++) - { - sprintf(namebuf, "STTNUM%d", i); - tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STYSNUM%d", i); - shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - } - tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC); - for (i=0;i<NUMCARDS;i++) - { - sprintf(namebuf, "STKEYS%d", i); - keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - } - armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC); - for (i=0;i<6;i++) - { - sprintf(namebuf, "STGNUM%d", i+2); - arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - arms[i][1] = shortnum[i+2]; - } - sprintf(namebuf, "STFB%d", consoleplayer); - faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC); - facenum = 0; - for (i=0;i<ST_NUMPAINFACES;i++) - { - for (j=0;j<ST_NUMSTRAIGHTFACES;j++) - { - sprintf(namebuf, "STFST%d%d", i, j); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + int i, j, facenum; + char namebuf[9]; + + lu_palette = W_GetNumForName("PLAYPAL"); + for (i = 0; i < 10; ++i) { + sprintf(namebuf, "STTNUM%d", i); + tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); + sprintf(namebuf, "STYSNUM%d", i); + shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); } - sprintf(namebuf, "STFTR%d0", i); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STFTL%d0", i); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STFOUCH%d", i); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STFEVL%d", i); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STFKILL%d", i); - faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); - } - faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC); - faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC); -} -void ST_loadData(void) -{ - lu_palette = W_GetNumForName ("PLAYPAL"); - ST_loadGraphics(); + tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC); + for (i = 0; i < NUMCARDS; ++i) { + sprintf(namebuf, "STKEYS%d", i); + keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); + } + armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC); + for (i = 0; i < 6; ++i) { + sprintf(namebuf, "STGNUM%d", i+2); + arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); + arms[i][1] = shortnum[i+2]; + } + sprintf(namebuf, "STFB%d", consoleplayer); + faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); + sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC); + facenum = 0; + for (i = 0; i < ST_NUMPAINFACES; ++i) { + for (j = 0; j < ST_NUMSTRAIGHTFACES; ++j) { + sprintf(namebuf, "STFST%d%d", i, j); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + } + sprintf(namebuf, "STFTR%d0", i); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + sprintf(namebuf, "STFTL%d0", i); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + sprintf(namebuf, "STFOUCH%d", i); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + sprintf(namebuf, "STFEVL%d", i); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + sprintf(namebuf, "STFKILL%d", i); + faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC); + } + faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC); + faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC); } -void ST_unloadGraphics(void) + +void +ST_unloadGraphics() { - int i; - for (i=0;i<10;i++) - { - Z_ChangeTag(tallnum[i], PU_CACHE); - Z_ChangeTag(shortnum[i], PU_CACHE); - } - Z_ChangeTag(tallpercent, PU_CACHE); - Z_ChangeTag(armsbg, PU_CACHE); - for (i=0;i<6;i++) - Z_ChangeTag(arms[i][0], PU_CACHE); - for (i=0;i<NUMCARDS;i++) - Z_ChangeTag(keys[i], PU_CACHE); - Z_ChangeTag(sbar, PU_CACHE); - Z_ChangeTag(faceback, PU_CACHE); - for (i=0;i<ST_NUMFACES;i++) - Z_ChangeTag(faces[i], PU_CACHE); + int i; + + for (i = 0; i < 10; ++i) { + Z_ChangeTag(tallnum[i], PU_CACHE); + Z_ChangeTag(shortnum[i], PU_CACHE); + } + Z_ChangeTag(tallpercent, PU_CACHE); + Z_ChangeTag(armsbg, PU_CACHE); + for (i = 0; i < 6; ++i) Z_ChangeTag(arms[i][0], PU_CACHE); + for (i = 0; i < NUMCARDS; ++i) Z_ChangeTag(keys[i], PU_CACHE); + Z_ChangeTag(sbar, PU_CACHE); + Z_ChangeTag(faceback, PU_CACHE); + for (i = 0; i < ST_NUMFACES; ++i) Z_ChangeTag(faces[i], PU_CACHE); } -void ST_unloadData(void) + +void +ST_unloadData() { - ST_unloadGraphics(); + ST_unloadGraphics(); } -void ST_initData(void) + +void +ST_initData() { - int i; - st_firsttime = true; - plyr = &players[consoleplayer]; - st_clock = 0; - st_chatstate = StartChatState; - st_gamestate = FirstPersonState; - st_statusbaron = true; - st_oldchat = st_chat = false; - st_cursoron = false; - st_faceindex = 0; - st_palette = -1; - st_oldhealth = -1; - for (i=0;i<NUMWEAPONS;i++) - oldweaponsowned[i] = plyr->weaponowned[i]; - for (i=0;i<3;i++) - keyboxes[i] = -1; - STlib_init(); + int i; + + st_firsttime = true; + plyr = &players[consoleplayer]; + st_clock = 0; + st_chatstate = StartChatState; + st_gamestate = FirstPersonState; + st_statusbaron = true; + st_oldchat = st_chat = false; + st_cursoron = false; + st_faceindex = 0; + st_palette = -1; + st_oldhealth = -1; + for (i = 0; i < NUMWEAPONS; ++i) oldweaponsowned[i] = plyr->weaponowned[i]; + for (i = 0; i < 3; ++i) keyboxes[i] = -1; + STlib_init(); } -void ST_createWidgets(void) + +void +ST_createWidgets() { - int i; - STlib_initNum(&w_ready, - ST_AMMOX, - ST_AMMOY, - tallnum, - &plyr->ammo[weaponinfo[plyr->readyweapon].ammo], - &st_statusbaron, - ST_AMMOWIDTH ); - w_ready.data = plyr->readyweapon; - STlib_initPercent(&w_health, - ST_HEALTHX, - ST_HEALTHY, - tallnum, - &plyr->health, - &st_statusbaron, - tallpercent); - STlib_initBinIcon(&w_armsbg, - ST_ARMSBGX, - ST_ARMSBGY, - armsbg, - &st_notdeathmatch, - &st_statusbaron); - for(i=0;i<6;i++) - { - STlib_initMultIcon(&w_arms[i], - ST_ARMSX+(i%3)*ST_ARMSXSPACE, - ST_ARMSY+(i/3)*ST_ARMSYSPACE, - arms[i], (int *) &plyr->weaponowned[i+1], - &st_armson); - } - STlib_initNum(&w_frags, - ST_FRAGSX, - ST_FRAGSY, - tallnum, - &st_fragscount, - &st_fragson, - ST_FRAGSWIDTH); - STlib_initMultIcon(&w_faces, - ST_FACESX, - ST_FACESY, - faces, - &st_faceindex, - &st_statusbaron); - STlib_initPercent(&w_armor, - ST_ARMORX, - ST_ARMORY, - tallnum, - &plyr->armorpoints, - &st_statusbaron, tallpercent); - STlib_initMultIcon(&w_keyboxes[0], - ST_KEY0X, - ST_KEY0Y, - keys, - &keyboxes[0], - &st_statusbaron); - STlib_initMultIcon(&w_keyboxes[1], - ST_KEY1X, - ST_KEY1Y, - keys, - &keyboxes[1], - &st_statusbaron); - STlib_initMultIcon(&w_keyboxes[2], - ST_KEY2X, - ST_KEY2Y, - keys, - &keyboxes[2], - &st_statusbaron); - STlib_initNum(&w_ammo[0], - ST_AMMO0X, - ST_AMMO0Y, - shortnum, - &plyr->ammo[0], - &st_statusbaron, - ST_AMMO0WIDTH); - STlib_initNum(&w_ammo[1], - ST_AMMO1X, - ST_AMMO1Y, - shortnum, - &plyr->ammo[1], - &st_statusbaron, - ST_AMMO1WIDTH); - STlib_initNum(&w_ammo[2], - ST_AMMO2X, - ST_AMMO2Y, - shortnum, - &plyr->ammo[2], - &st_statusbaron, - ST_AMMO2WIDTH); - STlib_initNum(&w_ammo[3], - ST_AMMO3X, - ST_AMMO3Y, - shortnum, - &plyr->ammo[3], - &st_statusbaron, - ST_AMMO3WIDTH); - STlib_initNum(&w_maxammo[0], - ST_MAXAMMO0X, - ST_MAXAMMO0Y, - shortnum, - &plyr->maxammo[0], - &st_statusbaron, - ST_MAXAMMO0WIDTH); - STlib_initNum(&w_maxammo[1], - ST_MAXAMMO1X, - ST_MAXAMMO1Y, - shortnum, - &plyr->maxammo[1], - &st_statusbaron, - ST_MAXAMMO1WIDTH); - STlib_initNum(&w_maxammo[2], - ST_MAXAMMO2X, - ST_MAXAMMO2Y, - shortnum, - &plyr->maxammo[2], - &st_statusbaron, - ST_MAXAMMO2WIDTH); - STlib_initNum(&w_maxammo[3], - ST_MAXAMMO3X, - ST_MAXAMMO3Y, - shortnum, - &plyr->maxammo[3], - &st_statusbaron, - ST_MAXAMMO3WIDTH); + int i; + + STlib_initNum(&w_ready, ST_AMMOX, ST_AMMOY, tallnum, &plyr->ammo[weaponinfo[plyr->readyweapon].ammo], &st_statusbaron, ST_AMMOWIDTH); + w_ready.data = plyr->readyweapon; + STlib_initPercent(&w_health, ST_HEALTHX, ST_HEALTHY, tallnum, &plyr->health, &st_statusbaron, tallpercent); + STlib_initBinIcon(&w_armsbg, ST_ARMSBGX, ST_ARMSBGY, armsbg, &st_notdeathmatch, &st_statusbaron); + for (i = 0; i < 6; ++i) + STlib_initMultIcon(&w_arms[i], ST_ARMSX+(i%3)*ST_ARMSXSPACE, ST_ARMSY+(i/3)*ST_ARMSYSPACE, arms[i], (int *) &plyr->weaponowned[i+1], &st_armson); + STlib_initNum(&w_frags, ST_FRAGSX, ST_FRAGSY, tallnum, &st_fragscount, &st_fragson, ST_FRAGSWIDTH); + STlib_initMultIcon(&w_faces, ST_FACESX, ST_FACESY, faces, &st_faceindex, &st_statusbaron); + STlib_initPercent(&w_armor, ST_ARMORX, ST_ARMORY, tallnum, &plyr->armorpoints, &st_statusbaron, tallpercent); + STlib_initMultIcon(&w_keyboxes[0], ST_KEY0X, ST_KEY0Y, keys, &keyboxes[0], &st_statusbaron); + STlib_initMultIcon(&w_keyboxes[1], ST_KEY1X, ST_KEY1Y, keys, &keyboxes[1], &st_statusbaron); + STlib_initMultIcon(&w_keyboxes[2], ST_KEY2X, ST_KEY2Y, keys, &keyboxes[2], &st_statusbaron); + STlib_initNum(&w_ammo[0], ST_AMMO0X, ST_AMMO0Y, shortnum, &plyr->ammo[0], &st_statusbaron, ST_AMMO0WIDTH); + STlib_initNum(&w_ammo[1], ST_AMMO1X, ST_AMMO1Y, shortnum, &plyr->ammo[1], &st_statusbaron, ST_AMMO1WIDTH); + STlib_initNum(&w_ammo[2], ST_AMMO2X, ST_AMMO2Y, shortnum, &plyr->ammo[2], &st_statusbaron, ST_AMMO2WIDTH); + STlib_initNum(&w_ammo[3], ST_AMMO3X, ST_AMMO3Y, shortnum, &plyr->ammo[3], &st_statusbaron, ST_AMMO3WIDTH); + STlib_initNum(&w_maxammo[0], ST_MAXAMMO0X, ST_MAXAMMO0Y, shortnum, &plyr->maxammo[0], &st_statusbaron, ST_MAXAMMO0WIDTH); + STlib_initNum(&w_maxammo[1], ST_MAXAMMO1X, ST_MAXAMMO1Y, shortnum, &plyr->maxammo[1], &st_statusbaron, ST_MAXAMMO1WIDTH); + STlib_initNum(&w_maxammo[2], ST_MAXAMMO2X, ST_MAXAMMO2Y, shortnum, &plyr->maxammo[2], &st_statusbaron, ST_MAXAMMO2WIDTH); + STlib_initNum(&w_maxammo[3], ST_MAXAMMO3X, ST_MAXAMMO3Y, shortnum, &plyr->maxammo[3], &st_statusbaron, ST_MAXAMMO3WIDTH); } -static boolean st_stopped = true; -void ST_Start (void) + +void +ST_Stop() { - if (!st_stopped) - ST_Stop(); - ST_initData(); - ST_createWidgets(); - st_stopped = false; + if (st_stopped) return; + I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE)); + st_stopped = true; } -void ST_Stop (void) + +void +ST_Start() { - if (st_stopped) - return; - I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE)); - st_stopped = true; + if (!st_stopped) ST_Stop(); + ST_initData(); + ST_createWidgets(); + st_stopped = false; } -void ST_Init (void) + +void +ST_Init() { - veryfirsttime = 0; - ST_loadData(); - screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0); + veryfirsttime = 0; + ST_loadData(); + screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0); } diff --git a/src/st_stuff.h b/src/st_stuff.h @@ -1,25 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + #ifndef __STSTUFF_H__ #define __STSTUFF_H__ -#include "doomtype.h" + +#include "doomdef.h" #include "d_event.h" + + + #define ST_HEIGHT 32*SCREEN_MUL #define ST_WIDTH SCREENWIDTH #define ST_Y (SCREENHEIGHT - ST_HEIGHT) + + + + + + + boolean ST_Responder (event_t* ev); + + void ST_Ticker (void); + + void ST_Drawer (boolean fullscreen, boolean refresh); + + void ST_Start (void); + + void ST_Init (void); + + + + typedef enum { AutomapState, FirstPersonState + } st_stateenum_t; + + + typedef enum { StartChatState, WaitDestState, GetChatState + } st_chatstateenum_t; + + boolean ST_Responder(event_t* ev); + + + #endif + + + + + diff --git a/src/tables.c b/src/tables.c @@ -1,2070 +1,2069 @@ #include "tables.h" + int -SlopeDiv -( unsigned num, - unsigned den) +SlopeDiv(unsigned num, unsigned den) { - unsigned ans; - if (den < 512) - return SLOPERANGE; - ans = (num<<3)/(den>>8); - return ans <= SLOPERANGE ? ans : SLOPERANGE; + unsigned ans; + + if (den < 512) return SLOPERANGE; + ans = (num<<3)/(den>>8); + return ans <= SLOPERANGE ? ans : SLOPERANGE; } -int finetangent[4096] = -{ - -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, - -10052327,-8994149,-8137527,-7429880,-6835455,-6329090,-5892567,-5512368, - -5178251,-4882318,-4618375,-4381502,-4167737,-3973855,-3797206,-3635590, - -3487165,-3350381,-3223918,-3106651,-2997613,-2895966,-2800983,-2712030, - -2628549,-2550052,-2476104,-2406322,-2340362,-2277919,-2218719,-2162516, - -2109087,-2058233,-2009771,-1963536,-1919378,-1877161,-1836758,-1798063, - -1760956,-1725348,-1691149,-1658278,-1626658,-1596220,-1566898,-1538632, - -1511367,-1485049,-1459630,-1435065,-1411312,-1388330,-1366084,-1344537, - -1323658,-1303416,-1283783,-1264730,-1246234,-1228269,-1210813,-1193846, - -1177345,-1161294,-1145673,-1130465,-1115654,-1101225,-1087164,-1073455, - -1060087,-1047046,-1034322,-1021901,-1009774,-997931,-986361,-975054, - -964003,-953199,-942633,-932298,-922186,-912289,-902602,-893117, - -883829,-874730,-865817,-857081,-848520,-840127,-831898,-823827, - -815910,-808143,-800521,-793041,-785699,-778490,-771411,-764460, - -757631,-750922,-744331,-737853,-731486,-725227,-719074,-713023, - -707072,-701219,-695462,-689797,-684223,-678737,-673338,-668024, - -662792,-657640,-652568,-647572,-642651,-637803,-633028,-628323, - -623686,-619117,-614613,-610174,-605798,-601483,-597229,-593033, - -588896,-584815,-580789,-576818,-572901,-569035,-565221,-561456, - -557741,-554074,-550455,-546881,-543354,-539870,-536431,-533034, - -529680,-526366,-523094,-519861,-516667,-513512,-510394,-507313, - -504269,-501261,-498287,-495348,-492443,-489571,-486732,-483925, - -481150,-478406,-475692,-473009,-470355,-467730,-465133,-462565, - -460024,-457511,-455024,-452564,-450129,-447720,-445337,-442978, - -440643,-438332,-436045,-433781,-431540,-429321,-427125,-424951, - -422798,-420666,-418555,-416465,-414395,-412344,-410314,-408303, - -406311,-404338,-402384,-400448,-398530,-396630,-394747,-392882, - -391034,-389202,-387387,-385589,-383807,-382040,-380290,-378555, - -376835,-375130,-373440,-371765,-370105,-368459,-366826,-365208, - -363604,-362013,-360436,-358872,-357321,-355783,-354257,-352744, - -351244,-349756,-348280,-346816,-345364,-343924,-342495,-341078, - -339671,-338276,-336892,-335519,-334157,-332805,-331464,-330133, - -328812,-327502,-326201,-324910,-323629,-322358,-321097,-319844, - -318601,-317368,-316143,-314928,-313721,-312524,-311335,-310154, - -308983,-307819,-306664,-305517,-304379,-303248,-302126,-301011, - -299904,-298805,-297714,-296630,-295554,-294485,-293423,-292369, - -291322,-290282,-289249,-288223,-287204,-286192,-285186,-284188, - -283195,-282210,-281231,-280258,-279292,-278332,-277378,-276430, - -275489,-274553,-273624,-272700,-271782,-270871,-269965,-269064, - -268169,-267280,-266397,-265519,-264646,-263779,-262917,-262060, - -261209,-260363,-259522,-258686,-257855,-257029,-256208,-255392, - -254581,-253774,-252973,-252176,-251384,-250596,-249813,-249035, - -248261,-247492,-246727,-245966,-245210,-244458,-243711,-242967, - -242228,-241493,-240763,-240036,-239314,-238595,-237881,-237170, - -236463,-235761,-235062,-234367,-233676,-232988,-232304,-231624, - -230948,-230275,-229606,-228941,-228279,-227621,-226966,-226314, - -225666,-225022,-224381,-223743,-223108,-222477,-221849,-221225, - -220603,-219985,-219370,-218758,-218149,-217544,-216941,-216341, - -215745,-215151,-214561,-213973,-213389,-212807,-212228,-211652, - -211079,-210509,-209941,-209376,-208815,-208255,-207699,-207145, - -206594,-206045,-205500,-204956,-204416,-203878,-203342,-202809, - -202279,-201751,-201226,-200703,-200182,-199664,-199149,-198636, - -198125,-197616,-197110,-196606,-196105,-195606,-195109,-194614, - -194122,-193631,-193143,-192658,-192174,-191693,-191213,-190736, - -190261,-189789,-189318,-188849,-188382,-187918,-187455,-186995, - -186536,-186080,-185625,-185173,-184722,-184274,-183827,-183382, - -182939,-182498,-182059,-181622,-181186,-180753,-180321,-179891, - -179463,-179037,-178612,-178190,-177769,-177349,-176932,-176516, - -176102,-175690,-175279,-174870,-174463,-174057,-173653,-173251, - -172850,-172451,-172053,-171657,-171263,-170870,-170479,-170089, - -169701,-169315,-168930,-168546,-168164,-167784,-167405,-167027, - -166651,-166277,-165904,-165532,-165162,-164793,-164426,-164060, - -163695,-163332,-162970,-162610,-162251,-161893,-161537,-161182, - -160828,-160476,-160125,-159775,-159427,-159079,-158734,-158389, - -158046,-157704,-157363,-157024,-156686,-156349,-156013,-155678, - -155345,-155013,-154682,-154352,-154024,-153697,-153370,-153045, - -152722,-152399,-152077,-151757,-151438,-151120,-150803,-150487, - -150172,-149859,-149546,-149235,-148924,-148615,-148307,-148000, - -147693,-147388,-147084,-146782,-146480,-146179,-145879,-145580, - -145282,-144986,-144690,-144395,-144101,-143808,-143517,-143226, - -142936,-142647,-142359,-142072,-141786,-141501,-141217,-140934, - -140651,-140370,-140090,-139810,-139532,-139254,-138977,-138701, - -138426,-138152,-137879,-137607,-137335,-137065,-136795,-136526, - -136258,-135991,-135725,-135459,-135195,-134931,-134668,-134406, - -134145,-133884,-133625,-133366,-133108,-132851,-132594,-132339, - -132084,-131830,-131576,-131324,-131072,-130821,-130571,-130322, - -130073,-129825,-129578,-129332,-129086,-128841,-128597,-128353, - -128111,-127869,-127627,-127387,-127147,-126908,-126669,-126432, - -126195,-125959,-125723,-125488,-125254,-125020,-124787,-124555, - -124324,-124093,-123863,-123633,-123404,-123176,-122949,-122722, - -122496,-122270,-122045,-121821,-121597,-121374,-121152,-120930, - -120709,-120489,-120269,-120050,-119831,-119613,-119396,-119179, - -118963,-118747,-118532,-118318,-118104,-117891,-117678,-117466, - -117254,-117044,-116833,-116623,-116414,-116206,-115998,-115790, - -115583,-115377,-115171,-114966,-114761,-114557,-114354,-114151, - -113948,-113746,-113545,-113344,-113143,-112944,-112744,-112546, - -112347,-112150,-111952,-111756,-111560,-111364,-111169,-110974, - -110780,-110586,-110393,-110200,-110008,-109817,-109626,-109435, - -109245,-109055,-108866,-108677,-108489,-108301,-108114,-107927, - -107741,-107555,-107369,-107184,-107000,-106816,-106632,-106449, - -106266,-106084,-105902,-105721,-105540,-105360,-105180,-105000, - -104821,-104643,-104465,-104287,-104109,-103933,-103756,-103580, - -103404,-103229,-103054,-102880,-102706,-102533,-102360,-102187, - -102015,-101843,-101671,-101500,-101330,-101159,-100990,-100820, - -100651,-100482,-100314,-100146,-99979,-99812,-99645,-99479, - -99313,-99148,-98982,-98818,-98653,-98489,-98326,-98163, - -98000,-97837,-97675,-97513,-97352,-97191,-97030,-96870, - -96710,-96551,-96391,-96233,-96074,-95916,-95758,-95601, - -95444,-95287,-95131,-94975,-94819,-94664,-94509,-94354, - -94200,-94046,-93892,-93739,-93586,-93434,-93281,-93129, - -92978,-92826,-92675,-92525,-92375,-92225,-92075,-91926, - -91777,-91628,-91480,-91332,-91184,-91036,-90889,-90742, - -90596,-90450,-90304,-90158,-90013,-89868,-89724,-89579, - -89435,-89292,-89148,-89005,-88862,-88720,-88577,-88435, - -88294,-88152,-88011,-87871,-87730,-87590,-87450,-87310, - -87171,-87032,-86893,-86755,-86616,-86479,-86341,-86204, - -86066,-85930,-85793,-85657,-85521,-85385,-85250,-85114, - -84980,-84845,-84710,-84576,-84443,-84309,-84176,-84043, - -83910,-83777,-83645,-83513,-83381,-83250,-83118,-82987, - -82857,-82726,-82596,-82466,-82336,-82207,-82078,-81949, - -81820,-81691,-81563,-81435,-81307,-81180,-81053,-80925, - -80799,-80672,-80546,-80420,-80294,-80168,-80043,-79918, - -79793,-79668,-79544,-79420,-79296,-79172,-79048,-78925, - -78802,-78679,-78557,-78434,-78312,-78190,-78068,-77947, - -77826,-77705,-77584,-77463,-77343,-77223,-77103,-76983, - -76864,-76744,-76625,-76506,-76388,-76269,-76151,-76033, - -75915,-75797,-75680,-75563,-75446,-75329,-75213,-75096, - -74980,-74864,-74748,-74633,-74517,-74402,-74287,-74172, - -74058,-73944,-73829,-73715,-73602,-73488,-73375,-73262, - -73149,-73036,-72923,-72811,-72699,-72587,-72475,-72363, - -72252,-72140,-72029,-71918,-71808,-71697,-71587,-71477, - -71367,-71257,-71147,-71038,-70929,-70820,-70711,-70602, - -70494,-70385,-70277,-70169,-70061,-69954,-69846,-69739, - -69632,-69525,-69418,-69312,-69205,-69099,-68993,-68887, - -68781,-68676,-68570,-68465,-68360,-68255,-68151,-68046, - -67942,-67837,-67733,-67629,-67526,-67422,-67319,-67216, - -67113,-67010,-66907,-66804,-66702,-66600,-66498,-66396, - -66294,-66192,-66091,-65989,-65888,-65787,-65686,-65586, - -65485,-65385,-65285,-65185,-65085,-64985,-64885,-64786, - -64687,-64587,-64488,-64389,-64291,-64192,-64094,-63996, - -63897,-63799,-63702,-63604,-63506,-63409,-63312,-63215, - -63118,-63021,-62924,-62828,-62731,-62635,-62539,-62443, - -62347,-62251,-62156,-62060,-61965,-61870,-61775,-61680, - -61585,-61491,-61396,-61302,-61208,-61114,-61020,-60926, - -60833,-60739,-60646,-60552,-60459,-60366,-60273,-60181, - -60088,-59996,-59903,-59811,-59719,-59627,-59535,-59444, - -59352,-59261,-59169,-59078,-58987,-58896,-58805,-58715, - -58624,-58534,-58443,-58353,-58263,-58173,-58083,-57994, - -57904,-57815,-57725,-57636,-57547,-57458,-57369,-57281, - -57192,-57104,-57015,-56927,-56839,-56751,-56663,-56575, - -56487,-56400,-56312,-56225,-56138,-56051,-55964,-55877, - -55790,-55704,-55617,-55531,-55444,-55358,-55272,-55186, - -55100,-55015,-54929,-54843,-54758,-54673,-54587,-54502, - -54417,-54333,-54248,-54163,-54079,-53994,-53910,-53826, - -53741,-53657,-53574,-53490,-53406,-53322,-53239,-53156, - -53072,-52989,-52906,-52823,-52740,-52657,-52575,-52492, - -52410,-52327,-52245,-52163,-52081,-51999,-51917,-51835, - -51754,-51672,-51591,-51509,-51428,-51347,-51266,-51185, - -51104,-51023,-50942,-50862,-50781,-50701,-50621,-50540, - -50460,-50380,-50300,-50221,-50141,-50061,-49982,-49902, - -49823,-49744,-49664,-49585,-49506,-49427,-49349,-49270, - -49191,-49113,-49034,-48956,-48878,-48799,-48721,-48643, - -48565,-48488,-48410,-48332,-48255,-48177,-48100,-48022, - -47945,-47868,-47791,-47714,-47637,-47560,-47484,-47407, - -47331,-47254,-47178,-47102,-47025,-46949,-46873,-46797, - -46721,-46646,-46570,-46494,-46419,-46343,-46268,-46193, - -46118,-46042,-45967,-45892,-45818,-45743,-45668,-45593, - -45519,-45444,-45370,-45296,-45221,-45147,-45073,-44999, - -44925,-44851,-44778,-44704,-44630,-44557,-44483,-44410, - -44337,-44263,-44190,-44117,-44044,-43971,-43898,-43826, - -43753,-43680,-43608,-43535,-43463,-43390,-43318,-43246, - -43174,-43102,-43030,-42958,-42886,-42814,-42743,-42671, - -42600,-42528,-42457,-42385,-42314,-42243,-42172,-42101, - -42030,-41959,-41888,-41817,-41747,-41676,-41605,-41535, - -41465,-41394,-41324,-41254,-41184,-41113,-41043,-40973, - -40904,-40834,-40764,-40694,-40625,-40555,-40486,-40416, - -40347,-40278,-40208,-40139,-40070,-40001,-39932,-39863, - -39794,-39726,-39657,-39588,-39520,-39451,-39383,-39314, - -39246,-39178,-39110,-39042,-38973,-38905,-38837,-38770, - -38702,-38634,-38566,-38499,-38431,-38364,-38296,-38229, - -38161,-38094,-38027,-37960,-37893,-37826,-37759,-37692, - -37625,-37558,-37491,-37425,-37358,-37291,-37225,-37158, - -37092,-37026,-36959,-36893,-36827,-36761,-36695,-36629, - -36563,-36497,-36431,-36365,-36300,-36234,-36168,-36103, - -36037,-35972,-35907,-35841,-35776,-35711,-35646,-35580, - -35515,-35450,-35385,-35321,-35256,-35191,-35126,-35062, - -34997,-34932,-34868,-34803,-34739,-34675,-34610,-34546, - -34482,-34418,-34354,-34289,-34225,-34162,-34098,-34034, - -33970,-33906,-33843,-33779,-33715,-33652,-33588,-33525, - -33461,-33398,-33335,-33272,-33208,-33145,-33082,-33019, - -32956,-32893,-32830,-32767,-32705,-32642,-32579,-32516, - -32454,-32391,-32329,-32266,-32204,-32141,-32079,-32017, - -31955,-31892,-31830,-31768,-31706,-31644,-31582,-31520, - -31458,-31396,-31335,-31273,-31211,-31150,-31088,-31026, - -30965,-30904,-30842,-30781,-30719,-30658,-30597,-30536, - -30474,-30413,-30352,-30291,-30230,-30169,-30108,-30048, - -29987,-29926,-29865,-29805,-29744,-29683,-29623,-29562, - -29502,-29441,-29381,-29321,-29260,-29200,-29140,-29080, - -29020,-28959,-28899,-28839,-28779,-28719,-28660,-28600, - -28540,-28480,-28420,-28361,-28301,-28241,-28182,-28122, - -28063,-28003,-27944,-27884,-27825,-27766,-27707,-27647, - -27588,-27529,-27470,-27411,-27352,-27293,-27234,-27175, - -27116,-27057,-26998,-26940,-26881,-26822,-26763,-26705, - -26646,-26588,-26529,-26471,-26412,-26354,-26295,-26237, - -26179,-26120,-26062,-26004,-25946,-25888,-25830,-25772, - -25714,-25656,-25598,-25540,-25482,-25424,-25366,-25308, - -25251,-25193,-25135,-25078,-25020,-24962,-24905,-24847, - -24790,-24732,-24675,-24618,-24560,-24503,-24446,-24389, - -24331,-24274,-24217,-24160,-24103,-24046,-23989,-23932, - -23875,-23818,-23761,-23704,-23647,-23591,-23534,-23477, - -23420,-23364,-23307,-23250,-23194,-23137,-23081,-23024, - -22968,-22911,-22855,-22799,-22742,-22686,-22630,-22573, - -22517,-22461,-22405,-22349,-22293,-22237,-22181,-22125, - -22069,-22013,-21957,-21901,-21845,-21789,-21733,-21678, - -21622,-21566,-21510,-21455,-21399,-21343,-21288,-21232, - -21177,-21121,-21066,-21010,-20955,-20900,-20844,-20789, - -20734,-20678,-20623,-20568,-20513,-20457,-20402,-20347, - -20292,-20237,-20182,-20127,-20072,-20017,-19962,-19907, - -19852,-19797,-19742,-19688,-19633,-19578,-19523,-19469, - -19414,-19359,-19305,-19250,-19195,-19141,-19086,-19032, - -18977,-18923,-18868,-18814,-18760,-18705,-18651,-18597, - -18542,-18488,-18434,-18380,-18325,-18271,-18217,-18163, - -18109,-18055,-18001,-17946,-17892,-17838,-17784,-17731, - -17677,-17623,-17569,-17515,-17461,-17407,-17353,-17300, - -17246,-17192,-17138,-17085,-17031,-16977,-16924,-16870, - -16817,-16763,-16710,-16656,-16603,-16549,-16496,-16442, - -16389,-16335,-16282,-16229,-16175,-16122,-16069,-16015, - -15962,-15909,-15856,-15802,-15749,-15696,-15643,-15590, - -15537,-15484,-15431,-15378,-15325,-15272,-15219,-15166, - -15113,-15060,-15007,-14954,-14901,-14848,-14795,-14743, - -14690,-14637,-14584,-14531,-14479,-14426,-14373,-14321, - -14268,-14215,-14163,-14110,-14057,-14005,-13952,-13900, - -13847,-13795,-13742,-13690,-13637,-13585,-13533,-13480, - -13428,-13375,-13323,-13271,-13218,-13166,-13114,-13062, - -13009,-12957,-12905,-12853,-12800,-12748,-12696,-12644, - -12592,-12540,-12488,-12436,-12383,-12331,-12279,-12227, - -12175,-12123,-12071,-12019,-11967,-11916,-11864,-11812, - -11760,-11708,-11656,-11604,-11552,-11501,-11449,-11397, - -11345,-11293,-11242,-11190,-11138,-11086,-11035,-10983, - -10931,-10880,-10828,-10777,-10725,-10673,-10622,-10570, - -10519,-10467,-10415,-10364,-10312,-10261,-10209,-10158, - -10106,-10055,-10004,-9952,-9901,-9849,-9798,-9747, - -9695,-9644,-9592,-9541,-9490,-9438,-9387,-9336, - -9285,-9233,-9182,-9131,-9080,-9028,-8977,-8926, - -8875,-8824,-8772,-8721,-8670,-8619,-8568,-8517, - -8466,-8414,-8363,-8312,-8261,-8210,-8159,-8108, - -8057,-8006,-7955,-7904,-7853,-7802,-7751,-7700, - -7649,-7598,-7547,-7496,-7445,-7395,-7344,-7293, - -7242,-7191,-7140,-7089,-7038,-6988,-6937,-6886, - -6835,-6784,-6733,-6683,-6632,-6581,-6530,-6480, - -6429,-6378,-6327,-6277,-6226,-6175,-6124,-6074, - -6023,-5972,-5922,-5871,-5820,-5770,-5719,-5668, - -5618,-5567,-5517,-5466,-5415,-5365,-5314,-5264, - -5213,-5162,-5112,-5061,-5011,-4960,-4910,-4859, - -4808,-4758,-4707,-4657,-4606,-4556,-4505,-4455, - -4404,-4354,-4303,-4253,-4202,-4152,-4101,-4051, - -4001,-3950,-3900,-3849,-3799,-3748,-3698,-3648, - -3597,-3547,-3496,-3446,-3395,-3345,-3295,-3244, - -3194,-3144,-3093,-3043,-2992,-2942,-2892,-2841, - -2791,-2741,-2690,-2640,-2590,-2539,-2489,-2439, - -2388,-2338,-2288,-2237,-2187,-2137,-2086,-2036, - -1986,-1935,-1885,-1835,-1784,-1734,-1684,-1633, - -1583,-1533,-1483,-1432,-1382,-1332,-1281,-1231, - -1181,-1131,-1080,-1030,-980,-929,-879,-829, - -779,-728,-678,-628,-578,-527,-477,-427, - -376,-326,-276,-226,-175,-125,-75,-25, - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1131,1181, - 1231,1281,1332,1382,1432,1483,1533,1583, - 1633,1684,1734,1784,1835,1885,1935,1986, - 2036,2086,2137,2187,2237,2288,2338,2388, - 2439,2489,2539,2590,2640,2690,2741,2791, - 2841,2892,2942,2992,3043,3093,3144,3194, - 3244,3295,3345,3395,3446,3496,3547,3597, - 3648,3698,3748,3799,3849,3900,3950,4001, - 4051,4101,4152,4202,4253,4303,4354,4404, - 4455,4505,4556,4606,4657,4707,4758,4808, - 4859,4910,4960,5011,5061,5112,5162,5213, - 5264,5314,5365,5415,5466,5517,5567,5618, - 5668,5719,5770,5820,5871,5922,5972,6023, - 6074,6124,6175,6226,6277,6327,6378,6429, - 6480,6530,6581,6632,6683,6733,6784,6835, - 6886,6937,6988,7038,7089,7140,7191,7242, - 7293,7344,7395,7445,7496,7547,7598,7649, - 7700,7751,7802,7853,7904,7955,8006,8057, - 8108,8159,8210,8261,8312,8363,8414,8466, - 8517,8568,8619,8670,8721,8772,8824,8875, - 8926,8977,9028,9080,9131,9182,9233,9285, - 9336,9387,9438,9490,9541,9592,9644,9695, - 9747,9798,9849,9901,9952,10004,10055,10106, - 10158,10209,10261,10312,10364,10415,10467,10519, - 10570,10622,10673,10725,10777,10828,10880,10931, - 10983,11035,11086,11138,11190,11242,11293,11345, - 11397,11449,11501,11552,11604,11656,11708,11760, - 11812,11864,11916,11967,12019,12071,12123,12175, - 12227,12279,12331,12383,12436,12488,12540,12592, - 12644,12696,12748,12800,12853,12905,12957,13009, - 13062,13114,13166,13218,13271,13323,13375,13428, - 13480,13533,13585,13637,13690,13742,13795,13847, - 13900,13952,14005,14057,14110,14163,14215,14268, - 14321,14373,14426,14479,14531,14584,14637,14690, - 14743,14795,14848,14901,14954,15007,15060,15113, - 15166,15219,15272,15325,15378,15431,15484,15537, - 15590,15643,15696,15749,15802,15856,15909,15962, - 16015,16069,16122,16175,16229,16282,16335,16389, - 16442,16496,16549,16603,16656,16710,16763,16817, - 16870,16924,16977,17031,17085,17138,17192,17246, - 17300,17353,17407,17461,17515,17569,17623,17677, - 17731,17784,17838,17892,17946,18001,18055,18109, - 18163,18217,18271,18325,18380,18434,18488,18542, - 18597,18651,18705,18760,18814,18868,18923,18977, - 19032,19086,19141,19195,19250,19305,19359,19414, - 19469,19523,19578,19633,19688,19742,19797,19852, - 19907,19962,20017,20072,20127,20182,20237,20292, - 20347,20402,20457,20513,20568,20623,20678,20734, - 20789,20844,20900,20955,21010,21066,21121,21177, - 21232,21288,21343,21399,21455,21510,21566,21622, - 21678,21733,21789,21845,21901,21957,22013,22069, - 22125,22181,22237,22293,22349,22405,22461,22517, - 22573,22630,22686,22742,22799,22855,22911,22968, - 23024,23081,23137,23194,23250,23307,23364,23420, - 23477,23534,23591,23647,23704,23761,23818,23875, - 23932,23989,24046,24103,24160,24217,24274,24331, - 24389,24446,24503,24560,24618,24675,24732,24790, - 24847,24905,24962,25020,25078,25135,25193,25251, - 25308,25366,25424,25482,25540,25598,25656,25714, - 25772,25830,25888,25946,26004,26062,26120,26179, - 26237,26295,26354,26412,26471,26529,26588,26646, - 26705,26763,26822,26881,26940,26998,27057,27116, - 27175,27234,27293,27352,27411,27470,27529,27588, - 27647,27707,27766,27825,27884,27944,28003,28063, - 28122,28182,28241,28301,28361,28420,28480,28540, - 28600,28660,28719,28779,28839,28899,28959,29020, - 29080,29140,29200,29260,29321,29381,29441,29502, - 29562,29623,29683,29744,29805,29865,29926,29987, - 30048,30108,30169,30230,30291,30352,30413,30474, - 30536,30597,30658,30719,30781,30842,30904,30965, - 31026,31088,31150,31211,31273,31335,31396,31458, - 31520,31582,31644,31706,31768,31830,31892,31955, - 32017,32079,32141,32204,32266,32329,32391,32454, - 32516,32579,32642,32705,32767,32830,32893,32956, - 33019,33082,33145,33208,33272,33335,33398,33461, - 33525,33588,33652,33715,33779,33843,33906,33970, - 34034,34098,34162,34225,34289,34354,34418,34482, - 34546,34610,34675,34739,34803,34868,34932,34997, - 35062,35126,35191,35256,35321,35385,35450,35515, - 35580,35646,35711,35776,35841,35907,35972,36037, - 36103,36168,36234,36300,36365,36431,36497,36563, - 36629,36695,36761,36827,36893,36959,37026,37092, - 37158,37225,37291,37358,37425,37491,37558,37625, - 37692,37759,37826,37893,37960,38027,38094,38161, - 38229,38296,38364,38431,38499,38566,38634,38702, - 38770,38837,38905,38973,39042,39110,39178,39246, - 39314,39383,39451,39520,39588,39657,39726,39794, - 39863,39932,40001,40070,40139,40208,40278,40347, - 40416,40486,40555,40625,40694,40764,40834,40904, - 40973,41043,41113,41184,41254,41324,41394,41465, - 41535,41605,41676,41747,41817,41888,41959,42030, - 42101,42172,42243,42314,42385,42457,42528,42600, - 42671,42743,42814,42886,42958,43030,43102,43174, - 43246,43318,43390,43463,43535,43608,43680,43753, - 43826,43898,43971,44044,44117,44190,44263,44337, - 44410,44483,44557,44630,44704,44778,44851,44925, - 44999,45073,45147,45221,45296,45370,45444,45519, - 45593,45668,45743,45818,45892,45967,46042,46118, - 46193,46268,46343,46419,46494,46570,46646,46721, - 46797,46873,46949,47025,47102,47178,47254,47331, - 47407,47484,47560,47637,47714,47791,47868,47945, - 48022,48100,48177,48255,48332,48410,48488,48565, - 48643,48721,48799,48878,48956,49034,49113,49191, - 49270,49349,49427,49506,49585,49664,49744,49823, - 49902,49982,50061,50141,50221,50300,50380,50460, - 50540,50621,50701,50781,50862,50942,51023,51104, - 51185,51266,51347,51428,51509,51591,51672,51754, - 51835,51917,51999,52081,52163,52245,52327,52410, - 52492,52575,52657,52740,52823,52906,52989,53072, - 53156,53239,53322,53406,53490,53574,53657,53741, - 53826,53910,53994,54079,54163,54248,54333,54417, - 54502,54587,54673,54758,54843,54929,55015,55100, - 55186,55272,55358,55444,55531,55617,55704,55790, - 55877,55964,56051,56138,56225,56312,56400,56487, - 56575,56663,56751,56839,56927,57015,57104,57192, - 57281,57369,57458,57547,57636,57725,57815,57904, - 57994,58083,58173,58263,58353,58443,58534,58624, - 58715,58805,58896,58987,59078,59169,59261,59352, - 59444,59535,59627,59719,59811,59903,59996,60088, - 60181,60273,60366,60459,60552,60646,60739,60833, - 60926,61020,61114,61208,61302,61396,61491,61585, - 61680,61775,61870,61965,62060,62156,62251,62347, - 62443,62539,62635,62731,62828,62924,63021,63118, - 63215,63312,63409,63506,63604,63702,63799,63897, - 63996,64094,64192,64291,64389,64488,64587,64687, - 64786,64885,64985,65085,65185,65285,65385,65485, - 65586,65686,65787,65888,65989,66091,66192,66294, - 66396,66498,66600,66702,66804,66907,67010,67113, - 67216,67319,67422,67526,67629,67733,67837,67942, - 68046,68151,68255,68360,68465,68570,68676,68781, - 68887,68993,69099,69205,69312,69418,69525,69632, - 69739,69846,69954,70061,70169,70277,70385,70494, - 70602,70711,70820,70929,71038,71147,71257,71367, - 71477,71587,71697,71808,71918,72029,72140,72252, - 72363,72475,72587,72699,72811,72923,73036,73149, - 73262,73375,73488,73602,73715,73829,73944,74058, - 74172,74287,74402,74517,74633,74748,74864,74980, - 75096,75213,75329,75446,75563,75680,75797,75915, - 76033,76151,76269,76388,76506,76625,76744,76864, - 76983,77103,77223,77343,77463,77584,77705,77826, - 77947,78068,78190,78312,78434,78557,78679,78802, - 78925,79048,79172,79296,79420,79544,79668,79793, - 79918,80043,80168,80294,80420,80546,80672,80799, - 80925,81053,81180,81307,81435,81563,81691,81820, - 81949,82078,82207,82336,82466,82596,82726,82857, - 82987,83118,83250,83381,83513,83645,83777,83910, - 84043,84176,84309,84443,84576,84710,84845,84980, - 85114,85250,85385,85521,85657,85793,85930,86066, - 86204,86341,86479,86616,86755,86893,87032,87171, - 87310,87450,87590,87730,87871,88011,88152,88294, - 88435,88577,88720,88862,89005,89148,89292,89435, - 89579,89724,89868,90013,90158,90304,90450,90596, - 90742,90889,91036,91184,91332,91480,91628,91777, - 91926,92075,92225,92375,92525,92675,92826,92978, - 93129,93281,93434,93586,93739,93892,94046,94200, - 94354,94509,94664,94819,94975,95131,95287,95444, - 95601,95758,95916,96074,96233,96391,96551,96710, - 96870,97030,97191,97352,97513,97675,97837,98000, - 98163,98326,98489,98653,98818,98982,99148,99313, - 99479,99645,99812,99979,100146,100314,100482,100651, - 100820,100990,101159,101330,101500,101671,101843,102015, - 102187,102360,102533,102706,102880,103054,103229,103404, - 103580,103756,103933,104109,104287,104465,104643,104821, - 105000,105180,105360,105540,105721,105902,106084,106266, - 106449,106632,106816,107000,107184,107369,107555,107741, - 107927,108114,108301,108489,108677,108866,109055,109245, - 109435,109626,109817,110008,110200,110393,110586,110780, - 110974,111169,111364,111560,111756,111952,112150,112347, - 112546,112744,112944,113143,113344,113545,113746,113948, - 114151,114354,114557,114761,114966,115171,115377,115583, - 115790,115998,116206,116414,116623,116833,117044,117254, - 117466,117678,117891,118104,118318,118532,118747,118963, - 119179,119396,119613,119831,120050,120269,120489,120709, - 120930,121152,121374,121597,121821,122045,122270,122496, - 122722,122949,123176,123404,123633,123863,124093,124324, - 124555,124787,125020,125254,125488,125723,125959,126195, - 126432,126669,126908,127147,127387,127627,127869,128111, - 128353,128597,128841,129086,129332,129578,129825,130073, - 130322,130571,130821,131072,131324,131576,131830,132084, - 132339,132594,132851,133108,133366,133625,133884,134145, - 134406,134668,134931,135195,135459,135725,135991,136258, - 136526,136795,137065,137335,137607,137879,138152,138426, - 138701,138977,139254,139532,139810,140090,140370,140651, - 140934,141217,141501,141786,142072,142359,142647,142936, - 143226,143517,143808,144101,144395,144690,144986,145282, - 145580,145879,146179,146480,146782,147084,147388,147693, - 148000,148307,148615,148924,149235,149546,149859,150172, - 150487,150803,151120,151438,151757,152077,152399,152722, - 153045,153370,153697,154024,154352,154682,155013,155345, - 155678,156013,156349,156686,157024,157363,157704,158046, - 158389,158734,159079,159427,159775,160125,160476,160828, - 161182,161537,161893,162251,162610,162970,163332,163695, - 164060,164426,164793,165162,165532,165904,166277,166651, - 167027,167405,167784,168164,168546,168930,169315,169701, - 170089,170479,170870,171263,171657,172053,172451,172850, - 173251,173653,174057,174463,174870,175279,175690,176102, - 176516,176932,177349,177769,178190,178612,179037,179463, - 179891,180321,180753,181186,181622,182059,182498,182939, - 183382,183827,184274,184722,185173,185625,186080,186536, - 186995,187455,187918,188382,188849,189318,189789,190261, - 190736,191213,191693,192174,192658,193143,193631,194122, - 194614,195109,195606,196105,196606,197110,197616,198125, - 198636,199149,199664,200182,200703,201226,201751,202279, - 202809,203342,203878,204416,204956,205500,206045,206594, - 207145,207699,208255,208815,209376,209941,210509,211079, - 211652,212228,212807,213389,213973,214561,215151,215745, - 216341,216941,217544,218149,218758,219370,219985,220603, - 221225,221849,222477,223108,223743,224381,225022,225666, - 226314,226966,227621,228279,228941,229606,230275,230948, - 231624,232304,232988,233676,234367,235062,235761,236463, - 237170,237881,238595,239314,240036,240763,241493,242228, - 242967,243711,244458,245210,245966,246727,247492,248261, - 249035,249813,250596,251384,252176,252973,253774,254581, - 255392,256208,257029,257855,258686,259522,260363,261209, - 262060,262917,263779,264646,265519,266397,267280,268169, - 269064,269965,270871,271782,272700,273624,274553,275489, - 276430,277378,278332,279292,280258,281231,282210,283195, - 284188,285186,286192,287204,288223,289249,290282,291322, - 292369,293423,294485,295554,296630,297714,298805,299904, - 301011,302126,303248,304379,305517,306664,307819,308983, - 310154,311335,312524,313721,314928,316143,317368,318601, - 319844,321097,322358,323629,324910,326201,327502,328812, - 330133,331464,332805,334157,335519,336892,338276,339671, - 341078,342495,343924,345364,346816,348280,349756,351244, - 352744,354257,355783,357321,358872,360436,362013,363604, - 365208,366826,368459,370105,371765,373440,375130,376835, - 378555,380290,382040,383807,385589,387387,389202,391034, - 392882,394747,396630,398530,400448,402384,404338,406311, - 408303,410314,412344,414395,416465,418555,420666,422798, - 424951,427125,429321,431540,433781,436045,438332,440643, - 442978,445337,447720,450129,452564,455024,457511,460024, - 462565,465133,467730,470355,473009,475692,478406,481150, - 483925,486732,489571,492443,495348,498287,501261,504269, - 507313,510394,513512,516667,519861,523094,526366,529680, - 533034,536431,539870,543354,546881,550455,554074,557741, - 561456,565221,569035,572901,576818,580789,584815,588896, - 593033,597229,601483,605798,610174,614613,619117,623686, - 628323,633028,637803,642651,647572,652568,657640,662792, - 668024,673338,678737,684223,689797,695462,701219,707072, - 713023,719074,725227,731486,737853,744331,750922,757631, - 764460,771411,778490,785699,793041,800521,808143,815910, - 823827,831898,840127,848520,857081,865817,874730,883829, - 893117,902602,912289,922186,932298,942633,953199,964003, - 975054,986361,997931,1009774,1021901,1034322,1047046,1060087, - 1073455,1087164,1101225,1115654,1130465,1145673,1161294,1177345, - 1193846,1210813,1228269,1246234,1264730,1283783,1303416,1323658, - 1344537,1366084,1388330,1411312,1435065,1459630,1485049,1511367, - 1538632,1566898,1596220,1626658,1658278,1691149,1725348,1760956, - 1798063,1836758,1877161,1919378,1963536,2009771,2058233,2109087, - 2162516,2218719,2277919,2340362,2406322,2476104,2550052,2628549, - 2712030,2800983,2895966,2997613,3106651,3223918,3350381,3487165, - 3635590,3797206,3973855,4167737,4381502,4618375,4882318,5178251, - 5512368,5892567,6329090,6835455,7429880,8137527,8994149,10052327, - 11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304 + +int finetangent[4096] = { + -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, + -10052327,-8994149,-8137527,-7429880,-6835455,-6329090,-5892567,-5512368, + -5178251,-4882318,-4618375,-4381502,-4167737,-3973855,-3797206,-3635590, + -3487165,-3350381,-3223918,-3106651,-2997613,-2895966,-2800983,-2712030, + -2628549,-2550052,-2476104,-2406322,-2340362,-2277919,-2218719,-2162516, + -2109087,-2058233,-2009771,-1963536,-1919378,-1877161,-1836758,-1798063, + -1760956,-1725348,-1691149,-1658278,-1626658,-1596220,-1566898,-1538632, + -1511367,-1485049,-1459630,-1435065,-1411312,-1388330,-1366084,-1344537, + -1323658,-1303416,-1283783,-1264730,-1246234,-1228269,-1210813,-1193846, + -1177345,-1161294,-1145673,-1130465,-1115654,-1101225,-1087164,-1073455, + -1060087,-1047046,-1034322,-1021901,-1009774,-997931,-986361,-975054, + -964003,-953199,-942633,-932298,-922186,-912289,-902602,-893117, + -883829,-874730,-865817,-857081,-848520,-840127,-831898,-823827, + -815910,-808143,-800521,-793041,-785699,-778490,-771411,-764460, + -757631,-750922,-744331,-737853,-731486,-725227,-719074,-713023, + -707072,-701219,-695462,-689797,-684223,-678737,-673338,-668024, + -662792,-657640,-652568,-647572,-642651,-637803,-633028,-628323, + -623686,-619117,-614613,-610174,-605798,-601483,-597229,-593033, + -588896,-584815,-580789,-576818,-572901,-569035,-565221,-561456, + -557741,-554074,-550455,-546881,-543354,-539870,-536431,-533034, + -529680,-526366,-523094,-519861,-516667,-513512,-510394,-507313, + -504269,-501261,-498287,-495348,-492443,-489571,-486732,-483925, + -481150,-478406,-475692,-473009,-470355,-467730,-465133,-462565, + -460024,-457511,-455024,-452564,-450129,-447720,-445337,-442978, + -440643,-438332,-436045,-433781,-431540,-429321,-427125,-424951, + -422798,-420666,-418555,-416465,-414395,-412344,-410314,-408303, + -406311,-404338,-402384,-400448,-398530,-396630,-394747,-392882, + -391034,-389202,-387387,-385589,-383807,-382040,-380290,-378555, + -376835,-375130,-373440,-371765,-370105,-368459,-366826,-365208, + -363604,-362013,-360436,-358872,-357321,-355783,-354257,-352744, + -351244,-349756,-348280,-346816,-345364,-343924,-342495,-341078, + -339671,-338276,-336892,-335519,-334157,-332805,-331464,-330133, + -328812,-327502,-326201,-324910,-323629,-322358,-321097,-319844, + -318601,-317368,-316143,-314928,-313721,-312524,-311335,-310154, + -308983,-307819,-306664,-305517,-304379,-303248,-302126,-301011, + -299904,-298805,-297714,-296630,-295554,-294485,-293423,-292369, + -291322,-290282,-289249,-288223,-287204,-286192,-285186,-284188, + -283195,-282210,-281231,-280258,-279292,-278332,-277378,-276430, + -275489,-274553,-273624,-272700,-271782,-270871,-269965,-269064, + -268169,-267280,-266397,-265519,-264646,-263779,-262917,-262060, + -261209,-260363,-259522,-258686,-257855,-257029,-256208,-255392, + -254581,-253774,-252973,-252176,-251384,-250596,-249813,-249035, + -248261,-247492,-246727,-245966,-245210,-244458,-243711,-242967, + -242228,-241493,-240763,-240036,-239314,-238595,-237881,-237170, + -236463,-235761,-235062,-234367,-233676,-232988,-232304,-231624, + -230948,-230275,-229606,-228941,-228279,-227621,-226966,-226314, + -225666,-225022,-224381,-223743,-223108,-222477,-221849,-221225, + -220603,-219985,-219370,-218758,-218149,-217544,-216941,-216341, + -215745,-215151,-214561,-213973,-213389,-212807,-212228,-211652, + -211079,-210509,-209941,-209376,-208815,-208255,-207699,-207145, + -206594,-206045,-205500,-204956,-204416,-203878,-203342,-202809, + -202279,-201751,-201226,-200703,-200182,-199664,-199149,-198636, + -198125,-197616,-197110,-196606,-196105,-195606,-195109,-194614, + -194122,-193631,-193143,-192658,-192174,-191693,-191213,-190736, + -190261,-189789,-189318,-188849,-188382,-187918,-187455,-186995, + -186536,-186080,-185625,-185173,-184722,-184274,-183827,-183382, + -182939,-182498,-182059,-181622,-181186,-180753,-180321,-179891, + -179463,-179037,-178612,-178190,-177769,-177349,-176932,-176516, + -176102,-175690,-175279,-174870,-174463,-174057,-173653,-173251, + -172850,-172451,-172053,-171657,-171263,-170870,-170479,-170089, + -169701,-169315,-168930,-168546,-168164,-167784,-167405,-167027, + -166651,-166277,-165904,-165532,-165162,-164793,-164426,-164060, + -163695,-163332,-162970,-162610,-162251,-161893,-161537,-161182, + -160828,-160476,-160125,-159775,-159427,-159079,-158734,-158389, + -158046,-157704,-157363,-157024,-156686,-156349,-156013,-155678, + -155345,-155013,-154682,-154352,-154024,-153697,-153370,-153045, + -152722,-152399,-152077,-151757,-151438,-151120,-150803,-150487, + -150172,-149859,-149546,-149235,-148924,-148615,-148307,-148000, + -147693,-147388,-147084,-146782,-146480,-146179,-145879,-145580, + -145282,-144986,-144690,-144395,-144101,-143808,-143517,-143226, + -142936,-142647,-142359,-142072,-141786,-141501,-141217,-140934, + -140651,-140370,-140090,-139810,-139532,-139254,-138977,-138701, + -138426,-138152,-137879,-137607,-137335,-137065,-136795,-136526, + -136258,-135991,-135725,-135459,-135195,-134931,-134668,-134406, + -134145,-133884,-133625,-133366,-133108,-132851,-132594,-132339, + -132084,-131830,-131576,-131324,-131072,-130821,-130571,-130322, + -130073,-129825,-129578,-129332,-129086,-128841,-128597,-128353, + -128111,-127869,-127627,-127387,-127147,-126908,-126669,-126432, + -126195,-125959,-125723,-125488,-125254,-125020,-124787,-124555, + -124324,-124093,-123863,-123633,-123404,-123176,-122949,-122722, + -122496,-122270,-122045,-121821,-121597,-121374,-121152,-120930, + -120709,-120489,-120269,-120050,-119831,-119613,-119396,-119179, + -118963,-118747,-118532,-118318,-118104,-117891,-117678,-117466, + -117254,-117044,-116833,-116623,-116414,-116206,-115998,-115790, + -115583,-115377,-115171,-114966,-114761,-114557,-114354,-114151, + -113948,-113746,-113545,-113344,-113143,-112944,-112744,-112546, + -112347,-112150,-111952,-111756,-111560,-111364,-111169,-110974, + -110780,-110586,-110393,-110200,-110008,-109817,-109626,-109435, + -109245,-109055,-108866,-108677,-108489,-108301,-108114,-107927, + -107741,-107555,-107369,-107184,-107000,-106816,-106632,-106449, + -106266,-106084,-105902,-105721,-105540,-105360,-105180,-105000, + -104821,-104643,-104465,-104287,-104109,-103933,-103756,-103580, + -103404,-103229,-103054,-102880,-102706,-102533,-102360,-102187, + -102015,-101843,-101671,-101500,-101330,-101159,-100990,-100820, + -100651,-100482,-100314,-100146,-99979,-99812,-99645,-99479, + -99313,-99148,-98982,-98818,-98653,-98489,-98326,-98163, + -98000,-97837,-97675,-97513,-97352,-97191,-97030,-96870, + -96710,-96551,-96391,-96233,-96074,-95916,-95758,-95601, + -95444,-95287,-95131,-94975,-94819,-94664,-94509,-94354, + -94200,-94046,-93892,-93739,-93586,-93434,-93281,-93129, + -92978,-92826,-92675,-92525,-92375,-92225,-92075,-91926, + -91777,-91628,-91480,-91332,-91184,-91036,-90889,-90742, + -90596,-90450,-90304,-90158,-90013,-89868,-89724,-89579, + -89435,-89292,-89148,-89005,-88862,-88720,-88577,-88435, + -88294,-88152,-88011,-87871,-87730,-87590,-87450,-87310, + -87171,-87032,-86893,-86755,-86616,-86479,-86341,-86204, + -86066,-85930,-85793,-85657,-85521,-85385,-85250,-85114, + -84980,-84845,-84710,-84576,-84443,-84309,-84176,-84043, + -83910,-83777,-83645,-83513,-83381,-83250,-83118,-82987, + -82857,-82726,-82596,-82466,-82336,-82207,-82078,-81949, + -81820,-81691,-81563,-81435,-81307,-81180,-81053,-80925, + -80799,-80672,-80546,-80420,-80294,-80168,-80043,-79918, + -79793,-79668,-79544,-79420,-79296,-79172,-79048,-78925, + -78802,-78679,-78557,-78434,-78312,-78190,-78068,-77947, + -77826,-77705,-77584,-77463,-77343,-77223,-77103,-76983, + -76864,-76744,-76625,-76506,-76388,-76269,-76151,-76033, + -75915,-75797,-75680,-75563,-75446,-75329,-75213,-75096, + -74980,-74864,-74748,-74633,-74517,-74402,-74287,-74172, + -74058,-73944,-73829,-73715,-73602,-73488,-73375,-73262, + -73149,-73036,-72923,-72811,-72699,-72587,-72475,-72363, + -72252,-72140,-72029,-71918,-71808,-71697,-71587,-71477, + -71367,-71257,-71147,-71038,-70929,-70820,-70711,-70602, + -70494,-70385,-70277,-70169,-70061,-69954,-69846,-69739, + -69632,-69525,-69418,-69312,-69205,-69099,-68993,-68887, + -68781,-68676,-68570,-68465,-68360,-68255,-68151,-68046, + -67942,-67837,-67733,-67629,-67526,-67422,-67319,-67216, + -67113,-67010,-66907,-66804,-66702,-66600,-66498,-66396, + -66294,-66192,-66091,-65989,-65888,-65787,-65686,-65586, + -65485,-65385,-65285,-65185,-65085,-64985,-64885,-64786, + -64687,-64587,-64488,-64389,-64291,-64192,-64094,-63996, + -63897,-63799,-63702,-63604,-63506,-63409,-63312,-63215, + -63118,-63021,-62924,-62828,-62731,-62635,-62539,-62443, + -62347,-62251,-62156,-62060,-61965,-61870,-61775,-61680, + -61585,-61491,-61396,-61302,-61208,-61114,-61020,-60926, + -60833,-60739,-60646,-60552,-60459,-60366,-60273,-60181, + -60088,-59996,-59903,-59811,-59719,-59627,-59535,-59444, + -59352,-59261,-59169,-59078,-58987,-58896,-58805,-58715, + -58624,-58534,-58443,-58353,-58263,-58173,-58083,-57994, + -57904,-57815,-57725,-57636,-57547,-57458,-57369,-57281, + -57192,-57104,-57015,-56927,-56839,-56751,-56663,-56575, + -56487,-56400,-56312,-56225,-56138,-56051,-55964,-55877, + -55790,-55704,-55617,-55531,-55444,-55358,-55272,-55186, + -55100,-55015,-54929,-54843,-54758,-54673,-54587,-54502, + -54417,-54333,-54248,-54163,-54079,-53994,-53910,-53826, + -53741,-53657,-53574,-53490,-53406,-53322,-53239,-53156, + -53072,-52989,-52906,-52823,-52740,-52657,-52575,-52492, + -52410,-52327,-52245,-52163,-52081,-51999,-51917,-51835, + -51754,-51672,-51591,-51509,-51428,-51347,-51266,-51185, + -51104,-51023,-50942,-50862,-50781,-50701,-50621,-50540, + -50460,-50380,-50300,-50221,-50141,-50061,-49982,-49902, + -49823,-49744,-49664,-49585,-49506,-49427,-49349,-49270, + -49191,-49113,-49034,-48956,-48878,-48799,-48721,-48643, + -48565,-48488,-48410,-48332,-48255,-48177,-48100,-48022, + -47945,-47868,-47791,-47714,-47637,-47560,-47484,-47407, + -47331,-47254,-47178,-47102,-47025,-46949,-46873,-46797, + -46721,-46646,-46570,-46494,-46419,-46343,-46268,-46193, + -46118,-46042,-45967,-45892,-45818,-45743,-45668,-45593, + -45519,-45444,-45370,-45296,-45221,-45147,-45073,-44999, + -44925,-44851,-44778,-44704,-44630,-44557,-44483,-44410, + -44337,-44263,-44190,-44117,-44044,-43971,-43898,-43826, + -43753,-43680,-43608,-43535,-43463,-43390,-43318,-43246, + -43174,-43102,-43030,-42958,-42886,-42814,-42743,-42671, + -42600,-42528,-42457,-42385,-42314,-42243,-42172,-42101, + -42030,-41959,-41888,-41817,-41747,-41676,-41605,-41535, + -41465,-41394,-41324,-41254,-41184,-41113,-41043,-40973, + -40904,-40834,-40764,-40694,-40625,-40555,-40486,-40416, + -40347,-40278,-40208,-40139,-40070,-40001,-39932,-39863, + -39794,-39726,-39657,-39588,-39520,-39451,-39383,-39314, + -39246,-39178,-39110,-39042,-38973,-38905,-38837,-38770, + -38702,-38634,-38566,-38499,-38431,-38364,-38296,-38229, + -38161,-38094,-38027,-37960,-37893,-37826,-37759,-37692, + -37625,-37558,-37491,-37425,-37358,-37291,-37225,-37158, + -37092,-37026,-36959,-36893,-36827,-36761,-36695,-36629, + -36563,-36497,-36431,-36365,-36300,-36234,-36168,-36103, + -36037,-35972,-35907,-35841,-35776,-35711,-35646,-35580, + -35515,-35450,-35385,-35321,-35256,-35191,-35126,-35062, + -34997,-34932,-34868,-34803,-34739,-34675,-34610,-34546, + -34482,-34418,-34354,-34289,-34225,-34162,-34098,-34034, + -33970,-33906,-33843,-33779,-33715,-33652,-33588,-33525, + -33461,-33398,-33335,-33272,-33208,-33145,-33082,-33019, + -32956,-32893,-32830,-32767,-32705,-32642,-32579,-32516, + -32454,-32391,-32329,-32266,-32204,-32141,-32079,-32017, + -31955,-31892,-31830,-31768,-31706,-31644,-31582,-31520, + -31458,-31396,-31335,-31273,-31211,-31150,-31088,-31026, + -30965,-30904,-30842,-30781,-30719,-30658,-30597,-30536, + -30474,-30413,-30352,-30291,-30230,-30169,-30108,-30048, + -29987,-29926,-29865,-29805,-29744,-29683,-29623,-29562, + -29502,-29441,-29381,-29321,-29260,-29200,-29140,-29080, + -29020,-28959,-28899,-28839,-28779,-28719,-28660,-28600, + -28540,-28480,-28420,-28361,-28301,-28241,-28182,-28122, + -28063,-28003,-27944,-27884,-27825,-27766,-27707,-27647, + -27588,-27529,-27470,-27411,-27352,-27293,-27234,-27175, + -27116,-27057,-26998,-26940,-26881,-26822,-26763,-26705, + -26646,-26588,-26529,-26471,-26412,-26354,-26295,-26237, + -26179,-26120,-26062,-26004,-25946,-25888,-25830,-25772, + -25714,-25656,-25598,-25540,-25482,-25424,-25366,-25308, + -25251,-25193,-25135,-25078,-25020,-24962,-24905,-24847, + -24790,-24732,-24675,-24618,-24560,-24503,-24446,-24389, + -24331,-24274,-24217,-24160,-24103,-24046,-23989,-23932, + -23875,-23818,-23761,-23704,-23647,-23591,-23534,-23477, + -23420,-23364,-23307,-23250,-23194,-23137,-23081,-23024, + -22968,-22911,-22855,-22799,-22742,-22686,-22630,-22573, + -22517,-22461,-22405,-22349,-22293,-22237,-22181,-22125, + -22069,-22013,-21957,-21901,-21845,-21789,-21733,-21678, + -21622,-21566,-21510,-21455,-21399,-21343,-21288,-21232, + -21177,-21121,-21066,-21010,-20955,-20900,-20844,-20789, + -20734,-20678,-20623,-20568,-20513,-20457,-20402,-20347, + -20292,-20237,-20182,-20127,-20072,-20017,-19962,-19907, + -19852,-19797,-19742,-19688,-19633,-19578,-19523,-19469, + -19414,-19359,-19305,-19250,-19195,-19141,-19086,-19032, + -18977,-18923,-18868,-18814,-18760,-18705,-18651,-18597, + -18542,-18488,-18434,-18380,-18325,-18271,-18217,-18163, + -18109,-18055,-18001,-17946,-17892,-17838,-17784,-17731, + -17677,-17623,-17569,-17515,-17461,-17407,-17353,-17300, + -17246,-17192,-17138,-17085,-17031,-16977,-16924,-16870, + -16817,-16763,-16710,-16656,-16603,-16549,-16496,-16442, + -16389,-16335,-16282,-16229,-16175,-16122,-16069,-16015, + -15962,-15909,-15856,-15802,-15749,-15696,-15643,-15590, + -15537,-15484,-15431,-15378,-15325,-15272,-15219,-15166, + -15113,-15060,-15007,-14954,-14901,-14848,-14795,-14743, + -14690,-14637,-14584,-14531,-14479,-14426,-14373,-14321, + -14268,-14215,-14163,-14110,-14057,-14005,-13952,-13900, + -13847,-13795,-13742,-13690,-13637,-13585,-13533,-13480, + -13428,-13375,-13323,-13271,-13218,-13166,-13114,-13062, + -13009,-12957,-12905,-12853,-12800,-12748,-12696,-12644, + -12592,-12540,-12488,-12436,-12383,-12331,-12279,-12227, + -12175,-12123,-12071,-12019,-11967,-11916,-11864,-11812, + -11760,-11708,-11656,-11604,-11552,-11501,-11449,-11397, + -11345,-11293,-11242,-11190,-11138,-11086,-11035,-10983, + -10931,-10880,-10828,-10777,-10725,-10673,-10622,-10570, + -10519,-10467,-10415,-10364,-10312,-10261,-10209,-10158, + -10106,-10055,-10004,-9952,-9901,-9849,-9798,-9747, + -9695,-9644,-9592,-9541,-9490,-9438,-9387,-9336, + -9285,-9233,-9182,-9131,-9080,-9028,-8977,-8926, + -8875,-8824,-8772,-8721,-8670,-8619,-8568,-8517, + -8466,-8414,-8363,-8312,-8261,-8210,-8159,-8108, + -8057,-8006,-7955,-7904,-7853,-7802,-7751,-7700, + -7649,-7598,-7547,-7496,-7445,-7395,-7344,-7293, + -7242,-7191,-7140,-7089,-7038,-6988,-6937,-6886, + -6835,-6784,-6733,-6683,-6632,-6581,-6530,-6480, + -6429,-6378,-6327,-6277,-6226,-6175,-6124,-6074, + -6023,-5972,-5922,-5871,-5820,-5770,-5719,-5668, + -5618,-5567,-5517,-5466,-5415,-5365,-5314,-5264, + -5213,-5162,-5112,-5061,-5011,-4960,-4910,-4859, + -4808,-4758,-4707,-4657,-4606,-4556,-4505,-4455, + -4404,-4354,-4303,-4253,-4202,-4152,-4101,-4051, + -4001,-3950,-3900,-3849,-3799,-3748,-3698,-3648, + -3597,-3547,-3496,-3446,-3395,-3345,-3295,-3244, + -3194,-3144,-3093,-3043,-2992,-2942,-2892,-2841, + -2791,-2741,-2690,-2640,-2590,-2539,-2489,-2439, + -2388,-2338,-2288,-2237,-2187,-2137,-2086,-2036, + -1986,-1935,-1885,-1835,-1784,-1734,-1684,-1633, + -1583,-1533,-1483,-1432,-1382,-1332,-1281,-1231, + -1181,-1131,-1080,-1030,-980,-929,-879,-829, + -779,-728,-678,-628,-578,-527,-477,-427, + -376,-326,-276,-226,-175,-125,-75,-25, + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1131,1181, + 1231,1281,1332,1382,1432,1483,1533,1583, + 1633,1684,1734,1784,1835,1885,1935,1986, + 2036,2086,2137,2187,2237,2288,2338,2388, + 2439,2489,2539,2590,2640,2690,2741,2791, + 2841,2892,2942,2992,3043,3093,3144,3194, + 3244,3295,3345,3395,3446,3496,3547,3597, + 3648,3698,3748,3799,3849,3900,3950,4001, + 4051,4101,4152,4202,4253,4303,4354,4404, + 4455,4505,4556,4606,4657,4707,4758,4808, + 4859,4910,4960,5011,5061,5112,5162,5213, + 5264,5314,5365,5415,5466,5517,5567,5618, + 5668,5719,5770,5820,5871,5922,5972,6023, + 6074,6124,6175,6226,6277,6327,6378,6429, + 6480,6530,6581,6632,6683,6733,6784,6835, + 6886,6937,6988,7038,7089,7140,7191,7242, + 7293,7344,7395,7445,7496,7547,7598,7649, + 7700,7751,7802,7853,7904,7955,8006,8057, + 8108,8159,8210,8261,8312,8363,8414,8466, + 8517,8568,8619,8670,8721,8772,8824,8875, + 8926,8977,9028,9080,9131,9182,9233,9285, + 9336,9387,9438,9490,9541,9592,9644,9695, + 9747,9798,9849,9901,9952,10004,10055,10106, + 10158,10209,10261,10312,10364,10415,10467,10519, + 10570,10622,10673,10725,10777,10828,10880,10931, + 10983,11035,11086,11138,11190,11242,11293,11345, + 11397,11449,11501,11552,11604,11656,11708,11760, + 11812,11864,11916,11967,12019,12071,12123,12175, + 12227,12279,12331,12383,12436,12488,12540,12592, + 12644,12696,12748,12800,12853,12905,12957,13009, + 13062,13114,13166,13218,13271,13323,13375,13428, + 13480,13533,13585,13637,13690,13742,13795,13847, + 13900,13952,14005,14057,14110,14163,14215,14268, + 14321,14373,14426,14479,14531,14584,14637,14690, + 14743,14795,14848,14901,14954,15007,15060,15113, + 15166,15219,15272,15325,15378,15431,15484,15537, + 15590,15643,15696,15749,15802,15856,15909,15962, + 16015,16069,16122,16175,16229,16282,16335,16389, + 16442,16496,16549,16603,16656,16710,16763,16817, + 16870,16924,16977,17031,17085,17138,17192,17246, + 17300,17353,17407,17461,17515,17569,17623,17677, + 17731,17784,17838,17892,17946,18001,18055,18109, + 18163,18217,18271,18325,18380,18434,18488,18542, + 18597,18651,18705,18760,18814,18868,18923,18977, + 19032,19086,19141,19195,19250,19305,19359,19414, + 19469,19523,19578,19633,19688,19742,19797,19852, + 19907,19962,20017,20072,20127,20182,20237,20292, + 20347,20402,20457,20513,20568,20623,20678,20734, + 20789,20844,20900,20955,21010,21066,21121,21177, + 21232,21288,21343,21399,21455,21510,21566,21622, + 21678,21733,21789,21845,21901,21957,22013,22069, + 22125,22181,22237,22293,22349,22405,22461,22517, + 22573,22630,22686,22742,22799,22855,22911,22968, + 23024,23081,23137,23194,23250,23307,23364,23420, + 23477,23534,23591,23647,23704,23761,23818,23875, + 23932,23989,24046,24103,24160,24217,24274,24331, + 24389,24446,24503,24560,24618,24675,24732,24790, + 24847,24905,24962,25020,25078,25135,25193,25251, + 25308,25366,25424,25482,25540,25598,25656,25714, + 25772,25830,25888,25946,26004,26062,26120,26179, + 26237,26295,26354,26412,26471,26529,26588,26646, + 26705,26763,26822,26881,26940,26998,27057,27116, + 27175,27234,27293,27352,27411,27470,27529,27588, + 27647,27707,27766,27825,27884,27944,28003,28063, + 28122,28182,28241,28301,28361,28420,28480,28540, + 28600,28660,28719,28779,28839,28899,28959,29020, + 29080,29140,29200,29260,29321,29381,29441,29502, + 29562,29623,29683,29744,29805,29865,29926,29987, + 30048,30108,30169,30230,30291,30352,30413,30474, + 30536,30597,30658,30719,30781,30842,30904,30965, + 31026,31088,31150,31211,31273,31335,31396,31458, + 31520,31582,31644,31706,31768,31830,31892,31955, + 32017,32079,32141,32204,32266,32329,32391,32454, + 32516,32579,32642,32705,32767,32830,32893,32956, + 33019,33082,33145,33208,33272,33335,33398,33461, + 33525,33588,33652,33715,33779,33843,33906,33970, + 34034,34098,34162,34225,34289,34354,34418,34482, + 34546,34610,34675,34739,34803,34868,34932,34997, + 35062,35126,35191,35256,35321,35385,35450,35515, + 35580,35646,35711,35776,35841,35907,35972,36037, + 36103,36168,36234,36300,36365,36431,36497,36563, + 36629,36695,36761,36827,36893,36959,37026,37092, + 37158,37225,37291,37358,37425,37491,37558,37625, + 37692,37759,37826,37893,37960,38027,38094,38161, + 38229,38296,38364,38431,38499,38566,38634,38702, + 38770,38837,38905,38973,39042,39110,39178,39246, + 39314,39383,39451,39520,39588,39657,39726,39794, + 39863,39932,40001,40070,40139,40208,40278,40347, + 40416,40486,40555,40625,40694,40764,40834,40904, + 40973,41043,41113,41184,41254,41324,41394,41465, + 41535,41605,41676,41747,41817,41888,41959,42030, + 42101,42172,42243,42314,42385,42457,42528,42600, + 42671,42743,42814,42886,42958,43030,43102,43174, + 43246,43318,43390,43463,43535,43608,43680,43753, + 43826,43898,43971,44044,44117,44190,44263,44337, + 44410,44483,44557,44630,44704,44778,44851,44925, + 44999,45073,45147,45221,45296,45370,45444,45519, + 45593,45668,45743,45818,45892,45967,46042,46118, + 46193,46268,46343,46419,46494,46570,46646,46721, + 46797,46873,46949,47025,47102,47178,47254,47331, + 47407,47484,47560,47637,47714,47791,47868,47945, + 48022,48100,48177,48255,48332,48410,48488,48565, + 48643,48721,48799,48878,48956,49034,49113,49191, + 49270,49349,49427,49506,49585,49664,49744,49823, + 49902,49982,50061,50141,50221,50300,50380,50460, + 50540,50621,50701,50781,50862,50942,51023,51104, + 51185,51266,51347,51428,51509,51591,51672,51754, + 51835,51917,51999,52081,52163,52245,52327,52410, + 52492,52575,52657,52740,52823,52906,52989,53072, + 53156,53239,53322,53406,53490,53574,53657,53741, + 53826,53910,53994,54079,54163,54248,54333,54417, + 54502,54587,54673,54758,54843,54929,55015,55100, + 55186,55272,55358,55444,55531,55617,55704,55790, + 55877,55964,56051,56138,56225,56312,56400,56487, + 56575,56663,56751,56839,56927,57015,57104,57192, + 57281,57369,57458,57547,57636,57725,57815,57904, + 57994,58083,58173,58263,58353,58443,58534,58624, + 58715,58805,58896,58987,59078,59169,59261,59352, + 59444,59535,59627,59719,59811,59903,59996,60088, + 60181,60273,60366,60459,60552,60646,60739,60833, + 60926,61020,61114,61208,61302,61396,61491,61585, + 61680,61775,61870,61965,62060,62156,62251,62347, + 62443,62539,62635,62731,62828,62924,63021,63118, + 63215,63312,63409,63506,63604,63702,63799,63897, + 63996,64094,64192,64291,64389,64488,64587,64687, + 64786,64885,64985,65085,65185,65285,65385,65485, + 65586,65686,65787,65888,65989,66091,66192,66294, + 66396,66498,66600,66702,66804,66907,67010,67113, + 67216,67319,67422,67526,67629,67733,67837,67942, + 68046,68151,68255,68360,68465,68570,68676,68781, + 68887,68993,69099,69205,69312,69418,69525,69632, + 69739,69846,69954,70061,70169,70277,70385,70494, + 70602,70711,70820,70929,71038,71147,71257,71367, + 71477,71587,71697,71808,71918,72029,72140,72252, + 72363,72475,72587,72699,72811,72923,73036,73149, + 73262,73375,73488,73602,73715,73829,73944,74058, + 74172,74287,74402,74517,74633,74748,74864,74980, + 75096,75213,75329,75446,75563,75680,75797,75915, + 76033,76151,76269,76388,76506,76625,76744,76864, + 76983,77103,77223,77343,77463,77584,77705,77826, + 77947,78068,78190,78312,78434,78557,78679,78802, + 78925,79048,79172,79296,79420,79544,79668,79793, + 79918,80043,80168,80294,80420,80546,80672,80799, + 80925,81053,81180,81307,81435,81563,81691,81820, + 81949,82078,82207,82336,82466,82596,82726,82857, + 82987,83118,83250,83381,83513,83645,83777,83910, + 84043,84176,84309,84443,84576,84710,84845,84980, + 85114,85250,85385,85521,85657,85793,85930,86066, + 86204,86341,86479,86616,86755,86893,87032,87171, + 87310,87450,87590,87730,87871,88011,88152,88294, + 88435,88577,88720,88862,89005,89148,89292,89435, + 89579,89724,89868,90013,90158,90304,90450,90596, + 90742,90889,91036,91184,91332,91480,91628,91777, + 91926,92075,92225,92375,92525,92675,92826,92978, + 93129,93281,93434,93586,93739,93892,94046,94200, + 94354,94509,94664,94819,94975,95131,95287,95444, + 95601,95758,95916,96074,96233,96391,96551,96710, + 96870,97030,97191,97352,97513,97675,97837,98000, + 98163,98326,98489,98653,98818,98982,99148,99313, + 99479,99645,99812,99979,100146,100314,100482,100651, + 100820,100990,101159,101330,101500,101671,101843,102015, + 102187,102360,102533,102706,102880,103054,103229,103404, + 103580,103756,103933,104109,104287,104465,104643,104821, + 105000,105180,105360,105540,105721,105902,106084,106266, + 106449,106632,106816,107000,107184,107369,107555,107741, + 107927,108114,108301,108489,108677,108866,109055,109245, + 109435,109626,109817,110008,110200,110393,110586,110780, + 110974,111169,111364,111560,111756,111952,112150,112347, + 112546,112744,112944,113143,113344,113545,113746,113948, + 114151,114354,114557,114761,114966,115171,115377,115583, + 115790,115998,116206,116414,116623,116833,117044,117254, + 117466,117678,117891,118104,118318,118532,118747,118963, + 119179,119396,119613,119831,120050,120269,120489,120709, + 120930,121152,121374,121597,121821,122045,122270,122496, + 122722,122949,123176,123404,123633,123863,124093,124324, + 124555,124787,125020,125254,125488,125723,125959,126195, + 126432,126669,126908,127147,127387,127627,127869,128111, + 128353,128597,128841,129086,129332,129578,129825,130073, + 130322,130571,130821,131072,131324,131576,131830,132084, + 132339,132594,132851,133108,133366,133625,133884,134145, + 134406,134668,134931,135195,135459,135725,135991,136258, + 136526,136795,137065,137335,137607,137879,138152,138426, + 138701,138977,139254,139532,139810,140090,140370,140651, + 140934,141217,141501,141786,142072,142359,142647,142936, + 143226,143517,143808,144101,144395,144690,144986,145282, + 145580,145879,146179,146480,146782,147084,147388,147693, + 148000,148307,148615,148924,149235,149546,149859,150172, + 150487,150803,151120,151438,151757,152077,152399,152722, + 153045,153370,153697,154024,154352,154682,155013,155345, + 155678,156013,156349,156686,157024,157363,157704,158046, + 158389,158734,159079,159427,159775,160125,160476,160828, + 161182,161537,161893,162251,162610,162970,163332,163695, + 164060,164426,164793,165162,165532,165904,166277,166651, + 167027,167405,167784,168164,168546,168930,169315,169701, + 170089,170479,170870,171263,171657,172053,172451,172850, + 173251,173653,174057,174463,174870,175279,175690,176102, + 176516,176932,177349,177769,178190,178612,179037,179463, + 179891,180321,180753,181186,181622,182059,182498,182939, + 183382,183827,184274,184722,185173,185625,186080,186536, + 186995,187455,187918,188382,188849,189318,189789,190261, + 190736,191213,191693,192174,192658,193143,193631,194122, + 194614,195109,195606,196105,196606,197110,197616,198125, + 198636,199149,199664,200182,200703,201226,201751,202279, + 202809,203342,203878,204416,204956,205500,206045,206594, + 207145,207699,208255,208815,209376,209941,210509,211079, + 211652,212228,212807,213389,213973,214561,215151,215745, + 216341,216941,217544,218149,218758,219370,219985,220603, + 221225,221849,222477,223108,223743,224381,225022,225666, + 226314,226966,227621,228279,228941,229606,230275,230948, + 231624,232304,232988,233676,234367,235062,235761,236463, + 237170,237881,238595,239314,240036,240763,241493,242228, + 242967,243711,244458,245210,245966,246727,247492,248261, + 249035,249813,250596,251384,252176,252973,253774,254581, + 255392,256208,257029,257855,258686,259522,260363,261209, + 262060,262917,263779,264646,265519,266397,267280,268169, + 269064,269965,270871,271782,272700,273624,274553,275489, + 276430,277378,278332,279292,280258,281231,282210,283195, + 284188,285186,286192,287204,288223,289249,290282,291322, + 292369,293423,294485,295554,296630,297714,298805,299904, + 301011,302126,303248,304379,305517,306664,307819,308983, + 310154,311335,312524,313721,314928,316143,317368,318601, + 319844,321097,322358,323629,324910,326201,327502,328812, + 330133,331464,332805,334157,335519,336892,338276,339671, + 341078,342495,343924,345364,346816,348280,349756,351244, + 352744,354257,355783,357321,358872,360436,362013,363604, + 365208,366826,368459,370105,371765,373440,375130,376835, + 378555,380290,382040,383807,385589,387387,389202,391034, + 392882,394747,396630,398530,400448,402384,404338,406311, + 408303,410314,412344,414395,416465,418555,420666,422798, + 424951,427125,429321,431540,433781,436045,438332,440643, + 442978,445337,447720,450129,452564,455024,457511,460024, + 462565,465133,467730,470355,473009,475692,478406,481150, + 483925,486732,489571,492443,495348,498287,501261,504269, + 507313,510394,513512,516667,519861,523094,526366,529680, + 533034,536431,539870,543354,546881,550455,554074,557741, + 561456,565221,569035,572901,576818,580789,584815,588896, + 593033,597229,601483,605798,610174,614613,619117,623686, + 628323,633028,637803,642651,647572,652568,657640,662792, + 668024,673338,678737,684223,689797,695462,701219,707072, + 713023,719074,725227,731486,737853,744331,750922,757631, + 764460,771411,778490,785699,793041,800521,808143,815910, + 823827,831898,840127,848520,857081,865817,874730,883829, + 893117,902602,912289,922186,932298,942633,953199,964003, + 975054,986361,997931,1009774,1021901,1034322,1047046,1060087, + 1073455,1087164,1101225,1115654,1130465,1145673,1161294,1177345, + 1193846,1210813,1228269,1246234,1264730,1283783,1303416,1323658, + 1344537,1366084,1388330,1411312,1435065,1459630,1485049,1511367, + 1538632,1566898,1596220,1626658,1658278,1691149,1725348,1760956, + 1798063,1836758,1877161,1919378,1963536,2009771,2058233,2109087, + 2162516,2218719,2277919,2340362,2406322,2476104,2550052,2628549, + 2712030,2800983,2895966,2997613,3106651,3223918,3350381,3487165, + 3635590,3797206,3973855,4167737,4381502,4618375,4882318,5178251, + 5512368,5892567,6329090,6835455,7429880,8137527,8994149,10052327, + 11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304 }; -int finesine[10240] = -{ - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1130,1181, - 1231,1281,1331,1382,1432,1482,1532,1583, - 1633,1683,1733,1784,1834,1884,1934,1985, - 2035,2085,2135,2186,2236,2286,2336,2387, - 2437,2487,2537,2587,2638,2688,2738,2788, - 2839,2889,2939,2989,3039,3090,3140,3190, - 3240,3291,3341,3391,3441,3491,3541,3592, - 3642,3692,3742,3792,3843,3893,3943,3993, - 4043,4093,4144,4194,4244,4294,4344,4394, - 4445,4495,4545,4595,4645,4695,4745,4796, - 4846,4896,4946,4996,5046,5096,5146,5197, - 5247,5297,5347,5397,5447,5497,5547,5597, - 5647,5697,5748,5798,5848,5898,5948,5998, - 6048,6098,6148,6198,6248,6298,6348,6398, - 6448,6498,6548,6598,6648,6698,6748,6798, - 6848,6898,6948,6998,7048,7098,7148,7198, - 7248,7298,7348,7398,7448,7498,7548,7598, - 7648,7697,7747,7797,7847,7897,7947,7997, - 8047,8097,8147,8196,8246,8296,8346,8396, - 8446,8496,8545,8595,8645,8695,8745,8794, - 8844,8894,8944,8994,9043,9093,9143,9193, - 9243,9292,9342,9392,9442,9491,9541,9591, - 9640,9690,9740,9790,9839,9889,9939,9988, - 10038,10088,10137,10187,10237,10286,10336,10386, - 10435,10485,10534,10584,10634,10683,10733,10782, - 10832,10882,10931,10981,11030,11080,11129,11179, - 11228,11278,11327,11377,11426,11476,11525,11575, - 11624,11674,11723,11773,11822,11872,11921,11970, - 12020,12069,12119,12168,12218,12267,12316,12366, - 12415,12464,12514,12563,12612,12662,12711,12760, - 12810,12859,12908,12957,13007,13056,13105,13154, - 13204,13253,13302,13351,13401,13450,13499,13548, - 13597,13647,13696,13745,13794,13843,13892,13941, - 13990,14040,14089,14138,14187,14236,14285,14334, - 14383,14432,14481,14530,14579,14628,14677,14726, - 14775,14824,14873,14922,14971,15020,15069,15118, - 15167,15215,15264,15313,15362,15411,15460,15509, - 15557,15606,15655,15704,15753,15802,15850,15899, - 15948,15997,16045,16094,16143,16191,16240,16289, - 16338,16386,16435,16484,16532,16581,16629,16678, - 16727,16775,16824,16872,16921,16970,17018,17067, - 17115,17164,17212,17261,17309,17358,17406,17455, - 17503,17551,17600,17648,17697,17745,17793,17842, - 17890,17939,17987,18035,18084,18132,18180,18228, - 18277,18325,18373,18421,18470,18518,18566,18614, - 18663,18711,18759,18807,18855,18903,18951,19000, - 19048,19096,19144,19192,19240,19288,19336,19384, - 19432,19480,19528,19576,19624,19672,19720,19768, - 19816,19864,19912,19959,20007,20055,20103,20151, - 20199,20246,20294,20342,20390,20438,20485,20533, - 20581,20629,20676,20724,20772,20819,20867,20915, - 20962,21010,21057,21105,21153,21200,21248,21295, - 21343,21390,21438,21485,21533,21580,21628,21675, - 21723,21770,21817,21865,21912,21960,22007,22054, - 22102,22149,22196,22243,22291,22338,22385,22433, - 22480,22527,22574,22621,22668,22716,22763,22810, - 22857,22904,22951,22998,23045,23092,23139,23186, - 23233,23280,23327,23374,23421,23468,23515,23562, - 23609,23656,23703,23750,23796,23843,23890,23937, - 23984,24030,24077,24124,24171,24217,24264,24311, - 24357,24404,24451,24497,24544,24591,24637,24684, - 24730,24777,24823,24870,24916,24963,25009,25056, - 25102,25149,25195,25241,25288,25334,25381,25427, - 25473,25520,25566,25612,25658,25705,25751,25797, - 25843,25889,25936,25982,26028,26074,26120,26166, - 26212,26258,26304,26350,26396,26442,26488,26534, - 26580,26626,26672,26718,26764,26810,26856,26902, - 26947,26993,27039,27085,27131,27176,27222,27268, - 27313,27359,27405,27450,27496,27542,27587,27633, - 27678,27724,27770,27815,27861,27906,27952,27997, - 28042,28088,28133,28179,28224,28269,28315,28360, - 28405,28451,28496,28541,28586,28632,28677,28722, - 28767,28812,28858,28903,28948,28993,29038,29083, - 29128,29173,29218,29263,29308,29353,29398,29443, - 29488,29533,29577,29622,29667,29712,29757,29801, - 29846,29891,29936,29980,30025,30070,30114,30159, - 30204,30248,30293,30337,30382,30426,30471,30515, - 30560,30604,30649,30693,30738,30782,30826,30871, - 30915,30959,31004,31048,31092,31136,31181,31225, - 31269,31313,31357,31402,31446,31490,31534,31578, - 31622,31666,31710,31754,31798,31842,31886,31930, - 31974,32017,32061,32105,32149,32193,32236,32280, - 32324,32368,32411,32455,32499,32542,32586,32630, - 32673,32717,32760,32804,32847,32891,32934,32978, - 33021,33065,33108,33151,33195,33238,33281,33325, - 33368,33411,33454,33498,33541,33584,33627,33670, - 33713,33756,33799,33843,33886,33929,33972,34015, - 34057,34100,34143,34186,34229,34272,34315,34358, - 34400,34443,34486,34529,34571,34614,34657,34699, - 34742,34785,34827,34870,34912,34955,34997,35040, - 35082,35125,35167,35210,35252,35294,35337,35379, - 35421,35464,35506,35548,35590,35633,35675,35717, - 35759,35801,35843,35885,35927,35969,36011,36053, - 36095,36137,36179,36221,36263,36305,36347,36388, - 36430,36472,36514,36555,36597,36639,36681,36722, - 36764,36805,36847,36889,36930,36972,37013,37055, - 37096,37137,37179,37220,37262,37303,37344,37386, - 37427,37468,37509,37551,37592,37633,37674,37715, - 37756,37797,37838,37879,37920,37961,38002,38043, - 38084,38125,38166,38207,38248,38288,38329,38370, - 38411,38451,38492,38533,38573,38614,38655,38695, - 38736,38776,38817,38857,38898,38938,38979,39019, - 39059,39100,39140,39180,39221,39261,39301,39341, - 39382,39422,39462,39502,39542,39582,39622,39662, - 39702,39742,39782,39822,39862,39902,39942,39982, - 40021,40061,40101,40141,40180,40220,40260,40300, - 40339,40379,40418,40458,40497,40537,40576,40616, - 40655,40695,40734,40773,40813,40852,40891,40931, - 40970,41009,41048,41087,41127,41166,41205,41244, - 41283,41322,41361,41400,41439,41478,41517,41556, - 41595,41633,41672,41711,41750,41788,41827,41866, - 41904,41943,41982,42020,42059,42097,42136,42174, - 42213,42251,42290,42328,42366,42405,42443,42481, - 42520,42558,42596,42634,42672,42711,42749,42787, - 42825,42863,42901,42939,42977,43015,43053,43091, - 43128,43166,43204,43242,43280,43317,43355,43393, - 43430,43468,43506,43543,43581,43618,43656,43693, - 43731,43768,43806,43843,43880,43918,43955,43992, - 44029,44067,44104,44141,44178,44215,44252,44289, - 44326,44363,44400,44437,44474,44511,44548,44585, - 44622,44659,44695,44732,44769,44806,44842,44879, - 44915,44952,44989,45025,45062,45098,45135,45171, - 45207,45244,45280,45316,45353,45389,45425,45462, - 45498,45534,45570,45606,45642,45678,45714,45750, - 45786,45822,45858,45894,45930,45966,46002,46037, - 46073,46109,46145,46180,46216,46252,46287,46323, - 46358,46394,46429,46465,46500,46536,46571,46606, - 46642,46677,46712,46747,46783,46818,46853,46888, - 46923,46958,46993,47028,47063,47098,47133,47168, - 47203,47238,47273,47308,47342,47377,47412,47446, - 47481,47516,47550,47585,47619,47654,47688,47723, - 47757,47792,47826,47860,47895,47929,47963,47998, - 48032,48066,48100,48134,48168,48202,48237,48271, - 48305,48338,48372,48406,48440,48474,48508,48542, - 48575,48609,48643,48676,48710,48744,48777,48811, - 48844,48878,48911,48945,48978,49012,49045,49078, - 49112,49145,49178,49211,49244,49278,49311,49344, - 49377,49410,49443,49476,49509,49542,49575,49608, - 49640,49673,49706,49739,49771,49804,49837,49869, - 49902,49935,49967,50000,50032,50065,50097,50129, - 50162,50194,50226,50259,50291,50323,50355,50387, - 50420,50452,50484,50516,50548,50580,50612,50644, - 50675,50707,50739,50771,50803,50834,50866,50898, - 50929,50961,50993,51024,51056,51087,51119,51150, - 51182,51213,51244,51276,51307,51338,51369,51401, - 51432,51463,51494,51525,51556,51587,51618,51649, - 51680,51711,51742,51773,51803,51834,51865,51896, - 51926,51957,51988,52018,52049,52079,52110,52140, - 52171,52201,52231,52262,52292,52322,52353,52383, - 52413,52443,52473,52503,52534,52564,52594,52624, - 52653,52683,52713,52743,52773,52803,52832,52862, - 52892,52922,52951,52981,53010,53040,53069,53099, - 53128,53158,53187,53216,53246,53275,53304,53334, - 53363,53392,53421,53450,53479,53508,53537,53566, - 53595,53624,53653,53682,53711,53739,53768,53797, - 53826,53854,53883,53911,53940,53969,53997,54026, - 54054,54082,54111,54139,54167,54196,54224,54252, - 54280,54308,54337,54365,54393,54421,54449,54477, - 54505,54533,54560,54588,54616,54644,54672,54699, - 54727,54755,54782,54810,54837,54865,54892,54920, - 54947,54974,55002,55029,55056,55084,55111,55138, - 55165,55192,55219,55246,55274,55300,55327,55354, - 55381,55408,55435,55462,55489,55515,55542,55569, - 55595,55622,55648,55675,55701,55728,55754,55781, - 55807,55833,55860,55886,55912,55938,55965,55991, - 56017,56043,56069,56095,56121,56147,56173,56199, - 56225,56250,56276,56302,56328,56353,56379,56404, - 56430,56456,56481,56507,56532,56557,56583,56608, - 56633,56659,56684,56709,56734,56760,56785,56810, - 56835,56860,56885,56910,56935,56959,56984,57009, - 57034,57059,57083,57108,57133,57157,57182,57206, - 57231,57255,57280,57304,57329,57353,57377,57402, - 57426,57450,57474,57498,57522,57546,57570,57594, - 57618,57642,57666,57690,57714,57738,57762,57785, - 57809,57833,57856,57880,57903,57927,57950,57974, - 57997,58021,58044,58067,58091,58114,58137,58160, - 58183,58207,58230,58253,58276,58299,58322,58345, - 58367,58390,58413,58436,58459,58481,58504,58527, - 58549,58572,58594,58617,58639,58662,58684,58706, - 58729,58751,58773,58795,58818,58840,58862,58884, - 58906,58928,58950,58972,58994,59016,59038,59059, - 59081,59103,59125,59146,59168,59190,59211,59233, - 59254,59276,59297,59318,59340,59361,59382,59404, - 59425,59446,59467,59488,59509,59530,59551,59572, - 59593,59614,59635,59656,59677,59697,59718,59739, - 59759,59780,59801,59821,59842,59862,59883,59903, - 59923,59944,59964,59984,60004,60025,60045,60065, - 60085,60105,60125,60145,60165,60185,60205,60225, - 60244,60264,60284,60304,60323,60343,60363,60382, - 60402,60421,60441,60460,60479,60499,60518,60537, - 60556,60576,60595,60614,60633,60652,60671,60690, - 60709,60728,60747,60766,60785,60803,60822,60841, - 60859,60878,60897,60915,60934,60952,60971,60989, - 61007,61026,61044,61062,61081,61099,61117,61135, - 61153,61171,61189,61207,61225,61243,61261,61279, - 61297,61314,61332,61350,61367,61385,61403,61420, - 61438,61455,61473,61490,61507,61525,61542,61559, - 61577,61594,61611,61628,61645,61662,61679,61696, - 61713,61730,61747,61764,61780,61797,61814,61831, - 61847,61864,61880,61897,61913,61930,61946,61963, - 61979,61995,62012,62028,62044,62060,62076,62092, - 62108,62125,62141,62156,62172,62188,62204,62220, - 62236,62251,62267,62283,62298,62314,62329,62345, - 62360,62376,62391,62407,62422,62437,62453,62468, - 62483,62498,62513,62528,62543,62558,62573,62588, - 62603,62618,62633,62648,62662,62677,62692,62706, - 62721,62735,62750,62764,62779,62793,62808,62822, - 62836,62850,62865,62879,62893,62907,62921,62935, - 62949,62963,62977,62991,63005,63019,63032,63046, - 63060,63074,63087,63101,63114,63128,63141,63155, - 63168,63182,63195,63208,63221,63235,63248,63261, - 63274,63287,63300,63313,63326,63339,63352,63365, - 63378,63390,63403,63416,63429,63441,63454,63466, - 63479,63491,63504,63516,63528,63541,63553,63565, - 63578,63590,63602,63614,63626,63638,63650,63662, - 63674,63686,63698,63709,63721,63733,63745,63756, - 63768,63779,63791,63803,63814,63825,63837,63848, - 63859,63871,63882,63893,63904,63915,63927,63938, - 63949,63960,63971,63981,63992,64003,64014,64025, - 64035,64046,64057,64067,64078,64088,64099,64109, - 64120,64130,64140,64151,64161,64171,64181,64192, - 64202,64212,64222,64232,64242,64252,64261,64271, - 64281,64291,64301,64310,64320,64330,64339,64349, - 64358,64368,64377,64387,64396,64405,64414,64424, - 64433,64442,64451,64460,64469,64478,64487,64496, - 64505,64514,64523,64532,64540,64549,64558,64566, - 64575,64584,64592,64601,64609,64617,64626,64634, - 64642,64651,64659,64667,64675,64683,64691,64699, - 64707,64715,64723,64731,64739,64747,64754,64762, - 64770,64777,64785,64793,64800,64808,64815,64822, - 64830,64837,64844,64852,64859,64866,64873,64880, - 64887,64895,64902,64908,64915,64922,64929,64936, - 64943,64949,64956,64963,64969,64976,64982,64989, - 64995,65002,65008,65015,65021,65027,65033,65040, - 65046,65052,65058,65064,65070,65076,65082,65088, - 65094,65099,65105,65111,65117,65122,65128,65133, - 65139,65144,65150,65155,65161,65166,65171,65177, - 65182,65187,65192,65197,65202,65207,65212,65217, - 65222,65227,65232,65237,65242,65246,65251,65256, - 65260,65265,65270,65274,65279,65283,65287,65292, - 65296,65300,65305,65309,65313,65317,65321,65325, - 65329,65333,65337,65341,65345,65349,65352,65356, - 65360,65363,65367,65371,65374,65378,65381,65385, - 65388,65391,65395,65398,65401,65404,65408,65411, - 65414,65417,65420,65423,65426,65429,65431,65434, - 65437,65440,65442,65445,65448,65450,65453,65455, - 65458,65460,65463,65465,65467,65470,65472,65474, - 65476,65478,65480,65482,65484,65486,65488,65490, - 65492,65494,65496,65497,65499,65501,65502,65504, - 65505,65507,65508,65510,65511,65513,65514,65515, - 65516,65518,65519,65520,65521,65522,65523,65524, - 65525,65526,65527,65527,65528,65529,65530,65530, - 65531,65531,65532,65532,65533,65533,65534,65534, - 65534,65535,65535,65535,65535,65535,65535,65535, - 65535,65535,65535,65535,65535,65535,65535,65534, - 65534,65534,65533,65533,65532,65532,65531,65531, - 65530,65530,65529,65528,65527,65527,65526,65525, - 65524,65523,65522,65521,65520,65519,65518,65516, - 65515,65514,65513,65511,65510,65508,65507,65505, - 65504,65502,65501,65499,65497,65496,65494,65492, - 65490,65488,65486,65484,65482,65480,65478,65476, - 65474,65472,65470,65467,65465,65463,65460,65458, - 65455,65453,65450,65448,65445,65442,65440,65437, - 65434,65431,65429,65426,65423,65420,65417,65414, - 65411,65408,65404,65401,65398,65395,65391,65388, - 65385,65381,65378,65374,65371,65367,65363,65360, - 65356,65352,65349,65345,65341,65337,65333,65329, - 65325,65321,65317,65313,65309,65305,65300,65296, - 65292,65287,65283,65279,65274,65270,65265,65260, - 65256,65251,65246,65242,65237,65232,65227,65222, - 65217,65212,65207,65202,65197,65192,65187,65182, - 65177,65171,65166,65161,65155,65150,65144,65139, - 65133,65128,65122,65117,65111,65105,65099,65094, - 65088,65082,65076,65070,65064,65058,65052,65046, - 65040,65033,65027,65021,65015,65008,65002,64995, - 64989,64982,64976,64969,64963,64956,64949,64943, - 64936,64929,64922,64915,64908,64902,64895,64887, - 64880,64873,64866,64859,64852,64844,64837,64830, - 64822,64815,64808,64800,64793,64785,64777,64770, - 64762,64754,64747,64739,64731,64723,64715,64707, - 64699,64691,64683,64675,64667,64659,64651,64642, - 64634,64626,64617,64609,64600,64592,64584,64575, - 64566,64558,64549,64540,64532,64523,64514,64505, - 64496,64487,64478,64469,64460,64451,64442,64433, - 64424,64414,64405,64396,64387,64377,64368,64358, - 64349,64339,64330,64320,64310,64301,64291,64281, - 64271,64261,64252,64242,64232,64222,64212,64202, - 64192,64181,64171,64161,64151,64140,64130,64120, - 64109,64099,64088,64078,64067,64057,64046,64035, - 64025,64014,64003,63992,63981,63971,63960,63949, - 63938,63927,63915,63904,63893,63882,63871,63859, - 63848,63837,63825,63814,63803,63791,63779,63768, - 63756,63745,63733,63721,63709,63698,63686,63674, - 63662,63650,63638,63626,63614,63602,63590,63578, - 63565,63553,63541,63528,63516,63504,63491,63479, - 63466,63454,63441,63429,63416,63403,63390,63378, - 63365,63352,63339,63326,63313,63300,63287,63274, - 63261,63248,63235,63221,63208,63195,63182,63168, - 63155,63141,63128,63114,63101,63087,63074,63060, - 63046,63032,63019,63005,62991,62977,62963,62949, - 62935,62921,62907,62893,62879,62865,62850,62836, - 62822,62808,62793,62779,62764,62750,62735,62721, - 62706,62692,62677,62662,62648,62633,62618,62603, - 62588,62573,62558,62543,62528,62513,62498,62483, - 62468,62453,62437,62422,62407,62391,62376,62360, - 62345,62329,62314,62298,62283,62267,62251,62236, - 62220,62204,62188,62172,62156,62141,62125,62108, - 62092,62076,62060,62044,62028,62012,61995,61979, - 61963,61946,61930,61913,61897,61880,61864,61847, - 61831,61814,61797,61780,61764,61747,61730,61713, - 61696,61679,61662,61645,61628,61611,61594,61577, - 61559,61542,61525,61507,61490,61473,61455,61438, - 61420,61403,61385,61367,61350,61332,61314,61297, - 61279,61261,61243,61225,61207,61189,61171,61153, - 61135,61117,61099,61081,61062,61044,61026,61007, - 60989,60971,60952,60934,60915,60897,60878,60859, - 60841,60822,60803,60785,60766,60747,60728,60709, - 60690,60671,60652,60633,60614,60595,60576,60556, - 60537,60518,60499,60479,60460,60441,60421,60402, - 60382,60363,60343,60323,60304,60284,60264,60244, - 60225,60205,60185,60165,60145,60125,60105,60085, - 60065,60045,60025,60004,59984,59964,59944,59923, - 59903,59883,59862,59842,59821,59801,59780,59759, - 59739,59718,59697,59677,59656,59635,59614,59593, - 59572,59551,59530,59509,59488,59467,59446,59425, - 59404,59382,59361,59340,59318,59297,59276,59254, - 59233,59211,59190,59168,59146,59125,59103,59081, - 59059,59038,59016,58994,58972,58950,58928,58906, - 58884,58862,58840,58818,58795,58773,58751,58729, - 58706,58684,58662,58639,58617,58594,58572,58549, - 58527,58504,58481,58459,58436,58413,58390,58367, - 58345,58322,58299,58276,58253,58230,58207,58183, - 58160,58137,58114,58091,58067,58044,58021,57997, - 57974,57950,57927,57903,57880,57856,57833,57809, - 57785,57762,57738,57714,57690,57666,57642,57618, - 57594,57570,57546,57522,57498,57474,57450,57426, - 57402,57377,57353,57329,57304,57280,57255,57231, - 57206,57182,57157,57133,57108,57083,57059,57034, - 57009,56984,56959,56935,56910,56885,56860,56835, - 56810,56785,56760,56734,56709,56684,56659,56633, - 56608,56583,56557,56532,56507,56481,56456,56430, - 56404,56379,56353,56328,56302,56276,56250,56225, - 56199,56173,56147,56121,56095,56069,56043,56017, - 55991,55965,55938,55912,55886,55860,55833,55807, - 55781,55754,55728,55701,55675,55648,55622,55595, - 55569,55542,55515,55489,55462,55435,55408,55381, - 55354,55327,55300,55274,55246,55219,55192,55165, - 55138,55111,55084,55056,55029,55002,54974,54947, - 54920,54892,54865,54837,54810,54782,54755,54727, - 54699,54672,54644,54616,54588,54560,54533,54505, - 54477,54449,54421,54393,54365,54337,54308,54280, - 54252,54224,54196,54167,54139,54111,54082,54054, - 54026,53997,53969,53940,53911,53883,53854,53826, - 53797,53768,53739,53711,53682,53653,53624,53595, - 53566,53537,53508,53479,53450,53421,53392,53363, - 53334,53304,53275,53246,53216,53187,53158,53128, - 53099,53069,53040,53010,52981,52951,52922,52892, - 52862,52832,52803,52773,52743,52713,52683,52653, - 52624,52594,52564,52534,52503,52473,52443,52413, - 52383,52353,52322,52292,52262,52231,52201,52171, - 52140,52110,52079,52049,52018,51988,51957,51926, - 51896,51865,51834,51803,51773,51742,51711,51680, - 51649,51618,51587,51556,51525,51494,51463,51432, - 51401,51369,51338,51307,51276,51244,51213,51182, - 51150,51119,51087,51056,51024,50993,50961,50929, - 50898,50866,50834,50803,50771,50739,50707,50675, - 50644,50612,50580,50548,50516,50484,50452,50420, - 50387,50355,50323,50291,50259,50226,50194,50162, - 50129,50097,50065,50032,50000,49967,49935,49902, - 49869,49837,49804,49771,49739,49706,49673,49640, - 49608,49575,49542,49509,49476,49443,49410,49377, - 49344,49311,49278,49244,49211,49178,49145,49112, - 49078,49045,49012,48978,48945,48911,48878,48844, - 48811,48777,48744,48710,48676,48643,48609,48575, - 48542,48508,48474,48440,48406,48372,48338,48304, - 48271,48237,48202,48168,48134,48100,48066,48032, - 47998,47963,47929,47895,47860,47826,47792,47757, - 47723,47688,47654,47619,47585,47550,47516,47481, - 47446,47412,47377,47342,47308,47273,47238,47203, - 47168,47133,47098,47063,47028,46993,46958,46923, - 46888,46853,46818,46783,46747,46712,46677,46642, - 46606,46571,46536,46500,46465,46429,46394,46358, - 46323,46287,46252,46216,46180,46145,46109,46073, - 46037,46002,45966,45930,45894,45858,45822,45786, - 45750,45714,45678,45642,45606,45570,45534,45498, - 45462,45425,45389,45353,45316,45280,45244,45207, - 45171,45135,45098,45062,45025,44989,44952,44915, - 44879,44842,44806,44769,44732,44695,44659,44622, - 44585,44548,44511,44474,44437,44400,44363,44326, - 44289,44252,44215,44178,44141,44104,44067,44029, - 43992,43955,43918,43880,43843,43806,43768,43731, - 43693,43656,43618,43581,43543,43506,43468,43430, - 43393,43355,43317,43280,43242,43204,43166,43128, - 43091,43053,43015,42977,42939,42901,42863,42825, - 42787,42749,42711,42672,42634,42596,42558,42520, - 42481,42443,42405,42366,42328,42290,42251,42213, - 42174,42136,42097,42059,42020,41982,41943,41904, - 41866,41827,41788,41750,41711,41672,41633,41595, - 41556,41517,41478,41439,41400,41361,41322,41283, - 41244,41205,41166,41127,41088,41048,41009,40970, - 40931,40891,40852,40813,40773,40734,40695,40655, - 40616,40576,40537,40497,40458,40418,40379,40339, - 40300,40260,40220,40180,40141,40101,40061,40021, - 39982,39942,39902,39862,39822,39782,39742,39702, - 39662,39622,39582,39542,39502,39462,39422,39382, - 39341,39301,39261,39221,39180,39140,39100,39059, - 39019,38979,38938,38898,38857,38817,38776,38736, - 38695,38655,38614,38573,38533,38492,38451,38411, - 38370,38329,38288,38248,38207,38166,38125,38084, - 38043,38002,37961,37920,37879,37838,37797,37756, - 37715,37674,37633,37592,37551,37509,37468,37427, - 37386,37344,37303,37262,37220,37179,37137,37096, - 37055,37013,36972,36930,36889,36847,36805,36764, - 36722,36681,36639,36597,36556,36514,36472,36430, - 36388,36347,36305,36263,36221,36179,36137,36095, - 36053,36011,35969,35927,35885,35843,35801,35759, - 35717,35675,35633,35590,35548,35506,35464,35421, - 35379,35337,35294,35252,35210,35167,35125,35082, - 35040,34997,34955,34912,34870,34827,34785,34742, - 34699,34657,34614,34571,34529,34486,34443,34400, - 34358,34315,34272,34229,34186,34143,34100,34057, - 34015,33972,33929,33886,33843,33799,33756,33713, - 33670,33627,33584,33541,33498,33454,33411,33368, - 33325,33281,33238,33195,33151,33108,33065,33021, - 32978,32934,32891,32847,32804,32760,32717,32673, - 32630,32586,32542,32499,32455,32411,32368,32324, - 32280,32236,32193,32149,32105,32061,32017,31974, - 31930,31886,31842,31798,31754,31710,31666,31622, - 31578,31534,31490,31446,31402,31357,31313,31269, - 31225,31181,31136,31092,31048,31004,30959,30915, - 30871,30826,30782,30738,30693,30649,30604,30560, - 30515,30471,30426,30382,30337,30293,30248,30204, - 30159,30114,30070,30025,29980,29936,29891,29846, - 29801,29757,29712,29667,29622,29577,29533,29488, - 29443,29398,29353,29308,29263,29218,29173,29128, - 29083,29038,28993,28948,28903,28858,28812,28767, - 28722,28677,28632,28586,28541,28496,28451,28405, - 28360,28315,28269,28224,28179,28133,28088,28042, - 27997,27952,27906,27861,27815,27770,27724,27678, - 27633,27587,27542,27496,27450,27405,27359,27313, - 27268,27222,27176,27131,27085,27039,26993,26947, - 26902,26856,26810,26764,26718,26672,26626,26580, - 26534,26488,26442,26396,26350,26304,26258,26212, - 26166,26120,26074,26028,25982,25936,25889,25843, - 25797,25751,25705,25658,25612,25566,25520,25473, - 25427,25381,25334,25288,25241,25195,25149,25102, - 25056,25009,24963,24916,24870,24823,24777,24730, - 24684,24637,24591,24544,24497,24451,24404,24357, - 24311,24264,24217,24171,24124,24077,24030,23984, - 23937,23890,23843,23796,23750,23703,23656,23609, - 23562,23515,23468,23421,23374,23327,23280,23233, - 23186,23139,23092,23045,22998,22951,22904,22857, - 22810,22763,22716,22668,22621,22574,22527,22480, - 22433,22385,22338,22291,22243,22196,22149,22102, - 22054,22007,21960,21912,21865,21817,21770,21723, - 21675,21628,21580,21533,21485,21438,21390,21343, - 21295,21248,21200,21153,21105,21057,21010,20962, - 20915,20867,20819,20772,20724,20676,20629,20581, - 20533,20485,20438,20390,20342,20294,20246,20199, - 20151,20103,20055,20007,19959,19912,19864,19816, - 19768,19720,19672,19624,19576,19528,19480,19432, - 19384,19336,19288,19240,19192,19144,19096,19048, - 19000,18951,18903,18855,18807,18759,18711,18663, - 18614,18566,18518,18470,18421,18373,18325,18277, - 18228,18180,18132,18084,18035,17987,17939,17890, - 17842,17793,17745,17697,17648,17600,17551,17503, - 17455,17406,17358,17309,17261,17212,17164,17115, - 17067,17018,16970,16921,16872,16824,16775,16727, - 16678,16629,16581,16532,16484,16435,16386,16338, - 16289,16240,16191,16143,16094,16045,15997,15948, - 15899,15850,15802,15753,15704,15655,15606,15557, - 15509,15460,15411,15362,15313,15264,15215,15167, - 15118,15069,15020,14971,14922,14873,14824,14775, - 14726,14677,14628,14579,14530,14481,14432,14383, - 14334,14285,14236,14187,14138,14089,14040,13990, - 13941,13892,13843,13794,13745,13696,13646,13597, - 13548,13499,13450,13401,13351,13302,13253,13204, - 13154,13105,13056,13007,12957,12908,12859,12810, - 12760,12711,12662,12612,12563,12514,12464,12415, - 12366,12316,12267,12218,12168,12119,12069,12020, - 11970,11921,11872,11822,11773,11723,11674,11624, - 11575,11525,11476,11426,11377,11327,11278,11228, - 11179,11129,11080,11030,10981,10931,10882,10832, - 10782,10733,10683,10634,10584,10534,10485,10435, - 10386,10336,10286,10237,10187,10137,10088,10038, - 9988,9939,9889,9839,9790,9740,9690,9640, - 9591,9541,9491,9442,9392,9342,9292,9243, - 9193,9143,9093,9043,8994,8944,8894,8844, - 8794,8745,8695,8645,8595,8545,8496,8446, - 8396,8346,8296,8246,8196,8147,8097,8047, - 7997,7947,7897,7847,7797,7747,7697,7648, - 7598,7548,7498,7448,7398,7348,7298,7248, - 7198,7148,7098,7048,6998,6948,6898,6848, - 6798,6748,6698,6648,6598,6548,6498,6448, - 6398,6348,6298,6248,6198,6148,6098,6048, - 5998,5948,5898,5848,5798,5748,5697,5647, - 5597,5547,5497,5447,5397,5347,5297,5247, - 5197,5146,5096,5046,4996,4946,4896,4846, - 4796,4745,4695,4645,4595,4545,4495,4445, - 4394,4344,4294,4244,4194,4144,4093,4043, - 3993,3943,3893,3843,3792,3742,3692,3642, - 3592,3541,3491,3441,3391,3341,3291,3240, - 3190,3140,3090,3039,2989,2939,2889,2839, - 2788,2738,2688,2638,2587,2537,2487,2437, - 2387,2336,2286,2236,2186,2135,2085,2035, - 1985,1934,1884,1834,1784,1733,1683,1633, - 1583,1532,1482,1432,1382,1331,1281,1231, - 1181,1130,1080,1030,980,929,879,829, - 779,728,678,628,578,527,477,427, - 376,326,276,226,175,125,75,25, - -25,-75,-125,-175,-226,-276,-326,-376, - -427,-477,-527,-578,-628,-678,-728,-779, - -829,-879,-929,-980,-1030,-1080,-1130,-1181, - -1231,-1281,-1331,-1382,-1432,-1482,-1532,-1583, - -1633,-1683,-1733,-1784,-1834,-1884,-1934,-1985, - -2035,-2085,-2135,-2186,-2236,-2286,-2336,-2387, - -2437,-2487,-2537,-2588,-2638,-2688,-2738,-2788, - -2839,-2889,-2939,-2989,-3039,-3090,-3140,-3190, - -3240,-3291,-3341,-3391,-3441,-3491,-3541,-3592, - -3642,-3692,-3742,-3792,-3843,-3893,-3943,-3993, - -4043,-4093,-4144,-4194,-4244,-4294,-4344,-4394, - -4445,-4495,-4545,-4595,-4645,-4695,-4745,-4796, - -4846,-4896,-4946,-4996,-5046,-5096,-5146,-5197, - -5247,-5297,-5347,-5397,-5447,-5497,-5547,-5597, - -5647,-5697,-5748,-5798,-5848,-5898,-5948,-5998, - -6048,-6098,-6148,-6198,-6248,-6298,-6348,-6398, - -6448,-6498,-6548,-6598,-6648,-6698,-6748,-6798, - -6848,-6898,-6948,-6998,-7048,-7098,-7148,-7198, - -7248,-7298,-7348,-7398,-7448,-7498,-7548,-7598, - -7648,-7697,-7747,-7797,-7847,-7897,-7947,-7997, - -8047,-8097,-8147,-8196,-8246,-8296,-8346,-8396, - -8446,-8496,-8545,-8595,-8645,-8695,-8745,-8794, - -8844,-8894,-8944,-8994,-9043,-9093,-9143,-9193, - -9243,-9292,-9342,-9392,-9442,-9491,-9541,-9591, - -9640,-9690,-9740,-9790,-9839,-9889,-9939,-9988, - -10038,-10088,-10137,-10187,-10237,-10286,-10336,-10386, - -10435,-10485,-10534,-10584,-10634,-10683,-10733,-10782, - -10832,-10882,-10931,-10981,-11030,-11080,-11129,-11179, - -11228,-11278,-11327,-11377,-11426,-11476,-11525,-11575, - -11624,-11674,-11723,-11773,-11822,-11872,-11921,-11970, - -12020,-12069,-12119,-12168,-12218,-12267,-12316,-12366, - -12415,-12464,-12514,-12563,-12612,-12662,-12711,-12760, - -12810,-12859,-12908,-12957,-13007,-13056,-13105,-13154, - -13204,-13253,-13302,-13351,-13401,-13450,-13499,-13548, - -13597,-13647,-13696,-13745,-13794,-13843,-13892,-13941, - -13990,-14040,-14089,-14138,-14187,-14236,-14285,-14334, - -14383,-14432,-14481,-14530,-14579,-14628,-14677,-14726, - -14775,-14824,-14873,-14922,-14971,-15020,-15069,-15118, - -15167,-15215,-15264,-15313,-15362,-15411,-15460,-15509, - -15557,-15606,-15655,-15704,-15753,-15802,-15850,-15899, - -15948,-15997,-16045,-16094,-16143,-16191,-16240,-16289, - -16338,-16386,-16435,-16484,-16532,-16581,-16629,-16678, - -16727,-16775,-16824,-16872,-16921,-16970,-17018,-17067, - -17115,-17164,-17212,-17261,-17309,-17358,-17406,-17455, - -17503,-17551,-17600,-17648,-17697,-17745,-17793,-17842, - -17890,-17939,-17987,-18035,-18084,-18132,-18180,-18228, - -18277,-18325,-18373,-18421,-18470,-18518,-18566,-18614, - -18663,-18711,-18759,-18807,-18855,-18903,-18951,-19000, - -19048,-19096,-19144,-19192,-19240,-19288,-19336,-19384, - -19432,-19480,-19528,-19576,-19624,-19672,-19720,-19768, - -19816,-19864,-19912,-19959,-20007,-20055,-20103,-20151, - -20199,-20246,-20294,-20342,-20390,-20438,-20485,-20533, - -20581,-20629,-20676,-20724,-20772,-20819,-20867,-20915, - -20962,-21010,-21057,-21105,-21153,-21200,-21248,-21295, - -21343,-21390,-21438,-21485,-21533,-21580,-21628,-21675, - -21723,-21770,-21817,-21865,-21912,-21960,-22007,-22054, - -22102,-22149,-22196,-22243,-22291,-22338,-22385,-22433, - -22480,-22527,-22574,-22621,-22668,-22716,-22763,-22810, - -22857,-22904,-22951,-22998,-23045,-23092,-23139,-23186, - -23233,-23280,-23327,-23374,-23421,-23468,-23515,-23562, - -23609,-23656,-23703,-23750,-23796,-23843,-23890,-23937, - -23984,-24030,-24077,-24124,-24171,-24217,-24264,-24311, - -24357,-24404,-24451,-24497,-24544,-24591,-24637,-24684, - -24730,-24777,-24823,-24870,-24916,-24963,-25009,-25056, - -25102,-25149,-25195,-25241,-25288,-25334,-25381,-25427, - -25473,-25520,-25566,-25612,-25658,-25705,-25751,-25797, - -25843,-25889,-25936,-25982,-26028,-26074,-26120,-26166, - -26212,-26258,-26304,-26350,-26396,-26442,-26488,-26534, - -26580,-26626,-26672,-26718,-26764,-26810,-26856,-26902, - -26947,-26993,-27039,-27085,-27131,-27176,-27222,-27268, - -27313,-27359,-27405,-27450,-27496,-27542,-27587,-27633, - -27678,-27724,-27770,-27815,-27861,-27906,-27952,-27997, - -28042,-28088,-28133,-28179,-28224,-28269,-28315,-28360, - -28405,-28451,-28496,-28541,-28586,-28632,-28677,-28722, - -28767,-28812,-28858,-28903,-28948,-28993,-29038,-29083, - -29128,-29173,-29218,-29263,-29308,-29353,-29398,-29443, - -29488,-29533,-29577,-29622,-29667,-29712,-29757,-29801, - -29846,-29891,-29936,-29980,-30025,-30070,-30114,-30159, - -30204,-30248,-30293,-30337,-30382,-30426,-30471,-30515, - -30560,-30604,-30649,-30693,-30738,-30782,-30826,-30871, - -30915,-30959,-31004,-31048,-31092,-31136,-31181,-31225, - -31269,-31313,-31357,-31402,-31446,-31490,-31534,-31578, - -31622,-31666,-31710,-31754,-31798,-31842,-31886,-31930, - -31974,-32017,-32061,-32105,-32149,-32193,-32236,-32280, - -32324,-32368,-32411,-32455,-32499,-32542,-32586,-32630, - -32673,-32717,-32760,-32804,-32847,-32891,-32934,-32978, - -33021,-33065,-33108,-33151,-33195,-33238,-33281,-33325, - -33368,-33411,-33454,-33498,-33541,-33584,-33627,-33670, - -33713,-33756,-33799,-33843,-33886,-33929,-33972,-34015, - -34057,-34100,-34143,-34186,-34229,-34272,-34315,-34358, - -34400,-34443,-34486,-34529,-34571,-34614,-34657,-34699, - -34742,-34785,-34827,-34870,-34912,-34955,-34997,-35040, - -35082,-35125,-35167,-35210,-35252,-35294,-35337,-35379, - -35421,-35464,-35506,-35548,-35590,-35633,-35675,-35717, - -35759,-35801,-35843,-35885,-35927,-35969,-36011,-36053, - -36095,-36137,-36179,-36221,-36263,-36305,-36347,-36388, - -36430,-36472,-36514,-36555,-36597,-36639,-36681,-36722, - -36764,-36805,-36847,-36889,-36930,-36972,-37013,-37055, - -37096,-37137,-37179,-37220,-37262,-37303,-37344,-37386, - -37427,-37468,-37509,-37551,-37592,-37633,-37674,-37715, - -37756,-37797,-37838,-37879,-37920,-37961,-38002,-38043, - -38084,-38125,-38166,-38207,-38248,-38288,-38329,-38370, - -38411,-38451,-38492,-38533,-38573,-38614,-38655,-38695, - -38736,-38776,-38817,-38857,-38898,-38938,-38979,-39019, - -39059,-39100,-39140,-39180,-39221,-39261,-39301,-39341, - -39382,-39422,-39462,-39502,-39542,-39582,-39622,-39662, - -39702,-39742,-39782,-39822,-39862,-39902,-39942,-39982, - -40021,-40061,-40101,-40141,-40180,-40220,-40260,-40299, - -40339,-40379,-40418,-40458,-40497,-40537,-40576,-40616, - -40655,-40695,-40734,-40773,-40813,-40852,-40891,-40931, - -40970,-41009,-41048,-41087,-41127,-41166,-41205,-41244, - -41283,-41322,-41361,-41400,-41439,-41478,-41517,-41556, - -41595,-41633,-41672,-41711,-41750,-41788,-41827,-41866, - -41904,-41943,-41982,-42020,-42059,-42097,-42136,-42174, - -42213,-42251,-42290,-42328,-42366,-42405,-42443,-42481, - -42520,-42558,-42596,-42634,-42672,-42711,-42749,-42787, - -42825,-42863,-42901,-42939,-42977,-43015,-43053,-43091, - -43128,-43166,-43204,-43242,-43280,-43317,-43355,-43393, - -43430,-43468,-43506,-43543,-43581,-43618,-43656,-43693, - -43731,-43768,-43806,-43843,-43880,-43918,-43955,-43992, - -44029,-44067,-44104,-44141,-44178,-44215,-44252,-44289, - -44326,-44363,-44400,-44437,-44474,-44511,-44548,-44585, - -44622,-44659,-44695,-44732,-44769,-44806,-44842,-44879, - -44915,-44952,-44989,-45025,-45062,-45098,-45135,-45171, - -45207,-45244,-45280,-45316,-45353,-45389,-45425,-45462, - -45498,-45534,-45570,-45606,-45642,-45678,-45714,-45750, - -45786,-45822,-45858,-45894,-45930,-45966,-46002,-46037, - -46073,-46109,-46145,-46180,-46216,-46252,-46287,-46323, - -46358,-46394,-46429,-46465,-46500,-46536,-46571,-46606, - -46642,-46677,-46712,-46747,-46783,-46818,-46853,-46888, - -46923,-46958,-46993,-47028,-47063,-47098,-47133,-47168, - -47203,-47238,-47273,-47308,-47342,-47377,-47412,-47446, - -47481,-47516,-47550,-47585,-47619,-47654,-47688,-47723, - -47757,-47792,-47826,-47860,-47895,-47929,-47963,-47998, - -48032,-48066,-48100,-48134,-48168,-48202,-48236,-48271, - -48304,-48338,-48372,-48406,-48440,-48474,-48508,-48542, - -48575,-48609,-48643,-48676,-48710,-48744,-48777,-48811, - -48844,-48878,-48911,-48945,-48978,-49012,-49045,-49078, - -49112,-49145,-49178,-49211,-49244,-49278,-49311,-49344, - -49377,-49410,-49443,-49476,-49509,-49542,-49575,-49608, - -49640,-49673,-49706,-49739,-49771,-49804,-49837,-49869, - -49902,-49935,-49967,-50000,-50032,-50065,-50097,-50129, - -50162,-50194,-50226,-50259,-50291,-50323,-50355,-50387, - -50420,-50452,-50484,-50516,-50548,-50580,-50612,-50644, - -50675,-50707,-50739,-50771,-50803,-50834,-50866,-50898, - -50929,-50961,-50993,-51024,-51056,-51087,-51119,-51150, - -51182,-51213,-51244,-51276,-51307,-51338,-51369,-51401, - -51432,-51463,-51494,-51525,-51556,-51587,-51618,-51649, - -51680,-51711,-51742,-51773,-51803,-51834,-51865,-51896, - -51926,-51957,-51988,-52018,-52049,-52079,-52110,-52140, - -52171,-52201,-52231,-52262,-52292,-52322,-52353,-52383, - -52413,-52443,-52473,-52503,-52534,-52564,-52594,-52624, - -52653,-52683,-52713,-52743,-52773,-52803,-52832,-52862, - -52892,-52922,-52951,-52981,-53010,-53040,-53069,-53099, - -53128,-53158,-53187,-53216,-53246,-53275,-53304,-53334, - -53363,-53392,-53421,-53450,-53479,-53508,-53537,-53566, - -53595,-53624,-53653,-53682,-53711,-53739,-53768,-53797, - -53826,-53854,-53883,-53911,-53940,-53969,-53997,-54026, - -54054,-54082,-54111,-54139,-54167,-54196,-54224,-54252, - -54280,-54308,-54337,-54365,-54393,-54421,-54449,-54477, - -54505,-54533,-54560,-54588,-54616,-54644,-54672,-54699, - -54727,-54755,-54782,-54810,-54837,-54865,-54892,-54920, - -54947,-54974,-55002,-55029,-55056,-55084,-55111,-55138, - -55165,-55192,-55219,-55246,-55274,-55300,-55327,-55354, - -55381,-55408,-55435,-55462,-55489,-55515,-55542,-55569, - -55595,-55622,-55648,-55675,-55701,-55728,-55754,-55781, - -55807,-55833,-55860,-55886,-55912,-55938,-55965,-55991, - -56017,-56043,-56069,-56095,-56121,-56147,-56173,-56199, - -56225,-56250,-56276,-56302,-56328,-56353,-56379,-56404, - -56430,-56456,-56481,-56507,-56532,-56557,-56583,-56608, - -56633,-56659,-56684,-56709,-56734,-56760,-56785,-56810, - -56835,-56860,-56885,-56910,-56935,-56959,-56984,-57009, - -57034,-57059,-57083,-57108,-57133,-57157,-57182,-57206, - -57231,-57255,-57280,-57304,-57329,-57353,-57377,-57402, - -57426,-57450,-57474,-57498,-57522,-57546,-57570,-57594, - -57618,-57642,-57666,-57690,-57714,-57738,-57762,-57785, - -57809,-57833,-57856,-57880,-57903,-57927,-57950,-57974, - -57997,-58021,-58044,-58067,-58091,-58114,-58137,-58160, - -58183,-58207,-58230,-58253,-58276,-58299,-58322,-58345, - -58367,-58390,-58413,-58436,-58459,-58481,-58504,-58527, - -58549,-58572,-58594,-58617,-58639,-58662,-58684,-58706, - -58729,-58751,-58773,-58795,-58818,-58840,-58862,-58884, - -58906,-58928,-58950,-58972,-58994,-59016,-59038,-59059, - -59081,-59103,-59125,-59146,-59168,-59190,-59211,-59233, - -59254,-59276,-59297,-59318,-59340,-59361,-59382,-59404, - -59425,-59446,-59467,-59488,-59509,-59530,-59551,-59572, - -59593,-59614,-59635,-59656,-59677,-59697,-59718,-59739, - -59759,-59780,-59801,-59821,-59842,-59862,-59883,-59903, - -59923,-59944,-59964,-59984,-60004,-60025,-60045,-60065, - -60085,-60105,-60125,-60145,-60165,-60185,-60205,-60225, - -60244,-60264,-60284,-60304,-60323,-60343,-60363,-60382, - -60402,-60421,-60441,-60460,-60479,-60499,-60518,-60537, - -60556,-60576,-60595,-60614,-60633,-60652,-60671,-60690, - -60709,-60728,-60747,-60766,-60785,-60803,-60822,-60841, - -60859,-60878,-60897,-60915,-60934,-60952,-60971,-60989, - -61007,-61026,-61044,-61062,-61081,-61099,-61117,-61135, - -61153,-61171,-61189,-61207,-61225,-61243,-61261,-61279, - -61297,-61314,-61332,-61350,-61367,-61385,-61403,-61420, - -61438,-61455,-61473,-61490,-61507,-61525,-61542,-61559, - -61577,-61594,-61611,-61628,-61645,-61662,-61679,-61696, - -61713,-61730,-61747,-61764,-61780,-61797,-61814,-61831, - -61847,-61864,-61880,-61897,-61913,-61930,-61946,-61963, - -61979,-61995,-62012,-62028,-62044,-62060,-62076,-62092, - -62108,-62125,-62141,-62156,-62172,-62188,-62204,-62220, - -62236,-62251,-62267,-62283,-62298,-62314,-62329,-62345, - -62360,-62376,-62391,-62407,-62422,-62437,-62453,-62468, - -62483,-62498,-62513,-62528,-62543,-62558,-62573,-62588, - -62603,-62618,-62633,-62648,-62662,-62677,-62692,-62706, - -62721,-62735,-62750,-62764,-62779,-62793,-62808,-62822, - -62836,-62850,-62865,-62879,-62893,-62907,-62921,-62935, - -62949,-62963,-62977,-62991,-63005,-63019,-63032,-63046, - -63060,-63074,-63087,-63101,-63114,-63128,-63141,-63155, - -63168,-63182,-63195,-63208,-63221,-63235,-63248,-63261, - -63274,-63287,-63300,-63313,-63326,-63339,-63352,-63365, - -63378,-63390,-63403,-63416,-63429,-63441,-63454,-63466, - -63479,-63491,-63504,-63516,-63528,-63541,-63553,-63565, - -63578,-63590,-63602,-63614,-63626,-63638,-63650,-63662, - -63674,-63686,-63698,-63709,-63721,-63733,-63745,-63756, - -63768,-63779,-63791,-63803,-63814,-63825,-63837,-63848, - -63859,-63871,-63882,-63893,-63904,-63915,-63927,-63938, - -63949,-63960,-63971,-63981,-63992,-64003,-64014,-64025, - -64035,-64046,-64057,-64067,-64078,-64088,-64099,-64109, - -64120,-64130,-64140,-64151,-64161,-64171,-64181,-64192, - -64202,-64212,-64222,-64232,-64242,-64252,-64261,-64271, - -64281,-64291,-64301,-64310,-64320,-64330,-64339,-64349, - -64358,-64368,-64377,-64387,-64396,-64405,-64414,-64424, - -64433,-64442,-64451,-64460,-64469,-64478,-64487,-64496, - -64505,-64514,-64523,-64532,-64540,-64549,-64558,-64566, - -64575,-64584,-64592,-64601,-64609,-64617,-64626,-64634, - -64642,-64651,-64659,-64667,-64675,-64683,-64691,-64699, - -64707,-64715,-64723,-64731,-64739,-64747,-64754,-64762, - -64770,-64777,-64785,-64793,-64800,-64808,-64815,-64822, - -64830,-64837,-64844,-64852,-64859,-64866,-64873,-64880, - -64887,-64895,-64902,-64908,-64915,-64922,-64929,-64936, - -64943,-64949,-64956,-64963,-64969,-64976,-64982,-64989, - -64995,-65002,-65008,-65015,-65021,-65027,-65033,-65040, - -65046,-65052,-65058,-65064,-65070,-65076,-65082,-65088, - -65094,-65099,-65105,-65111,-65117,-65122,-65128,-65133, - -65139,-65144,-65150,-65155,-65161,-65166,-65171,-65177, - -65182,-65187,-65192,-65197,-65202,-65207,-65212,-65217, - -65222,-65227,-65232,-65237,-65242,-65246,-65251,-65256, - -65260,-65265,-65270,-65274,-65279,-65283,-65287,-65292, - -65296,-65300,-65305,-65309,-65313,-65317,-65321,-65325, - -65329,-65333,-65337,-65341,-65345,-65349,-65352,-65356, - -65360,-65363,-65367,-65371,-65374,-65378,-65381,-65385, - -65388,-65391,-65395,-65398,-65401,-65404,-65408,-65411, - -65414,-65417,-65420,-65423,-65426,-65429,-65431,-65434, - -65437,-65440,-65442,-65445,-65448,-65450,-65453,-65455, - -65458,-65460,-65463,-65465,-65467,-65470,-65472,-65474, - -65476,-65478,-65480,-65482,-65484,-65486,-65488,-65490, - -65492,-65494,-65496,-65497,-65499,-65501,-65502,-65504, - -65505,-65507,-65508,-65510,-65511,-65513,-65514,-65515, - -65516,-65518,-65519,-65520,-65521,-65522,-65523,-65524, - -65525,-65526,-65527,-65527,-65528,-65529,-65530,-65530, - -65531,-65531,-65532,-65532,-65533,-65533,-65534,-65534, - -65534,-65535,-65535,-65535,-65535,-65535,-65535,-65535, - -65535,-65535,-65535,-65535,-65535,-65535,-65535,-65534, - -65534,-65534,-65533,-65533,-65532,-65532,-65531,-65531, - -65530,-65530,-65529,-65528,-65527,-65527,-65526,-65525, - -65524,-65523,-65522,-65521,-65520,-65519,-65518,-65516, - -65515,-65514,-65513,-65511,-65510,-65508,-65507,-65505, - -65504,-65502,-65501,-65499,-65497,-65496,-65494,-65492, - -65490,-65488,-65486,-65484,-65482,-65480,-65478,-65476, - -65474,-65472,-65470,-65467,-65465,-65463,-65460,-65458, - -65455,-65453,-65450,-65448,-65445,-65442,-65440,-65437, - -65434,-65431,-65429,-65426,-65423,-65420,-65417,-65414, - -65411,-65408,-65404,-65401,-65398,-65395,-65391,-65388, - -65385,-65381,-65378,-65374,-65371,-65367,-65363,-65360, - -65356,-65352,-65349,-65345,-65341,-65337,-65333,-65329, - -65325,-65321,-65317,-65313,-65309,-65305,-65300,-65296, - -65292,-65287,-65283,-65279,-65274,-65270,-65265,-65260, - -65256,-65251,-65246,-65242,-65237,-65232,-65227,-65222, - -65217,-65212,-65207,-65202,-65197,-65192,-65187,-65182, - -65177,-65171,-65166,-65161,-65155,-65150,-65144,-65139, - -65133,-65128,-65122,-65117,-65111,-65105,-65099,-65094, - -65088,-65082,-65076,-65070,-65064,-65058,-65052,-65046, - -65040,-65033,-65027,-65021,-65015,-65008,-65002,-64995, - -64989,-64982,-64976,-64969,-64963,-64956,-64949,-64943, - -64936,-64929,-64922,-64915,-64908,-64902,-64895,-64887, - -64880,-64873,-64866,-64859,-64852,-64844,-64837,-64830, - -64822,-64815,-64808,-64800,-64793,-64785,-64777,-64770, - -64762,-64754,-64747,-64739,-64731,-64723,-64715,-64707, - -64699,-64691,-64683,-64675,-64667,-64659,-64651,-64642, - -64634,-64626,-64617,-64609,-64601,-64592,-64584,-64575, - -64566,-64558,-64549,-64540,-64532,-64523,-64514,-64505, - -64496,-64487,-64478,-64469,-64460,-64451,-64442,-64433, - -64424,-64414,-64405,-64396,-64387,-64377,-64368,-64358, - -64349,-64339,-64330,-64320,-64310,-64301,-64291,-64281, - -64271,-64261,-64252,-64242,-64232,-64222,-64212,-64202, - -64192,-64181,-64171,-64161,-64151,-64140,-64130,-64120, - -64109,-64099,-64088,-64078,-64067,-64057,-64046,-64035, - -64025,-64014,-64003,-63992,-63981,-63971,-63960,-63949, - -63938,-63927,-63915,-63904,-63893,-63882,-63871,-63859, - -63848,-63837,-63825,-63814,-63803,-63791,-63779,-63768, - -63756,-63745,-63733,-63721,-63709,-63698,-63686,-63674, - -63662,-63650,-63638,-63626,-63614,-63602,-63590,-63578, - -63565,-63553,-63541,-63528,-63516,-63504,-63491,-63479, - -63466,-63454,-63441,-63429,-63416,-63403,-63390,-63378, - -63365,-63352,-63339,-63326,-63313,-63300,-63287,-63274, - -63261,-63248,-63235,-63221,-63208,-63195,-63182,-63168, - -63155,-63141,-63128,-63114,-63101,-63087,-63074,-63060, - -63046,-63032,-63019,-63005,-62991,-62977,-62963,-62949, - -62935,-62921,-62907,-62893,-62879,-62865,-62850,-62836, - -62822,-62808,-62793,-62779,-62764,-62750,-62735,-62721, - -62706,-62692,-62677,-62662,-62648,-62633,-62618,-62603, - -62588,-62573,-62558,-62543,-62528,-62513,-62498,-62483, - -62468,-62453,-62437,-62422,-62407,-62391,-62376,-62360, - -62345,-62329,-62314,-62298,-62283,-62267,-62251,-62236, - -62220,-62204,-62188,-62172,-62156,-62141,-62125,-62108, - -62092,-62076,-62060,-62044,-62028,-62012,-61995,-61979, - -61963,-61946,-61930,-61913,-61897,-61880,-61864,-61847, - -61831,-61814,-61797,-61780,-61764,-61747,-61730,-61713, - -61696,-61679,-61662,-61645,-61628,-61611,-61594,-61577, - -61559,-61542,-61525,-61507,-61490,-61473,-61455,-61438, - -61420,-61403,-61385,-61367,-61350,-61332,-61314,-61297, - -61279,-61261,-61243,-61225,-61207,-61189,-61171,-61153, - -61135,-61117,-61099,-61081,-61062,-61044,-61026,-61007, - -60989,-60971,-60952,-60934,-60915,-60897,-60878,-60859, - -60841,-60822,-60803,-60785,-60766,-60747,-60728,-60709, - -60690,-60671,-60652,-60633,-60614,-60595,-60576,-60556, - -60537,-60518,-60499,-60479,-60460,-60441,-60421,-60402, - -60382,-60363,-60343,-60323,-60304,-60284,-60264,-60244, - -60225,-60205,-60185,-60165,-60145,-60125,-60105,-60085, - -60065,-60045,-60025,-60004,-59984,-59964,-59944,-59923, - -59903,-59883,-59862,-59842,-59821,-59801,-59780,-59759, - -59739,-59718,-59697,-59677,-59656,-59635,-59614,-59593, - -59572,-59551,-59530,-59509,-59488,-59467,-59446,-59425, - -59404,-59382,-59361,-59340,-59318,-59297,-59276,-59254, - -59233,-59211,-59189,-59168,-59146,-59125,-59103,-59081, - -59059,-59038,-59016,-58994,-58972,-58950,-58928,-58906, - -58884,-58862,-58840,-58818,-58795,-58773,-58751,-58729, - -58706,-58684,-58662,-58639,-58617,-58594,-58572,-58549, - -58527,-58504,-58481,-58459,-58436,-58413,-58390,-58367, - -58345,-58322,-58299,-58276,-58253,-58230,-58207,-58183, - -58160,-58137,-58114,-58091,-58067,-58044,-58021,-57997, - -57974,-57950,-57927,-57903,-57880,-57856,-57833,-57809, - -57785,-57762,-57738,-57714,-57690,-57666,-57642,-57618, - -57594,-57570,-57546,-57522,-57498,-57474,-57450,-57426, - -57402,-57377,-57353,-57329,-57304,-57280,-57255,-57231, - -57206,-57182,-57157,-57133,-57108,-57083,-57059,-57034, - -57009,-56984,-56959,-56935,-56910,-56885,-56860,-56835, - -56810,-56785,-56760,-56734,-56709,-56684,-56659,-56633, - -56608,-56583,-56557,-56532,-56507,-56481,-56456,-56430, - -56404,-56379,-56353,-56328,-56302,-56276,-56250,-56225, - -56199,-56173,-56147,-56121,-56095,-56069,-56043,-56017, - -55991,-55965,-55938,-55912,-55886,-55860,-55833,-55807, - -55781,-55754,-55728,-55701,-55675,-55648,-55622,-55595, - -55569,-55542,-55515,-55489,-55462,-55435,-55408,-55381, - -55354,-55327,-55300,-55274,-55246,-55219,-55192,-55165, - -55138,-55111,-55084,-55056,-55029,-55002,-54974,-54947, - -54920,-54892,-54865,-54837,-54810,-54782,-54755,-54727, - -54699,-54672,-54644,-54616,-54588,-54560,-54533,-54505, - -54477,-54449,-54421,-54393,-54365,-54337,-54308,-54280, - -54252,-54224,-54196,-54167,-54139,-54111,-54082,-54054, - -54026,-53997,-53969,-53940,-53911,-53883,-53854,-53826, - -53797,-53768,-53739,-53711,-53682,-53653,-53624,-53595, - -53566,-53537,-53508,-53479,-53450,-53421,-53392,-53363, - -53334,-53304,-53275,-53246,-53216,-53187,-53158,-53128, - -53099,-53069,-53040,-53010,-52981,-52951,-52922,-52892, - -52862,-52832,-52803,-52773,-52743,-52713,-52683,-52653, - -52624,-52594,-52564,-52534,-52503,-52473,-52443,-52413, - -52383,-52353,-52322,-52292,-52262,-52231,-52201,-52171, - -52140,-52110,-52079,-52049,-52018,-51988,-51957,-51926, - -51896,-51865,-51834,-51803,-51773,-51742,-51711,-51680, - -51649,-51618,-51587,-51556,-51525,-51494,-51463,-51432, - -51401,-51369,-51338,-51307,-51276,-51244,-51213,-51182, - -51150,-51119,-51087,-51056,-51024,-50993,-50961,-50929, - -50898,-50866,-50834,-50803,-50771,-50739,-50707,-50675, - -50644,-50612,-50580,-50548,-50516,-50484,-50452,-50420, - -50387,-50355,-50323,-50291,-50259,-50226,-50194,-50162, - -50129,-50097,-50065,-50032,-50000,-49967,-49935,-49902, - -49869,-49837,-49804,-49771,-49739,-49706,-49673,-49640, - -49608,-49575,-49542,-49509,-49476,-49443,-49410,-49377, - -49344,-49311,-49278,-49244,-49211,-49178,-49145,-49112, - -49078,-49045,-49012,-48978,-48945,-48911,-48878,-48844, - -48811,-48777,-48744,-48710,-48676,-48643,-48609,-48575, - -48542,-48508,-48474,-48440,-48406,-48372,-48338,-48305, - -48271,-48237,-48202,-48168,-48134,-48100,-48066,-48032, - -47998,-47963,-47929,-47895,-47860,-47826,-47792,-47757, - -47723,-47688,-47654,-47619,-47585,-47550,-47516,-47481, - -47446,-47412,-47377,-47342,-47307,-47273,-47238,-47203, - -47168,-47133,-47098,-47063,-47028,-46993,-46958,-46923, - -46888,-46853,-46818,-46783,-46747,-46712,-46677,-46642, - -46606,-46571,-46536,-46500,-46465,-46429,-46394,-46358, - -46323,-46287,-46251,-46216,-46180,-46145,-46109,-46073, - -46037,-46002,-45966,-45930,-45894,-45858,-45822,-45786, - -45750,-45714,-45678,-45642,-45606,-45570,-45534,-45498, - -45462,-45425,-45389,-45353,-45316,-45280,-45244,-45207, - -45171,-45135,-45098,-45062,-45025,-44989,-44952,-44915, - -44879,-44842,-44806,-44769,-44732,-44695,-44659,-44622, - -44585,-44548,-44511,-44474,-44437,-44400,-44363,-44326, - -44289,-44252,-44215,-44178,-44141,-44104,-44067,-44029, - -43992,-43955,-43918,-43880,-43843,-43806,-43768,-43731, - -43693,-43656,-43618,-43581,-43543,-43506,-43468,-43430, - -43393,-43355,-43317,-43280,-43242,-43204,-43166,-43128, - -43091,-43053,-43015,-42977,-42939,-42901,-42863,-42825, - -42787,-42749,-42711,-42672,-42634,-42596,-42558,-42520, - -42481,-42443,-42405,-42366,-42328,-42290,-42251,-42213, - -42174,-42136,-42097,-42059,-42020,-41982,-41943,-41904, - -41866,-41827,-41788,-41750,-41711,-41672,-41633,-41595, - -41556,-41517,-41478,-41439,-41400,-41361,-41322,-41283, - -41244,-41205,-41166,-41127,-41087,-41048,-41009,-40970, - -40931,-40891,-40852,-40813,-40773,-40734,-40695,-40655, - -40616,-40576,-40537,-40497,-40458,-40418,-40379,-40339, - -40299,-40260,-40220,-40180,-40141,-40101,-40061,-40021, - -39982,-39942,-39902,-39862,-39822,-39782,-39742,-39702, - -39662,-39622,-39582,-39542,-39502,-39462,-39422,-39382, - -39341,-39301,-39261,-39221,-39180,-39140,-39100,-39059, - -39019,-38979,-38938,-38898,-38857,-38817,-38776,-38736, - -38695,-38655,-38614,-38573,-38533,-38492,-38451,-38411, - -38370,-38329,-38288,-38248,-38207,-38166,-38125,-38084, - -38043,-38002,-37961,-37920,-37879,-37838,-37797,-37756, - -37715,-37674,-37633,-37592,-37550,-37509,-37468,-37427, - -37386,-37344,-37303,-37262,-37220,-37179,-37137,-37096, - -37055,-37013,-36972,-36930,-36889,-36847,-36805,-36764, - -36722,-36681,-36639,-36597,-36556,-36514,-36472,-36430, - -36388,-36347,-36305,-36263,-36221,-36179,-36137,-36095, - -36053,-36011,-35969,-35927,-35885,-35843,-35801,-35759, - -35717,-35675,-35633,-35590,-35548,-35506,-35464,-35421, - -35379,-35337,-35294,-35252,-35210,-35167,-35125,-35082, - -35040,-34997,-34955,-34912,-34870,-34827,-34785,-34742, - -34699,-34657,-34614,-34571,-34529,-34486,-34443,-34400, - -34358,-34315,-34272,-34229,-34186,-34143,-34100,-34057, - -34015,-33972,-33929,-33886,-33843,-33799,-33756,-33713, - -33670,-33627,-33584,-33541,-33498,-33454,-33411,-33368, - -33325,-33281,-33238,-33195,-33151,-33108,-33065,-33021, - -32978,-32934,-32891,-32847,-32804,-32760,-32717,-32673, - -32630,-32586,-32542,-32499,-32455,-32411,-32368,-32324, - -32280,-32236,-32193,-32149,-32105,-32061,-32017,-31974, - -31930,-31886,-31842,-31798,-31754,-31710,-31666,-31622, - -31578,-31534,-31490,-31446,-31402,-31357,-31313,-31269, - -31225,-31181,-31136,-31092,-31048,-31004,-30959,-30915, - -30871,-30826,-30782,-30738,-30693,-30649,-30604,-30560, - -30515,-30471,-30426,-30382,-30337,-30293,-30248,-30204, - -30159,-30114,-30070,-30025,-29980,-29936,-29891,-29846, - -29801,-29757,-29712,-29667,-29622,-29577,-29533,-29488, - -29443,-29398,-29353,-29308,-29263,-29218,-29173,-29128, - -29083,-29038,-28993,-28948,-28903,-28858,-28812,-28767, - -28722,-28677,-28632,-28586,-28541,-28496,-28451,-28405, - -28360,-28315,-28269,-28224,-28179,-28133,-28088,-28042, - -27997,-27952,-27906,-27861,-27815,-27770,-27724,-27678, - -27633,-27587,-27542,-27496,-27450,-27405,-27359,-27313, - -27268,-27222,-27176,-27131,-27085,-27039,-26993,-26947, - -26902,-26856,-26810,-26764,-26718,-26672,-26626,-26580, - -26534,-26488,-26442,-26396,-26350,-26304,-26258,-26212, - -26166,-26120,-26074,-26028,-25982,-25936,-25889,-25843, - -25797,-25751,-25705,-25658,-25612,-25566,-25520,-25473, - -25427,-25381,-25334,-25288,-25241,-25195,-25149,-25102, - -25056,-25009,-24963,-24916,-24870,-24823,-24777,-24730, - -24684,-24637,-24591,-24544,-24497,-24451,-24404,-24357, - -24311,-24264,-24217,-24171,-24124,-24077,-24030,-23984, - -23937,-23890,-23843,-23796,-23750,-23703,-23656,-23609, - -23562,-23515,-23468,-23421,-23374,-23327,-23280,-23233, - -23186,-23139,-23092,-23045,-22998,-22951,-22904,-22857, - -22810,-22763,-22716,-22668,-22621,-22574,-22527,-22480, - -22432,-22385,-22338,-22291,-22243,-22196,-22149,-22102, - -22054,-22007,-21960,-21912,-21865,-21817,-21770,-21723, - -21675,-21628,-21580,-21533,-21485,-21438,-21390,-21343, - -21295,-21248,-21200,-21153,-21105,-21057,-21010,-20962, - -20915,-20867,-20819,-20772,-20724,-20676,-20629,-20581, - -20533,-20485,-20438,-20390,-20342,-20294,-20246,-20199, - -20151,-20103,-20055,-20007,-19959,-19912,-19864,-19816, - -19768,-19720,-19672,-19624,-19576,-19528,-19480,-19432, - -19384,-19336,-19288,-19240,-19192,-19144,-19096,-19048, - -19000,-18951,-18903,-18855,-18807,-18759,-18711,-18663, - -18614,-18566,-18518,-18470,-18421,-18373,-18325,-18277, - -18228,-18180,-18132,-18084,-18035,-17987,-17939,-17890, - -17842,-17793,-17745,-17697,-17648,-17600,-17551,-17503, - -17455,-17406,-17358,-17309,-17261,-17212,-17164,-17115, - -17067,-17018,-16970,-16921,-16872,-16824,-16775,-16727, - -16678,-16629,-16581,-16532,-16484,-16435,-16386,-16338, - -16289,-16240,-16191,-16143,-16094,-16045,-15997,-15948, - -15899,-15850,-15802,-15753,-15704,-15655,-15606,-15557, - -15509,-15460,-15411,-15362,-15313,-15264,-15215,-15167, - -15118,-15069,-15020,-14971,-14922,-14873,-14824,-14775, - -14726,-14677,-14628,-14579,-14530,-14481,-14432,-14383, - -14334,-14285,-14236,-14187,-14138,-14089,-14040,-13990, - -13941,-13892,-13843,-13794,-13745,-13696,-13647,-13597, - -13548,-13499,-13450,-13401,-13351,-13302,-13253,-13204, - -13154,-13105,-13056,-13007,-12957,-12908,-12859,-12810, - -12760,-12711,-12662,-12612,-12563,-12514,-12464,-12415, - -12366,-12316,-12267,-12217,-12168,-12119,-12069,-12020, - -11970,-11921,-11872,-11822,-11773,-11723,-11674,-11624, - -11575,-11525,-11476,-11426,-11377,-11327,-11278,-11228, - -11179,-11129,-11080,-11030,-10981,-10931,-10882,-10832, - -10782,-10733,-10683,-10634,-10584,-10534,-10485,-10435, - -10386,-10336,-10286,-10237,-10187,-10137,-10088,-10038, - -9988,-9939,-9889,-9839,-9790,-9740,-9690,-9640, - -9591,-9541,-9491,-9442,-9392,-9342,-9292,-9243, - -9193,-9143,-9093,-9043,-8994,-8944,-8894,-8844, - -8794,-8745,-8695,-8645,-8595,-8545,-8496,-8446, - -8396,-8346,-8296,-8246,-8196,-8147,-8097,-8047, - -7997,-7947,-7897,-7847,-7797,-7747,-7697,-7648, - -7598,-7548,-7498,-7448,-7398,-7348,-7298,-7248, - -7198,-7148,-7098,-7048,-6998,-6948,-6898,-6848, - -6798,-6748,-6698,-6648,-6598,-6548,-6498,-6448, - -6398,-6348,-6298,-6248,-6198,-6148,-6098,-6048, - -5998,-5948,-5898,-5848,-5798,-5747,-5697,-5647, - -5597,-5547,-5497,-5447,-5397,-5347,-5297,-5247, - -5197,-5146,-5096,-5046,-4996,-4946,-4896,-4846, - -4796,-4745,-4695,-4645,-4595,-4545,-4495,-4445, - -4394,-4344,-4294,-4244,-4194,-4144,-4093,-4043, - -3993,-3943,-3893,-3843,-3792,-3742,-3692,-3642, - -3592,-3541,-3491,-3441,-3391,-3341,-3291,-3240, - -3190,-3140,-3090,-3039,-2989,-2939,-2889,-2839, - -2788,-2738,-2688,-2638,-2588,-2537,-2487,-2437, - -2387,-2336,-2286,-2236,-2186,-2135,-2085,-2035, - -1985,-1934,-1884,-1834,-1784,-1733,-1683,-1633, - -1583,-1532,-1482,-1432,-1382,-1331,-1281,-1231, - -1181,-1130,-1080,-1030,-980,-929,-879,-829, - -779,-728,-678,-628,-578,-527,-477,-427, - -376,-326,-276,-226,-175,-125,-75,-25, - 25,75,125,175,226,276,326,376, - 427,477,527,578,628,678,728,779, - 829,879,929,980,1030,1080,1130,1181, - 1231,1281,1331,1382,1432,1482,1532,1583, - 1633,1683,1733,1784,1834,1884,1934,1985, - 2035,2085,2135,2186,2236,2286,2336,2387, - 2437,2487,2537,2587,2638,2688,2738,2788, - 2839,2889,2939,2989,3039,3090,3140,3190, - 3240,3291,3341,3391,3441,3491,3542,3592, - 3642,3692,3742,3792,3843,3893,3943,3993, - 4043,4093,4144,4194,4244,4294,4344,4394, - 4445,4495,4545,4595,4645,4695,4745,4796, - 4846,4896,4946,4996,5046,5096,5146,5197, - 5247,5297,5347,5397,5447,5497,5547,5597, - 5647,5697,5747,5798,5848,5898,5948,5998, - 6048,6098,6148,6198,6248,6298,6348,6398, - 6448,6498,6548,6598,6648,6698,6748,6798, - 6848,6898,6948,6998,7048,7098,7148,7198, - 7248,7298,7348,7398,7448,7498,7548,7598, - 7648,7697,7747,7797,7847,7897,7947,7997, - 8047,8097,8147,8196,8246,8296,8346,8396, - 8446,8496,8545,8595,8645,8695,8745,8794, - 8844,8894,8944,8994,9043,9093,9143,9193, - 9243,9292,9342,9392,9442,9491,9541,9591, - 9640,9690,9740,9790,9839,9889,9939,9988, - 10038,10088,10137,10187,10237,10286,10336,10386, - 10435,10485,10534,10584,10634,10683,10733,10782, - 10832,10882,10931,10981,11030,11080,11129,11179, - 11228,11278,11327,11377,11426,11476,11525,11575, - 11624,11674,11723,11773,11822,11872,11921,11970, - 12020,12069,12119,12168,12218,12267,12316,12366, - 12415,12464,12514,12563,12612,12662,12711,12760, - 12810,12859,12908,12957,13007,13056,13105,13154, - 13204,13253,13302,13351,13401,13450,13499,13548, - 13597,13647,13696,13745,13794,13843,13892,13941, - 13990,14040,14089,14138,14187,14236,14285,14334, - 14383,14432,14481,14530,14579,14628,14677,14726, - 14775,14824,14873,14922,14971,15020,15069,15118, - 15167,15215,15264,15313,15362,15411,15460,15509, - 15557,15606,15655,15704,15753,15802,15850,15899, - 15948,15997,16045,16094,16143,16191,16240,16289, - 16338,16386,16435,16484,16532,16581,16629,16678, - 16727,16775,16824,16872,16921,16970,17018,17067, - 17115,17164,17212,17261,17309,17358,17406,17455, - 17503,17551,17600,17648,17697,17745,17793,17842, - 17890,17939,17987,18035,18084,18132,18180,18228, - 18277,18325,18373,18421,18470,18518,18566,18614, - 18663,18711,18759,18807,18855,18903,18951,19000, - 19048,19096,19144,19192,19240,19288,19336,19384, - 19432,19480,19528,19576,19624,19672,19720,19768, - 19816,19864,19912,19959,20007,20055,20103,20151, - 20199,20246,20294,20342,20390,20438,20485,20533, - 20581,20629,20676,20724,20772,20819,20867,20915, - 20962,21010,21057,21105,21153,21200,21248,21295, - 21343,21390,21438,21485,21533,21580,21628,21675, - 21723,21770,21817,21865,21912,21960,22007,22054, - 22102,22149,22196,22243,22291,22338,22385,22432, - 22480,22527,22574,22621,22668,22716,22763,22810, - 22857,22904,22951,22998,23045,23092,23139,23186, - 23233,23280,23327,23374,23421,23468,23515,23562, - 23609,23656,23703,23750,23796,23843,23890,23937, - 23984,24030,24077,24124,24171,24217,24264,24311, - 24357,24404,24451,24497,24544,24591,24637,24684, - 24730,24777,24823,24870,24916,24963,25009,25056, - 25102,25149,25195,25241,25288,25334,25381,25427, - 25473,25520,25566,25612,25658,25705,25751,25797, - 25843,25889,25936,25982,26028,26074,26120,26166, - 26212,26258,26304,26350,26396,26442,26488,26534, - 26580,26626,26672,26718,26764,26810,26856,26902, - 26947,26993,27039,27085,27131,27176,27222,27268, - 27313,27359,27405,27450,27496,27542,27587,27633, - 27678,27724,27770,27815,27861,27906,27952,27997, - 28042,28088,28133,28179,28224,28269,28315,28360, - 28405,28451,28496,28541,28586,28632,28677,28722, - 28767,28812,28858,28903,28948,28993,29038,29083, - 29128,29173,29218,29263,29308,29353,29398,29443, - 29488,29533,29577,29622,29667,29712,29757,29801, - 29846,29891,29936,29980,30025,30070,30114,30159, - 30204,30248,30293,30337,30382,30427,30471,30516, - 30560,30604,30649,30693,30738,30782,30826,30871, - 30915,30959,31004,31048,31092,31136,31181,31225, - 31269,31313,31357,31402,31446,31490,31534,31578, - 31622,31666,31710,31754,31798,31842,31886,31930, - 31974,32017,32061,32105,32149,32193,32236,32280, - 32324,32368,32411,32455,32499,32542,32586,32630, - 32673,32717,32760,32804,32847,32891,32934,32978, - 33021,33065,33108,33151,33195,33238,33281,33325, - 33368,33411,33454,33498,33541,33584,33627,33670, - 33713,33756,33799,33843,33886,33929,33972,34015, - 34057,34100,34143,34186,34229,34272,34315,34358, - 34400,34443,34486,34529,34571,34614,34657,34699, - 34742,34785,34827,34870,34912,34955,34997,35040, - 35082,35125,35167,35210,35252,35294,35337,35379, - 35421,35464,35506,35548,35590,35633,35675,35717, - 35759,35801,35843,35885,35927,35969,36011,36053, - 36095,36137,36179,36221,36263,36305,36347,36388, - 36430,36472,36514,36556,36597,36639,36681,36722, - 36764,36805,36847,36889,36930,36972,37013,37055, - 37096,37137,37179,37220,37262,37303,37344,37386, - 37427,37468,37509,37551,37592,37633,37674,37715, - 37756,37797,37838,37879,37920,37961,38002,38043, - 38084,38125,38166,38207,38248,38288,38329,38370, - 38411,38451,38492,38533,38573,38614,38655,38695, - 38736,38776,38817,38857,38898,38938,38979,39019, - 39059,39100,39140,39180,39221,39261,39301,39341, - 39382,39422,39462,39502,39542,39582,39622,39662, - 39702,39742,39782,39822,39862,39902,39942,39982, - 40021,40061,40101,40141,40180,40220,40260,40299, - 40339,40379,40418,40458,40497,40537,40576,40616, - 40655,40695,40734,40773,40813,40852,40891,40931, - 40970,41009,41048,41087,41127,41166,41205,41244, - 41283,41322,41361,41400,41439,41478,41517,41556, - 41595,41633,41672,41711,41750,41788,41827,41866, - 41904,41943,41982,42020,42059,42097,42136,42174, - 42213,42251,42290,42328,42366,42405,42443,42481, - 42520,42558,42596,42634,42672,42711,42749,42787, - 42825,42863,42901,42939,42977,43015,43053,43091, - 43128,43166,43204,43242,43280,43317,43355,43393, - 43430,43468,43506,43543,43581,43618,43656,43693, - 43731,43768,43806,43843,43880,43918,43955,43992, - 44029,44067,44104,44141,44178,44215,44252,44289, - 44326,44363,44400,44437,44474,44511,44548,44585, - 44622,44659,44695,44732,44769,44806,44842,44879, - 44915,44952,44989,45025,45062,45098,45135,45171, - 45207,45244,45280,45316,45353,45389,45425,45462, - 45498,45534,45570,45606,45642,45678,45714,45750, - 45786,45822,45858,45894,45930,45966,46002,46037, - 46073,46109,46145,46180,46216,46252,46287,46323, - 46358,46394,46429,46465,46500,46536,46571,46606, - 46642,46677,46712,46747,46783,46818,46853,46888, - 46923,46958,46993,47028,47063,47098,47133,47168, - 47203,47238,47273,47308,47342,47377,47412,47446, - 47481,47516,47550,47585,47619,47654,47688,47723, - 47757,47792,47826,47861,47895,47929,47963,47998, - 48032,48066,48100,48134,48168,48202,48237,48271, - 48305,48338,48372,48406,48440,48474,48508,48542, - 48575,48609,48643,48676,48710,48744,48777,48811, - 48844,48878,48911,48945,48978,49012,49045,49078, - 49112,49145,49178,49211,49244,49278,49311,49344, - 49377,49410,49443,49476,49509,49542,49575,49608, - 49640,49673,49706,49739,49771,49804,49837,49869, - 49902,49935,49967,50000,50032,50064,50097,50129, - 50162,50194,50226,50259,50291,50323,50355,50387, - 50420,50452,50484,50516,50548,50580,50612,50644, - 50675,50707,50739,50771,50803,50834,50866,50898, - 50929,50961,50993,51024,51056,51087,51119,51150, - 51182,51213,51244,51276,51307,51338,51369,51401, - 51432,51463,51494,51525,51556,51587,51618,51649, - 51680,51711,51742,51773,51803,51834,51865,51896, - 51926,51957,51988,52018,52049,52079,52110,52140, - 52171,52201,52231,52262,52292,52322,52353,52383, - 52413,52443,52473,52503,52534,52564,52594,52624, - 52653,52683,52713,52743,52773,52803,52832,52862, - 52892,52922,52951,52981,53010,53040,53069,53099, - 53128,53158,53187,53216,53246,53275,53304,53334, - 53363,53392,53421,53450,53479,53508,53537,53566, - 53595,53624,53653,53682,53711,53739,53768,53797, - 53826,53854,53883,53912,53940,53969,53997,54026, - 54054,54082,54111,54139,54167,54196,54224,54252, - 54280,54309,54337,54365,54393,54421,54449,54477, - 54505,54533,54560,54588,54616,54644,54672,54699, - 54727,54755,54782,54810,54837,54865,54892,54920, - 54947,54974,55002,55029,55056,55084,55111,55138, - 55165,55192,55219,55246,55274,55300,55327,55354, - 55381,55408,55435,55462,55489,55515,55542,55569, - 55595,55622,55648,55675,55701,55728,55754,55781, - 55807,55833,55860,55886,55912,55938,55965,55991, - 56017,56043,56069,56095,56121,56147,56173,56199, - 56225,56250,56276,56302,56328,56353,56379,56404, - 56430,56456,56481,56507,56532,56557,56583,56608, - 56633,56659,56684,56709,56734,56760,56785,56810, - 56835,56860,56885,56910,56935,56959,56984,57009, - 57034,57059,57083,57108,57133,57157,57182,57206, - 57231,57255,57280,57304,57329,57353,57377,57402, - 57426,57450,57474,57498,57522,57546,57570,57594, - 57618,57642,57666,57690,57714,57738,57762,57785, - 57809,57833,57856,57880,57903,57927,57950,57974, - 57997,58021,58044,58067,58091,58114,58137,58160, - 58183,58207,58230,58253,58276,58299,58322,58345, - 58367,58390,58413,58436,58459,58481,58504,58527, - 58549,58572,58594,58617,58639,58662,58684,58706, - 58729,58751,58773,58795,58818,58840,58862,58884, - 58906,58928,58950,58972,58994,59016,59038,59059, - 59081,59103,59125,59146,59168,59190,59211,59233, - 59254,59276,59297,59318,59340,59361,59382,59404, - 59425,59446,59467,59488,59509,59530,59551,59572, - 59593,59614,59635,59656,59677,59697,59718,59739, - 59759,59780,59801,59821,59842,59862,59883,59903, - 59923,59944,59964,59984,60004,60025,60045,60065, - 60085,60105,60125,60145,60165,60185,60205,60225, - 60244,60264,60284,60304,60323,60343,60363,60382, - 60402,60421,60441,60460,60479,60499,60518,60537, - 60556,60576,60595,60614,60633,60652,60671,60690, - 60709,60728,60747,60766,60785,60803,60822,60841, - 60859,60878,60897,60915,60934,60952,60971,60989, - 61007,61026,61044,61062,61081,61099,61117,61135, - 61153,61171,61189,61207,61225,61243,61261,61279, - 61297,61314,61332,61350,61367,61385,61403,61420, - 61438,61455,61473,61490,61507,61525,61542,61559, - 61577,61594,61611,61628,61645,61662,61679,61696, - 61713,61730,61747,61764,61780,61797,61814,61831, - 61847,61864,61880,61897,61913,61930,61946,61963, - 61979,61995,62012,62028,62044,62060,62076,62092, - 62108,62125,62141,62156,62172,62188,62204,62220, - 62236,62251,62267,62283,62298,62314,62329,62345, - 62360,62376,62391,62407,62422,62437,62453,62468, - 62483,62498,62513,62528,62543,62558,62573,62588, - 62603,62618,62633,62648,62662,62677,62692,62706, - 62721,62735,62750,62764,62779,62793,62808,62822, - 62836,62850,62865,62879,62893,62907,62921,62935, - 62949,62963,62977,62991,63005,63019,63032,63046, - 63060,63074,63087,63101,63114,63128,63141,63155, - 63168,63182,63195,63208,63221,63235,63248,63261, - 63274,63287,63300,63313,63326,63339,63352,63365, - 63378,63390,63403,63416,63429,63441,63454,63466, - 63479,63491,63504,63516,63528,63541,63553,63565, - 63578,63590,63602,63614,63626,63638,63650,63662, - 63674,63686,63698,63709,63721,63733,63745,63756, - 63768,63779,63791,63803,63814,63825,63837,63848, - 63859,63871,63882,63893,63904,63915,63927,63938, - 63949,63960,63971,63981,63992,64003,64014,64025, - 64035,64046,64057,64067,64078,64088,64099,64109, - 64120,64130,64140,64151,64161,64171,64181,64192, - 64202,64212,64222,64232,64242,64252,64261,64271, - 64281,64291,64301,64310,64320,64330,64339,64349, - 64358,64368,64377,64387,64396,64405,64414,64424, - 64433,64442,64451,64460,64469,64478,64487,64496, - 64505,64514,64523,64532,64540,64549,64558,64566, - 64575,64584,64592,64600,64609,64617,64626,64634, - 64642,64651,64659,64667,64675,64683,64691,64699, - 64707,64715,64723,64731,64739,64747,64754,64762, - 64770,64777,64785,64793,64800,64808,64815,64822, - 64830,64837,64844,64852,64859,64866,64873,64880, - 64887,64895,64902,64908,64915,64922,64929,64936, - 64943,64949,64956,64963,64969,64976,64982,64989, - 64995,65002,65008,65015,65021,65027,65033,65040, - 65046,65052,65058,65064,65070,65076,65082,65088, - 65094,65099,65105,65111,65117,65122,65128,65133, - 65139,65144,65150,65155,65161,65166,65171,65177, - 65182,65187,65192,65197,65202,65207,65212,65217, - 65222,65227,65232,65237,65242,65246,65251,65256, - 65260,65265,65270,65274,65279,65283,65287,65292, - 65296,65300,65305,65309,65313,65317,65321,65325, - 65329,65333,65337,65341,65345,65349,65352,65356, - 65360,65363,65367,65371,65374,65378,65381,65385, - 65388,65391,65395,65398,65401,65404,65408,65411, - 65414,65417,65420,65423,65426,65429,65431,65434, - 65437,65440,65442,65445,65448,65450,65453,65455, - 65458,65460,65463,65465,65467,65470,65472,65474, - 65476,65478,65480,65482,65484,65486,65488,65490, - 65492,65494,65496,65497,65499,65501,65502,65504, - 65505,65507,65508,65510,65511,65513,65514,65515, - 65516,65518,65519,65520,65521,65522,65523,65524, - 65525,65526,65527,65527,65528,65529,65530,65530, - 65531,65531,65532,65532,65533,65533,65534,65534, - 65534,65535,65535,65535,65535,65535,65535,65535 + +int finesine[10240] = { + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1130,1181, + 1231,1281,1331,1382,1432,1482,1532,1583, + 1633,1683,1733,1784,1834,1884,1934,1985, + 2035,2085,2135,2186,2236,2286,2336,2387, + 2437,2487,2537,2587,2638,2688,2738,2788, + 2839,2889,2939,2989,3039,3090,3140,3190, + 3240,3291,3341,3391,3441,3491,3541,3592, + 3642,3692,3742,3792,3843,3893,3943,3993, + 4043,4093,4144,4194,4244,4294,4344,4394, + 4445,4495,4545,4595,4645,4695,4745,4796, + 4846,4896,4946,4996,5046,5096,5146,5197, + 5247,5297,5347,5397,5447,5497,5547,5597, + 5647,5697,5748,5798,5848,5898,5948,5998, + 6048,6098,6148,6198,6248,6298,6348,6398, + 6448,6498,6548,6598,6648,6698,6748,6798, + 6848,6898,6948,6998,7048,7098,7148,7198, + 7248,7298,7348,7398,7448,7498,7548,7598, + 7648,7697,7747,7797,7847,7897,7947,7997, + 8047,8097,8147,8196,8246,8296,8346,8396, + 8446,8496,8545,8595,8645,8695,8745,8794, + 8844,8894,8944,8994,9043,9093,9143,9193, + 9243,9292,9342,9392,9442,9491,9541,9591, + 9640,9690,9740,9790,9839,9889,9939,9988, + 10038,10088,10137,10187,10237,10286,10336,10386, + 10435,10485,10534,10584,10634,10683,10733,10782, + 10832,10882,10931,10981,11030,11080,11129,11179, + 11228,11278,11327,11377,11426,11476,11525,11575, + 11624,11674,11723,11773,11822,11872,11921,11970, + 12020,12069,12119,12168,12218,12267,12316,12366, + 12415,12464,12514,12563,12612,12662,12711,12760, + 12810,12859,12908,12957,13007,13056,13105,13154, + 13204,13253,13302,13351,13401,13450,13499,13548, + 13597,13647,13696,13745,13794,13843,13892,13941, + 13990,14040,14089,14138,14187,14236,14285,14334, + 14383,14432,14481,14530,14579,14628,14677,14726, + 14775,14824,14873,14922,14971,15020,15069,15118, + 15167,15215,15264,15313,15362,15411,15460,15509, + 15557,15606,15655,15704,15753,15802,15850,15899, + 15948,15997,16045,16094,16143,16191,16240,16289, + 16338,16386,16435,16484,16532,16581,16629,16678, + 16727,16775,16824,16872,16921,16970,17018,17067, + 17115,17164,17212,17261,17309,17358,17406,17455, + 17503,17551,17600,17648,17697,17745,17793,17842, + 17890,17939,17987,18035,18084,18132,18180,18228, + 18277,18325,18373,18421,18470,18518,18566,18614, + 18663,18711,18759,18807,18855,18903,18951,19000, + 19048,19096,19144,19192,19240,19288,19336,19384, + 19432,19480,19528,19576,19624,19672,19720,19768, + 19816,19864,19912,19959,20007,20055,20103,20151, + 20199,20246,20294,20342,20390,20438,20485,20533, + 20581,20629,20676,20724,20772,20819,20867,20915, + 20962,21010,21057,21105,21153,21200,21248,21295, + 21343,21390,21438,21485,21533,21580,21628,21675, + 21723,21770,21817,21865,21912,21960,22007,22054, + 22102,22149,22196,22243,22291,22338,22385,22433, + 22480,22527,22574,22621,22668,22716,22763,22810, + 22857,22904,22951,22998,23045,23092,23139,23186, + 23233,23280,23327,23374,23421,23468,23515,23562, + 23609,23656,23703,23750,23796,23843,23890,23937, + 23984,24030,24077,24124,24171,24217,24264,24311, + 24357,24404,24451,24497,24544,24591,24637,24684, + 24730,24777,24823,24870,24916,24963,25009,25056, + 25102,25149,25195,25241,25288,25334,25381,25427, + 25473,25520,25566,25612,25658,25705,25751,25797, + 25843,25889,25936,25982,26028,26074,26120,26166, + 26212,26258,26304,26350,26396,26442,26488,26534, + 26580,26626,26672,26718,26764,26810,26856,26902, + 26947,26993,27039,27085,27131,27176,27222,27268, + 27313,27359,27405,27450,27496,27542,27587,27633, + 27678,27724,27770,27815,27861,27906,27952,27997, + 28042,28088,28133,28179,28224,28269,28315,28360, + 28405,28451,28496,28541,28586,28632,28677,28722, + 28767,28812,28858,28903,28948,28993,29038,29083, + 29128,29173,29218,29263,29308,29353,29398,29443, + 29488,29533,29577,29622,29667,29712,29757,29801, + 29846,29891,29936,29980,30025,30070,30114,30159, + 30204,30248,30293,30337,30382,30426,30471,30515, + 30560,30604,30649,30693,30738,30782,30826,30871, + 30915,30959,31004,31048,31092,31136,31181,31225, + 31269,31313,31357,31402,31446,31490,31534,31578, + 31622,31666,31710,31754,31798,31842,31886,31930, + 31974,32017,32061,32105,32149,32193,32236,32280, + 32324,32368,32411,32455,32499,32542,32586,32630, + 32673,32717,32760,32804,32847,32891,32934,32978, + 33021,33065,33108,33151,33195,33238,33281,33325, + 33368,33411,33454,33498,33541,33584,33627,33670, + 33713,33756,33799,33843,33886,33929,33972,34015, + 34057,34100,34143,34186,34229,34272,34315,34358, + 34400,34443,34486,34529,34571,34614,34657,34699, + 34742,34785,34827,34870,34912,34955,34997,35040, + 35082,35125,35167,35210,35252,35294,35337,35379, + 35421,35464,35506,35548,35590,35633,35675,35717, + 35759,35801,35843,35885,35927,35969,36011,36053, + 36095,36137,36179,36221,36263,36305,36347,36388, + 36430,36472,36514,36555,36597,36639,36681,36722, + 36764,36805,36847,36889,36930,36972,37013,37055, + 37096,37137,37179,37220,37262,37303,37344,37386, + 37427,37468,37509,37551,37592,37633,37674,37715, + 37756,37797,37838,37879,37920,37961,38002,38043, + 38084,38125,38166,38207,38248,38288,38329,38370, + 38411,38451,38492,38533,38573,38614,38655,38695, + 38736,38776,38817,38857,38898,38938,38979,39019, + 39059,39100,39140,39180,39221,39261,39301,39341, + 39382,39422,39462,39502,39542,39582,39622,39662, + 39702,39742,39782,39822,39862,39902,39942,39982, + 40021,40061,40101,40141,40180,40220,40260,40300, + 40339,40379,40418,40458,40497,40537,40576,40616, + 40655,40695,40734,40773,40813,40852,40891,40931, + 40970,41009,41048,41087,41127,41166,41205,41244, + 41283,41322,41361,41400,41439,41478,41517,41556, + 41595,41633,41672,41711,41750,41788,41827,41866, + 41904,41943,41982,42020,42059,42097,42136,42174, + 42213,42251,42290,42328,42366,42405,42443,42481, + 42520,42558,42596,42634,42672,42711,42749,42787, + 42825,42863,42901,42939,42977,43015,43053,43091, + 43128,43166,43204,43242,43280,43317,43355,43393, + 43430,43468,43506,43543,43581,43618,43656,43693, + 43731,43768,43806,43843,43880,43918,43955,43992, + 44029,44067,44104,44141,44178,44215,44252,44289, + 44326,44363,44400,44437,44474,44511,44548,44585, + 44622,44659,44695,44732,44769,44806,44842,44879, + 44915,44952,44989,45025,45062,45098,45135,45171, + 45207,45244,45280,45316,45353,45389,45425,45462, + 45498,45534,45570,45606,45642,45678,45714,45750, + 45786,45822,45858,45894,45930,45966,46002,46037, + 46073,46109,46145,46180,46216,46252,46287,46323, + 46358,46394,46429,46465,46500,46536,46571,46606, + 46642,46677,46712,46747,46783,46818,46853,46888, + 46923,46958,46993,47028,47063,47098,47133,47168, + 47203,47238,47273,47308,47342,47377,47412,47446, + 47481,47516,47550,47585,47619,47654,47688,47723, + 47757,47792,47826,47860,47895,47929,47963,47998, + 48032,48066,48100,48134,48168,48202,48237,48271, + 48305,48338,48372,48406,48440,48474,48508,48542, + 48575,48609,48643,48676,48710,48744,48777,48811, + 48844,48878,48911,48945,48978,49012,49045,49078, + 49112,49145,49178,49211,49244,49278,49311,49344, + 49377,49410,49443,49476,49509,49542,49575,49608, + 49640,49673,49706,49739,49771,49804,49837,49869, + 49902,49935,49967,50000,50032,50065,50097,50129, + 50162,50194,50226,50259,50291,50323,50355,50387, + 50420,50452,50484,50516,50548,50580,50612,50644, + 50675,50707,50739,50771,50803,50834,50866,50898, + 50929,50961,50993,51024,51056,51087,51119,51150, + 51182,51213,51244,51276,51307,51338,51369,51401, + 51432,51463,51494,51525,51556,51587,51618,51649, + 51680,51711,51742,51773,51803,51834,51865,51896, + 51926,51957,51988,52018,52049,52079,52110,52140, + 52171,52201,52231,52262,52292,52322,52353,52383, + 52413,52443,52473,52503,52534,52564,52594,52624, + 52653,52683,52713,52743,52773,52803,52832,52862, + 52892,52922,52951,52981,53010,53040,53069,53099, + 53128,53158,53187,53216,53246,53275,53304,53334, + 53363,53392,53421,53450,53479,53508,53537,53566, + 53595,53624,53653,53682,53711,53739,53768,53797, + 53826,53854,53883,53911,53940,53969,53997,54026, + 54054,54082,54111,54139,54167,54196,54224,54252, + 54280,54308,54337,54365,54393,54421,54449,54477, + 54505,54533,54560,54588,54616,54644,54672,54699, + 54727,54755,54782,54810,54837,54865,54892,54920, + 54947,54974,55002,55029,55056,55084,55111,55138, + 55165,55192,55219,55246,55274,55300,55327,55354, + 55381,55408,55435,55462,55489,55515,55542,55569, + 55595,55622,55648,55675,55701,55728,55754,55781, + 55807,55833,55860,55886,55912,55938,55965,55991, + 56017,56043,56069,56095,56121,56147,56173,56199, + 56225,56250,56276,56302,56328,56353,56379,56404, + 56430,56456,56481,56507,56532,56557,56583,56608, + 56633,56659,56684,56709,56734,56760,56785,56810, + 56835,56860,56885,56910,56935,56959,56984,57009, + 57034,57059,57083,57108,57133,57157,57182,57206, + 57231,57255,57280,57304,57329,57353,57377,57402, + 57426,57450,57474,57498,57522,57546,57570,57594, + 57618,57642,57666,57690,57714,57738,57762,57785, + 57809,57833,57856,57880,57903,57927,57950,57974, + 57997,58021,58044,58067,58091,58114,58137,58160, + 58183,58207,58230,58253,58276,58299,58322,58345, + 58367,58390,58413,58436,58459,58481,58504,58527, + 58549,58572,58594,58617,58639,58662,58684,58706, + 58729,58751,58773,58795,58818,58840,58862,58884, + 58906,58928,58950,58972,58994,59016,59038,59059, + 59081,59103,59125,59146,59168,59190,59211,59233, + 59254,59276,59297,59318,59340,59361,59382,59404, + 59425,59446,59467,59488,59509,59530,59551,59572, + 59593,59614,59635,59656,59677,59697,59718,59739, + 59759,59780,59801,59821,59842,59862,59883,59903, + 59923,59944,59964,59984,60004,60025,60045,60065, + 60085,60105,60125,60145,60165,60185,60205,60225, + 60244,60264,60284,60304,60323,60343,60363,60382, + 60402,60421,60441,60460,60479,60499,60518,60537, + 60556,60576,60595,60614,60633,60652,60671,60690, + 60709,60728,60747,60766,60785,60803,60822,60841, + 60859,60878,60897,60915,60934,60952,60971,60989, + 61007,61026,61044,61062,61081,61099,61117,61135, + 61153,61171,61189,61207,61225,61243,61261,61279, + 61297,61314,61332,61350,61367,61385,61403,61420, + 61438,61455,61473,61490,61507,61525,61542,61559, + 61577,61594,61611,61628,61645,61662,61679,61696, + 61713,61730,61747,61764,61780,61797,61814,61831, + 61847,61864,61880,61897,61913,61930,61946,61963, + 61979,61995,62012,62028,62044,62060,62076,62092, + 62108,62125,62141,62156,62172,62188,62204,62220, + 62236,62251,62267,62283,62298,62314,62329,62345, + 62360,62376,62391,62407,62422,62437,62453,62468, + 62483,62498,62513,62528,62543,62558,62573,62588, + 62603,62618,62633,62648,62662,62677,62692,62706, + 62721,62735,62750,62764,62779,62793,62808,62822, + 62836,62850,62865,62879,62893,62907,62921,62935, + 62949,62963,62977,62991,63005,63019,63032,63046, + 63060,63074,63087,63101,63114,63128,63141,63155, + 63168,63182,63195,63208,63221,63235,63248,63261, + 63274,63287,63300,63313,63326,63339,63352,63365, + 63378,63390,63403,63416,63429,63441,63454,63466, + 63479,63491,63504,63516,63528,63541,63553,63565, + 63578,63590,63602,63614,63626,63638,63650,63662, + 63674,63686,63698,63709,63721,63733,63745,63756, + 63768,63779,63791,63803,63814,63825,63837,63848, + 63859,63871,63882,63893,63904,63915,63927,63938, + 63949,63960,63971,63981,63992,64003,64014,64025, + 64035,64046,64057,64067,64078,64088,64099,64109, + 64120,64130,64140,64151,64161,64171,64181,64192, + 64202,64212,64222,64232,64242,64252,64261,64271, + 64281,64291,64301,64310,64320,64330,64339,64349, + 64358,64368,64377,64387,64396,64405,64414,64424, + 64433,64442,64451,64460,64469,64478,64487,64496, + 64505,64514,64523,64532,64540,64549,64558,64566, + 64575,64584,64592,64601,64609,64617,64626,64634, + 64642,64651,64659,64667,64675,64683,64691,64699, + 64707,64715,64723,64731,64739,64747,64754,64762, + 64770,64777,64785,64793,64800,64808,64815,64822, + 64830,64837,64844,64852,64859,64866,64873,64880, + 64887,64895,64902,64908,64915,64922,64929,64936, + 64943,64949,64956,64963,64969,64976,64982,64989, + 64995,65002,65008,65015,65021,65027,65033,65040, + 65046,65052,65058,65064,65070,65076,65082,65088, + 65094,65099,65105,65111,65117,65122,65128,65133, + 65139,65144,65150,65155,65161,65166,65171,65177, + 65182,65187,65192,65197,65202,65207,65212,65217, + 65222,65227,65232,65237,65242,65246,65251,65256, + 65260,65265,65270,65274,65279,65283,65287,65292, + 65296,65300,65305,65309,65313,65317,65321,65325, + 65329,65333,65337,65341,65345,65349,65352,65356, + 65360,65363,65367,65371,65374,65378,65381,65385, + 65388,65391,65395,65398,65401,65404,65408,65411, + 65414,65417,65420,65423,65426,65429,65431,65434, + 65437,65440,65442,65445,65448,65450,65453,65455, + 65458,65460,65463,65465,65467,65470,65472,65474, + 65476,65478,65480,65482,65484,65486,65488,65490, + 65492,65494,65496,65497,65499,65501,65502,65504, + 65505,65507,65508,65510,65511,65513,65514,65515, + 65516,65518,65519,65520,65521,65522,65523,65524, + 65525,65526,65527,65527,65528,65529,65530,65530, + 65531,65531,65532,65532,65533,65533,65534,65534, + 65534,65535,65535,65535,65535,65535,65535,65535, + 65535,65535,65535,65535,65535,65535,65535,65534, + 65534,65534,65533,65533,65532,65532,65531,65531, + 65530,65530,65529,65528,65527,65527,65526,65525, + 65524,65523,65522,65521,65520,65519,65518,65516, + 65515,65514,65513,65511,65510,65508,65507,65505, + 65504,65502,65501,65499,65497,65496,65494,65492, + 65490,65488,65486,65484,65482,65480,65478,65476, + 65474,65472,65470,65467,65465,65463,65460,65458, + 65455,65453,65450,65448,65445,65442,65440,65437, + 65434,65431,65429,65426,65423,65420,65417,65414, + 65411,65408,65404,65401,65398,65395,65391,65388, + 65385,65381,65378,65374,65371,65367,65363,65360, + 65356,65352,65349,65345,65341,65337,65333,65329, + 65325,65321,65317,65313,65309,65305,65300,65296, + 65292,65287,65283,65279,65274,65270,65265,65260, + 65256,65251,65246,65242,65237,65232,65227,65222, + 65217,65212,65207,65202,65197,65192,65187,65182, + 65177,65171,65166,65161,65155,65150,65144,65139, + 65133,65128,65122,65117,65111,65105,65099,65094, + 65088,65082,65076,65070,65064,65058,65052,65046, + 65040,65033,65027,65021,65015,65008,65002,64995, + 64989,64982,64976,64969,64963,64956,64949,64943, + 64936,64929,64922,64915,64908,64902,64895,64887, + 64880,64873,64866,64859,64852,64844,64837,64830, + 64822,64815,64808,64800,64793,64785,64777,64770, + 64762,64754,64747,64739,64731,64723,64715,64707, + 64699,64691,64683,64675,64667,64659,64651,64642, + 64634,64626,64617,64609,64600,64592,64584,64575, + 64566,64558,64549,64540,64532,64523,64514,64505, + 64496,64487,64478,64469,64460,64451,64442,64433, + 64424,64414,64405,64396,64387,64377,64368,64358, + 64349,64339,64330,64320,64310,64301,64291,64281, + 64271,64261,64252,64242,64232,64222,64212,64202, + 64192,64181,64171,64161,64151,64140,64130,64120, + 64109,64099,64088,64078,64067,64057,64046,64035, + 64025,64014,64003,63992,63981,63971,63960,63949, + 63938,63927,63915,63904,63893,63882,63871,63859, + 63848,63837,63825,63814,63803,63791,63779,63768, + 63756,63745,63733,63721,63709,63698,63686,63674, + 63662,63650,63638,63626,63614,63602,63590,63578, + 63565,63553,63541,63528,63516,63504,63491,63479, + 63466,63454,63441,63429,63416,63403,63390,63378, + 63365,63352,63339,63326,63313,63300,63287,63274, + 63261,63248,63235,63221,63208,63195,63182,63168, + 63155,63141,63128,63114,63101,63087,63074,63060, + 63046,63032,63019,63005,62991,62977,62963,62949, + 62935,62921,62907,62893,62879,62865,62850,62836, + 62822,62808,62793,62779,62764,62750,62735,62721, + 62706,62692,62677,62662,62648,62633,62618,62603, + 62588,62573,62558,62543,62528,62513,62498,62483, + 62468,62453,62437,62422,62407,62391,62376,62360, + 62345,62329,62314,62298,62283,62267,62251,62236, + 62220,62204,62188,62172,62156,62141,62125,62108, + 62092,62076,62060,62044,62028,62012,61995,61979, + 61963,61946,61930,61913,61897,61880,61864,61847, + 61831,61814,61797,61780,61764,61747,61730,61713, + 61696,61679,61662,61645,61628,61611,61594,61577, + 61559,61542,61525,61507,61490,61473,61455,61438, + 61420,61403,61385,61367,61350,61332,61314,61297, + 61279,61261,61243,61225,61207,61189,61171,61153, + 61135,61117,61099,61081,61062,61044,61026,61007, + 60989,60971,60952,60934,60915,60897,60878,60859, + 60841,60822,60803,60785,60766,60747,60728,60709, + 60690,60671,60652,60633,60614,60595,60576,60556, + 60537,60518,60499,60479,60460,60441,60421,60402, + 60382,60363,60343,60323,60304,60284,60264,60244, + 60225,60205,60185,60165,60145,60125,60105,60085, + 60065,60045,60025,60004,59984,59964,59944,59923, + 59903,59883,59862,59842,59821,59801,59780,59759, + 59739,59718,59697,59677,59656,59635,59614,59593, + 59572,59551,59530,59509,59488,59467,59446,59425, + 59404,59382,59361,59340,59318,59297,59276,59254, + 59233,59211,59190,59168,59146,59125,59103,59081, + 59059,59038,59016,58994,58972,58950,58928,58906, + 58884,58862,58840,58818,58795,58773,58751,58729, + 58706,58684,58662,58639,58617,58594,58572,58549, + 58527,58504,58481,58459,58436,58413,58390,58367, + 58345,58322,58299,58276,58253,58230,58207,58183, + 58160,58137,58114,58091,58067,58044,58021,57997, + 57974,57950,57927,57903,57880,57856,57833,57809, + 57785,57762,57738,57714,57690,57666,57642,57618, + 57594,57570,57546,57522,57498,57474,57450,57426, + 57402,57377,57353,57329,57304,57280,57255,57231, + 57206,57182,57157,57133,57108,57083,57059,57034, + 57009,56984,56959,56935,56910,56885,56860,56835, + 56810,56785,56760,56734,56709,56684,56659,56633, + 56608,56583,56557,56532,56507,56481,56456,56430, + 56404,56379,56353,56328,56302,56276,56250,56225, + 56199,56173,56147,56121,56095,56069,56043,56017, + 55991,55965,55938,55912,55886,55860,55833,55807, + 55781,55754,55728,55701,55675,55648,55622,55595, + 55569,55542,55515,55489,55462,55435,55408,55381, + 55354,55327,55300,55274,55246,55219,55192,55165, + 55138,55111,55084,55056,55029,55002,54974,54947, + 54920,54892,54865,54837,54810,54782,54755,54727, + 54699,54672,54644,54616,54588,54560,54533,54505, + 54477,54449,54421,54393,54365,54337,54308,54280, + 54252,54224,54196,54167,54139,54111,54082,54054, + 54026,53997,53969,53940,53911,53883,53854,53826, + 53797,53768,53739,53711,53682,53653,53624,53595, + 53566,53537,53508,53479,53450,53421,53392,53363, + 53334,53304,53275,53246,53216,53187,53158,53128, + 53099,53069,53040,53010,52981,52951,52922,52892, + 52862,52832,52803,52773,52743,52713,52683,52653, + 52624,52594,52564,52534,52503,52473,52443,52413, + 52383,52353,52322,52292,52262,52231,52201,52171, + 52140,52110,52079,52049,52018,51988,51957,51926, + 51896,51865,51834,51803,51773,51742,51711,51680, + 51649,51618,51587,51556,51525,51494,51463,51432, + 51401,51369,51338,51307,51276,51244,51213,51182, + 51150,51119,51087,51056,51024,50993,50961,50929, + 50898,50866,50834,50803,50771,50739,50707,50675, + 50644,50612,50580,50548,50516,50484,50452,50420, + 50387,50355,50323,50291,50259,50226,50194,50162, + 50129,50097,50065,50032,50000,49967,49935,49902, + 49869,49837,49804,49771,49739,49706,49673,49640, + 49608,49575,49542,49509,49476,49443,49410,49377, + 49344,49311,49278,49244,49211,49178,49145,49112, + 49078,49045,49012,48978,48945,48911,48878,48844, + 48811,48777,48744,48710,48676,48643,48609,48575, + 48542,48508,48474,48440,48406,48372,48338,48304, + 48271,48237,48202,48168,48134,48100,48066,48032, + 47998,47963,47929,47895,47860,47826,47792,47757, + 47723,47688,47654,47619,47585,47550,47516,47481, + 47446,47412,47377,47342,47308,47273,47238,47203, + 47168,47133,47098,47063,47028,46993,46958,46923, + 46888,46853,46818,46783,46747,46712,46677,46642, + 46606,46571,46536,46500,46465,46429,46394,46358, + 46323,46287,46252,46216,46180,46145,46109,46073, + 46037,46002,45966,45930,45894,45858,45822,45786, + 45750,45714,45678,45642,45606,45570,45534,45498, + 45462,45425,45389,45353,45316,45280,45244,45207, + 45171,45135,45098,45062,45025,44989,44952,44915, + 44879,44842,44806,44769,44732,44695,44659,44622, + 44585,44548,44511,44474,44437,44400,44363,44326, + 44289,44252,44215,44178,44141,44104,44067,44029, + 43992,43955,43918,43880,43843,43806,43768,43731, + 43693,43656,43618,43581,43543,43506,43468,43430, + 43393,43355,43317,43280,43242,43204,43166,43128, + 43091,43053,43015,42977,42939,42901,42863,42825, + 42787,42749,42711,42672,42634,42596,42558,42520, + 42481,42443,42405,42366,42328,42290,42251,42213, + 42174,42136,42097,42059,42020,41982,41943,41904, + 41866,41827,41788,41750,41711,41672,41633,41595, + 41556,41517,41478,41439,41400,41361,41322,41283, + 41244,41205,41166,41127,41088,41048,41009,40970, + 40931,40891,40852,40813,40773,40734,40695,40655, + 40616,40576,40537,40497,40458,40418,40379,40339, + 40300,40260,40220,40180,40141,40101,40061,40021, + 39982,39942,39902,39862,39822,39782,39742,39702, + 39662,39622,39582,39542,39502,39462,39422,39382, + 39341,39301,39261,39221,39180,39140,39100,39059, + 39019,38979,38938,38898,38857,38817,38776,38736, + 38695,38655,38614,38573,38533,38492,38451,38411, + 38370,38329,38288,38248,38207,38166,38125,38084, + 38043,38002,37961,37920,37879,37838,37797,37756, + 37715,37674,37633,37592,37551,37509,37468,37427, + 37386,37344,37303,37262,37220,37179,37137,37096, + 37055,37013,36972,36930,36889,36847,36805,36764, + 36722,36681,36639,36597,36556,36514,36472,36430, + 36388,36347,36305,36263,36221,36179,36137,36095, + 36053,36011,35969,35927,35885,35843,35801,35759, + 35717,35675,35633,35590,35548,35506,35464,35421, + 35379,35337,35294,35252,35210,35167,35125,35082, + 35040,34997,34955,34912,34870,34827,34785,34742, + 34699,34657,34614,34571,34529,34486,34443,34400, + 34358,34315,34272,34229,34186,34143,34100,34057, + 34015,33972,33929,33886,33843,33799,33756,33713, + 33670,33627,33584,33541,33498,33454,33411,33368, + 33325,33281,33238,33195,33151,33108,33065,33021, + 32978,32934,32891,32847,32804,32760,32717,32673, + 32630,32586,32542,32499,32455,32411,32368,32324, + 32280,32236,32193,32149,32105,32061,32017,31974, + 31930,31886,31842,31798,31754,31710,31666,31622, + 31578,31534,31490,31446,31402,31357,31313,31269, + 31225,31181,31136,31092,31048,31004,30959,30915, + 30871,30826,30782,30738,30693,30649,30604,30560, + 30515,30471,30426,30382,30337,30293,30248,30204, + 30159,30114,30070,30025,29980,29936,29891,29846, + 29801,29757,29712,29667,29622,29577,29533,29488, + 29443,29398,29353,29308,29263,29218,29173,29128, + 29083,29038,28993,28948,28903,28858,28812,28767, + 28722,28677,28632,28586,28541,28496,28451,28405, + 28360,28315,28269,28224,28179,28133,28088,28042, + 27997,27952,27906,27861,27815,27770,27724,27678, + 27633,27587,27542,27496,27450,27405,27359,27313, + 27268,27222,27176,27131,27085,27039,26993,26947, + 26902,26856,26810,26764,26718,26672,26626,26580, + 26534,26488,26442,26396,26350,26304,26258,26212, + 26166,26120,26074,26028,25982,25936,25889,25843, + 25797,25751,25705,25658,25612,25566,25520,25473, + 25427,25381,25334,25288,25241,25195,25149,25102, + 25056,25009,24963,24916,24870,24823,24777,24730, + 24684,24637,24591,24544,24497,24451,24404,24357, + 24311,24264,24217,24171,24124,24077,24030,23984, + 23937,23890,23843,23796,23750,23703,23656,23609, + 23562,23515,23468,23421,23374,23327,23280,23233, + 23186,23139,23092,23045,22998,22951,22904,22857, + 22810,22763,22716,22668,22621,22574,22527,22480, + 22433,22385,22338,22291,22243,22196,22149,22102, + 22054,22007,21960,21912,21865,21817,21770,21723, + 21675,21628,21580,21533,21485,21438,21390,21343, + 21295,21248,21200,21153,21105,21057,21010,20962, + 20915,20867,20819,20772,20724,20676,20629,20581, + 20533,20485,20438,20390,20342,20294,20246,20199, + 20151,20103,20055,20007,19959,19912,19864,19816, + 19768,19720,19672,19624,19576,19528,19480,19432, + 19384,19336,19288,19240,19192,19144,19096,19048, + 19000,18951,18903,18855,18807,18759,18711,18663, + 18614,18566,18518,18470,18421,18373,18325,18277, + 18228,18180,18132,18084,18035,17987,17939,17890, + 17842,17793,17745,17697,17648,17600,17551,17503, + 17455,17406,17358,17309,17261,17212,17164,17115, + 17067,17018,16970,16921,16872,16824,16775,16727, + 16678,16629,16581,16532,16484,16435,16386,16338, + 16289,16240,16191,16143,16094,16045,15997,15948, + 15899,15850,15802,15753,15704,15655,15606,15557, + 15509,15460,15411,15362,15313,15264,15215,15167, + 15118,15069,15020,14971,14922,14873,14824,14775, + 14726,14677,14628,14579,14530,14481,14432,14383, + 14334,14285,14236,14187,14138,14089,14040,13990, + 13941,13892,13843,13794,13745,13696,13646,13597, + 13548,13499,13450,13401,13351,13302,13253,13204, + 13154,13105,13056,13007,12957,12908,12859,12810, + 12760,12711,12662,12612,12563,12514,12464,12415, + 12366,12316,12267,12218,12168,12119,12069,12020, + 11970,11921,11872,11822,11773,11723,11674,11624, + 11575,11525,11476,11426,11377,11327,11278,11228, + 11179,11129,11080,11030,10981,10931,10882,10832, + 10782,10733,10683,10634,10584,10534,10485,10435, + 10386,10336,10286,10237,10187,10137,10088,10038, + 9988,9939,9889,9839,9790,9740,9690,9640, + 9591,9541,9491,9442,9392,9342,9292,9243, + 9193,9143,9093,9043,8994,8944,8894,8844, + 8794,8745,8695,8645,8595,8545,8496,8446, + 8396,8346,8296,8246,8196,8147,8097,8047, + 7997,7947,7897,7847,7797,7747,7697,7648, + 7598,7548,7498,7448,7398,7348,7298,7248, + 7198,7148,7098,7048,6998,6948,6898,6848, + 6798,6748,6698,6648,6598,6548,6498,6448, + 6398,6348,6298,6248,6198,6148,6098,6048, + 5998,5948,5898,5848,5798,5748,5697,5647, + 5597,5547,5497,5447,5397,5347,5297,5247, + 5197,5146,5096,5046,4996,4946,4896,4846, + 4796,4745,4695,4645,4595,4545,4495,4445, + 4394,4344,4294,4244,4194,4144,4093,4043, + 3993,3943,3893,3843,3792,3742,3692,3642, + 3592,3541,3491,3441,3391,3341,3291,3240, + 3190,3140,3090,3039,2989,2939,2889,2839, + 2788,2738,2688,2638,2587,2537,2487,2437, + 2387,2336,2286,2236,2186,2135,2085,2035, + 1985,1934,1884,1834,1784,1733,1683,1633, + 1583,1532,1482,1432,1382,1331,1281,1231, + 1181,1130,1080,1030,980,929,879,829, + 779,728,678,628,578,527,477,427, + 376,326,276,226,175,125,75,25, + -25,-75,-125,-175,-226,-276,-326,-376, + -427,-477,-527,-578,-628,-678,-728,-779, + -829,-879,-929,-980,-1030,-1080,-1130,-1181, + -1231,-1281,-1331,-1382,-1432,-1482,-1532,-1583, + -1633,-1683,-1733,-1784,-1834,-1884,-1934,-1985, + -2035,-2085,-2135,-2186,-2236,-2286,-2336,-2387, + -2437,-2487,-2537,-2588,-2638,-2688,-2738,-2788, + -2839,-2889,-2939,-2989,-3039,-3090,-3140,-3190, + -3240,-3291,-3341,-3391,-3441,-3491,-3541,-3592, + -3642,-3692,-3742,-3792,-3843,-3893,-3943,-3993, + -4043,-4093,-4144,-4194,-4244,-4294,-4344,-4394, + -4445,-4495,-4545,-4595,-4645,-4695,-4745,-4796, + -4846,-4896,-4946,-4996,-5046,-5096,-5146,-5197, + -5247,-5297,-5347,-5397,-5447,-5497,-5547,-5597, + -5647,-5697,-5748,-5798,-5848,-5898,-5948,-5998, + -6048,-6098,-6148,-6198,-6248,-6298,-6348,-6398, + -6448,-6498,-6548,-6598,-6648,-6698,-6748,-6798, + -6848,-6898,-6948,-6998,-7048,-7098,-7148,-7198, + -7248,-7298,-7348,-7398,-7448,-7498,-7548,-7598, + -7648,-7697,-7747,-7797,-7847,-7897,-7947,-7997, + -8047,-8097,-8147,-8196,-8246,-8296,-8346,-8396, + -8446,-8496,-8545,-8595,-8645,-8695,-8745,-8794, + -8844,-8894,-8944,-8994,-9043,-9093,-9143,-9193, + -9243,-9292,-9342,-9392,-9442,-9491,-9541,-9591, + -9640,-9690,-9740,-9790,-9839,-9889,-9939,-9988, + -10038,-10088,-10137,-10187,-10237,-10286,-10336,-10386, + -10435,-10485,-10534,-10584,-10634,-10683,-10733,-10782, + -10832,-10882,-10931,-10981,-11030,-11080,-11129,-11179, + -11228,-11278,-11327,-11377,-11426,-11476,-11525,-11575, + -11624,-11674,-11723,-11773,-11822,-11872,-11921,-11970, + -12020,-12069,-12119,-12168,-12218,-12267,-12316,-12366, + -12415,-12464,-12514,-12563,-12612,-12662,-12711,-12760, + -12810,-12859,-12908,-12957,-13007,-13056,-13105,-13154, + -13204,-13253,-13302,-13351,-13401,-13450,-13499,-13548, + -13597,-13647,-13696,-13745,-13794,-13843,-13892,-13941, + -13990,-14040,-14089,-14138,-14187,-14236,-14285,-14334, + -14383,-14432,-14481,-14530,-14579,-14628,-14677,-14726, + -14775,-14824,-14873,-14922,-14971,-15020,-15069,-15118, + -15167,-15215,-15264,-15313,-15362,-15411,-15460,-15509, + -15557,-15606,-15655,-15704,-15753,-15802,-15850,-15899, + -15948,-15997,-16045,-16094,-16143,-16191,-16240,-16289, + -16338,-16386,-16435,-16484,-16532,-16581,-16629,-16678, + -16727,-16775,-16824,-16872,-16921,-16970,-17018,-17067, + -17115,-17164,-17212,-17261,-17309,-17358,-17406,-17455, + -17503,-17551,-17600,-17648,-17697,-17745,-17793,-17842, + -17890,-17939,-17987,-18035,-18084,-18132,-18180,-18228, + -18277,-18325,-18373,-18421,-18470,-18518,-18566,-18614, + -18663,-18711,-18759,-18807,-18855,-18903,-18951,-19000, + -19048,-19096,-19144,-19192,-19240,-19288,-19336,-19384, + -19432,-19480,-19528,-19576,-19624,-19672,-19720,-19768, + -19816,-19864,-19912,-19959,-20007,-20055,-20103,-20151, + -20199,-20246,-20294,-20342,-20390,-20438,-20485,-20533, + -20581,-20629,-20676,-20724,-20772,-20819,-20867,-20915, + -20962,-21010,-21057,-21105,-21153,-21200,-21248,-21295, + -21343,-21390,-21438,-21485,-21533,-21580,-21628,-21675, + -21723,-21770,-21817,-21865,-21912,-21960,-22007,-22054, + -22102,-22149,-22196,-22243,-22291,-22338,-22385,-22433, + -22480,-22527,-22574,-22621,-22668,-22716,-22763,-22810, + -22857,-22904,-22951,-22998,-23045,-23092,-23139,-23186, + -23233,-23280,-23327,-23374,-23421,-23468,-23515,-23562, + -23609,-23656,-23703,-23750,-23796,-23843,-23890,-23937, + -23984,-24030,-24077,-24124,-24171,-24217,-24264,-24311, + -24357,-24404,-24451,-24497,-24544,-24591,-24637,-24684, + -24730,-24777,-24823,-24870,-24916,-24963,-25009,-25056, + -25102,-25149,-25195,-25241,-25288,-25334,-25381,-25427, + -25473,-25520,-25566,-25612,-25658,-25705,-25751,-25797, + -25843,-25889,-25936,-25982,-26028,-26074,-26120,-26166, + -26212,-26258,-26304,-26350,-26396,-26442,-26488,-26534, + -26580,-26626,-26672,-26718,-26764,-26810,-26856,-26902, + -26947,-26993,-27039,-27085,-27131,-27176,-27222,-27268, + -27313,-27359,-27405,-27450,-27496,-27542,-27587,-27633, + -27678,-27724,-27770,-27815,-27861,-27906,-27952,-27997, + -28042,-28088,-28133,-28179,-28224,-28269,-28315,-28360, + -28405,-28451,-28496,-28541,-28586,-28632,-28677,-28722, + -28767,-28812,-28858,-28903,-28948,-28993,-29038,-29083, + -29128,-29173,-29218,-29263,-29308,-29353,-29398,-29443, + -29488,-29533,-29577,-29622,-29667,-29712,-29757,-29801, + -29846,-29891,-29936,-29980,-30025,-30070,-30114,-30159, + -30204,-30248,-30293,-30337,-30382,-30426,-30471,-30515, + -30560,-30604,-30649,-30693,-30738,-30782,-30826,-30871, + -30915,-30959,-31004,-31048,-31092,-31136,-31181,-31225, + -31269,-31313,-31357,-31402,-31446,-31490,-31534,-31578, + -31622,-31666,-31710,-31754,-31798,-31842,-31886,-31930, + -31974,-32017,-32061,-32105,-32149,-32193,-32236,-32280, + -32324,-32368,-32411,-32455,-32499,-32542,-32586,-32630, + -32673,-32717,-32760,-32804,-32847,-32891,-32934,-32978, + -33021,-33065,-33108,-33151,-33195,-33238,-33281,-33325, + -33368,-33411,-33454,-33498,-33541,-33584,-33627,-33670, + -33713,-33756,-33799,-33843,-33886,-33929,-33972,-34015, + -34057,-34100,-34143,-34186,-34229,-34272,-34315,-34358, + -34400,-34443,-34486,-34529,-34571,-34614,-34657,-34699, + -34742,-34785,-34827,-34870,-34912,-34955,-34997,-35040, + -35082,-35125,-35167,-35210,-35252,-35294,-35337,-35379, + -35421,-35464,-35506,-35548,-35590,-35633,-35675,-35717, + -35759,-35801,-35843,-35885,-35927,-35969,-36011,-36053, + -36095,-36137,-36179,-36221,-36263,-36305,-36347,-36388, + -36430,-36472,-36514,-36555,-36597,-36639,-36681,-36722, + -36764,-36805,-36847,-36889,-36930,-36972,-37013,-37055, + -37096,-37137,-37179,-37220,-37262,-37303,-37344,-37386, + -37427,-37468,-37509,-37551,-37592,-37633,-37674,-37715, + -37756,-37797,-37838,-37879,-37920,-37961,-38002,-38043, + -38084,-38125,-38166,-38207,-38248,-38288,-38329,-38370, + -38411,-38451,-38492,-38533,-38573,-38614,-38655,-38695, + -38736,-38776,-38817,-38857,-38898,-38938,-38979,-39019, + -39059,-39100,-39140,-39180,-39221,-39261,-39301,-39341, + -39382,-39422,-39462,-39502,-39542,-39582,-39622,-39662, + -39702,-39742,-39782,-39822,-39862,-39902,-39942,-39982, + -40021,-40061,-40101,-40141,-40180,-40220,-40260,-40299, + -40339,-40379,-40418,-40458,-40497,-40537,-40576,-40616, + -40655,-40695,-40734,-40773,-40813,-40852,-40891,-40931, + -40970,-41009,-41048,-41087,-41127,-41166,-41205,-41244, + -41283,-41322,-41361,-41400,-41439,-41478,-41517,-41556, + -41595,-41633,-41672,-41711,-41750,-41788,-41827,-41866, + -41904,-41943,-41982,-42020,-42059,-42097,-42136,-42174, + -42213,-42251,-42290,-42328,-42366,-42405,-42443,-42481, + -42520,-42558,-42596,-42634,-42672,-42711,-42749,-42787, + -42825,-42863,-42901,-42939,-42977,-43015,-43053,-43091, + -43128,-43166,-43204,-43242,-43280,-43317,-43355,-43393, + -43430,-43468,-43506,-43543,-43581,-43618,-43656,-43693, + -43731,-43768,-43806,-43843,-43880,-43918,-43955,-43992, + -44029,-44067,-44104,-44141,-44178,-44215,-44252,-44289, + -44326,-44363,-44400,-44437,-44474,-44511,-44548,-44585, + -44622,-44659,-44695,-44732,-44769,-44806,-44842,-44879, + -44915,-44952,-44989,-45025,-45062,-45098,-45135,-45171, + -45207,-45244,-45280,-45316,-45353,-45389,-45425,-45462, + -45498,-45534,-45570,-45606,-45642,-45678,-45714,-45750, + -45786,-45822,-45858,-45894,-45930,-45966,-46002,-46037, + -46073,-46109,-46145,-46180,-46216,-46252,-46287,-46323, + -46358,-46394,-46429,-46465,-46500,-46536,-46571,-46606, + -46642,-46677,-46712,-46747,-46783,-46818,-46853,-46888, + -46923,-46958,-46993,-47028,-47063,-47098,-47133,-47168, + -47203,-47238,-47273,-47308,-47342,-47377,-47412,-47446, + -47481,-47516,-47550,-47585,-47619,-47654,-47688,-47723, + -47757,-47792,-47826,-47860,-47895,-47929,-47963,-47998, + -48032,-48066,-48100,-48134,-48168,-48202,-48236,-48271, + -48304,-48338,-48372,-48406,-48440,-48474,-48508,-48542, + -48575,-48609,-48643,-48676,-48710,-48744,-48777,-48811, + -48844,-48878,-48911,-48945,-48978,-49012,-49045,-49078, + -49112,-49145,-49178,-49211,-49244,-49278,-49311,-49344, + -49377,-49410,-49443,-49476,-49509,-49542,-49575,-49608, + -49640,-49673,-49706,-49739,-49771,-49804,-49837,-49869, + -49902,-49935,-49967,-50000,-50032,-50065,-50097,-50129, + -50162,-50194,-50226,-50259,-50291,-50323,-50355,-50387, + -50420,-50452,-50484,-50516,-50548,-50580,-50612,-50644, + -50675,-50707,-50739,-50771,-50803,-50834,-50866,-50898, + -50929,-50961,-50993,-51024,-51056,-51087,-51119,-51150, + -51182,-51213,-51244,-51276,-51307,-51338,-51369,-51401, + -51432,-51463,-51494,-51525,-51556,-51587,-51618,-51649, + -51680,-51711,-51742,-51773,-51803,-51834,-51865,-51896, + -51926,-51957,-51988,-52018,-52049,-52079,-52110,-52140, + -52171,-52201,-52231,-52262,-52292,-52322,-52353,-52383, + -52413,-52443,-52473,-52503,-52534,-52564,-52594,-52624, + -52653,-52683,-52713,-52743,-52773,-52803,-52832,-52862, + -52892,-52922,-52951,-52981,-53010,-53040,-53069,-53099, + -53128,-53158,-53187,-53216,-53246,-53275,-53304,-53334, + -53363,-53392,-53421,-53450,-53479,-53508,-53537,-53566, + -53595,-53624,-53653,-53682,-53711,-53739,-53768,-53797, + -53826,-53854,-53883,-53911,-53940,-53969,-53997,-54026, + -54054,-54082,-54111,-54139,-54167,-54196,-54224,-54252, + -54280,-54308,-54337,-54365,-54393,-54421,-54449,-54477, + -54505,-54533,-54560,-54588,-54616,-54644,-54672,-54699, + -54727,-54755,-54782,-54810,-54837,-54865,-54892,-54920, + -54947,-54974,-55002,-55029,-55056,-55084,-55111,-55138, + -55165,-55192,-55219,-55246,-55274,-55300,-55327,-55354, + -55381,-55408,-55435,-55462,-55489,-55515,-55542,-55569, + -55595,-55622,-55648,-55675,-55701,-55728,-55754,-55781, + -55807,-55833,-55860,-55886,-55912,-55938,-55965,-55991, + -56017,-56043,-56069,-56095,-56121,-56147,-56173,-56199, + -56225,-56250,-56276,-56302,-56328,-56353,-56379,-56404, + -56430,-56456,-56481,-56507,-56532,-56557,-56583,-56608, + -56633,-56659,-56684,-56709,-56734,-56760,-56785,-56810, + -56835,-56860,-56885,-56910,-56935,-56959,-56984,-57009, + -57034,-57059,-57083,-57108,-57133,-57157,-57182,-57206, + -57231,-57255,-57280,-57304,-57329,-57353,-57377,-57402, + -57426,-57450,-57474,-57498,-57522,-57546,-57570,-57594, + -57618,-57642,-57666,-57690,-57714,-57738,-57762,-57785, + -57809,-57833,-57856,-57880,-57903,-57927,-57950,-57974, + -57997,-58021,-58044,-58067,-58091,-58114,-58137,-58160, + -58183,-58207,-58230,-58253,-58276,-58299,-58322,-58345, + -58367,-58390,-58413,-58436,-58459,-58481,-58504,-58527, + -58549,-58572,-58594,-58617,-58639,-58662,-58684,-58706, + -58729,-58751,-58773,-58795,-58818,-58840,-58862,-58884, + -58906,-58928,-58950,-58972,-58994,-59016,-59038,-59059, + -59081,-59103,-59125,-59146,-59168,-59190,-59211,-59233, + -59254,-59276,-59297,-59318,-59340,-59361,-59382,-59404, + -59425,-59446,-59467,-59488,-59509,-59530,-59551,-59572, + -59593,-59614,-59635,-59656,-59677,-59697,-59718,-59739, + -59759,-59780,-59801,-59821,-59842,-59862,-59883,-59903, + -59923,-59944,-59964,-59984,-60004,-60025,-60045,-60065, + -60085,-60105,-60125,-60145,-60165,-60185,-60205,-60225, + -60244,-60264,-60284,-60304,-60323,-60343,-60363,-60382, + -60402,-60421,-60441,-60460,-60479,-60499,-60518,-60537, + -60556,-60576,-60595,-60614,-60633,-60652,-60671,-60690, + -60709,-60728,-60747,-60766,-60785,-60803,-60822,-60841, + -60859,-60878,-60897,-60915,-60934,-60952,-60971,-60989, + -61007,-61026,-61044,-61062,-61081,-61099,-61117,-61135, + -61153,-61171,-61189,-61207,-61225,-61243,-61261,-61279, + -61297,-61314,-61332,-61350,-61367,-61385,-61403,-61420, + -61438,-61455,-61473,-61490,-61507,-61525,-61542,-61559, + -61577,-61594,-61611,-61628,-61645,-61662,-61679,-61696, + -61713,-61730,-61747,-61764,-61780,-61797,-61814,-61831, + -61847,-61864,-61880,-61897,-61913,-61930,-61946,-61963, + -61979,-61995,-62012,-62028,-62044,-62060,-62076,-62092, + -62108,-62125,-62141,-62156,-62172,-62188,-62204,-62220, + -62236,-62251,-62267,-62283,-62298,-62314,-62329,-62345, + -62360,-62376,-62391,-62407,-62422,-62437,-62453,-62468, + -62483,-62498,-62513,-62528,-62543,-62558,-62573,-62588, + -62603,-62618,-62633,-62648,-62662,-62677,-62692,-62706, + -62721,-62735,-62750,-62764,-62779,-62793,-62808,-62822, + -62836,-62850,-62865,-62879,-62893,-62907,-62921,-62935, + -62949,-62963,-62977,-62991,-63005,-63019,-63032,-63046, + -63060,-63074,-63087,-63101,-63114,-63128,-63141,-63155, + -63168,-63182,-63195,-63208,-63221,-63235,-63248,-63261, + -63274,-63287,-63300,-63313,-63326,-63339,-63352,-63365, + -63378,-63390,-63403,-63416,-63429,-63441,-63454,-63466, + -63479,-63491,-63504,-63516,-63528,-63541,-63553,-63565, + -63578,-63590,-63602,-63614,-63626,-63638,-63650,-63662, + -63674,-63686,-63698,-63709,-63721,-63733,-63745,-63756, + -63768,-63779,-63791,-63803,-63814,-63825,-63837,-63848, + -63859,-63871,-63882,-63893,-63904,-63915,-63927,-63938, + -63949,-63960,-63971,-63981,-63992,-64003,-64014,-64025, + -64035,-64046,-64057,-64067,-64078,-64088,-64099,-64109, + -64120,-64130,-64140,-64151,-64161,-64171,-64181,-64192, + -64202,-64212,-64222,-64232,-64242,-64252,-64261,-64271, + -64281,-64291,-64301,-64310,-64320,-64330,-64339,-64349, + -64358,-64368,-64377,-64387,-64396,-64405,-64414,-64424, + -64433,-64442,-64451,-64460,-64469,-64478,-64487,-64496, + -64505,-64514,-64523,-64532,-64540,-64549,-64558,-64566, + -64575,-64584,-64592,-64601,-64609,-64617,-64626,-64634, + -64642,-64651,-64659,-64667,-64675,-64683,-64691,-64699, + -64707,-64715,-64723,-64731,-64739,-64747,-64754,-64762, + -64770,-64777,-64785,-64793,-64800,-64808,-64815,-64822, + -64830,-64837,-64844,-64852,-64859,-64866,-64873,-64880, + -64887,-64895,-64902,-64908,-64915,-64922,-64929,-64936, + -64943,-64949,-64956,-64963,-64969,-64976,-64982,-64989, + -64995,-65002,-65008,-65015,-65021,-65027,-65033,-65040, + -65046,-65052,-65058,-65064,-65070,-65076,-65082,-65088, + -65094,-65099,-65105,-65111,-65117,-65122,-65128,-65133, + -65139,-65144,-65150,-65155,-65161,-65166,-65171,-65177, + -65182,-65187,-65192,-65197,-65202,-65207,-65212,-65217, + -65222,-65227,-65232,-65237,-65242,-65246,-65251,-65256, + -65260,-65265,-65270,-65274,-65279,-65283,-65287,-65292, + -65296,-65300,-65305,-65309,-65313,-65317,-65321,-65325, + -65329,-65333,-65337,-65341,-65345,-65349,-65352,-65356, + -65360,-65363,-65367,-65371,-65374,-65378,-65381,-65385, + -65388,-65391,-65395,-65398,-65401,-65404,-65408,-65411, + -65414,-65417,-65420,-65423,-65426,-65429,-65431,-65434, + -65437,-65440,-65442,-65445,-65448,-65450,-65453,-65455, + -65458,-65460,-65463,-65465,-65467,-65470,-65472,-65474, + -65476,-65478,-65480,-65482,-65484,-65486,-65488,-65490, + -65492,-65494,-65496,-65497,-65499,-65501,-65502,-65504, + -65505,-65507,-65508,-65510,-65511,-65513,-65514,-65515, + -65516,-65518,-65519,-65520,-65521,-65522,-65523,-65524, + -65525,-65526,-65527,-65527,-65528,-65529,-65530,-65530, + -65531,-65531,-65532,-65532,-65533,-65533,-65534,-65534, + -65534,-65535,-65535,-65535,-65535,-65535,-65535,-65535, + -65535,-65535,-65535,-65535,-65535,-65535,-65535,-65534, + -65534,-65534,-65533,-65533,-65532,-65532,-65531,-65531, + -65530,-65530,-65529,-65528,-65527,-65527,-65526,-65525, + -65524,-65523,-65522,-65521,-65520,-65519,-65518,-65516, + -65515,-65514,-65513,-65511,-65510,-65508,-65507,-65505, + -65504,-65502,-65501,-65499,-65497,-65496,-65494,-65492, + -65490,-65488,-65486,-65484,-65482,-65480,-65478,-65476, + -65474,-65472,-65470,-65467,-65465,-65463,-65460,-65458, + -65455,-65453,-65450,-65448,-65445,-65442,-65440,-65437, + -65434,-65431,-65429,-65426,-65423,-65420,-65417,-65414, + -65411,-65408,-65404,-65401,-65398,-65395,-65391,-65388, + -65385,-65381,-65378,-65374,-65371,-65367,-65363,-65360, + -65356,-65352,-65349,-65345,-65341,-65337,-65333,-65329, + -65325,-65321,-65317,-65313,-65309,-65305,-65300,-65296, + -65292,-65287,-65283,-65279,-65274,-65270,-65265,-65260, + -65256,-65251,-65246,-65242,-65237,-65232,-65227,-65222, + -65217,-65212,-65207,-65202,-65197,-65192,-65187,-65182, + -65177,-65171,-65166,-65161,-65155,-65150,-65144,-65139, + -65133,-65128,-65122,-65117,-65111,-65105,-65099,-65094, + -65088,-65082,-65076,-65070,-65064,-65058,-65052,-65046, + -65040,-65033,-65027,-65021,-65015,-65008,-65002,-64995, + -64989,-64982,-64976,-64969,-64963,-64956,-64949,-64943, + -64936,-64929,-64922,-64915,-64908,-64902,-64895,-64887, + -64880,-64873,-64866,-64859,-64852,-64844,-64837,-64830, + -64822,-64815,-64808,-64800,-64793,-64785,-64777,-64770, + -64762,-64754,-64747,-64739,-64731,-64723,-64715,-64707, + -64699,-64691,-64683,-64675,-64667,-64659,-64651,-64642, + -64634,-64626,-64617,-64609,-64601,-64592,-64584,-64575, + -64566,-64558,-64549,-64540,-64532,-64523,-64514,-64505, + -64496,-64487,-64478,-64469,-64460,-64451,-64442,-64433, + -64424,-64414,-64405,-64396,-64387,-64377,-64368,-64358, + -64349,-64339,-64330,-64320,-64310,-64301,-64291,-64281, + -64271,-64261,-64252,-64242,-64232,-64222,-64212,-64202, + -64192,-64181,-64171,-64161,-64151,-64140,-64130,-64120, + -64109,-64099,-64088,-64078,-64067,-64057,-64046,-64035, + -64025,-64014,-64003,-63992,-63981,-63971,-63960,-63949, + -63938,-63927,-63915,-63904,-63893,-63882,-63871,-63859, + -63848,-63837,-63825,-63814,-63803,-63791,-63779,-63768, + -63756,-63745,-63733,-63721,-63709,-63698,-63686,-63674, + -63662,-63650,-63638,-63626,-63614,-63602,-63590,-63578, + -63565,-63553,-63541,-63528,-63516,-63504,-63491,-63479, + -63466,-63454,-63441,-63429,-63416,-63403,-63390,-63378, + -63365,-63352,-63339,-63326,-63313,-63300,-63287,-63274, + -63261,-63248,-63235,-63221,-63208,-63195,-63182,-63168, + -63155,-63141,-63128,-63114,-63101,-63087,-63074,-63060, + -63046,-63032,-63019,-63005,-62991,-62977,-62963,-62949, + -62935,-62921,-62907,-62893,-62879,-62865,-62850,-62836, + -62822,-62808,-62793,-62779,-62764,-62750,-62735,-62721, + -62706,-62692,-62677,-62662,-62648,-62633,-62618,-62603, + -62588,-62573,-62558,-62543,-62528,-62513,-62498,-62483, + -62468,-62453,-62437,-62422,-62407,-62391,-62376,-62360, + -62345,-62329,-62314,-62298,-62283,-62267,-62251,-62236, + -62220,-62204,-62188,-62172,-62156,-62141,-62125,-62108, + -62092,-62076,-62060,-62044,-62028,-62012,-61995,-61979, + -61963,-61946,-61930,-61913,-61897,-61880,-61864,-61847, + -61831,-61814,-61797,-61780,-61764,-61747,-61730,-61713, + -61696,-61679,-61662,-61645,-61628,-61611,-61594,-61577, + -61559,-61542,-61525,-61507,-61490,-61473,-61455,-61438, + -61420,-61403,-61385,-61367,-61350,-61332,-61314,-61297, + -61279,-61261,-61243,-61225,-61207,-61189,-61171,-61153, + -61135,-61117,-61099,-61081,-61062,-61044,-61026,-61007, + -60989,-60971,-60952,-60934,-60915,-60897,-60878,-60859, + -60841,-60822,-60803,-60785,-60766,-60747,-60728,-60709, + -60690,-60671,-60652,-60633,-60614,-60595,-60576,-60556, + -60537,-60518,-60499,-60479,-60460,-60441,-60421,-60402, + -60382,-60363,-60343,-60323,-60304,-60284,-60264,-60244, + -60225,-60205,-60185,-60165,-60145,-60125,-60105,-60085, + -60065,-60045,-60025,-60004,-59984,-59964,-59944,-59923, + -59903,-59883,-59862,-59842,-59821,-59801,-59780,-59759, + -59739,-59718,-59697,-59677,-59656,-59635,-59614,-59593, + -59572,-59551,-59530,-59509,-59488,-59467,-59446,-59425, + -59404,-59382,-59361,-59340,-59318,-59297,-59276,-59254, + -59233,-59211,-59189,-59168,-59146,-59125,-59103,-59081, + -59059,-59038,-59016,-58994,-58972,-58950,-58928,-58906, + -58884,-58862,-58840,-58818,-58795,-58773,-58751,-58729, + -58706,-58684,-58662,-58639,-58617,-58594,-58572,-58549, + -58527,-58504,-58481,-58459,-58436,-58413,-58390,-58367, + -58345,-58322,-58299,-58276,-58253,-58230,-58207,-58183, + -58160,-58137,-58114,-58091,-58067,-58044,-58021,-57997, + -57974,-57950,-57927,-57903,-57880,-57856,-57833,-57809, + -57785,-57762,-57738,-57714,-57690,-57666,-57642,-57618, + -57594,-57570,-57546,-57522,-57498,-57474,-57450,-57426, + -57402,-57377,-57353,-57329,-57304,-57280,-57255,-57231, + -57206,-57182,-57157,-57133,-57108,-57083,-57059,-57034, + -57009,-56984,-56959,-56935,-56910,-56885,-56860,-56835, + -56810,-56785,-56760,-56734,-56709,-56684,-56659,-56633, + -56608,-56583,-56557,-56532,-56507,-56481,-56456,-56430, + -56404,-56379,-56353,-56328,-56302,-56276,-56250,-56225, + -56199,-56173,-56147,-56121,-56095,-56069,-56043,-56017, + -55991,-55965,-55938,-55912,-55886,-55860,-55833,-55807, + -55781,-55754,-55728,-55701,-55675,-55648,-55622,-55595, + -55569,-55542,-55515,-55489,-55462,-55435,-55408,-55381, + -55354,-55327,-55300,-55274,-55246,-55219,-55192,-55165, + -55138,-55111,-55084,-55056,-55029,-55002,-54974,-54947, + -54920,-54892,-54865,-54837,-54810,-54782,-54755,-54727, + -54699,-54672,-54644,-54616,-54588,-54560,-54533,-54505, + -54477,-54449,-54421,-54393,-54365,-54337,-54308,-54280, + -54252,-54224,-54196,-54167,-54139,-54111,-54082,-54054, + -54026,-53997,-53969,-53940,-53911,-53883,-53854,-53826, + -53797,-53768,-53739,-53711,-53682,-53653,-53624,-53595, + -53566,-53537,-53508,-53479,-53450,-53421,-53392,-53363, + -53334,-53304,-53275,-53246,-53216,-53187,-53158,-53128, + -53099,-53069,-53040,-53010,-52981,-52951,-52922,-52892, + -52862,-52832,-52803,-52773,-52743,-52713,-52683,-52653, + -52624,-52594,-52564,-52534,-52503,-52473,-52443,-52413, + -52383,-52353,-52322,-52292,-52262,-52231,-52201,-52171, + -52140,-52110,-52079,-52049,-52018,-51988,-51957,-51926, + -51896,-51865,-51834,-51803,-51773,-51742,-51711,-51680, + -51649,-51618,-51587,-51556,-51525,-51494,-51463,-51432, + -51401,-51369,-51338,-51307,-51276,-51244,-51213,-51182, + -51150,-51119,-51087,-51056,-51024,-50993,-50961,-50929, + -50898,-50866,-50834,-50803,-50771,-50739,-50707,-50675, + -50644,-50612,-50580,-50548,-50516,-50484,-50452,-50420, + -50387,-50355,-50323,-50291,-50259,-50226,-50194,-50162, + -50129,-50097,-50065,-50032,-50000,-49967,-49935,-49902, + -49869,-49837,-49804,-49771,-49739,-49706,-49673,-49640, + -49608,-49575,-49542,-49509,-49476,-49443,-49410,-49377, + -49344,-49311,-49278,-49244,-49211,-49178,-49145,-49112, + -49078,-49045,-49012,-48978,-48945,-48911,-48878,-48844, + -48811,-48777,-48744,-48710,-48676,-48643,-48609,-48575, + -48542,-48508,-48474,-48440,-48406,-48372,-48338,-48305, + -48271,-48237,-48202,-48168,-48134,-48100,-48066,-48032, + -47998,-47963,-47929,-47895,-47860,-47826,-47792,-47757, + -47723,-47688,-47654,-47619,-47585,-47550,-47516,-47481, + -47446,-47412,-47377,-47342,-47307,-47273,-47238,-47203, + -47168,-47133,-47098,-47063,-47028,-46993,-46958,-46923, + -46888,-46853,-46818,-46783,-46747,-46712,-46677,-46642, + -46606,-46571,-46536,-46500,-46465,-46429,-46394,-46358, + -46323,-46287,-46251,-46216,-46180,-46145,-46109,-46073, + -46037,-46002,-45966,-45930,-45894,-45858,-45822,-45786, + -45750,-45714,-45678,-45642,-45606,-45570,-45534,-45498, + -45462,-45425,-45389,-45353,-45316,-45280,-45244,-45207, + -45171,-45135,-45098,-45062,-45025,-44989,-44952,-44915, + -44879,-44842,-44806,-44769,-44732,-44695,-44659,-44622, + -44585,-44548,-44511,-44474,-44437,-44400,-44363,-44326, + -44289,-44252,-44215,-44178,-44141,-44104,-44067,-44029, + -43992,-43955,-43918,-43880,-43843,-43806,-43768,-43731, + -43693,-43656,-43618,-43581,-43543,-43506,-43468,-43430, + -43393,-43355,-43317,-43280,-43242,-43204,-43166,-43128, + -43091,-43053,-43015,-42977,-42939,-42901,-42863,-42825, + -42787,-42749,-42711,-42672,-42634,-42596,-42558,-42520, + -42481,-42443,-42405,-42366,-42328,-42290,-42251,-42213, + -42174,-42136,-42097,-42059,-42020,-41982,-41943,-41904, + -41866,-41827,-41788,-41750,-41711,-41672,-41633,-41595, + -41556,-41517,-41478,-41439,-41400,-41361,-41322,-41283, + -41244,-41205,-41166,-41127,-41087,-41048,-41009,-40970, + -40931,-40891,-40852,-40813,-40773,-40734,-40695,-40655, + -40616,-40576,-40537,-40497,-40458,-40418,-40379,-40339, + -40299,-40260,-40220,-40180,-40141,-40101,-40061,-40021, + -39982,-39942,-39902,-39862,-39822,-39782,-39742,-39702, + -39662,-39622,-39582,-39542,-39502,-39462,-39422,-39382, + -39341,-39301,-39261,-39221,-39180,-39140,-39100,-39059, + -39019,-38979,-38938,-38898,-38857,-38817,-38776,-38736, + -38695,-38655,-38614,-38573,-38533,-38492,-38451,-38411, + -38370,-38329,-38288,-38248,-38207,-38166,-38125,-38084, + -38043,-38002,-37961,-37920,-37879,-37838,-37797,-37756, + -37715,-37674,-37633,-37592,-37550,-37509,-37468,-37427, + -37386,-37344,-37303,-37262,-37220,-37179,-37137,-37096, + -37055,-37013,-36972,-36930,-36889,-36847,-36805,-36764, + -36722,-36681,-36639,-36597,-36556,-36514,-36472,-36430, + -36388,-36347,-36305,-36263,-36221,-36179,-36137,-36095, + -36053,-36011,-35969,-35927,-35885,-35843,-35801,-35759, + -35717,-35675,-35633,-35590,-35548,-35506,-35464,-35421, + -35379,-35337,-35294,-35252,-35210,-35167,-35125,-35082, + -35040,-34997,-34955,-34912,-34870,-34827,-34785,-34742, + -34699,-34657,-34614,-34571,-34529,-34486,-34443,-34400, + -34358,-34315,-34272,-34229,-34186,-34143,-34100,-34057, + -34015,-33972,-33929,-33886,-33843,-33799,-33756,-33713, + -33670,-33627,-33584,-33541,-33498,-33454,-33411,-33368, + -33325,-33281,-33238,-33195,-33151,-33108,-33065,-33021, + -32978,-32934,-32891,-32847,-32804,-32760,-32717,-32673, + -32630,-32586,-32542,-32499,-32455,-32411,-32368,-32324, + -32280,-32236,-32193,-32149,-32105,-32061,-32017,-31974, + -31930,-31886,-31842,-31798,-31754,-31710,-31666,-31622, + -31578,-31534,-31490,-31446,-31402,-31357,-31313,-31269, + -31225,-31181,-31136,-31092,-31048,-31004,-30959,-30915, + -30871,-30826,-30782,-30738,-30693,-30649,-30604,-30560, + -30515,-30471,-30426,-30382,-30337,-30293,-30248,-30204, + -30159,-30114,-30070,-30025,-29980,-29936,-29891,-29846, + -29801,-29757,-29712,-29667,-29622,-29577,-29533,-29488, + -29443,-29398,-29353,-29308,-29263,-29218,-29173,-29128, + -29083,-29038,-28993,-28948,-28903,-28858,-28812,-28767, + -28722,-28677,-28632,-28586,-28541,-28496,-28451,-28405, + -28360,-28315,-28269,-28224,-28179,-28133,-28088,-28042, + -27997,-27952,-27906,-27861,-27815,-27770,-27724,-27678, + -27633,-27587,-27542,-27496,-27450,-27405,-27359,-27313, + -27268,-27222,-27176,-27131,-27085,-27039,-26993,-26947, + -26902,-26856,-26810,-26764,-26718,-26672,-26626,-26580, + -26534,-26488,-26442,-26396,-26350,-26304,-26258,-26212, + -26166,-26120,-26074,-26028,-25982,-25936,-25889,-25843, + -25797,-25751,-25705,-25658,-25612,-25566,-25520,-25473, + -25427,-25381,-25334,-25288,-25241,-25195,-25149,-25102, + -25056,-25009,-24963,-24916,-24870,-24823,-24777,-24730, + -24684,-24637,-24591,-24544,-24497,-24451,-24404,-24357, + -24311,-24264,-24217,-24171,-24124,-24077,-24030,-23984, + -23937,-23890,-23843,-23796,-23750,-23703,-23656,-23609, + -23562,-23515,-23468,-23421,-23374,-23327,-23280,-23233, + -23186,-23139,-23092,-23045,-22998,-22951,-22904,-22857, + -22810,-22763,-22716,-22668,-22621,-22574,-22527,-22480, + -22432,-22385,-22338,-22291,-22243,-22196,-22149,-22102, + -22054,-22007,-21960,-21912,-21865,-21817,-21770,-21723, + -21675,-21628,-21580,-21533,-21485,-21438,-21390,-21343, + -21295,-21248,-21200,-21153,-21105,-21057,-21010,-20962, + -20915,-20867,-20819,-20772,-20724,-20676,-20629,-20581, + -20533,-20485,-20438,-20390,-20342,-20294,-20246,-20199, + -20151,-20103,-20055,-20007,-19959,-19912,-19864,-19816, + -19768,-19720,-19672,-19624,-19576,-19528,-19480,-19432, + -19384,-19336,-19288,-19240,-19192,-19144,-19096,-19048, + -19000,-18951,-18903,-18855,-18807,-18759,-18711,-18663, + -18614,-18566,-18518,-18470,-18421,-18373,-18325,-18277, + -18228,-18180,-18132,-18084,-18035,-17987,-17939,-17890, + -17842,-17793,-17745,-17697,-17648,-17600,-17551,-17503, + -17455,-17406,-17358,-17309,-17261,-17212,-17164,-17115, + -17067,-17018,-16970,-16921,-16872,-16824,-16775,-16727, + -16678,-16629,-16581,-16532,-16484,-16435,-16386,-16338, + -16289,-16240,-16191,-16143,-16094,-16045,-15997,-15948, + -15899,-15850,-15802,-15753,-15704,-15655,-15606,-15557, + -15509,-15460,-15411,-15362,-15313,-15264,-15215,-15167, + -15118,-15069,-15020,-14971,-14922,-14873,-14824,-14775, + -14726,-14677,-14628,-14579,-14530,-14481,-14432,-14383, + -14334,-14285,-14236,-14187,-14138,-14089,-14040,-13990, + -13941,-13892,-13843,-13794,-13745,-13696,-13647,-13597, + -13548,-13499,-13450,-13401,-13351,-13302,-13253,-13204, + -13154,-13105,-13056,-13007,-12957,-12908,-12859,-12810, + -12760,-12711,-12662,-12612,-12563,-12514,-12464,-12415, + -12366,-12316,-12267,-12217,-12168,-12119,-12069,-12020, + -11970,-11921,-11872,-11822,-11773,-11723,-11674,-11624, + -11575,-11525,-11476,-11426,-11377,-11327,-11278,-11228, + -11179,-11129,-11080,-11030,-10981,-10931,-10882,-10832, + -10782,-10733,-10683,-10634,-10584,-10534,-10485,-10435, + -10386,-10336,-10286,-10237,-10187,-10137,-10088,-10038, + -9988,-9939,-9889,-9839,-9790,-9740,-9690,-9640, + -9591,-9541,-9491,-9442,-9392,-9342,-9292,-9243, + -9193,-9143,-9093,-9043,-8994,-8944,-8894,-8844, + -8794,-8745,-8695,-8645,-8595,-8545,-8496,-8446, + -8396,-8346,-8296,-8246,-8196,-8147,-8097,-8047, + -7997,-7947,-7897,-7847,-7797,-7747,-7697,-7648, + -7598,-7548,-7498,-7448,-7398,-7348,-7298,-7248, + -7198,-7148,-7098,-7048,-6998,-6948,-6898,-6848, + -6798,-6748,-6698,-6648,-6598,-6548,-6498,-6448, + -6398,-6348,-6298,-6248,-6198,-6148,-6098,-6048, + -5998,-5948,-5898,-5848,-5798,-5747,-5697,-5647, + -5597,-5547,-5497,-5447,-5397,-5347,-5297,-5247, + -5197,-5146,-5096,-5046,-4996,-4946,-4896,-4846, + -4796,-4745,-4695,-4645,-4595,-4545,-4495,-4445, + -4394,-4344,-4294,-4244,-4194,-4144,-4093,-4043, + -3993,-3943,-3893,-3843,-3792,-3742,-3692,-3642, + -3592,-3541,-3491,-3441,-3391,-3341,-3291,-3240, + -3190,-3140,-3090,-3039,-2989,-2939,-2889,-2839, + -2788,-2738,-2688,-2638,-2588,-2537,-2487,-2437, + -2387,-2336,-2286,-2236,-2186,-2135,-2085,-2035, + -1985,-1934,-1884,-1834,-1784,-1733,-1683,-1633, + -1583,-1532,-1482,-1432,-1382,-1331,-1281,-1231, + -1181,-1130,-1080,-1030,-980,-929,-879,-829, + -779,-728,-678,-628,-578,-527,-477,-427, + -376,-326,-276,-226,-175,-125,-75,-25, + 25,75,125,175,226,276,326,376, + 427,477,527,578,628,678,728,779, + 829,879,929,980,1030,1080,1130,1181, + 1231,1281,1331,1382,1432,1482,1532,1583, + 1633,1683,1733,1784,1834,1884,1934,1985, + 2035,2085,2135,2186,2236,2286,2336,2387, + 2437,2487,2537,2587,2638,2688,2738,2788, + 2839,2889,2939,2989,3039,3090,3140,3190, + 3240,3291,3341,3391,3441,3491,3542,3592, + 3642,3692,3742,3792,3843,3893,3943,3993, + 4043,4093,4144,4194,4244,4294,4344,4394, + 4445,4495,4545,4595,4645,4695,4745,4796, + 4846,4896,4946,4996,5046,5096,5146,5197, + 5247,5297,5347,5397,5447,5497,5547,5597, + 5647,5697,5747,5798,5848,5898,5948,5998, + 6048,6098,6148,6198,6248,6298,6348,6398, + 6448,6498,6548,6598,6648,6698,6748,6798, + 6848,6898,6948,6998,7048,7098,7148,7198, + 7248,7298,7348,7398,7448,7498,7548,7598, + 7648,7697,7747,7797,7847,7897,7947,7997, + 8047,8097,8147,8196,8246,8296,8346,8396, + 8446,8496,8545,8595,8645,8695,8745,8794, + 8844,8894,8944,8994,9043,9093,9143,9193, + 9243,9292,9342,9392,9442,9491,9541,9591, + 9640,9690,9740,9790,9839,9889,9939,9988, + 10038,10088,10137,10187,10237,10286,10336,10386, + 10435,10485,10534,10584,10634,10683,10733,10782, + 10832,10882,10931,10981,11030,11080,11129,11179, + 11228,11278,11327,11377,11426,11476,11525,11575, + 11624,11674,11723,11773,11822,11872,11921,11970, + 12020,12069,12119,12168,12218,12267,12316,12366, + 12415,12464,12514,12563,12612,12662,12711,12760, + 12810,12859,12908,12957,13007,13056,13105,13154, + 13204,13253,13302,13351,13401,13450,13499,13548, + 13597,13647,13696,13745,13794,13843,13892,13941, + 13990,14040,14089,14138,14187,14236,14285,14334, + 14383,14432,14481,14530,14579,14628,14677,14726, + 14775,14824,14873,14922,14971,15020,15069,15118, + 15167,15215,15264,15313,15362,15411,15460,15509, + 15557,15606,15655,15704,15753,15802,15850,15899, + 15948,15997,16045,16094,16143,16191,16240,16289, + 16338,16386,16435,16484,16532,16581,16629,16678, + 16727,16775,16824,16872,16921,16970,17018,17067, + 17115,17164,17212,17261,17309,17358,17406,17455, + 17503,17551,17600,17648,17697,17745,17793,17842, + 17890,17939,17987,18035,18084,18132,18180,18228, + 18277,18325,18373,18421,18470,18518,18566,18614, + 18663,18711,18759,18807,18855,18903,18951,19000, + 19048,19096,19144,19192,19240,19288,19336,19384, + 19432,19480,19528,19576,19624,19672,19720,19768, + 19816,19864,19912,19959,20007,20055,20103,20151, + 20199,20246,20294,20342,20390,20438,20485,20533, + 20581,20629,20676,20724,20772,20819,20867,20915, + 20962,21010,21057,21105,21153,21200,21248,21295, + 21343,21390,21438,21485,21533,21580,21628,21675, + 21723,21770,21817,21865,21912,21960,22007,22054, + 22102,22149,22196,22243,22291,22338,22385,22432, + 22480,22527,22574,22621,22668,22716,22763,22810, + 22857,22904,22951,22998,23045,23092,23139,23186, + 23233,23280,23327,23374,23421,23468,23515,23562, + 23609,23656,23703,23750,23796,23843,23890,23937, + 23984,24030,24077,24124,24171,24217,24264,24311, + 24357,24404,24451,24497,24544,24591,24637,24684, + 24730,24777,24823,24870,24916,24963,25009,25056, + 25102,25149,25195,25241,25288,25334,25381,25427, + 25473,25520,25566,25612,25658,25705,25751,25797, + 25843,25889,25936,25982,26028,26074,26120,26166, + 26212,26258,26304,26350,26396,26442,26488,26534, + 26580,26626,26672,26718,26764,26810,26856,26902, + 26947,26993,27039,27085,27131,27176,27222,27268, + 27313,27359,27405,27450,27496,27542,27587,27633, + 27678,27724,27770,27815,27861,27906,27952,27997, + 28042,28088,28133,28179,28224,28269,28315,28360, + 28405,28451,28496,28541,28586,28632,28677,28722, + 28767,28812,28858,28903,28948,28993,29038,29083, + 29128,29173,29218,29263,29308,29353,29398,29443, + 29488,29533,29577,29622,29667,29712,29757,29801, + 29846,29891,29936,29980,30025,30070,30114,30159, + 30204,30248,30293,30337,30382,30427,30471,30516, + 30560,30604,30649,30693,30738,30782,30826,30871, + 30915,30959,31004,31048,31092,31136,31181,31225, + 31269,31313,31357,31402,31446,31490,31534,31578, + 31622,31666,31710,31754,31798,31842,31886,31930, + 31974,32017,32061,32105,32149,32193,32236,32280, + 32324,32368,32411,32455,32499,32542,32586,32630, + 32673,32717,32760,32804,32847,32891,32934,32978, + 33021,33065,33108,33151,33195,33238,33281,33325, + 33368,33411,33454,33498,33541,33584,33627,33670, + 33713,33756,33799,33843,33886,33929,33972,34015, + 34057,34100,34143,34186,34229,34272,34315,34358, + 34400,34443,34486,34529,34571,34614,34657,34699, + 34742,34785,34827,34870,34912,34955,34997,35040, + 35082,35125,35167,35210,35252,35294,35337,35379, + 35421,35464,35506,35548,35590,35633,35675,35717, + 35759,35801,35843,35885,35927,35969,36011,36053, + 36095,36137,36179,36221,36263,36305,36347,36388, + 36430,36472,36514,36556,36597,36639,36681,36722, + 36764,36805,36847,36889,36930,36972,37013,37055, + 37096,37137,37179,37220,37262,37303,37344,37386, + 37427,37468,37509,37551,37592,37633,37674,37715, + 37756,37797,37838,37879,37920,37961,38002,38043, + 38084,38125,38166,38207,38248,38288,38329,38370, + 38411,38451,38492,38533,38573,38614,38655,38695, + 38736,38776,38817,38857,38898,38938,38979,39019, + 39059,39100,39140,39180,39221,39261,39301,39341, + 39382,39422,39462,39502,39542,39582,39622,39662, + 39702,39742,39782,39822,39862,39902,39942,39982, + 40021,40061,40101,40141,40180,40220,40260,40299, + 40339,40379,40418,40458,40497,40537,40576,40616, + 40655,40695,40734,40773,40813,40852,40891,40931, + 40970,41009,41048,41087,41127,41166,41205,41244, + 41283,41322,41361,41400,41439,41478,41517,41556, + 41595,41633,41672,41711,41750,41788,41827,41866, + 41904,41943,41982,42020,42059,42097,42136,42174, + 42213,42251,42290,42328,42366,42405,42443,42481, + 42520,42558,42596,42634,42672,42711,42749,42787, + 42825,42863,42901,42939,42977,43015,43053,43091, + 43128,43166,43204,43242,43280,43317,43355,43393, + 43430,43468,43506,43543,43581,43618,43656,43693, + 43731,43768,43806,43843,43880,43918,43955,43992, + 44029,44067,44104,44141,44178,44215,44252,44289, + 44326,44363,44400,44437,44474,44511,44548,44585, + 44622,44659,44695,44732,44769,44806,44842,44879, + 44915,44952,44989,45025,45062,45098,45135,45171, + 45207,45244,45280,45316,45353,45389,45425,45462, + 45498,45534,45570,45606,45642,45678,45714,45750, + 45786,45822,45858,45894,45930,45966,46002,46037, + 46073,46109,46145,46180,46216,46252,46287,46323, + 46358,46394,46429,46465,46500,46536,46571,46606, + 46642,46677,46712,46747,46783,46818,46853,46888, + 46923,46958,46993,47028,47063,47098,47133,47168, + 47203,47238,47273,47308,47342,47377,47412,47446, + 47481,47516,47550,47585,47619,47654,47688,47723, + 47757,47792,47826,47861,47895,47929,47963,47998, + 48032,48066,48100,48134,48168,48202,48237,48271, + 48305,48338,48372,48406,48440,48474,48508,48542, + 48575,48609,48643,48676,48710,48744,48777,48811, + 48844,48878,48911,48945,48978,49012,49045,49078, + 49112,49145,49178,49211,49244,49278,49311,49344, + 49377,49410,49443,49476,49509,49542,49575,49608, + 49640,49673,49706,49739,49771,49804,49837,49869, + 49902,49935,49967,50000,50032,50064,50097,50129, + 50162,50194,50226,50259,50291,50323,50355,50387, + 50420,50452,50484,50516,50548,50580,50612,50644, + 50675,50707,50739,50771,50803,50834,50866,50898, + 50929,50961,50993,51024,51056,51087,51119,51150, + 51182,51213,51244,51276,51307,51338,51369,51401, + 51432,51463,51494,51525,51556,51587,51618,51649, + 51680,51711,51742,51773,51803,51834,51865,51896, + 51926,51957,51988,52018,52049,52079,52110,52140, + 52171,52201,52231,52262,52292,52322,52353,52383, + 52413,52443,52473,52503,52534,52564,52594,52624, + 52653,52683,52713,52743,52773,52803,52832,52862, + 52892,52922,52951,52981,53010,53040,53069,53099, + 53128,53158,53187,53216,53246,53275,53304,53334, + 53363,53392,53421,53450,53479,53508,53537,53566, + 53595,53624,53653,53682,53711,53739,53768,53797, + 53826,53854,53883,53912,53940,53969,53997,54026, + 54054,54082,54111,54139,54167,54196,54224,54252, + 54280,54309,54337,54365,54393,54421,54449,54477, + 54505,54533,54560,54588,54616,54644,54672,54699, + 54727,54755,54782,54810,54837,54865,54892,54920, + 54947,54974,55002,55029,55056,55084,55111,55138, + 55165,55192,55219,55246,55274,55300,55327,55354, + 55381,55408,55435,55462,55489,55515,55542,55569, + 55595,55622,55648,55675,55701,55728,55754,55781, + 55807,55833,55860,55886,55912,55938,55965,55991, + 56017,56043,56069,56095,56121,56147,56173,56199, + 56225,56250,56276,56302,56328,56353,56379,56404, + 56430,56456,56481,56507,56532,56557,56583,56608, + 56633,56659,56684,56709,56734,56760,56785,56810, + 56835,56860,56885,56910,56935,56959,56984,57009, + 57034,57059,57083,57108,57133,57157,57182,57206, + 57231,57255,57280,57304,57329,57353,57377,57402, + 57426,57450,57474,57498,57522,57546,57570,57594, + 57618,57642,57666,57690,57714,57738,57762,57785, + 57809,57833,57856,57880,57903,57927,57950,57974, + 57997,58021,58044,58067,58091,58114,58137,58160, + 58183,58207,58230,58253,58276,58299,58322,58345, + 58367,58390,58413,58436,58459,58481,58504,58527, + 58549,58572,58594,58617,58639,58662,58684,58706, + 58729,58751,58773,58795,58818,58840,58862,58884, + 58906,58928,58950,58972,58994,59016,59038,59059, + 59081,59103,59125,59146,59168,59190,59211,59233, + 59254,59276,59297,59318,59340,59361,59382,59404, + 59425,59446,59467,59488,59509,59530,59551,59572, + 59593,59614,59635,59656,59677,59697,59718,59739, + 59759,59780,59801,59821,59842,59862,59883,59903, + 59923,59944,59964,59984,60004,60025,60045,60065, + 60085,60105,60125,60145,60165,60185,60205,60225, + 60244,60264,60284,60304,60323,60343,60363,60382, + 60402,60421,60441,60460,60479,60499,60518,60537, + 60556,60576,60595,60614,60633,60652,60671,60690, + 60709,60728,60747,60766,60785,60803,60822,60841, + 60859,60878,60897,60915,60934,60952,60971,60989, + 61007,61026,61044,61062,61081,61099,61117,61135, + 61153,61171,61189,61207,61225,61243,61261,61279, + 61297,61314,61332,61350,61367,61385,61403,61420, + 61438,61455,61473,61490,61507,61525,61542,61559, + 61577,61594,61611,61628,61645,61662,61679,61696, + 61713,61730,61747,61764,61780,61797,61814,61831, + 61847,61864,61880,61897,61913,61930,61946,61963, + 61979,61995,62012,62028,62044,62060,62076,62092, + 62108,62125,62141,62156,62172,62188,62204,62220, + 62236,62251,62267,62283,62298,62314,62329,62345, + 62360,62376,62391,62407,62422,62437,62453,62468, + 62483,62498,62513,62528,62543,62558,62573,62588, + 62603,62618,62633,62648,62662,62677,62692,62706, + 62721,62735,62750,62764,62779,62793,62808,62822, + 62836,62850,62865,62879,62893,62907,62921,62935, + 62949,62963,62977,62991,63005,63019,63032,63046, + 63060,63074,63087,63101,63114,63128,63141,63155, + 63168,63182,63195,63208,63221,63235,63248,63261, + 63274,63287,63300,63313,63326,63339,63352,63365, + 63378,63390,63403,63416,63429,63441,63454,63466, + 63479,63491,63504,63516,63528,63541,63553,63565, + 63578,63590,63602,63614,63626,63638,63650,63662, + 63674,63686,63698,63709,63721,63733,63745,63756, + 63768,63779,63791,63803,63814,63825,63837,63848, + 63859,63871,63882,63893,63904,63915,63927,63938, + 63949,63960,63971,63981,63992,64003,64014,64025, + 64035,64046,64057,64067,64078,64088,64099,64109, + 64120,64130,64140,64151,64161,64171,64181,64192, + 64202,64212,64222,64232,64242,64252,64261,64271, + 64281,64291,64301,64310,64320,64330,64339,64349, + 64358,64368,64377,64387,64396,64405,64414,64424, + 64433,64442,64451,64460,64469,64478,64487,64496, + 64505,64514,64523,64532,64540,64549,64558,64566, + 64575,64584,64592,64600,64609,64617,64626,64634, + 64642,64651,64659,64667,64675,64683,64691,64699, + 64707,64715,64723,64731,64739,64747,64754,64762, + 64770,64777,64785,64793,64800,64808,64815,64822, + 64830,64837,64844,64852,64859,64866,64873,64880, + 64887,64895,64902,64908,64915,64922,64929,64936, + 64943,64949,64956,64963,64969,64976,64982,64989, + 64995,65002,65008,65015,65021,65027,65033,65040, + 65046,65052,65058,65064,65070,65076,65082,65088, + 65094,65099,65105,65111,65117,65122,65128,65133, + 65139,65144,65150,65155,65161,65166,65171,65177, + 65182,65187,65192,65197,65202,65207,65212,65217, + 65222,65227,65232,65237,65242,65246,65251,65256, + 65260,65265,65270,65274,65279,65283,65287,65292, + 65296,65300,65305,65309,65313,65317,65321,65325, + 65329,65333,65337,65341,65345,65349,65352,65356, + 65360,65363,65367,65371,65374,65378,65381,65385, + 65388,65391,65395,65398,65401,65404,65408,65411, + 65414,65417,65420,65423,65426,65429,65431,65434, + 65437,65440,65442,65445,65448,65450,65453,65455, + 65458,65460,65463,65465,65467,65470,65472,65474, + 65476,65478,65480,65482,65484,65486,65488,65490, + 65492,65494,65496,65497,65499,65501,65502,65504, + 65505,65507,65508,65510,65511,65513,65514,65515, + 65516,65518,65519,65520,65521,65522,65523,65524, + 65525,65526,65527,65527,65528,65529,65530,65530, + 65531,65531,65532,65532,65533,65533,65534,65534, + 65534,65535,65535,65535,65535,65535,65535,65535 }; -angle_t tantoangle[2049] = -{ - 0,333772,667544,1001315,1335086,1668857,2002626,2336395, - 2670163,3003929,3337694,3671457,4005219,4338979,4672736,5006492, - 5340245,5673995,6007743,6341488,6675230,7008968,7342704,7676435, - 8010164,8343888,8677609,9011325,9345037,9678744,10012447,10346145, - 10679838,11013526,11347209,11680887,12014558,12348225,12681885,13015539, - 13349187,13682829,14016464,14350092,14683714,15017328,15350936,15684536, - 16018129,16351714,16685291,17018860,17352422,17685974,18019518,18353054, - 18686582,19020100,19353610,19687110,20020600,20354080,20687552,21021014, - 21354466,21687906,22021338,22354758,22688168,23021568,23354956,23688332, - 24021698,24355052,24688396,25021726,25355046,25688352,26021648,26354930, - 26688200,27021456,27354702,27687932,28021150,28354356,28687548,29020724, - 29353888,29687038,30020174,30353296,30686404,31019496,31352574,31685636, - 32018684,32351718,32684734,33017736,33350722,33683692,34016648,34349584, - 34682508,35015412,35348300,35681172,36014028,36346868,36679688,37012492, - 37345276,37678044,38010792,38343524,38676240,39008936,39341612,39674272, - 40006912,40339532,40672132,41004716,41337276,41669820,42002344,42334848, - 42667332,42999796,43332236,43664660,43997060,44329444,44661800,44994140, - 45326456,45658752,45991028,46323280,46655512,46987720,47319908,47652072, - 47984212,48316332,48648428,48980500,49312548,49644576,49976580,50308556, - 50640512,50972444,51304352,51636236,51968096,52299928,52631740,52963524, - 53295284,53627020,53958728,54290412,54622068,54953704,55285308,55616888, - 55948444,56279972,56611472,56942948,57274396,57605816,57937212,58268576, - 58599916,58931228,59262512,59593768,59924992,60256192,60587364,60918508, - 61249620,61580704,61911760,62242788,62573788,62904756,63235692,63566604, - 63897480,64228332,64559148,64889940,65220696,65551424,65882120,66212788, - 66543420,66874024,67204600,67535136,67865648,68196120,68526568,68856984, - 69187360,69517712,69848024,70178304,70508560,70838776,71168960,71499112, - 71829224,72159312,72489360,72819376,73149360,73479304,73809216,74139096, - 74468936,74798744,75128520,75458264,75787968,76117632,76447264,76776864, - 77106424,77435952,77765440,78094888,78424304,78753688,79083032,79412336, - 79741608,80070840,80400032,80729192,81058312,81387392,81716432,82045440, - 82374408,82703336,83032224,83361080,83689896,84018664,84347400,84676096, - 85004760,85333376,85661952,85990488,86318984,86647448,86975864,87304240, - 87632576,87960872,88289128,88617344,88945520,89273648,89601736,89929792, - 90257792,90585760,90913688,91241568,91569408,91897200,92224960,92552672, - 92880336,93207968,93535552,93863088,94190584,94518040,94845448,95172816, - 95500136,95827416,96154648,96481832,96808976,97136080,97463136,97790144, - 98117112,98444032,98770904,99097736,99424520,99751256,100077944,100404592, - 100731192,101057744,101384248,101710712,102037128,102363488,102689808,103016080, - 103342312,103668488,103994616,104320696,104646736,104972720,105298656,105624552, - 105950392,106276184,106601928,106927624,107253272,107578872,107904416,108229920, - 108555368,108880768,109206120,109531416,109856664,110181872,110507016,110832120, - 111157168,111482168,111807112,112132008,112456856,112781648,113106392,113431080, - 113755720,114080312,114404848,114729328,115053760,115378136,115702464,116026744, - 116350960,116675128,116999248,117323312,117647320,117971272,118295176,118619024, - 118942816,119266560,119590248,119913880,120237456,120560984,120884456,121207864, - 121531224,121854528,122177784,122500976,122824112,123147200,123470224,123793200, - 124116120,124438976,124761784,125084528,125407224,125729856,126052432,126374960, - 126697424,127019832,127342184,127664472,127986712,128308888,128631008,128953072, - 129275080,129597024,129918912,130240744,130562520,130884232,131205888,131527480, - 131849016,132170496,132491912,132813272,133134576,133455816,133776992,134098120, - 134419184,134740176,135061120,135382000,135702816,136023584,136344272,136664912, - 136985488,137306016,137626464,137946864,138267184,138587456,138907664,139227808, - 139547904,139867920,140187888,140507776,140827616,141147392,141467104,141786752, - 142106336,142425856,142745312,143064720,143384048,143703312,144022512,144341664, - 144660736,144979744,145298704,145617584,145936400,146255168,146573856,146892480, - 147211040,147529536,147847968,148166336,148484640,148802880,149121056,149439152, - 149757200,150075168,150393072,150710912,151028688,151346400,151664048,151981616, - 152299136,152616576,152933952,153251264,153568496,153885680,154202784,154519824, - 154836784,155153696,155470528,155787296,156104000,156420624,156737200,157053696, - 157370112,157686480,158002768,158318976,158635136,158951216,159267232,159583168, - 159899040,160214848,160530592,160846256,161161840,161477376,161792832,162108208, - 162423520,162738768,163053952,163369040,163684080,163999040,164313936,164628752, - 164943504,165258176,165572784,165887312,166201776,166516160,166830480,167144736, - 167458912,167773008,168087040,168400992,168714880,169028688,169342432,169656096, - 169969696,170283216,170596672,170910032,171223344,171536576,171849728,172162800, - 172475808,172788736,173101600,173414384,173727104,174039728,174352288,174664784, - 174977200,175289536,175601792,175913984,176226096,176538144,176850096,177161984, - 177473792,177785536,178097200,178408784,178720288,179031728,179343088,179654368, - 179965568,180276704,180587744,180898720,181209616,181520448,181831184,182141856, - 182452448,182762960,183073408,183383760,183694048,184004240,184314368,184624416, - 184934400,185244288,185554096,185863840,186173504,186483072,186792576,187102000, - 187411344,187720608,188029808,188338912,188647936,188956896,189265760,189574560, - 189883264,190191904,190500448,190808928,191117312,191425632,191733872,192042016, - 192350096,192658096,192966000,193273840,193581584,193889264,194196848,194504352, - 194811792,195119136,195426400,195733584,196040688,196347712,196654656,196961520, - 197268304,197574992,197881616,198188144,198494592,198800960,199107248,199413456, - 199719584,200025616,200331584,200637456,200943248,201248960,201554576,201860128, - 202165584,202470960,202776256,203081456,203386592,203691632,203996592,204301472, - 204606256,204910976,205215600,205520144,205824592,206128960,206433248,206737456, - 207041584,207345616,207649568,207953424,208257216,208560912,208864512,209168048, - 209471488,209774832,210078112,210381296,210684384,210987408,211290336,211593184, - 211895936,212198608,212501184,212803680,213106096,213408432,213710672,214012816, - 214314880,214616864,214918768,215220576,215522288,215823920,216125472,216426928, - 216728304,217029584,217330784,217631904,217932928,218233856,218534704,218835472, - 219136144,219436720,219737216,220037632,220337952,220638192,220938336,221238384, - 221538352,221838240,222138032,222437728,222737344,223036880,223336304,223635664, - 223934912,224234096,224533168,224832160,225131072,225429872,225728608,226027232, - 226325776,226624240,226922608,227220880,227519056,227817152,228115168,228413088, - 228710912,229008640,229306288,229603840,229901312,230198688,230495968,230793152, - 231090256,231387280,231684192,231981024,232277760,232574416,232870960,233167440, - 233463808,233760096,234056288,234352384,234648384,234944304,235240128,235535872, - 235831504,236127056,236422512,236717888,237013152,237308336,237603424,237898416, - 238193328,238488144,238782864,239077488,239372016,239666464,239960816,240255072, - 240549232,240843312,241137280,241431168,241724960,242018656,242312256,242605776, - 242899200,243192512,243485744,243778896,244071936,244364880,244657744,244950496, - 245243168,245535744,245828224,246120608,246412912,246705104,246997216,247289216, - 247581136,247872960,248164688,248456320,248747856,249039296,249330640,249621904, - 249913056,250204128,250495088,250785968,251076736,251367424,251658016,251948512, - 252238912,252529200,252819408,253109520,253399536,253689456,253979280,254269008, - 254558640,254848176,255137632,255426976,255716224,256005376,256294432,256583392, - 256872256,257161024,257449696,257738272,258026752,258315136,258603424,258891600, - 259179696,259467696,259755600,260043392,260331104,260618704,260906224,261193632, - 261480960,261768176,262055296,262342320,262629248,262916080,263202816,263489456, - 263776000,264062432,264348784,264635024,264921168,265207216,265493168,265779024, - 266064784,266350448,266636000,266921472,267206832,267492096,267777264,268062336, - 268347312,268632192,268916960,269201632,269486208,269770688,270055072,270339360, - 270623552,270907616,271191616,271475488,271759296,272042976,272326560,272610048, - 272893440,273176736,273459936,273743040,274026048,274308928,274591744,274874432, - 275157024,275439520,275721920,276004224,276286432,276568512,276850528,277132416, - 277414240,277695936,277977536,278259040,278540448,278821728,279102944,279384032, - 279665056,279945952,280226752,280507456,280788064,281068544,281348960,281629248, - 281909472,282189568,282469568,282749440,283029248,283308960,283588544,283868032, - 284147424,284426720,284705920,284985024,285264000,285542912,285821696,286100384, - 286378976,286657440,286935840,287214112,287492320,287770400,288048384,288326240, - 288604032,288881696,289159264,289436768,289714112,289991392,290268576,290545632, - 290822592,291099456,291376224,291652896,291929440,292205888,292482272,292758528, - 293034656,293310720,293586656,293862496,294138240,294413888,294689440,294964864, - 295240192,295515424,295790560,296065600,296340512,296615360,296890080,297164704, - 297439200,297713632,297987936,298262144,298536256,298810240,299084160,299357952, - 299631648,299905248,300178720,300452128,300725408,300998592,301271680,301544640, - 301817536,302090304,302362976,302635520,302908000,303180352,303452608,303724768, - 303996800,304268768,304540608,304812320,305083968,305355520,305626944,305898272, - 306169472,306440608,306711616,306982528,307253344,307524064,307794656,308065152, - 308335552,308605856,308876032,309146112,309416096,309685984,309955744,310225408, - 310494976,310764448,311033824,311303072,311572224,311841280,312110208,312379040, - 312647776,312916416,313184960,313453376,313721696,313989920,314258016,314526016, - 314793920,315061728,315329408,315597024,315864512,316131872,316399168,316666336, - 316933408,317200384,317467232,317733984,318000640,318267200,318533632,318799968, - 319066208,319332352,319598368,319864288,320130112,320395808,320661408,320926912, - 321192320,321457632,321722816,321987904,322252864,322517760,322782528,323047200, - 323311744,323576192,323840544,324104800,324368928,324632992,324896928,325160736, - 325424448,325688096,325951584,326215008,326478304,326741504,327004608,327267584, - 327530464,327793248,328055904,328318496,328580960,328843296,329105568,329367712, - 329629760,329891680,330153536,330415264,330676864,330938400,331199808,331461120, - 331722304,331983392,332244384,332505280,332766048,333026752,333287296,333547776, - 333808128,334068384,334328544,334588576,334848512,335108352,335368064,335627712, - 335887200,336146624,336405920,336665120,336924224,337183200,337442112,337700864, - 337959552,338218112,338476576,338734944,338993184,339251328,339509376,339767296, - 340025120,340282848,340540480,340797984,341055392,341312704,341569888,341826976, - 342083968,342340832,342597600,342854272,343110848,343367296,343623648,343879904, - 344136032,344392064,344648000,344903808,345159520,345415136,345670656,345926048, - 346181344,346436512,346691616,346946592,347201440,347456224,347710880,347965440, - 348219872,348474208,348728448,348982592,349236608,349490528,349744320,349998048, - 350251648,350505152,350758528,351011808,351264992,351518048,351771040,352023872, - 352276640,352529280,352781824,353034272,353286592,353538816,353790944,354042944, - 354294880,354546656,354798368,355049952,355301440,355552800,355804096,356055264, - 356306304,356557280,356808128,357058848,357309504,357560032,357810464,358060768, - 358311008,358561088,358811104,359060992,359310784,359560480,359810048,360059520, - 360308896,360558144,360807296,361056352,361305312,361554144,361802880,362051488, - 362300032,362548448,362796736,363044960,363293056,363541024,363788928,364036704, - 364284384,364531936,364779392,365026752,365274016,365521152,365768192,366015136, - 366261952,366508672,366755296,367001792,367248192,367494496,367740704,367986784, - 368232768,368478656,368724416,368970080,369215648,369461088,369706432,369951680, - 370196800,370441824,370686752,370931584,371176288,371420896,371665408,371909792, - 372154080,372398272,372642336,372886304,373130176,373373952,373617600,373861152, - 374104608,374347936,374591168,374834304,375077312,375320224,375563040,375805760, - 376048352,376290848,376533248,376775520,377017696,377259776,377501728,377743584, - 377985344,378227008,378468544,378709984,378951328,379192544,379433664,379674688, - 379915584,380156416,380397088,380637696,380878176,381118560,381358848,381599040, - 381839104,382079072,382318912,382558656,382798304,383037856,383277280,383516640, - 383755840,383994976,384233984,384472896,384711712,384950400,385188992,385427488, - 385665888,385904160,386142336,386380384,386618368,386856224,387093984,387331616, - 387569152,387806592,388043936,388281152,388518272,388755296,388992224,389229024, - 389465728,389702336,389938816,390175200,390411488,390647680,390883744,391119712, - 391355584,391591328,391826976,392062528,392297984,392533312,392768544,393003680, - 393238720,393473632,393708448,393943168,394177760,394412256,394646656,394880960, - 395115136,395349216,395583200,395817088,396050848,396284512,396518080,396751520, - 396984864,397218112,397451264,397684288,397917248,398150080,398382784,398615424, - 398847936,399080320,399312640,399544832,399776928,400008928,400240832,400472608, - 400704288,400935872,401167328,401398720,401629984,401861120,402092192,402323136, - 402553984,402784736,403015360,403245888,403476320,403706656,403936896,404167008, - 404397024,404626944,404856736,405086432,405316032,405545536,405774912,406004224, - 406233408,406462464,406691456,406920320,407149088,407377760,407606336,407834784, - 408063136,408291392,408519520,408747584,408975520,409203360,409431072,409658720, - 409886240,410113664,410340992,410568192,410795296,411022304,411249216,411476032, - 411702720,411929312,412155808,412382176,412608480,412834656,413060736,413286720, - 413512576,413738336,413964000,414189568,414415040,414640384,414865632,415090784, - 415315840,415540800,415765632,415990368,416215008,416439552,416663968,416888288, - 417112512,417336640,417560672,417784576,418008384,418232096,418455712,418679200, - 418902624,419125920,419349120,419572192,419795200,420018080,420240864,420463552, - 420686144,420908608,421130976,421353280,421575424,421797504,422019488,422241344, - 422463104,422684768,422906336,423127776,423349120,423570400,423791520,424012576, - 424233536,424454368,424675104,424895744,425116288,425336736,425557056,425777280, - 425997408,426217440,426437376,426657184,426876928,427096544,427316064,427535488, - 427754784,427974016,428193120,428412128,428631040,428849856,429068544,429287168, - 429505664,429724064,429942368,430160576,430378656,430596672,430814560,431032352, - 431250048,431467616,431685120,431902496,432119808,432336992,432554080,432771040, - 432987936,433204736,433421408,433637984,433854464,434070848,434287104,434503296, - 434719360,434935360,435151232,435367008,435582656,435798240,436013696,436229088, - 436444352,436659520,436874592,437089568,437304416,437519200,437733856,437948416, - 438162880,438377248,438591520,438805696,439019744,439233728,439447584,439661344, - 439875008,440088576,440302048,440515392,440728672,440941824,441154880,441367872, - 441580736,441793472,442006144,442218720,442431168,442643552,442855808,443067968, - 443280032,443492000,443703872,443915648,444127296,444338880,444550336,444761696, - 444972992,445184160,445395232,445606176,445817056,446027840,446238496,446449088, - 446659552,446869920,447080192,447290400,447500448,447710432,447920320,448130112, - 448339776,448549376,448758848,448968224,449177536,449386720,449595808,449804800, - 450013664,450222464,450431168,450639776,450848256,451056640,451264960,451473152, - 451681248,451889248,452097152,452304960,452512672,452720288,452927808,453135232, - 453342528,453549760,453756864,453963904,454170816,454377632,454584384,454791008, - 454997536,455203968,455410304,455616544,455822688,456028704,456234656,456440512, - 456646240,456851904,457057472,457262912,457468256,457673536,457878688,458083744, - 458288736,458493600,458698368,458903040,459107616,459312096,459516480,459720768, - 459924960,460129056,460333056,460536960,460740736,460944448,461148064,461351584, - 461554976,461758304,461961536,462164640,462367680,462570592,462773440,462976160, - 463178816,463381344,463583776,463786144,463988384,464190560,464392608,464594560, - 464796448,464998208,465199872,465401472,465602944,465804320,466005600,466206816, - 466407904,466608896,466809824,467010624,467211328,467411936,467612480,467812896, - 468013216,468213440,468413600,468613632,468813568,469013440,469213184,469412832, - 469612416,469811872,470011232,470210528,470409696,470608800,470807776,471006688, - 471205472,471404192,471602784,471801312,471999712,472198048,472396288,472594400, - 472792448,472990400,473188256,473385984,473583648,473781216,473978688,474176064, - 474373344,474570528,474767616,474964608,475161504,475358336,475555040,475751648, - 475948192,476144608,476340928,476537184,476733312,476929376,477125344,477321184, - 477516960,477712640,477908224,478103712,478299104,478494400,478689600,478884704, - 479079744,479274656,479469504,479664224,479858880,480053408,480247872,480442240, - 480636512,480830656,481024736,481218752,481412640,481606432,481800128,481993760, - 482187264,482380704,482574016,482767264,482960416,483153472,483346432,483539296, - 483732064,483924768,484117344,484309856,484502240,484694560,484886784,485078912, - 485270944,485462880,485654720,485846464,486038144,486229696,486421184,486612576, - 486803840,486995040,487186176,487377184,487568096,487758912,487949664,488140320, - 488330880,488521312,488711712,488901984,489092160,489282240,489472256,489662176, - 489851968,490041696,490231328,490420896,490610336,490799712,490988960,491178144, - 491367232,491556224,491745120,491933920,492122656,492311264,492499808,492688256, - 492876608,493064864,493253056,493441120,493629120,493817024,494004832,494192544, - 494380160,494567712,494755136,494942496,495129760,495316928,495504000,495691008, - 495877888,496064704,496251424,496438048,496624608,496811040,496997408,497183680, - 497369856,497555936,497741920,497927840,498113632,498299360,498484992,498670560, - 498856000,499041376,499226656,499411840,499596928,499781920,499966848,500151680, - 500336416,500521056,500705600,500890080,501074464,501258752,501442944,501627040, - 501811072,501995008,502178848,502362592,502546240,502729824,502913312,503096704, - 503280000,503463232,503646368,503829408,504012352,504195200,504377984,504560672, - 504743264,504925760,505108192,505290496,505472736,505654912,505836960,506018944, - 506200832,506382624,506564320,506745952,506927488,507108928,507290272,507471552, - 507652736,507833824,508014816,508195744,508376576,508557312,508737952,508918528, - 509099008,509279392,509459680,509639904,509820032,510000064,510180000,510359872, - 510539648,510719328,510898944,511078432,511257856,511437216,511616448,511795616, - 511974688,512153664,512332576,512511392,512690112,512868768,513047296,513225792, - 513404160,513582432,513760640,513938784,514116800,514294752,514472608,514650368, - 514828064,515005664,515183168,515360608,515537952,515715200,515892352,516069440, - 516246432,516423328,516600160,516776896,516953536,517130112,517306592,517482976, - 517659264,517835488,518011616,518187680,518363648,518539520,518715296,518891008, - 519066624,519242144,519417600,519592960,519768256,519943424,520118528,520293568, - 520468480,520643328,520818112,520992800,521167392,521341888,521516320,521690656, - 521864896,522039072,522213152,522387168,522561056,522734912,522908640,523082304, - 523255872,523429376,523602784,523776096,523949312,524122464,524295552,524468512, - 524641440,524814240,524986976,525159616,525332192,525504640,525677056,525849344, - 526021568,526193728,526365792,526537760,526709632,526881440,527053152,527224800, - 527396352,527567840,527739200,527910528,528081728,528252864,528423936,528594880, - 528765760,528936576,529107296,529277920,529448480,529618944,529789344,529959648, - 530129856,530300000,530470048,530640000,530809888,530979712,531149440,531319072, - 531488608,531658080,531827488,531996800,532166016,532335168,532504224,532673184, - 532842080,533010912,533179616,533348288,533516832,533685312,533853728,534022048, - 534190272,534358432,534526496,534694496,534862400,535030240,535197984,535365632, - 535533216,535700704,535868128,536035456,536202720,536369888,536536992,536704000, - 536870912 + +angle_t tantoangle[2049] = { + 0,333772,667544,1001315,1335086,1668857,2002626,2336395, + 2670163,3003929,3337694,3671457,4005219,4338979,4672736,5006492, + 5340245,5673995,6007743,6341488,6675230,7008968,7342704,7676435, + 8010164,8343888,8677609,9011325,9345037,9678744,10012447,10346145, + 10679838,11013526,11347209,11680887,12014558,12348225,12681885,13015539, + 13349187,13682829,14016464,14350092,14683714,15017328,15350936,15684536, + 16018129,16351714,16685291,17018860,17352422,17685974,18019518,18353054, + 18686582,19020100,19353610,19687110,20020600,20354080,20687552,21021014, + 21354466,21687906,22021338,22354758,22688168,23021568,23354956,23688332, + 24021698,24355052,24688396,25021726,25355046,25688352,26021648,26354930, + 26688200,27021456,27354702,27687932,28021150,28354356,28687548,29020724, + 29353888,29687038,30020174,30353296,30686404,31019496,31352574,31685636, + 32018684,32351718,32684734,33017736,33350722,33683692,34016648,34349584, + 34682508,35015412,35348300,35681172,36014028,36346868,36679688,37012492, + 37345276,37678044,38010792,38343524,38676240,39008936,39341612,39674272, + 40006912,40339532,40672132,41004716,41337276,41669820,42002344,42334848, + 42667332,42999796,43332236,43664660,43997060,44329444,44661800,44994140, + 45326456,45658752,45991028,46323280,46655512,46987720,47319908,47652072, + 47984212,48316332,48648428,48980500,49312548,49644576,49976580,50308556, + 50640512,50972444,51304352,51636236,51968096,52299928,52631740,52963524, + 53295284,53627020,53958728,54290412,54622068,54953704,55285308,55616888, + 55948444,56279972,56611472,56942948,57274396,57605816,57937212,58268576, + 58599916,58931228,59262512,59593768,59924992,60256192,60587364,60918508, + 61249620,61580704,61911760,62242788,62573788,62904756,63235692,63566604, + 63897480,64228332,64559148,64889940,65220696,65551424,65882120,66212788, + 66543420,66874024,67204600,67535136,67865648,68196120,68526568,68856984, + 69187360,69517712,69848024,70178304,70508560,70838776,71168960,71499112, + 71829224,72159312,72489360,72819376,73149360,73479304,73809216,74139096, + 74468936,74798744,75128520,75458264,75787968,76117632,76447264,76776864, + 77106424,77435952,77765440,78094888,78424304,78753688,79083032,79412336, + 79741608,80070840,80400032,80729192,81058312,81387392,81716432,82045440, + 82374408,82703336,83032224,83361080,83689896,84018664,84347400,84676096, + 85004760,85333376,85661952,85990488,86318984,86647448,86975864,87304240, + 87632576,87960872,88289128,88617344,88945520,89273648,89601736,89929792, + 90257792,90585760,90913688,91241568,91569408,91897200,92224960,92552672, + 92880336,93207968,93535552,93863088,94190584,94518040,94845448,95172816, + 95500136,95827416,96154648,96481832,96808976,97136080,97463136,97790144, + 98117112,98444032,98770904,99097736,99424520,99751256,100077944,100404592, + 100731192,101057744,101384248,101710712,102037128,102363488,102689808,103016080, + 103342312,103668488,103994616,104320696,104646736,104972720,105298656,105624552, + 105950392,106276184,106601928,106927624,107253272,107578872,107904416,108229920, + 108555368,108880768,109206120,109531416,109856664,110181872,110507016,110832120, + 111157168,111482168,111807112,112132008,112456856,112781648,113106392,113431080, + 113755720,114080312,114404848,114729328,115053760,115378136,115702464,116026744, + 116350960,116675128,116999248,117323312,117647320,117971272,118295176,118619024, + 118942816,119266560,119590248,119913880,120237456,120560984,120884456,121207864, + 121531224,121854528,122177784,122500976,122824112,123147200,123470224,123793200, + 124116120,124438976,124761784,125084528,125407224,125729856,126052432,126374960, + 126697424,127019832,127342184,127664472,127986712,128308888,128631008,128953072, + 129275080,129597024,129918912,130240744,130562520,130884232,131205888,131527480, + 131849016,132170496,132491912,132813272,133134576,133455816,133776992,134098120, + 134419184,134740176,135061120,135382000,135702816,136023584,136344272,136664912, + 136985488,137306016,137626464,137946864,138267184,138587456,138907664,139227808, + 139547904,139867920,140187888,140507776,140827616,141147392,141467104,141786752, + 142106336,142425856,142745312,143064720,143384048,143703312,144022512,144341664, + 144660736,144979744,145298704,145617584,145936400,146255168,146573856,146892480, + 147211040,147529536,147847968,148166336,148484640,148802880,149121056,149439152, + 149757200,150075168,150393072,150710912,151028688,151346400,151664048,151981616, + 152299136,152616576,152933952,153251264,153568496,153885680,154202784,154519824, + 154836784,155153696,155470528,155787296,156104000,156420624,156737200,157053696, + 157370112,157686480,158002768,158318976,158635136,158951216,159267232,159583168, + 159899040,160214848,160530592,160846256,161161840,161477376,161792832,162108208, + 162423520,162738768,163053952,163369040,163684080,163999040,164313936,164628752, + 164943504,165258176,165572784,165887312,166201776,166516160,166830480,167144736, + 167458912,167773008,168087040,168400992,168714880,169028688,169342432,169656096, + 169969696,170283216,170596672,170910032,171223344,171536576,171849728,172162800, + 172475808,172788736,173101600,173414384,173727104,174039728,174352288,174664784, + 174977200,175289536,175601792,175913984,176226096,176538144,176850096,177161984, + 177473792,177785536,178097200,178408784,178720288,179031728,179343088,179654368, + 179965568,180276704,180587744,180898720,181209616,181520448,181831184,182141856, + 182452448,182762960,183073408,183383760,183694048,184004240,184314368,184624416, + 184934400,185244288,185554096,185863840,186173504,186483072,186792576,187102000, + 187411344,187720608,188029808,188338912,188647936,188956896,189265760,189574560, + 189883264,190191904,190500448,190808928,191117312,191425632,191733872,192042016, + 192350096,192658096,192966000,193273840,193581584,193889264,194196848,194504352, + 194811792,195119136,195426400,195733584,196040688,196347712,196654656,196961520, + 197268304,197574992,197881616,198188144,198494592,198800960,199107248,199413456, + 199719584,200025616,200331584,200637456,200943248,201248960,201554576,201860128, + 202165584,202470960,202776256,203081456,203386592,203691632,203996592,204301472, + 204606256,204910976,205215600,205520144,205824592,206128960,206433248,206737456, + 207041584,207345616,207649568,207953424,208257216,208560912,208864512,209168048, + 209471488,209774832,210078112,210381296,210684384,210987408,211290336,211593184, + 211895936,212198608,212501184,212803680,213106096,213408432,213710672,214012816, + 214314880,214616864,214918768,215220576,215522288,215823920,216125472,216426928, + 216728304,217029584,217330784,217631904,217932928,218233856,218534704,218835472, + 219136144,219436720,219737216,220037632,220337952,220638192,220938336,221238384, + 221538352,221838240,222138032,222437728,222737344,223036880,223336304,223635664, + 223934912,224234096,224533168,224832160,225131072,225429872,225728608,226027232, + 226325776,226624240,226922608,227220880,227519056,227817152,228115168,228413088, + 228710912,229008640,229306288,229603840,229901312,230198688,230495968,230793152, + 231090256,231387280,231684192,231981024,232277760,232574416,232870960,233167440, + 233463808,233760096,234056288,234352384,234648384,234944304,235240128,235535872, + 235831504,236127056,236422512,236717888,237013152,237308336,237603424,237898416, + 238193328,238488144,238782864,239077488,239372016,239666464,239960816,240255072, + 240549232,240843312,241137280,241431168,241724960,242018656,242312256,242605776, + 242899200,243192512,243485744,243778896,244071936,244364880,244657744,244950496, + 245243168,245535744,245828224,246120608,246412912,246705104,246997216,247289216, + 247581136,247872960,248164688,248456320,248747856,249039296,249330640,249621904, + 249913056,250204128,250495088,250785968,251076736,251367424,251658016,251948512, + 252238912,252529200,252819408,253109520,253399536,253689456,253979280,254269008, + 254558640,254848176,255137632,255426976,255716224,256005376,256294432,256583392, + 256872256,257161024,257449696,257738272,258026752,258315136,258603424,258891600, + 259179696,259467696,259755600,260043392,260331104,260618704,260906224,261193632, + 261480960,261768176,262055296,262342320,262629248,262916080,263202816,263489456, + 263776000,264062432,264348784,264635024,264921168,265207216,265493168,265779024, + 266064784,266350448,266636000,266921472,267206832,267492096,267777264,268062336, + 268347312,268632192,268916960,269201632,269486208,269770688,270055072,270339360, + 270623552,270907616,271191616,271475488,271759296,272042976,272326560,272610048, + 272893440,273176736,273459936,273743040,274026048,274308928,274591744,274874432, + 275157024,275439520,275721920,276004224,276286432,276568512,276850528,277132416, + 277414240,277695936,277977536,278259040,278540448,278821728,279102944,279384032, + 279665056,279945952,280226752,280507456,280788064,281068544,281348960,281629248, + 281909472,282189568,282469568,282749440,283029248,283308960,283588544,283868032, + 284147424,284426720,284705920,284985024,285264000,285542912,285821696,286100384, + 286378976,286657440,286935840,287214112,287492320,287770400,288048384,288326240, + 288604032,288881696,289159264,289436768,289714112,289991392,290268576,290545632, + 290822592,291099456,291376224,291652896,291929440,292205888,292482272,292758528, + 293034656,293310720,293586656,293862496,294138240,294413888,294689440,294964864, + 295240192,295515424,295790560,296065600,296340512,296615360,296890080,297164704, + 297439200,297713632,297987936,298262144,298536256,298810240,299084160,299357952, + 299631648,299905248,300178720,300452128,300725408,300998592,301271680,301544640, + 301817536,302090304,302362976,302635520,302908000,303180352,303452608,303724768, + 303996800,304268768,304540608,304812320,305083968,305355520,305626944,305898272, + 306169472,306440608,306711616,306982528,307253344,307524064,307794656,308065152, + 308335552,308605856,308876032,309146112,309416096,309685984,309955744,310225408, + 310494976,310764448,311033824,311303072,311572224,311841280,312110208,312379040, + 312647776,312916416,313184960,313453376,313721696,313989920,314258016,314526016, + 314793920,315061728,315329408,315597024,315864512,316131872,316399168,316666336, + 316933408,317200384,317467232,317733984,318000640,318267200,318533632,318799968, + 319066208,319332352,319598368,319864288,320130112,320395808,320661408,320926912, + 321192320,321457632,321722816,321987904,322252864,322517760,322782528,323047200, + 323311744,323576192,323840544,324104800,324368928,324632992,324896928,325160736, + 325424448,325688096,325951584,326215008,326478304,326741504,327004608,327267584, + 327530464,327793248,328055904,328318496,328580960,328843296,329105568,329367712, + 329629760,329891680,330153536,330415264,330676864,330938400,331199808,331461120, + 331722304,331983392,332244384,332505280,332766048,333026752,333287296,333547776, + 333808128,334068384,334328544,334588576,334848512,335108352,335368064,335627712, + 335887200,336146624,336405920,336665120,336924224,337183200,337442112,337700864, + 337959552,338218112,338476576,338734944,338993184,339251328,339509376,339767296, + 340025120,340282848,340540480,340797984,341055392,341312704,341569888,341826976, + 342083968,342340832,342597600,342854272,343110848,343367296,343623648,343879904, + 344136032,344392064,344648000,344903808,345159520,345415136,345670656,345926048, + 346181344,346436512,346691616,346946592,347201440,347456224,347710880,347965440, + 348219872,348474208,348728448,348982592,349236608,349490528,349744320,349998048, + 350251648,350505152,350758528,351011808,351264992,351518048,351771040,352023872, + 352276640,352529280,352781824,353034272,353286592,353538816,353790944,354042944, + 354294880,354546656,354798368,355049952,355301440,355552800,355804096,356055264, + 356306304,356557280,356808128,357058848,357309504,357560032,357810464,358060768, + 358311008,358561088,358811104,359060992,359310784,359560480,359810048,360059520, + 360308896,360558144,360807296,361056352,361305312,361554144,361802880,362051488, + 362300032,362548448,362796736,363044960,363293056,363541024,363788928,364036704, + 364284384,364531936,364779392,365026752,365274016,365521152,365768192,366015136, + 366261952,366508672,366755296,367001792,367248192,367494496,367740704,367986784, + 368232768,368478656,368724416,368970080,369215648,369461088,369706432,369951680, + 370196800,370441824,370686752,370931584,371176288,371420896,371665408,371909792, + 372154080,372398272,372642336,372886304,373130176,373373952,373617600,373861152, + 374104608,374347936,374591168,374834304,375077312,375320224,375563040,375805760, + 376048352,376290848,376533248,376775520,377017696,377259776,377501728,377743584, + 377985344,378227008,378468544,378709984,378951328,379192544,379433664,379674688, + 379915584,380156416,380397088,380637696,380878176,381118560,381358848,381599040, + 381839104,382079072,382318912,382558656,382798304,383037856,383277280,383516640, + 383755840,383994976,384233984,384472896,384711712,384950400,385188992,385427488, + 385665888,385904160,386142336,386380384,386618368,386856224,387093984,387331616, + 387569152,387806592,388043936,388281152,388518272,388755296,388992224,389229024, + 389465728,389702336,389938816,390175200,390411488,390647680,390883744,391119712, + 391355584,391591328,391826976,392062528,392297984,392533312,392768544,393003680, + 393238720,393473632,393708448,393943168,394177760,394412256,394646656,394880960, + 395115136,395349216,395583200,395817088,396050848,396284512,396518080,396751520, + 396984864,397218112,397451264,397684288,397917248,398150080,398382784,398615424, + 398847936,399080320,399312640,399544832,399776928,400008928,400240832,400472608, + 400704288,400935872,401167328,401398720,401629984,401861120,402092192,402323136, + 402553984,402784736,403015360,403245888,403476320,403706656,403936896,404167008, + 404397024,404626944,404856736,405086432,405316032,405545536,405774912,406004224, + 406233408,406462464,406691456,406920320,407149088,407377760,407606336,407834784, + 408063136,408291392,408519520,408747584,408975520,409203360,409431072,409658720, + 409886240,410113664,410340992,410568192,410795296,411022304,411249216,411476032, + 411702720,411929312,412155808,412382176,412608480,412834656,413060736,413286720, + 413512576,413738336,413964000,414189568,414415040,414640384,414865632,415090784, + 415315840,415540800,415765632,415990368,416215008,416439552,416663968,416888288, + 417112512,417336640,417560672,417784576,418008384,418232096,418455712,418679200, + 418902624,419125920,419349120,419572192,419795200,420018080,420240864,420463552, + 420686144,420908608,421130976,421353280,421575424,421797504,422019488,422241344, + 422463104,422684768,422906336,423127776,423349120,423570400,423791520,424012576, + 424233536,424454368,424675104,424895744,425116288,425336736,425557056,425777280, + 425997408,426217440,426437376,426657184,426876928,427096544,427316064,427535488, + 427754784,427974016,428193120,428412128,428631040,428849856,429068544,429287168, + 429505664,429724064,429942368,430160576,430378656,430596672,430814560,431032352, + 431250048,431467616,431685120,431902496,432119808,432336992,432554080,432771040, + 432987936,433204736,433421408,433637984,433854464,434070848,434287104,434503296, + 434719360,434935360,435151232,435367008,435582656,435798240,436013696,436229088, + 436444352,436659520,436874592,437089568,437304416,437519200,437733856,437948416, + 438162880,438377248,438591520,438805696,439019744,439233728,439447584,439661344, + 439875008,440088576,440302048,440515392,440728672,440941824,441154880,441367872, + 441580736,441793472,442006144,442218720,442431168,442643552,442855808,443067968, + 443280032,443492000,443703872,443915648,444127296,444338880,444550336,444761696, + 444972992,445184160,445395232,445606176,445817056,446027840,446238496,446449088, + 446659552,446869920,447080192,447290400,447500448,447710432,447920320,448130112, + 448339776,448549376,448758848,448968224,449177536,449386720,449595808,449804800, + 450013664,450222464,450431168,450639776,450848256,451056640,451264960,451473152, + 451681248,451889248,452097152,452304960,452512672,452720288,452927808,453135232, + 453342528,453549760,453756864,453963904,454170816,454377632,454584384,454791008, + 454997536,455203968,455410304,455616544,455822688,456028704,456234656,456440512, + 456646240,456851904,457057472,457262912,457468256,457673536,457878688,458083744, + 458288736,458493600,458698368,458903040,459107616,459312096,459516480,459720768, + 459924960,460129056,460333056,460536960,460740736,460944448,461148064,461351584, + 461554976,461758304,461961536,462164640,462367680,462570592,462773440,462976160, + 463178816,463381344,463583776,463786144,463988384,464190560,464392608,464594560, + 464796448,464998208,465199872,465401472,465602944,465804320,466005600,466206816, + 466407904,466608896,466809824,467010624,467211328,467411936,467612480,467812896, + 468013216,468213440,468413600,468613632,468813568,469013440,469213184,469412832, + 469612416,469811872,470011232,470210528,470409696,470608800,470807776,471006688, + 471205472,471404192,471602784,471801312,471999712,472198048,472396288,472594400, + 472792448,472990400,473188256,473385984,473583648,473781216,473978688,474176064, + 474373344,474570528,474767616,474964608,475161504,475358336,475555040,475751648, + 475948192,476144608,476340928,476537184,476733312,476929376,477125344,477321184, + 477516960,477712640,477908224,478103712,478299104,478494400,478689600,478884704, + 479079744,479274656,479469504,479664224,479858880,480053408,480247872,480442240, + 480636512,480830656,481024736,481218752,481412640,481606432,481800128,481993760, + 482187264,482380704,482574016,482767264,482960416,483153472,483346432,483539296, + 483732064,483924768,484117344,484309856,484502240,484694560,484886784,485078912, + 485270944,485462880,485654720,485846464,486038144,486229696,486421184,486612576, + 486803840,486995040,487186176,487377184,487568096,487758912,487949664,488140320, + 488330880,488521312,488711712,488901984,489092160,489282240,489472256,489662176, + 489851968,490041696,490231328,490420896,490610336,490799712,490988960,491178144, + 491367232,491556224,491745120,491933920,492122656,492311264,492499808,492688256, + 492876608,493064864,493253056,493441120,493629120,493817024,494004832,494192544, + 494380160,494567712,494755136,494942496,495129760,495316928,495504000,495691008, + 495877888,496064704,496251424,496438048,496624608,496811040,496997408,497183680, + 497369856,497555936,497741920,497927840,498113632,498299360,498484992,498670560, + 498856000,499041376,499226656,499411840,499596928,499781920,499966848,500151680, + 500336416,500521056,500705600,500890080,501074464,501258752,501442944,501627040, + 501811072,501995008,502178848,502362592,502546240,502729824,502913312,503096704, + 503280000,503463232,503646368,503829408,504012352,504195200,504377984,504560672, + 504743264,504925760,505108192,505290496,505472736,505654912,505836960,506018944, + 506200832,506382624,506564320,506745952,506927488,507108928,507290272,507471552, + 507652736,507833824,508014816,508195744,508376576,508557312,508737952,508918528, + 509099008,509279392,509459680,509639904,509820032,510000064,510180000,510359872, + 510539648,510719328,510898944,511078432,511257856,511437216,511616448,511795616, + 511974688,512153664,512332576,512511392,512690112,512868768,513047296,513225792, + 513404160,513582432,513760640,513938784,514116800,514294752,514472608,514650368, + 514828064,515005664,515183168,515360608,515537952,515715200,515892352,516069440, + 516246432,516423328,516600160,516776896,516953536,517130112,517306592,517482976, + 517659264,517835488,518011616,518187680,518363648,518539520,518715296,518891008, + 519066624,519242144,519417600,519592960,519768256,519943424,520118528,520293568, + 520468480,520643328,520818112,520992800,521167392,521341888,521516320,521690656, + 521864896,522039072,522213152,522387168,522561056,522734912,522908640,523082304, + 523255872,523429376,523602784,523776096,523949312,524122464,524295552,524468512, + 524641440,524814240,524986976,525159616,525332192,525504640,525677056,525849344, + 526021568,526193728,526365792,526537760,526709632,526881440,527053152,527224800, + 527396352,527567840,527739200,527910528,528081728,528252864,528423936,528594880, + 528765760,528936576,529107296,529277920,529448480,529618944,529789344,529959648, + 530129856,530300000,530470048,530640000,530809888,530979712,531149440,531319072, + 531488608,531658080,531827488,531996800,532166016,532335168,532504224,532673184, + 532842080,533010912,533179616,533348288,533516832,533685312,533853728,534022048, + 534190272,534358432,534526496,534694496,534862400,535030240,535197984,535365632, + 535533216,535700704,535868128,536035456,536202720,536369888,536536992,536704000, + 536870912 }; diff --git a/src/tables.h b/src/tables.h @@ -1,17 +1,13 @@ #ifndef __TABLES__ #define __TABLES__ -#ifdef LINUX + #include <math.h> -#else -#define PI 3.141592657 -#endif + #include "m_fixed.h" + #define FINEANGLES 8192 #define FINEMASK (FINEANGLES-1) #define ANGLETOFINESHIFT 19 -extern fixed_t finesine[5*FINEANGLES/4]; -extern fixed_t* finecosine; -extern fixed_t finetangent[FINEANGLES/2]; #define ANG45 0x20000000 #define ANG90 0x40000000 #define ANG180 0x80000000 @@ -19,10 +15,14 @@ extern fixed_t finetangent[FINEANGLES/2]; #define SLOPERANGE 2048 #define SLOPEBITS 11 #define DBITS (FRACBITS-SLOPEBITS) + typedef unsigned angle_t; -extern angle_t tantoangle[SLOPERANGE+1]; -int -SlopeDiv -( unsigned num, - unsigned den); + +extern fixed_t finesine[5*FINEANGLES/4]; +extern fixed_t* finecosine; +extern fixed_t finetangent[FINEANGLES/2]; +extern angle_t tantoangle[SLOPERANGE+1]; + +int SlopeDiv(unsigned num, unsigned den); + #endif diff --git a/src/todo b/src/todo @@ -0,0 +1,2 @@ +Fix the AI +Check if levels repeat diff --git a/src/v_video.c b/src/v_video.c @@ -1,275 +1,134 @@ +#include <stdlib.h> + #include "i_system.h" #include "r_local.h" #include "doomdef.h" #include "doomdata.h" -#include "m_bbox.h" #include "m_swap.h" +#include "m_bbox.h" #include "v_video.h" -byte* screens[5]; -int dirtybox[4]; -int usegamma; + +uchar* screens[5]; +int dirtybox[4]; + +int usegamma; void -V_MarkRect -( int x, - int y, - int width, - int height ) -{ - M_AddToBox (dirtybox, x, y); - M_AddToBox (dirtybox, x+width-1, y+height-1); -} +V_MarkRect(int x, int y, int width, int height) +{ + M_AddToBox(dirtybox, x, y); + M_AddToBox(dirtybox, x + width - 1, y + height - 1); +} + void -V_CopyRect -( int srcx, - int srcy, - int srcscrn, - int width, - int height, - int destx, - int desty, - int destscrn ) -{ - byte* src; - byte* dest; -#ifdef RANGECHECK - if (srcx<0 - ||srcx+width >SCREENWIDTH - || srcy<0 - || srcy+height>SCREENHEIGHT - ||destx<0||destx+width >SCREENWIDTH - || desty<0 - || desty+height>SCREENHEIGHT - || (unsigned)srcscrn>4 - || (unsigned)destscrn>4) - { - I_Error ("Bad V_CopyRect"); - } -#endif - V_MarkRect (destx, desty, width, height); - src = screens[srcscrn]+SCREENWIDTH*srcy+srcx; - dest = screens[destscrn]+SCREENWIDTH*desty+destx; - for ( ; height>0 ; height--) - { - memcpy (dest, src, width); - src += SCREENWIDTH; - dest += SCREENWIDTH; - } -} +V_CopyRect(int srcx, int srcy, int srcscrn, int width, int height, int destx, int desty, int destscrn) +{ + byte* src, *dest; + + V_MarkRect(destx, desty, width, height); + src = screens[srcscrn] + SCREENWIDTH * srcy + srcx; + dest = screens[destscrn] + SCREENWIDTH * desty + destx; + for (; height > 0; --height) { + memcpy(dest, src, width); + src += SCREENWIDTH; + dest += SCREENWIDTH; + } +} + void -V_DrawPatch -( int x, - int y, - int scrn, - patch_t* patch ) -{ - int count; - int col; - column_t* column; - byte* desttop; - byte* dest; - byte* source; - int w; - y -= SHORT(patch->topoffset); - x -= SHORT(patch->leftoffset); -#ifdef RANGECHECK - if (x<0 - ||x+SHORT(patch->width) >SCREENWIDTH - || y<0 - || y+SHORT(patch->height)>SCREENHEIGHT - || (unsigned)scrn>4) - { - fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y ); - fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n"); - return; - } -#endif - if (!scrn) - V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); - col = 0; - desttop = screens[scrn]+y*SCREENWIDTH+x; - w = SHORT(patch->width); - for ( ; col<w ; x++, col++, desttop++) - { - column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - while (column->topdelta != 0xff ) - { - source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; - count = column->length; - while (count--) - { - *dest = *source++; - dest += SCREENWIDTH; - } - column = (column_t *)( (byte *)column + column->length - + 4 ); - } - } -} +V_DrawPatch(int x, int y, int scrn, patch_t* patch) +{ + column_t* column; + byte* desttop, *dest, *source; + int count, col, w; + + y -= SHORT(patch->topoffset); + x -= SHORT(patch->leftoffset); + if (!scrn) + V_MarkRect(x, y, SHORT(patch->width), SHORT(patch->height)); + col = 0; + desttop = screens[scrn] + y * SCREENWIDTH + x; + w = SHORT(patch->width); + for (; col < w; ++x, ++col, ++desttop) { + column = (column_t*)((byte*)patch + LONG(patch->columnofs[col])); + while (column->topdelta != 0xff) { + source = (byte*)column + 3; + dest = desttop + column->topdelta*SCREENWIDTH; + count = column->length; + while (count--) { + *dest = *source++; + dest += SCREENWIDTH; + } + column = (column_t*)((byte*)column + column->length + 4); + } + } +} + void -V_DrawPatchFlipped -( int x, - int y, - int scrn, - patch_t* patch ) -{ - int count; - int col; - column_t* column; - byte* desttop; - byte* dest; - byte* source; - int w; - y -= SHORT(patch->topoffset); - x -= SHORT(patch->leftoffset); -#ifdef RANGECHECK - if (x<0 - ||x+SHORT(patch->width) >SCREENWIDTH - || y<0 - || y+SHORT(patch->height)>SCREENHEIGHT - || (unsigned)scrn>4) - { - fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y ); - I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped"); - } -#endif - if (!scrn) - V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); - col = 0; - desttop = screens[scrn]+y*SCREENWIDTH+x; - w = SHORT(patch->width); - for ( ; col<w ; x++, col++, desttop++) - { - column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); - while (column->topdelta != 0xff ) - { - source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; - count = column->length; - while (count--) - { - *dest = *source++; - dest += SCREENWIDTH; - } - column = (column_t *)( (byte *)column + column->length - + 4 ); - } - } -} +V_DrawPatchFlipped(int x, int y, int scrn, patch_t* patch) +{ + column_t* column; + byte* desttop, *dest, *source; + int w, count, col; + + y -= SHORT(patch->topoffset); + x -= SHORT(patch->leftoffset); + if (!scrn) + V_MarkRect(x, y, SHORT(patch->width), SHORT(patch->height)); + col = 0; + desttop = screens[scrn] + y * SCREENWIDTH + x; + w = SHORT(patch->width); + for (; col < w; ++x, ++col, ++desttop) { + column = (column_t*)((byte*)patch + LONG(patch->columnofs[w-1-col])); + while (column->topdelta != 0xff ) { + source = (byte*)column + 3; + dest = desttop + column->topdelta*SCREENWIDTH; + count = column->length; + while (count--) { + *dest = *source++; + dest += SCREENWIDTH; + } + column = (column_t*)((byte*)column + column->length + 4); + } + } +} + void -V_DrawPatchDirect -( int x, - int y, - int scrn, - patch_t* patch ) +V_DrawBlock(int x, int y, int scrn, int width, int height, byte* src) { - V_DrawPatch (x,y,scrn, patch); - /* - int count; - int col; - column_t* column; - byte* desttop; - byte* dest; - byte* source; - int w; - y -= SHORT(patch->topoffset); - x -= SHORT(patch->leftoffset); -#ifdef RANGECHECK - if (x<0 - ||x+SHORT(patch->width) >SCREENWIDTH - || y<0 - || y+SHORT(patch->height)>SCREENHEIGHT - || (unsigned)scrn>4) - { - I_Error ("Bad V_DrawPatchDirect"); - } -#endif - desttop = destscreen + y*SCREENWIDTH/4 + (x>>2); - w = SHORT(patch->width); - for ( col = 0 ; col<w ; col++) - { - outp (SC_INDEX+1,1<<(x&3)); - column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - while (column->topdelta != 0xff ) - { - source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH/4; - count = column->length; - while (count--) - { - *dest = *source++; - dest += SCREENWIDTH/4; - } - column = (column_t *)( (byte *)column + column->length - + 4 ); - } - if ( ((++x)&3) == 0 ) - desttop++; - }*/ -} + byte* dest; + + V_MarkRect(x, y, width, height); + dest = screens[scrn] + y*SCREENWIDTH+x; + while (height--) { + memcpy(dest, src, width); + src += width; + dest += SCREENWIDTH; + } +} + void -V_DrawBlock -( int x, - int y, - int scrn, - int width, - int height, - byte* src ) -{ - byte* dest; -#ifdef RANGECHECK - if (x<0 - ||x+width >SCREENWIDTH - || y<0 - || y+height>SCREENHEIGHT - || (unsigned)scrn>4 ) - { - I_Error ("Bad V_DrawBlock"); - } -#endif - V_MarkRect (x, y, width, height); - dest = screens[scrn] + y*SCREENWIDTH+x; - while (height--) - { - memcpy (dest, src, width); - src += width; - dest += SCREENWIDTH; - } -} +V_GetBlock(int x, int y, int scrn, int width, int height, byte* dest) +{ + byte* src; + + src = screens[scrn] + y * SCREENWIDTH + x; + while (height--) { + memcpy (dest, src, width); + src += SCREENWIDTH; + dest += width; + } +} + void -V_GetBlock -( int x, - int y, - int scrn, - int width, - int height, - byte* dest ) -{ - byte* src; -#ifdef RANGECHECK - if (x<0 - ||x+width >SCREENWIDTH - || y<0 - || y+height>SCREENHEIGHT - || (unsigned)scrn>4 ) - { - I_Error ("Bad V_DrawBlock"); - } -#endif - src = screens[scrn] + y*SCREENWIDTH+x; - while (height--) - { - memcpy (dest, src, width); - src += SCREENWIDTH; - dest += width; - } -} -void V_Init (void) -{ - int i; - byte* base; - base = I_AllocLow (SCREENWIDTH*SCREENHEIGHT*4); - for (i=0 ; i<4 ; i++) - screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT; +V_Init() +{ + uchar* buf; + + buf = malloc(SCREENWIDTH * SCREENHEIGHT * 4); + memset(buf, 0, SCREENWIDTH * SCREENHEIGHT * 4); + screens[0] = buf; + screens[1] = buf + SCREENWIDTH * SCREENHEIGHT; + screens[2] = buf + SCREENWIDTH * SCREENHEIGHT * 2; + screens[3] = buf + SCREENWIDTH * SCREENHEIGHT * 3; } diff --git a/src/v_video.h b/src/v_video.h @@ -1,56 +1,23 @@ #ifndef __V_VIDEO__ #define __V_VIDEO__ -#include "doomtype.h" + +#include "doomdef.h" #include "doomdef.h" #include "r_data.h" -#define CENTERY (SCREENHEIGHT/2) -extern byte* screens[5]; -extern int dirtybox[4]; -extern byte gammatable[5][256]; -extern int usegamma; -void V_Init (void); -void -V_CopyRect -( int srcx, - int srcy, - int srcscrn, - int width, - int height, - int destx, - int desty, - int destscrn ); -void -V_DrawPatch -( int x, - int y, - int scrn, - patch_t* patch); -void -V_DrawPatchDirect -( int x, - int y, - int scrn, - patch_t* patch ); -void -V_DrawBlock -( int x, - int y, - int scrn, - int width, - int height, - byte* src ); -void -V_GetBlock -( int x, - int y, - int scrn, - int width, - int height, - byte* dest ); -void -V_MarkRect -( int x, - int y, - int width, - int height ); + +#define CENTERY (SCREENHEIGHT/2) + +extern byte* screens[5]; +extern int dirtybox[4]; +extern byte gammatable[5][256]; +extern int usegamma; + +void V_Init(); +void V_CopyRect(int srcx, int srcy, int srcscrn, int width, int height, int destx, int desty, int destscrn); +void V_DrawPatch(int x, int y, int scrn, patch_t* patch); +void V_DrawPatch(int x, int y, int scrn, patch_t* patch); +void V_DrawBlock(int x, int y, int scrn, int width, int height, byte* src); +void V_GetBlock(int x, int y, int scrn, int width, int height, byte* dest); +void V_MarkRect(int x, int y, int width, int height); + #endif diff --git a/src/w_wad.c b/src/w_wad.c @@ -1,25 +1,27 @@ #include <ctype.h> #include <sys/types.h> #include <string.h> +#include <stdarg.h> #include <unistd.h> #include <malloc.h> #include <fcntl.h> #include <sys/stat.h> #include <alloca.h> -#include <stdarg.h> -#define O_BINARY 0 -#include "doomtype.h" + #include "doomdef.h" -#include "m_swap.h" #include "i_system.h" #include "z_zone.h" #include "w_wad.h" -lumpinfo_t* lumpinfo_g; -int numlumps_g; -void** lumpcache; -int reloadlump; -char* reloadname; +#define O_BINARY 0 + +lumpinfo_t* lumpinfo_g; +void** lumpcache_g; +char* reloadname; +int numlumps_g; +int reloadlump; +int info[2500][10]; +int profilecount; void unpack(uchar** buf, char* fmt, ...) @@ -73,7 +75,7 @@ unpack_filelump(uchar** buf, filelump_t* p) } void -W_AddFile(char *filename) +W_AddFile(char* filename) { lumpinfo_t* lumpinfo_p; filelump_t* filelump_p; @@ -115,63 +117,22 @@ W_AddFile(char *filename) } } -void W_Reload (void) -{ - wadinfo_t header; - int lumpcount; - lumpinfo_t* lump_p; - unsigned i; - int handle; - int length; - filelump_t* fileinfo; - if (!reloadname) - return; - if ( (handle = open (reloadname,O_RDONLY | O_BINARY)) == -1) - I_Error ("W_Reload: couldn't open %s",reloadname); - read (handle, &header, sizeof(header)); - lumpcount = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - length = lumpcount*sizeof(filelump_t); - fileinfo = alloca (length); - lseek (handle, header.infotableofs, SEEK_SET); - read (handle, fileinfo, length); - lump_p = &lumpinfo_g[reloadlump]; - for (i=reloadlump ; - i<reloadlump+lumpcount ; - i++,lump_p++, fileinfo++) - { - if (lumpcache[i]) - Z_Free (lumpcache[i]); - lump_p->position = LONG(fileinfo->filepos); - lump_p->size = LONG(fileinfo->size); - } - close (handle); -} -void W_InitMultipleFiles (char** filenames) -{ - int size; - numlumps_g = 0; - lumpinfo_g = malloc(1); - for ( ; *filenames ; filenames++) - W_AddFile (*filenames); - if (!numlumps_g) - I_Error ("W_InitFiles: no files found"); - size = numlumps_g * sizeof(*lumpcache); - lumpcache = malloc (size); - if (!lumpcache) - I_Error ("Couldn't allocate lumpcache"); - memset (lumpcache,0, size); -} -void W_InitFile (char* filename) -{ - char* names[2]; - names[0] = filename; - names[1] = NULL; - W_InitMultipleFiles (names); -} -int W_NumLumps (void) +void +W_InitMultipleFiles(char** filenames) { - return numlumps_g; + int size; + + numlumps_g = 0; + lumpinfo_g = malloc(1); + for (;*filenames; ++filenames) + W_AddFile(*filenames); + if (!numlumps_g) + I_Error("W_InitFiles: no files found"); + size = numlumps_g * sizeof(*lumpcache_g); + lumpcache_g = malloc(size); + if (!lumpcache_g) + I_Error("Couldn't allocate lumpcache_g"); + memset(lumpcache_g, 0, size); } int @@ -190,20 +151,23 @@ W_CheckNumForName(char* name) return -1; } -int W_GetNumForName (char* name) +int +W_GetNumForName(char* name) { - int i; - i = W_CheckNumForName (name); - if (i == -1) - I_Error ("W_GetNumForName: %s not found!", name); - return i; + int i; + + i = W_CheckNumForName(name); + if (i == -1) + I_Error("W_GetNumForName: %s not found!", name); + return i; } -int W_LumpLength (int lump) +int +W_LumpLength(int lump) { - if (lump >= numlumps_g) - I_Error ("W_LumpLength: %i >= numlumps_g",lump); - return lumpinfo_g[lump].size; + if (lump >= numlumps_g) + I_Error("W_LumpLength: %i >= numlumps_g", lump); + return lumpinfo_g[lump].size; } void @@ -220,73 +184,20 @@ W_ReadLump(int lump, void* dest) } void* -W_CacheLumpNum -( int lump, - int tag ) +W_CacheLumpNum(int lump, int tag) { - if ((unsigned)lump >= numlumps_g) - I_Error ("W_CacheLumpNum: %i >= numlumps_g",lump); - if (!lumpcache[lump]) { - Z_Malloc(W_LumpLength (lump), tag, &lumpcache[lump]); - W_ReadLump(lump, lumpcache[lump]); - } - else - { - Z_ChangeTag (lumpcache[lump],tag); - } - return lumpcache[lump]; + if ((unsigned)lump >= numlumps_g) + I_Error("W_CacheLumpNum: %i >= numlumps_g",lump); + if (!lumpcache_g[lump]) { + Z_Malloc(W_LumpLength(lump), tag, &lumpcache_g[lump]); + W_ReadLump(lump, lumpcache_g[lump]); + } else + Z_ChangeTag(lumpcache_g[lump],tag); + return lumpcache_g[lump]; } + void* -W_CacheLumpName -( char* name, - int tag ) -{ - return W_CacheLumpNum (W_GetNumForName(name), tag); -} -int info[2500][10]; -int profilecount; -void W_Profile (void) +W_CacheLumpName(char* name, int tag) { - int i; - memblock_t* block; - void* ptr; - char ch; - FILE* f; - int j; - char name[9]; - for (i=0 ; i<numlumps_g ; i++) - { - ptr = lumpcache[i]; - if (!ptr) - { - ch = ' '; - continue; - } - else - { - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); - if (block->tag < PU_PURGELEVEL) - ch = 'S'; - else - ch = 'P'; - } - info[i][profilecount] = ch; - } - profilecount++; - f = fopen ("waddump.txt","w"); - name[8] = 0; - for (i=0 ; i<numlumps_g ; i++) - { - memcpy (name,lumpinfo_g[i].name,8); - for (j=0 ; j<8 ; j++) - if (!name[j]) - break; - for ( ; j<8 ; j++) - name[j] = ' '; - fprintf (f,"%s ",name); - for (j=0 ; j<profilecount ; j++) - fprintf (f," %c",info[i][j]); - fprintf (f,"\n"); - } - fclose (f); + return W_CacheLumpNum(W_GetNumForName(name), tag); } diff --git a/src/wi_stuff.c b/src/wi_stuff.c @@ -1,7 +1,8 @@ #include <stdio.h> + +#include "m_swap.h" #include "z_zone.h" #include "m_random.h" -#include "m_swap.h" #include "i_system.h" #include "w_wad.h" #include "g_game.h" @@ -11,6 +12,7 @@ #include "sounds.h" #include "v_video.h" #include "wi_stuff.h" + #define NUMEPISODES 4 #define NUMMAPS 9 #define WI_TITLEY 2 @@ -30,146 +32,147 @@ #define DM_KILLERSY 100 #define DM_VICTIMSX 5 #define DM_VICTIMSY 50 -typedef enum -{ - ANIM_ALWAYS, - ANIM_RANDOM, - ANIM_LEVEL +#define FB 0 +#define SP_KILLS 0 +#define SP_ITEMS 2 +#define SP_SECRET 4 +#define SP_FRAGS 6 +#define SP_TIME 8 +#define SP_PAR ST_TIME +#define SP_PAUSE 1 +#define SHOWNEXTLOCDELAY 4 + + +typedef enum { + ANIM_ALWAYS, + ANIM_RANDOM, + ANIM_LEVEL } animenum_t; -typedef struct -{ - int x; - int y; + +typedef struct { + int x; + int y; } point_t; -typedef struct -{ - animenum_t type; - int period; - int nanims; - point_t loc; - int data1; - int data2; - patch_t* p[3]; - int nexttic; - int lastdrawn; - int ctr; - int state; + +typedef struct { + animenum_t type; + int period; + int nanims; + point_t loc; + int data1; + int data2; + patch_t* p[3]; + int nexttic; + int lastdrawn; + int ctr; + int state; } anim_t; -static point_t lnodes[NUMEPISODES][NUMMAPS] = -{ - { - { 185, 164 }, - { 148, 143 }, - { 69, 122 }, - { 209, 102 }, - { 116, 89 }, - { 166, 55 }, - { 71, 56 }, - { 135, 29 }, - { 71, 24 } - }, - { - { 254, 25 }, - { 97, 50 }, - { 188, 64 }, - { 128, 78 }, - { 214, 92 }, - { 133, 130 }, - { 208, 136 }, - { 148, 140 }, - { 235, 158 } - }, - { - { 156, 168 }, - { 48, 154 }, - { 174, 95 }, - { 265, 75 }, - { 130, 48 }, - { 279, 23 }, - { 198, 48 }, - { 140, 25 }, - { 281, 136 } - } + +static point_t lnodes[NUMEPISODES][NUMMAPS] = { + { + { 185, 164 }, + { 148, 143 }, + { 69, 122 }, + { 209, 102 }, + { 116, 89 }, + { 166, 55 }, + { 71, 56 }, + { 135, 29 }, + { 71, 24 } + }, + { + { 254, 25 }, + { 97, 50 }, + { 188, 64 }, + { 128, 78 }, + { 214, 92 }, + { 133, 130 }, + { 208, 136 }, + { 148, 140 }, + { 235, 158 } + }, + { + { 156, 168 }, + { 48, 154 }, + { 174, 95 }, + { 265, 75 }, + { 130, 48 }, + { 279, 23 }, + { 198, 48 }, + { 140, 25 }, + { 281, 136 } + } }; -static anim_t epsd0animinfo[] = -{ - { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } } + +static anim_t epsd0animinfo[] = { + { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } } }; -static anim_t epsd1animinfo[] = -{ - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7 }, - { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 }, - { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 } + +static anim_t epsd1animinfo[] = { + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7 }, + { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 }, + { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 } }; -static anim_t epsd2animinfo[] = -{ - { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 } }, - { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } }, - { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } } + +static anim_t epsd2animinfo[] = { + { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 } }, + { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } }, + { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } } }; -static int NUMANIMS[NUMEPISODES] = -{ - sizeof(epsd0animinfo)/sizeof(anim_t), - sizeof(epsd1animinfo)/sizeof(anim_t), - sizeof(epsd2animinfo)/sizeof(anim_t) + +static int NUMANIMS[NUMEPISODES] = { + sizeof(epsd0animinfo)/sizeof(anim_t), + sizeof(epsd1animinfo)/sizeof(anim_t), + sizeof(epsd2animinfo)/sizeof(anim_t) }; -static anim_t *anims[NUMEPISODES] = -{ - epsd0animinfo, - epsd1animinfo, - epsd2animinfo + +static anim_t *anims[NUMEPISODES] = { + epsd0animinfo, + epsd1animinfo, + epsd2animinfo }; -#define FB 0 -#define SP_KILLS 0 -#define SP_ITEMS 2 -#define SP_SECRET 4 -#define SP_FRAGS 6 -#define SP_TIME 8 -#define SP_PAR ST_TIME -#define SP_PAUSE 1 -#define SHOWNEXTLOCDELAY 4 + static int acceleratestage; static int me; static stateenum_t state; static wbstartstruct_t* wbs; -static wbplayerstruct_t* plrs; -static int cnt; +static wbplayerstruct_t* plrs; +static int cnt; static int bcnt; -static int firstrefresh; +static int firstrefresh; static int cnt_kills[MAXPLAYERS]; static int cnt_items[MAXPLAYERS]; static int cnt_secret[MAXPLAYERS]; static int cnt_time; static int cnt_par; static int cnt_pause; -static int NUMCMAPS; static patch_t* bg; -static patch_t* yah[2]; +static patch_t* yah[2]; static patch_t* splat; static patch_t* percent; static patch_t* colon; static patch_t* num[10]; static patch_t* wiminus; static patch_t* finished; -static patch_t* entering; +static patch_t* entering; static patch_t* sp_secret; static patch_t* kills; static patch_t* secret; @@ -179,1051 +182,853 @@ static patch_t* time; static patch_t* par; static patch_t* sucks; static patch_t* killers; -static patch_t* victims; +static patch_t* victims; static patch_t* total; static patch_t* star; static patch_t* bstar; static patch_t* p[MAXPLAYERS]; static patch_t* bp[MAXPLAYERS]; static patch_t** lnames; -void WI_slamBackground(void) +static boolean snl_pointeron = false; +static int dm_state; +static int dm_frags[MAXPLAYERS][MAXPLAYERS]; +static int dm_totals[MAXPLAYERS]; +static int cnt_frags[MAXPLAYERS]; +static int dofrags; +static int ng_state; +static int sp_state; + +void +WI_slamBackground() { - memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT); - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); + memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT); + V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); } -boolean WI_Responder(event_t* ev) + +boolean +WI_Responder(event_t* ev) { - return false; + return false; } -void WI_drawLF(void) + +void +WI_drawLF() { - int y = WI_TITLEY; - V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, - y, FB, lnames[wbs->last]); - y += (5*SHORT(lnames[wbs->last]->height))/4; - V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2, - y, FB, finished); + int y; + + y = WI_TITLEY; + V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, y, FB, lnames[wbs->last]); + y += (5*SHORT(lnames[wbs->last]->height))/4; + V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2, y, FB, finished); } -void WI_drawEL(void) + +void +WI_drawEL() { - int y = WI_TITLEY; - V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2, - y, FB, entering); - y += (5*SHORT(lnames[wbs->next]->height))/4; - V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, - y, FB, lnames[wbs->next]); + int y; + + y = WI_TITLEY; + V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2, y, FB, entering); + y += (5*SHORT(lnames[wbs->next]->height))/4; + V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, y, FB, lnames[wbs->next]); } + void -WI_drawOnLnode -( int n, - patch_t* c[] ) +WI_drawOnLnode(int n, patch_t* c[]) { - int i; - int left; - int top; - int right; - int bottom; - boolean fits = false; - i = 0; - do - { - left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset); - top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset); - right = left + SHORT(c[i]->width); - bottom = top + SHORT(c[i]->height); - if (left >= 0 - && right < SCREENWIDTH - && top >= 0 - && bottom < SCREENHEIGHT) - { - fits = true; - } + int i, left, top, right, bottom; + boolean fits; + + fits = false; + i = 0; + do { + left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset); + top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset); + right = left + SHORT(c[i]->width); + bottom = top + SHORT(c[i]->height); + if (left >= 0 && right < SCREENWIDTH && top >= 0 && bottom < SCREENHEIGHT) + fits = true; + else + ++i; + } while (!fits && i!=2); + if (fits && i<2) + V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, FB, c[i]); else - { - i++; - } - } while (!fits && i!=2); - if (fits && i<2) - { - V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, - FB, c[i]); - } - else - { - printf("Could not place patch on level %d", n+1); - } + printf("Could not place patch on level %d", n+1); } -void WI_initAnimatedBack(void) + +void +WI_initAnimatedBack() { - int i; - anim_t* a; - if (gamemode == commercial) - return; - if (wbs->epsd > 2) - return; - for (i=0;i<NUMANIMS[wbs->epsd];i++) - { - a = &anims[wbs->epsd][i]; - a->ctr = -1; - if (a->type == ANIM_ALWAYS) - a->nexttic = bcnt + 1 + (M_Random()%a->period); - else if (a->type == ANIM_RANDOM) - a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1); - else if (a->type == ANIM_LEVEL) - a->nexttic = bcnt + 1; - } + anim_t* a; + int i; + + if (wbs->epsd > 2) return; + for (i = 0; i < NUMANIMS[wbs->epsd]; ++i) { + a = &anims[wbs->epsd][i]; + a->ctr = -1; + if (a->type == ANIM_ALWAYS) a->nexttic = bcnt + 1 + (M_Random()%a->period); + if (a->type == ANIM_RANDOM) a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1); + if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; + } } -void WI_updateAnimatedBack(void) + +void +WI_updateAnimatedBack() { - int i; - anim_t* a; - if (gamemode == commercial) - return; - if (wbs->epsd > 2) - return; - for (i=0;i<NUMANIMS[wbs->epsd];i++) - { - a = &anims[wbs->epsd][i]; - if (bcnt == a->nexttic) - { - switch (a->type) - { - case ANIM_ALWAYS: - if (++a->ctr >= a->nanims) a->ctr = 0; - a->nexttic = bcnt + a->period; - break; - case ANIM_RANDOM: - a->ctr++; - if (a->ctr == a->nanims) - { - a->ctr = -1; - a->nexttic = bcnt+a->data2+(M_Random()%a->data1); - } - else a->nexttic = bcnt + a->period; - break; - case ANIM_LEVEL: - if (!(state == StatCount && i == 7) - && wbs->next == a->data1) - { - a->ctr++; - if (a->ctr == a->nanims) a->ctr--; - a->nexttic = bcnt + a->period; + anim_t* a; + int i; + + if (wbs->epsd > 2) + return; + for (i = 0; i < NUMANIMS[wbs->epsd]; ++i) { + a = &anims[wbs->epsd][i]; + if (bcnt == a->nexttic) { + switch (a->type) { + case ANIM_ALWAYS: + if (++a->ctr >= a->nanims) + a->ctr = 0; + a->nexttic = bcnt + a->period; + break; + case ANIM_RANDOM: + a->ctr++; + if (a->ctr == a->nanims) { + a->ctr = -1; + a->nexttic = bcnt+a->data2+(M_Random()%a->data1); + } else a->nexttic = bcnt + a->period; + break; + case ANIM_LEVEL: + if (!(state == StatCount && i == 7) && wbs->next == a->data1) { + if (++a->ctr == a->nanims) + a->ctr--; + a->nexttic = bcnt + a->period; + } + } } - break; - } } - } } -void WI_drawAnimatedBack(void) + +void +WI_drawAnimatedBack() { - int i; - anim_t* a; - if (commercial) - return; - if (wbs->epsd > 2) - return; - for (i=0 ; i<NUMANIMS[wbs->epsd] ; i++) - { - a = &anims[wbs->epsd][i]; - if (a->ctr >= 0) - V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]); - } + anim_t* a; + int i; + + if (wbs->epsd > 2) return; + for (i = 0; i < NUMANIMS[wbs->epsd]; ++i) { + a = &anims[wbs->epsd][i]; + if (a->ctr >= 0) + V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]); + } } + int -WI_drawNum -( int x, - int y, - int n, - int digits ) +WI_drawNum(int x, int y, int n, int digits) { - int fontwidth = SHORT(num[0]->width); - int neg; - int temp; - if (digits < 0) - { - if (!n) - { - digits = 1; + int fontwidth, neg, temp; + + fontwidth = SHORT(num[0]->width); + if (digits < 0) { + if (!n) + digits = 1; + else { + digits = 0; + for (temp = n; temp; temp /= 10) ++digits; + } } - else - { - digits = 0; - temp = n; - while (temp) - { - temp /= 10; - digits++; - } + neg = n < 0; + if (neg) + n = -n; + if (n == 1994) + return 0; + while (digits--) { + x -= fontwidth; + V_DrawPatch(x, y, FB, num[ n % 10 ]); + n /= 10; } - } - neg = n < 0; - if (neg) - n = -n; - if (n == 1994) - return 0; - while (digits--) - { - x -= fontwidth; - V_DrawPatch(x, y, FB, num[ n % 10 ]); - n /= 10; - } - if (neg) - V_DrawPatch(x-=8, y, FB, wiminus); - return x; + if (neg) + V_DrawPatch(x-=8, y, FB, wiminus); + return x; } + void -WI_drawPercent -( int x, - int y, - int p ) +WI_drawPercent(int x, int y, int p) { - if (p < 0) - return; - V_DrawPatch(x, y, FB, percent); - WI_drawNum(x, y, p, -1); + if (p < 0) + return; + V_DrawPatch(x, y, FB, percent); + WI_drawNum(x, y, p, -1); } + void -WI_drawTime -( int x, - int y, - int t ) +WI_drawTime(int x, int y, int t) { - int div; - int n; - if (t<0) - return; - if (t <= 61*59) - { - div = 1; - do - { - n = (t / div) % 60; - x = WI_drawNum(x, y, n, 2) - SHORT(colon->width); - div *= 60; - if (div==60 || t / div) - V_DrawPatch(x, y, FB, colon); - } while (t / div); - } - else - { - V_DrawPatch(x - SHORT(sucks->width), y, FB, sucks); - } -} -void WI_End(void) -{ - void WI_unloadData(void); - WI_unloadData(); -} -void WI_initNoState(void) -{ - state = NoState; - acceleratestage = 0; - cnt = 10; -} -void WI_updateNoState(void) { - WI_updateAnimatedBack(); - if (!--cnt) - { - WI_End(); - G_WorldDone(); - } -} -static boolean snl_pointeron = false; -void WI_initShowNextLoc(void) -{ - state = ShowNextLoc; - acceleratestage = 0; - cnt = SHOWNEXTLOCDELAY * TICRATE; - WI_initAnimatedBack(); + int div, n; + + if (t < 0) + return; + if (t <= 61*59) { + div = 1; + do { + n = (t / div) % 60; + x = WI_drawNum(x, y, n, 2) - SHORT(colon->width); + div *= 60; + if (div==60 || t / div) + V_DrawPatch(x, y, FB, colon); + + } while (t / div); + } else V_DrawPatch(x - SHORT(sucks->width), y, FB, sucks); } -void WI_updateShowNextLoc(void) + +void +WI_initShowNextLoc() { - WI_updateAnimatedBack(); - if (!--cnt || acceleratestage) - WI_initNoState(); - else - snl_pointeron = (cnt & 31) < 20; + state = ShowNextLoc; + acceleratestage = 0; + cnt = SHOWNEXTLOCDELAY * TICRATE; + WI_initAnimatedBack(); } -void WI_drawShowNextLoc(void) + +void +WI_drawShowNextLoc() { - int i; - int last; - WI_slamBackground(); - WI_drawAnimatedBack(); - if ( gamemode != commercial) - { - if (wbs->epsd > 2) - { + int i, last; + + WI_slamBackground(); + WI_drawAnimatedBack(); + if (wbs->epsd > 2) { WI_drawEL(); return; } last = (wbs->last == 8) ? wbs->next - 1 : wbs->last; - for (i=0 ; i<=last ; i++) + for (i = 0; i <= last; ++i) WI_drawOnLnode(i, &splat); - if (wbs->didsecret) - WI_drawOnLnode(8, &splat); - if (snl_pointeron) - WI_drawOnLnode(wbs->next, yah); - } - if ( (gamemode != commercial) - || wbs->next != 30) - WI_drawEL(); + if (wbs->didsecret) WI_drawOnLnode(8, &splat); + if (snl_pointeron) WI_drawOnLnode(wbs->next, yah); + if (wbs->next != 30) WI_drawEL(); } -void WI_drawNoState(void) + +void +WI_drawNoState() { - snl_pointeron = true; - WI_drawShowNextLoc(); + snl_pointeron = true; + WI_drawShowNextLoc(); } -int WI_fragSum(int playernum) + +int +WI_fragSum(int playernum) { - int i; - int frags = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i] - && i!=playernum) - { - frags += plrs[playernum].frags[i]; - } - } - frags -= plrs[playernum].frags[playernum]; - return frags; + int i, frags; + + frags = 0; + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && i!=playernum) + frags += plrs[playernum].frags[i]; + frags -= plrs[playernum].frags[playernum]; + return frags; } -static int dm_state; -static int dm_frags[MAXPLAYERS][MAXPLAYERS]; -static int dm_totals[MAXPLAYERS]; -void WI_initDeathmatchStats(void) + +void +WI_initDeathmatchStats() { - int i; - int j; - state = StatCount; - acceleratestage = 0; - dm_state = 1; - cnt_pause = TICRATE; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - for (j=0 ; j<MAXPLAYERS ; j++) - if (playeringame[j]) - dm_frags[i][j] = 0; - dm_totals[i] = 0; + int i, j; + + state = StatCount; + acceleratestage = 0; + dm_state = 1; + cnt_pause = TICRATE; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + for (j = 0; j < MAXPLAYERS; ++j) + if (playeringame[j]) + dm_frags[i][j] = 0; + dm_totals[i] = 0; + } } - } - WI_initAnimatedBack(); + WI_initAnimatedBack(); } -void WI_updateDeathmatchStats(void) + +void +WI_updateDeathmatchStats() { - int i; - int j; - boolean stillticking; - WI_updateAnimatedBack(); - if (acceleratestage && dm_state != 4) - { - acceleratestage = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - for (j=0 ; j<MAXPLAYERS ; j++) - if (playeringame[j]) - dm_frags[i][j] = plrs[i].frags[j]; - dm_totals[i] = WI_fragSum(i); - } - } - S_StartSound(0, sfx_barexp); - dm_state = 4; - } - if (dm_state == 2) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - for (j=0 ; j<MAXPLAYERS ; j++) - { - if (playeringame[j] - && dm_frags[i][j] != plrs[i].frags[j]) - { - if (plrs[i].frags[j] < 0) - dm_frags[i][j]--; - else - dm_frags[i][j]++; - if (dm_frags[i][j] > 99) - dm_frags[i][j] = 99; - if (dm_frags[i][j] < -99) - dm_frags[i][j] = -99; - stillticking = true; - } + boolean stillticking; + int i, j; + + WI_updateAnimatedBack(); + if (acceleratestage && dm_state != 4) { + acceleratestage = 0; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + for (j = 0; j < MAXPLAYERS; ++j) + if (playeringame[j]) + dm_frags[i][j] = plrs[i].frags[j]; + dm_totals[i] = WI_fragSum(i); + } } - dm_totals[i] = WI_fragSum(i); - if (dm_totals[i] > 99) - dm_totals[i] = 99; - if (dm_totals[i] < -99) - dm_totals[i] = -99; - } + S_StartSound(0, sfx_barexp); + dm_state = 4; } - if (!stillticking) - { - S_StartSound(0, sfx_barexp); - dm_state++; + if (dm_state == 2) { + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + stillticking = false; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + for (j = 0; j < MAXPLAYERS; ++j) { + if (playeringame[j] && dm_frags[i][j] != plrs[i].frags[j]) { + if (plrs[i].frags[j] < 0) dm_frags[i][j]--; + else dm_frags[i][j]++; + if (dm_frags[i][j] > 99) dm_frags[i][j] = 99; + if (dm_frags[i][j] < -99) dm_frags[i][j] = -99; + stillticking = true; + } + } + dm_totals[i] = WI_fragSum(i); + if (dm_totals[i] > 99) dm_totals[i] = 99; + if (dm_totals[i] < -99) dm_totals[i] = -99; + } + } + if (!stillticking) { + S_StartSound(0, sfx_barexp); + dm_state++; + } } - } - else if (dm_state == 4) - { - if (acceleratestage) - { - S_StartSound(0, sfx_slop); - if ( gamemode == commercial) - WI_initNoState(); - else - WI_initShowNextLoc(); + if (dm_state == 4) { + if (acceleratestage) { + S_StartSound(0, sfx_slop); + WI_initShowNextLoc(); + } } - } - else if (dm_state & 1) - { - if (!--cnt_pause) - { - dm_state++; - cnt_pause = TICRATE; + if (dm_state & 1) { + if (!--cnt_pause) { + dm_state++; + cnt_pause = TICRATE; + } } - } } -void WI_drawDeathmatchStats(void) + +void +WI_drawDeathmatchStats() { - int i; - int j; - int x; - int y; - int w; - - WI_slamBackground(); - WI_drawAnimatedBack(); - WI_drawLF(); - V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2, - DM_MATRIXY-WI_SPACINGY+10, - FB, - total); - V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, killers); - V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims); - x = DM_MATRIXX + DM_SPACINGX; - y = DM_MATRIXY; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - V_DrawPatch(x-SHORT(p[i]->width)/2, - DM_MATRIXY - WI_SPACINGY, - FB, - p[i]); - V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, - y, - FB, - p[i]); - if (i == me) - { - V_DrawPatch(x-SHORT(p[i]->width)/2, - DM_MATRIXY - WI_SPACINGY, - FB, - bstar); - V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, - y, - FB, - star); - } - } - else - { - } - x += DM_SPACINGX; - y += WI_SPACINGY; - } - y = DM_MATRIXY+10; - w = SHORT(num[0]->width); - for (i=0 ; i<MAXPLAYERS ; i++) - { + + int i, j, x, y, w; + + WI_slamBackground(); + WI_drawAnimatedBack(); + WI_drawLF(); + V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2, DM_MATRIXY-WI_SPACINGY+10, FB, total); + V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, killers); + V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims); x = DM_MATRIXX + DM_SPACINGX; - if (playeringame[i]) - { - for (j=0 ; j<MAXPLAYERS ; j++) - { - if (playeringame[j]) - WI_drawNum(x+w, y, dm_frags[i][j], 2); + y = DM_MATRIXY; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + V_DrawPatch(x-SHORT(p[i]->width)/2, DM_MATRIXY - WI_SPACINGY, FB, p[i]); + V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, p[i]); + if (i == me) { + V_DrawPatch(x-SHORT(p[i]->width)/2, DM_MATRIXY - WI_SPACINGY, FB, bstar); + V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, star); + } + } x += DM_SPACINGX; - } - WI_drawNum(DM_TOTALSX+w, y, dm_totals[i], 2); + y += WI_SPACINGY; + } + y = DM_MATRIXY+10; + w = SHORT(num[0]->width); + for (i = 0; i < MAXPLAYERS; ++i) { + x = DM_MATRIXX + DM_SPACINGX; + if (playeringame[i]) { + for (j = 0; j < MAXPLAYERS; ++j) { + if (playeringame[j]) + WI_drawNum(x+w, y, dm_frags[i][j], 2); + x += DM_SPACINGX; + } + WI_drawNum(DM_TOTALSX+w, y, dm_totals[i], 2); + } + y += WI_SPACINGY; } - y += WI_SPACINGY; - } -} -static int cnt_frags[MAXPLAYERS]; -static int dofrags; -static int ng_state; -void WI_initNetgameStats(void) -{ - int i; - state = StatCount; - acceleratestage = 0; - ng_state = 1; - cnt_pause = TICRATE; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_kills[i] = cnt_items[i] = cnt_secret[i] = cnt_frags[i] = 0; - dofrags += WI_fragSum(i); - } - dofrags = !!dofrags; - WI_initAnimatedBack(); } -void WI_updateNetgameStats(void) + +void +WI_initNetgameStats() { - int i; - int fsum; - boolean stillticking; - WI_updateAnimatedBack(); - if (acceleratestage && ng_state != 10) - { + int i; + + state = StatCount; acceleratestage = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; - cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; - cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; - if (dofrags) - cnt_frags[i] = WI_fragSum(i); - } - S_StartSound(0, sfx_barexp); - ng_state = 10; - } - if (ng_state == 2) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_kills[i] += 2; - if (cnt_kills[i] >= (plrs[i].skills * 100) / wbs->maxkills) - cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; - else - stillticking = true; - } - if (!stillticking) - { - S_StartSound(0, sfx_barexp); - ng_state++; - } - } - else if (ng_state == 4) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_items[i] += 2; - if (cnt_items[i] >= (plrs[i].sitems * 100) / wbs->maxitems) - cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; - else - stillticking = true; + ng_state = 1; + cnt_pause = TICRATE; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_kills[i] = cnt_items[i] = cnt_secret[i] = cnt_frags[i] = 0; + dofrags += WI_fragSum(i); } - if (!stillticking) - { - S_StartSound(0, sfx_barexp); - ng_state++; - } - } - else if (ng_state == 6) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_secret[i] += 2; - if (cnt_secret[i] >= (plrs[i].ssecret * 100) / wbs->maxsecret) - cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; - else - stillticking = true; - } - if (!stillticking) - { - S_StartSound(0, sfx_barexp); - ng_state += 1 + 2*!dofrags; - } - } - else if (ng_state == 8) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - cnt_frags[i] += 1; - if (cnt_frags[i] >= (fsum = WI_fragSum(i))) - cnt_frags[i] = fsum; - else - stillticking = true; + dofrags = !!dofrags; + WI_initAnimatedBack(); +} + +void +WI_updateNetgameStats() +{ + int i, fsum; + boolean stillticking; + + WI_updateAnimatedBack(); + if (acceleratestage && ng_state != 10) { + acceleratestage = 0; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; + cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; + cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; + if (dofrags) + cnt_frags[i] = WI_fragSum(i); + } + S_StartSound(0, sfx_barexp); + ng_state = 10; } - if (!stillticking) - { - S_StartSound(0, sfx_pldeth); - ng_state++; + switch (ng_state) { + case 2: + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + stillticking = false; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_kills[i] += 2; + if (cnt_kills[i] >= (plrs[i].skills * 100) / wbs->maxkills) + cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; + else stillticking = true; + } + if (!stillticking) { + S_StartSound(0, sfx_barexp); + ++ng_state; + } + break; + case 4: + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + stillticking = false; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_items[i] += 2; + if (cnt_items[i] >= (plrs[i].sitems * 100) / wbs->maxitems) + cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; + else stillticking = true; + } + if (!stillticking) { + S_StartSound(0, sfx_barexp); + ++ng_state; + } + break; + case 6: + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + stillticking = false; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_secret[i] += 2; + if (cnt_secret[i] >= (plrs[i].ssecret * 100) / wbs->maxsecret) + cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; + else stillticking = true; + } + if (!stillticking) { + S_StartSound(0, sfx_barexp); + ng_state += 1 + 2*!dofrags; + } + break; + case 8: + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + stillticking = false; + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + cnt_frags[i] += 1; + if (cnt_frags[i] >= (fsum = WI_fragSum(i))) + cnt_frags[i] = fsum; + else stillticking = true; + } + if (!stillticking) { + S_StartSound(0, sfx_pldeth); + ++ng_state; + } + break; + case 10: + if (acceleratestage) { + S_StartSound(0, sfx_sgcock); + WI_initShowNextLoc(); + } } - } - else if (ng_state == 10) - { - if (acceleratestage) - { - S_StartSound(0, sfx_sgcock); - if ( gamemode == commercial ) - WI_initNoState(); - else - WI_initShowNextLoc(); - } - } - else if (ng_state & 1) - { - if (!--cnt_pause) - { - ng_state++; - cnt_pause = TICRATE; + if (ng_state & 1) { + if (!--cnt_pause) { + ++ng_state; + cnt_pause = TICRATE; + } } - } } -void WI_drawNetgameStats(void) + +void +WI_drawNetgameStats() { - int i; - int x; - int y; - int pwidth = SHORT(percent->width); - WI_slamBackground(); - WI_drawAnimatedBack(); - WI_drawLF(); - V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width), - NG_STATSY, FB, kills); - V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width), - NG_STATSY, FB, items); - V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width), - NG_STATSY, FB, secret); - if (dofrags) - V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width), - NG_STATSY, FB, frags); - y = NG_STATSY + SHORT(kills->height); - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (!playeringame[i]) - continue; - x = NG_STATSX; - V_DrawPatch(x-SHORT(p[i]->width), y, FB, p[i]); - if (i == me) - V_DrawPatch(x-SHORT(p[i]->width), y, FB, star); - x += NG_SPACINGX; - WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX; - WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX; - WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX; + int i, x, y, pwidth; + + pwidth = SHORT(percent->width); + WI_slamBackground(); + WI_drawAnimatedBack(); + WI_drawLF(); + V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width), NG_STATSY, FB, kills); + V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width), NG_STATSY, FB, items); + V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width), NG_STATSY, FB, secret); if (dofrags) - WI_drawNum(x, y+10, cnt_frags[i], -1); - y += WI_SPACINGY; - } + V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width), NG_STATSY, FB, frags); + y = NG_STATSY + SHORT(kills->height); + for (i = 0; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) + continue; + x = NG_STATSX; + V_DrawPatch(x-SHORT(p[i]->width), y, FB, p[i]); + if (i == me) + V_DrawPatch(x-SHORT(p[i]->width), y, FB, star); + x += NG_SPACINGX; + WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX; + WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX; + WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX; + if (dofrags) + WI_drawNum(x, y+10, cnt_frags[i], -1); + y += WI_SPACINGY; + } } -static int sp_state; -void WI_initStats(void) + +void +WI_initStats() { - state = StatCount; - acceleratestage = 0; - sp_state = 1; - cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1; - cnt_time = cnt_par = -1; - cnt_pause = TICRATE; - WI_initAnimatedBack(); + state = StatCount; + acceleratestage = 0; + sp_state = 1; + cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1; + cnt_time = cnt_par = -1; + cnt_pause = TICRATE; + WI_initAnimatedBack(); } -void WI_updateStats(void) + +void +WI_updateStats() { - WI_updateAnimatedBack(); - if (acceleratestage && sp_state != 10) - { - acceleratestage = 0; - cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; - cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; - cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; - cnt_time = plrs[me].stime / TICRATE; - cnt_par = wbs->partime / TICRATE; - S_StartSound(0, sfx_barexp); - sp_state = 10; - } - if (sp_state == 2) - { - cnt_kills[0] += 2; - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills) - { - cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; - S_StartSound(0, sfx_barexp); - sp_state++; - } - } - else if (sp_state == 4) - { - cnt_items[0] += 2; - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems) - { - cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; - S_StartSound(0, sfx_barexp); - sp_state++; - } - } - else if (sp_state == 6) - { - cnt_secret[0] += 2; - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret) - { - cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; - S_StartSound(0, sfx_barexp); - sp_state++; - } - } - else if (sp_state == 8) - { - if (!(bcnt&3)) - S_StartSound(0, sfx_pistol); - cnt_time += 3; - if (cnt_time >= plrs[me].stime / TICRATE) - cnt_time = plrs[me].stime / TICRATE; - cnt_par += 3; - if (cnt_par >= wbs->partime / TICRATE) - { - cnt_par = wbs->partime / TICRATE; - if (cnt_time >= plrs[me].stime / TICRATE) - { + WI_updateAnimatedBack(); + if (acceleratestage && sp_state != 10) { + acceleratestage = 0; + cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; + cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; + cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; + cnt_time = plrs[me].stime / TICRATE; + cnt_par = wbs->partime / TICRATE; S_StartSound(0, sfx_barexp); - sp_state++; - } + sp_state = 10; } - } - else if (sp_state == 10) - { - if (acceleratestage) - { - S_StartSound(0, sfx_sgcock); - if (gamemode == commercial) - WI_initNoState(); - else - WI_initShowNextLoc(); + switch (sp_state) { + case 2: + cnt_kills[0] += 2; + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills) { + cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; + S_StartSound(0, sfx_barexp); + ++sp_state; + } + break; + case 4: + cnt_items[0] += 2; + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems) { + cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; + S_StartSound(0, sfx_barexp); + ++sp_state; + } + break; + case 6: + cnt_secret[0] += 2; + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret) { + cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; + S_StartSound(0, sfx_barexp); + ++sp_state; + } + break; + case 8: + if (!(bcnt&3)) + S_StartSound(0, sfx_pistol); + cnt_time += 3; + if (cnt_time >= plrs[me].stime / TICRATE) + cnt_time = plrs[me].stime / TICRATE; + cnt_par += 3; + if (cnt_par >= wbs->partime / TICRATE) { + cnt_par = wbs->partime / TICRATE; + if (cnt_time >= plrs[me].stime / TICRATE) { + S_StartSound(0, sfx_barexp); + ++sp_state; + } + } + break; + case 10: + if (acceleratestage) { + S_StartSound(0, sfx_sgcock); + WI_initShowNextLoc(); + } } - } - else if (sp_state & 1) - { - if (!--cnt_pause) - { - sp_state++; - cnt_pause = TICRATE; + if (sp_state & 1) { + if (!--cnt_pause) { + ++sp_state; + cnt_pause = TICRATE; + } } - } } -void WI_drawStats(void) + +void +WI_drawStats() { - int lh; - lh = (3*SHORT(num[0]->height))/2; - WI_slamBackground(); - WI_drawAnimatedBack(); - WI_drawLF(); - V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills); - WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); - V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items); - WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); - V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret); - WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); - V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time); - WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time); - if (wbs->epsd < 3) - { - V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par); - WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); - } + int lh; + + lh = (3*SHORT(num[0]->height))/2; + WI_slamBackground(); + WI_drawAnimatedBack(); + WI_drawLF(); + V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); + V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); + V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret); + WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); + V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time); + WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time); + if (wbs->epsd < 3) { + V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par); + WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); + } } -void WI_checkForAccelerate(void) + +void +WI_checkForAccelerate() { - int i; - player_t *player; - for (i=0, player = players ; i<MAXPLAYERS ; i++, player++) - { - if (playeringame[i]) - { - if (player->cmd.buttons & BT_ATTACK) - { - if (!player->attackdown) - acceleratestage = 1; - player->attackdown = true; - } - else - player->attackdown = false; - if (player->cmd.buttons & BT_USE) - { - if (!player->usedown) - acceleratestage = 1; - player->usedown = true; - } - else - player->usedown = false; + player_t* player; + int i; + + for (i = 0, player = players; i < MAXPLAYERS; ++i, ++player) { + if (playeringame[i]) { + if (player->cmd.buttons & BT_ATTACK) { + if (!player->attackdown) + acceleratestage = 1; + player->attackdown = true; + } else player->attackdown = false; + if (player->cmd.buttons & BT_USE) { + if (!player->usedown) + acceleratestage = 1; + player->usedown = true; + } else player->usedown = false; + } } - } } -void WI_Ticker(void) + +void +WI_initNoState() { - bcnt++; - if (bcnt == 1) - { - if ( gamemode == commercial ) - S_ChangeMusic(mus_dm2int, true); + state = NoState; + acceleratestage = 0; + cnt = 10; +} + +void +WI_updateShowNextLoc() +{ + WI_updateAnimatedBack(); + if (!--cnt || acceleratestage) + WI_initNoState(); else - S_ChangeMusic(mus_inter, true); - } - WI_checkForAccelerate(); - switch (state) - { - case StatCount: - if (deathmatch) WI_updateDeathmatchStats(); - else if (netgame) WI_updateNetgameStats(); - else WI_updateStats(); - break; - case ShowNextLoc: - WI_updateShowNextLoc(); - break; - case NoState: - WI_updateNoState(); - break; - } + snl_pointeron = (cnt & 31) < 20; } -void WI_loadData(void) + + +void +WI_updateNoState() { - int i; - int j; - char name[9]; - anim_t* a; - if (gamemode == commercial) - strcpy(name, "INTERPIC"); - else + WI_updateAnimatedBack(); + if (!--cnt) + G_WorldDone(); +} + +void +WI_Ticker() +{ + bcnt++; + + if (bcnt == 1) + S_ChangeMusic(mus_inter, true); + WI_checkForAccelerate(); + switch (state) { + case StatCount: + if (deathmatch) WI_updateDeathmatchStats(); + else if (netgame) WI_updateNetgameStats(); + else WI_updateStats(); + break; + case ShowNextLoc: + WI_updateShowNextLoc(); + break; + case NoState: + WI_updateNoState(); + } +} + +void +WI_loadData() +{ + char name[10]; + anim_t* a; + int i, j; + sprintf(name, "WIMAP%d", wbs->epsd); - if ( gamemode == retail ) - { - if (wbs->epsd == 3) - strcpy(name,"INTERPIC"); - } - bg = W_CacheLumpName(name, PU_CACHE); - V_DrawPatch(0, 0, 1, bg); - if (gamemode == commercial) - { - NUMCMAPS = 32; - lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMCMAPS, - PU_STATIC, 0); - for (i=0 ; i<NUMCMAPS ; i++) - { - sprintf(name, "CWILV%2.2d", i); - lnames[i] = W_CacheLumpName(name, PU_STATIC); - } - } - else - { - lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMMAPS, - PU_STATIC, 0); - for (i=0 ; i<NUMMAPS ; i++) - { + bg = W_CacheLumpName(name, PU_CACHE); + V_DrawPatch(0, 0, 1, bg); + lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMMAPS, PU_STATIC, 0); + for (i = 0; i < NUMMAPS; ++i) { sprintf(name, "WILV%d%d", wbs->epsd, i); lnames[i] = W_CacheLumpName(name, PU_STATIC); } yah[0] = W_CacheLumpName("WIURH0", PU_STATIC); yah[1] = W_CacheLumpName("WIURH1", PU_STATIC); - splat = W_CacheLumpName("WISPLAT", PU_STATIC); - if (wbs->epsd < 3) - { - for (j=0;j<NUMANIMS[wbs->epsd];j++) - { - a = &anims[wbs->epsd][j]; - for (i=0;i<a->nanims;i++) - { - if (wbs->epsd != 1 || j != 8) - { - sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i); - a->p[i] = W_CacheLumpName(name, PU_STATIC); - } - else - { - a->p[i] = anims[1][4].p[i]; - } + splat = W_CacheLumpName("WISPLAT", PU_STATIC); + if (wbs->epsd < 3) { + for (j = 0; j < NUMANIMS[wbs->epsd]; ++j) { + a = &anims[wbs->epsd][j]; + for (i = 0; i < a->nanims; ++i) { + if (wbs->epsd != 1 || j != 8) { + sprintf(name, "WIA%d%02d%02d", wbs->epsd % 10, j % 100, i % 100); + a->p[i] = W_CacheLumpName(name, PU_STATIC); + } else a->p[i] = anims[1][4].p[i]; + } } - } } - } - wiminus = W_CacheLumpName("WIMINUS", PU_STATIC); - for (i=0;i<10;i++) - { - sprintf(name, "WINUM%d", i); - num[i] = W_CacheLumpName(name, PU_STATIC); - } - percent = W_CacheLumpName("WIPCNT", PU_STATIC); - finished = W_CacheLumpName("WIF", PU_STATIC); - entering = W_CacheLumpName("WIENTER", PU_STATIC); - kills = W_CacheLumpName("WIOSTK", PU_STATIC); - secret = W_CacheLumpName("WIOSTS", PU_STATIC); - sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC); - if (french) - { - if (netgame && !deathmatch) - items = W_CacheLumpName("WIOBJ", PU_STATIC); - else - items = W_CacheLumpName("WIOSTI", PU_STATIC); - } else + wiminus = W_CacheLumpName("WIMINUS", PU_STATIC); + for (i = 0; i < 10; ++i) { + sprintf(name, "WINUM%d", i); + num[i] = W_CacheLumpName(name, PU_STATIC); + } + percent = W_CacheLumpName("WIPCNT", PU_STATIC); + finished = W_CacheLumpName("WIF", PU_STATIC); + entering = W_CacheLumpName("WIENTER", PU_STATIC); + kills = W_CacheLumpName("WIOSTK", PU_STATIC); + secret = W_CacheLumpName("WIOSTS", PU_STATIC); + sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC); items = W_CacheLumpName("WIOSTI", PU_STATIC); - frags = W_CacheLumpName("WIFRGS", PU_STATIC); - colon = W_CacheLumpName("WICOLON", PU_STATIC); - time = W_CacheLumpName("WITIME", PU_STATIC); - sucks = W_CacheLumpName("WISUCKS", PU_STATIC); - par = W_CacheLumpName("WIPAR", PU_STATIC); - killers = W_CacheLumpName("WIKILRS", PU_STATIC); - victims = W_CacheLumpName("WIVCTMS", PU_STATIC); - total = W_CacheLumpName("WIMSTT", PU_STATIC); - star = W_CacheLumpName("STFST01", PU_STATIC); - bstar = W_CacheLumpName("STFDEAD0", PU_STATIC); - for (i=0 ; i<MAXPLAYERS ; i++) - { - sprintf(name, "STPB%d", i); - p[i] = W_CacheLumpName(name, PU_STATIC); - sprintf(name, "WIBP%d", i+1); - bp[i] = W_CacheLumpName(name, PU_STATIC); - } + frags = W_CacheLumpName("WIFRGS", PU_STATIC); + colon = W_CacheLumpName("WICOLON", PU_STATIC); + time = W_CacheLumpName("WITIME", PU_STATIC); + sucks = W_CacheLumpName("WISUCKS", PU_STATIC); + par = W_CacheLumpName("WIPAR", PU_STATIC); + killers = W_CacheLumpName("WIKILRS", PU_STATIC); + victims = W_CacheLumpName("WIVCTMS", PU_STATIC); + total = W_CacheLumpName("WIMSTT", PU_STATIC); + star = W_CacheLumpName("STFST01", PU_STATIC); + bstar = W_CacheLumpName("STFDEAD0", PU_STATIC); + for (i = 0; i < MAXPLAYERS; ++i) { + sprintf(name, "STPB%d", i); + p[i] = W_CacheLumpName(name, PU_STATIC); + sprintf(name, "WIBP%d", i+1); + bp[i] = W_CacheLumpName(name, PU_STATIC); + } } -void WI_unloadData(void) + +void +WI_unloadData() { - int i; - int j; - Z_ChangeTag(wiminus, PU_CACHE); - for (i=0 ; i<10 ; i++) - Z_ChangeTag(num[i], PU_CACHE); - if (gamemode == commercial) - { - for (i=0 ; i<NUMCMAPS ; i++) - Z_ChangeTag(lnames[i], PU_CACHE); - } - else - { + int i, j; + + Z_ChangeTag(wiminus, PU_CACHE); + for (i = 0; i < 10; ++i) + Z_ChangeTag(num[i], PU_CACHE); Z_ChangeTag(yah[0], PU_CACHE); Z_ChangeTag(yah[1], PU_CACHE); Z_ChangeTag(splat, PU_CACHE); - for (i=0 ; i<NUMMAPS ; i++) + for (i = 0; i < NUMMAPS; ++i) Z_ChangeTag(lnames[i], PU_CACHE); - if (wbs->epsd < 3) - { - for (j=0;j<NUMANIMS[wbs->epsd];j++) - { - if (wbs->epsd != 1 || j != 8) - for (i=0;i<anims[wbs->epsd][j].nanims;i++) - Z_ChangeTag(anims[wbs->epsd][j].p[i], PU_CACHE); + if (wbs->epsd < 3) { + for (j = 0; j < NUMANIMS[wbs->epsd]; ++j) { + if (wbs->epsd != 1 || j != 8) + for (i = 0; i < anims[wbs->epsd][j].nanims; ++i) + Z_ChangeTag(anims[wbs->epsd][j].p[i], PU_CACHE); } } - } - Z_Free(lnames); - Z_ChangeTag(percent, PU_CACHE); - Z_ChangeTag(colon, PU_CACHE); - Z_ChangeTag(finished, PU_CACHE); - Z_ChangeTag(entering, PU_CACHE); - Z_ChangeTag(kills, PU_CACHE); - Z_ChangeTag(secret, PU_CACHE); - Z_ChangeTag(sp_secret, PU_CACHE); - Z_ChangeTag(items, PU_CACHE); - Z_ChangeTag(frags, PU_CACHE); - Z_ChangeTag(time, PU_CACHE); - Z_ChangeTag(sucks, PU_CACHE); - Z_ChangeTag(par, PU_CACHE); - Z_ChangeTag(victims, PU_CACHE); - Z_ChangeTag(killers, PU_CACHE); - Z_ChangeTag(total, PU_CACHE); - for (i=0 ; i<MAXPLAYERS ; i++) - Z_ChangeTag(p[i], PU_CACHE); - for (i=0 ; i<MAXPLAYERS ; i++) - Z_ChangeTag(bp[i], PU_CACHE); + Z_Free(lnames); + Z_ChangeTag(percent, PU_CACHE); + Z_ChangeTag(colon, PU_CACHE); + Z_ChangeTag(finished, PU_CACHE); + Z_ChangeTag(entering, PU_CACHE); + Z_ChangeTag(kills, PU_CACHE); + Z_ChangeTag(secret, PU_CACHE); + Z_ChangeTag(sp_secret, PU_CACHE); + Z_ChangeTag(items, PU_CACHE); + Z_ChangeTag(frags, PU_CACHE); + Z_ChangeTag(time, PU_CACHE); + Z_ChangeTag(sucks, PU_CACHE); + Z_ChangeTag(par, PU_CACHE); + Z_ChangeTag(victims, PU_CACHE); + Z_ChangeTag(killers, PU_CACHE); + Z_ChangeTag(total, PU_CACHE); + for (i = 0; i < MAXPLAYERS; ++i) + Z_ChangeTag(p[i], PU_CACHE); + for (i = 0; i < MAXPLAYERS; ++i) + Z_ChangeTag(bp[i], PU_CACHE); } -void WI_Drawer (void) + +void +WI_End() { - switch (state) - { - case StatCount: - if (deathmatch) - WI_drawDeathmatchStats(); - else if (netgame) - WI_drawNetgameStats(); - else - WI_drawStats(); - break; - case ShowNextLoc: - WI_drawShowNextLoc(); - break; - case NoState: - WI_drawNoState(); - break; - } + WI_unloadData(); +} + +void +WI_Drawer() +{ + switch (state) { + case StatCount: + if (deathmatch) WI_drawDeathmatchStats(); + else if (netgame) WI_drawNetgameStats(); + else WI_drawStats(); + break; + case ShowNextLoc: + WI_drawShowNextLoc(); + break; + case NoState: + WI_drawNoState(); + } } -void WI_initVariables(wbstartstruct_t* wbstartstruct) + +void +WI_initVariables(wbstartstruct_t* wbstartstruct) { - wbs = wbstartstruct; -#ifdef RANGECHECKING - if (gamemode != commercial) - { - if ( gamemode == retail ) - RNGCHECK(wbs->epsd, 0, 3); - else - RNGCHECK(wbs->epsd, 0, 2); - } - else - { - RNGCHECK(wbs->last, 0, 8); - RNGCHECK(wbs->next, 0, 8); - } - RNGCHECK(wbs->pnum, 0, MAXPLAYERS); - RNGCHECK(wbs->pnum, 0, MAXPLAYERS); -#endif - acceleratestage = 0; - cnt = bcnt = 0; - firstrefresh = 1; - me = wbs->pnum; - plrs = wbs->plyr; - if (!wbs->maxkills) - wbs->maxkills = 1; - if (!wbs->maxitems) - wbs->maxitems = 1; - if (!wbs->maxsecret) - wbs->maxsecret = 1; - if ( gamemode != retail ) - if (wbs->epsd > 2) - wbs->epsd -= 3; + wbs = wbstartstruct; + acceleratestage = cnt = bcnt = 0; + firstrefresh = 1; + me = wbs->pnum; + plrs = wbs->plyr; + if (!wbs->maxkills) wbs->maxkills = 1; + if (!wbs->maxitems) wbs->maxitems = 1; + if (!wbs->maxsecret) wbs->maxsecret = 1; + if (wbs->epsd > 2) wbs->epsd -= 3; } -void WI_Start(wbstartstruct_t* wbstartstruct) + +void +WI_Start(wbstartstruct_t* wbstartstruct) { - WI_initVariables(wbstartstruct); - WI_loadData(); - if (deathmatch) - WI_initDeathmatchStats(); - else if (netgame) - WI_initNetgameStats(); - else - WI_initStats(); + + WI_initVariables(wbstartstruct); + WI_loadData(); + if (deathmatch) WI_initDeathmatchStats(); + else if (netgame) WI_initNetgameStats(); + else WI_initStats(); } diff --git a/src/wi_stuff.h b/src/wi_stuff.h @@ -1,13 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + #ifndef __WI_STUFF__ #define __WI_STUFF__ + + + #include "doomdef.h" + + + typedef enum { NoState = -1, StatCount, ShowNextLoc + } stateenum_t; + + void WI_Ticker (void); + + + void WI_Drawer (void); + + void WI_Start(wbstartstruct_t* wbstartstruct); + #endif + + + + + diff --git a/src/z_zone.c b/src/z_zone.c @@ -1,208 +1,204 @@ +#include <stdlib.h> + #include "z_zone.h" #include "i_system.h" #include "doomdef.h" -#define ZONEID 0x1d4a11 -typedef struct -{ - int size; - memblock_t blocklist; - memblock_t* rover; -} memzone_t; -memzone_t* mainzone; -void Z_ClearZone (memzone_t* zone) -{ - memblock_t* block; - zone->blocklist.next = - zone->blocklist.prev = - block = (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); - zone->blocklist.user = (void *)zone; - zone->blocklist.tag = PU_STATIC; - zone->rover = block; - block->prev = block->next = &zone->blocklist; - block->user = NULL; - block->size = zone->size - sizeof(memzone_t); -} -void Z_Init (void) + +#define ZONEID 0x1d4a11 +#define MINFRAGMENT 64 + +typedef struct memzone_t memzone_t; + +struct memzone_t { + int size; + memblock_t mainblock; + memblock_t* rover; +}; + +memzone_t* mainzone_g; + +void +Z_Init() { - memblock_t* block; - int size; - mainzone = (memzone_t *)I_ZoneBase (&size); - mainzone->size = size; - mainzone->blocklist.next = - mainzone->blocklist.prev = - block = (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) ); - mainzone->blocklist.user = (void *)mainzone; - mainzone->blocklist.tag = PU_STATIC; - mainzone->rover = block; - block->prev = block->next = &mainzone->blocklist; - block->user = NULL; - block->size = mainzone->size - sizeof(memzone_t); + mainzone_g = malloc(4 * 1024 * 1024); + mainzone_g->size = 4 * 1024 * 1024; + mainzone_g->mainblock.user = (void*)mainzone_g; + mainzone_g->mainblock.tag = PU_STATIC; + mainzone_g->mainblock.prev = + mainzone_g->mainblock.next = + mainzone_g->rover = (memblock_t*)((uchar*)mainzone_g + sizeof(*mainzone_g)); + mainzone_g->rover->prev = + mainzone_g->rover->next = &mainzone_g->mainblock; + mainzone_g->rover->user = NULL; + mainzone_g->rover->size = mainzone_g->size - sizeof(*mainzone_g); } -void Z_Free (void* ptr) + +void +Z_Free(void* ptr) { - memblock_t* block; - memblock_t* other; - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); + memblock_t* block; + memblock_t* other; + + block = (memblock_t*)((uchar*)ptr - sizeof(memblock_t)); if (block->id != ZONEID) - I_Error ("Z_Free: freed a pointer without ZONEID"); - if (block->user > (void **)0x100) - { - *block->user = 0; - } - block->user = NULL; + I_Error("Z_Free: freed a pointer without ZONEID"); + if (block->user > (void**)0x100) + *block->user = 0; + block->user = NULL; block->tag = 0; block->id = 0; other = block->prev; - if (!other->user) - { - other->size += block->size; - other->next = block->next; - other->next->prev = other; - if (block == mainzone->rover) - mainzone->rover = other; - block = other; - } + if (!other->user) { + other->size += block->size; + other->next = block->next; + other->next->prev = other; + if (block == mainzone_g->rover) + mainzone_g->rover = other; + block = other; + } other = block->next; - if (!other->user) - { - block->size += other->size; - block->next = other->next; - block->next->prev = block; - if (other == mainzone->rover) - mainzone->rover = block; + if (!other->user) { + block->size += other->size; + block->next = other->next; + block->next->prev = block; + if (other == mainzone_g->rover) mainzone_g->rover = block; } } -#define MINFRAGMENT 64 + void* -Z_Malloc -( int size, - int tag, - void* user ) +Z_Malloc(int size, int tag, void* user) { - int extra; - memblock_t* start; - memblock_t* rover; - memblock_t* newblock; - memblock_t* base; + memblock_t* start, *rover, *newblock, *base; + int extra; + size = (size + 3) & ~3; size += sizeof(memblock_t); - base = mainzone->rover; + base = mainzone_g->rover; if (!base->prev->user) - base = base->prev; + base = base->prev; rover = base; start = base->prev; - do - { - if (rover == start) - { - I_Error ("Z_Malloc: failed on allocation of %i bytes", size); - } - if (rover->user) - { - if (rover->tag < PU_PURGELEVEL) - { - base = rover = rover->next; - } - else - { - base = base->prev; - Z_Free ((byte *)rover+sizeof(memblock_t)); - base = base->next; - rover = base->next; - } - } - else - rover = rover->next; + do { + if (rover == start) + I_Error("Z_Malloc: failed on allocation of %i bytes", size); + if (rover->user) { + if (rover->tag < PU_PURGELEVEL) + base = rover = rover->next; + else { + base = base->prev; + Z_Free((byte*)rover + sizeof(memblock_t)); + base = base->next; + rover = base->next; + } + } + else + rover = rover->next; } while (base->user || base->size < size); extra = base->size - size; - if (extra > MINFRAGMENT) - { - newblock = (memblock_t *) ((byte *)base + size ); - newblock->size = extra; - newblock->user = NULL; - newblock->tag = 0; - newblock->prev = base; - newblock->next = base->next; - newblock->next->prev = newblock; - base->next = newblock; - base->size = size; - } - if (user) - { - base->user = user; - *(void **)user = (void *) ((byte *)base + sizeof(memblock_t)); + if (extra > MINFRAGMENT) { + newblock = (memblock_t*)((uchar*)base + size); + newblock->size = extra; + newblock->user = NULL; + newblock->tag = 0; + newblock->prev = base; + newblock->next = base->next; + newblock->next->prev = newblock; + base->next = newblock; + base->size = size; } - else - { - if (tag >= PU_PURGELEVEL) - I_Error ("Z_Malloc: an owner is required for purgable blocks"); - base->user = (void *)2; + if (user) { + base->user = user; + *(void**)user = (void*)((byte*)base + sizeof(memblock_t)); + } else { + if (tag >= PU_PURGELEVEL) + I_Error("Z_Malloc: an owner is required for purgable blocks"); + base->user = (void*)2; } base->tag = tag; - mainzone->rover = base->next; + mainzone_g->rover = base->next; base->id = ZONEID; - return (void *) ((byte *)base + sizeof(memblock_t)); + return (void*)((byte*)base + sizeof(memblock_t)); } + void -Z_FreeTags -( int lowtag, - int hightag ) +Z_FreeTags(int lowtag, int hightag) +{ + memblock_t* block; + memblock_t* next; + + for (block = mainzone_g->mainblock.next; block != &mainzone_g->mainblock; block = next) { + next = block->next; + if (!block->user) + continue; + if (block->tag >= lowtag && block->tag <= hightag) + Z_Free((byte*)block+sizeof(memblock_t)); + } +} + +void +Z_DumpHeap(int lowtag, int hightag) +{ + memblock_t* block; + + printf("zone size: %i location: %p\n", mainzone_g->size, (void*)mainzone_g); + printf("tag range: %i to %i\n", lowtag, hightag); + for (block = mainzone_g->mainblock.next;; block = block->next) { + if (block->tag >= lowtag && block->tag <= hightag) printf("block:%p size:%7i user:%p tag:%3i\n", (void*)block, block->size, (void*)block->user, block->tag); + if (block->next == &mainzone_g->mainblock) break; + if ((byte*)block + block->size != (byte*)block->next) printf("ERROR: block size does not touch the next block\n"); + if (block->next->prev != block) printf("ERROR: next block doesn't have proper back link\n"); + if (!block->user && !block->next->user) printf("ERROR: two consecutive free blocks\n"); + } +} + +void +Z_FileDumpHeap(FILE* f) { memblock_t* block; - memblock_t* next; - for (block = mainzone->blocklist.next ; - block != &mainzone->blocklist ; - block = next) - { - next = block->next; - if (!block->user) - continue; - if (block->tag >= lowtag && block->tag <= hightag) - Z_Free ( (byte *)block+sizeof(memblock_t)); + + fprintf(f, "zone size: %i location: %p\n", mainzone_g->size, (void*)mainzone_g); + for (block = mainzone_g->mainblock.next;; block = block->next) { + fprintf(f, "block:%p size:%7i user:%p tag:%3i\n", (void*)block, block->size, (void*)block->user, block->tag); + if (block->next == &mainzone_g->mainblock) break; + if ((byte*)block + block->size != (byte*)block->next) fprintf(f, "ERROR: block size does not touch the next block\n"); + if (block->next->prev != block) fprintf(f, "ERROR: next block doesn't have proper back link\n"); + if (!block->user && !block->next->user) fprintf(f, "ERROR: two consecutive free blocks\n"); } } -void Z_CheckHeap (void) +void +Z_CheckHeap() { memblock_t* block; - for (block = mainzone->blocklist.next ; ; block = block->next) - { - if (block->next == &mainzone->blocklist) - { - break; - } - if ( (byte *)block + block->size != (byte *)block->next) - I_Error ("Z_CheckHeap: block size does not touch the next block\n"); - if ( block->next->prev != block) - I_Error ("Z_CheckHeap: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) - I_Error ("Z_CheckHeap: two consecutive free blocks\n"); + + for (block = mainzone_g->mainblock.next;; block = block->next) { + if (block->next == &mainzone_g->mainblock) break; + if ((byte*)block + block->size != (byte*)block->next) I_Error("Z_CheckHeap: block size does not touch the next block\n"); + if (block->next->prev != block) I_Error("Z_CheckHeap: next block doesn't have proper back link\n"); + if (!block->user && !block->next->user) I_Error("Z_CheckHeap: two consecutive free blocks\n"); } } + void -Z_ChangeTag2 -( void* ptr, - int tag ) +Z_ChangeTag2(void* ptr, int tag) { memblock_t* block; - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); - if (block->id != ZONEID) - I_Error ("Z_ChangeTag: freed a pointer without ZONEID"); - if (tag >= PU_PURGELEVEL && (unsigned long)block->user < 0x100) - I_Error ("Z_ChangeTag: an owner is required for purgable blocks"); - block->tag = tag; + + block = (memblock_t*)((byte*)ptr - sizeof(memblock_t)); + if (block->id != ZONEID) I_Error("Z_ChangeTag: freed a pointer without ZONEID"); + if (tag >= PU_PURGELEVEL &&(unsigned long)block->user < 0x100) I_Error("Z_ChangeTag: an owner is required for purgable blocks"); + block->tag = tag; } -int Z_FreeMemory (void) + +int +Z_FreeMemory() { - memblock_t* block; - int free; + memblock_t* block; + int free; + free = 0; - for (block = mainzone->blocklist.next ; - block != &mainzone->blocklist; - block = block->next) - { - if (!block->user || block->tag >= PU_PURGELEVEL) - free += block->size; - } + for (block = mainzone_g->mainblock.next; block != &mainzone_g->mainblock; block = block->next) + if (!block->user || block->tag >= PU_PURGELEVEL) + free += block->size; return free; } diff --git a/src/z_zone.h b/src/z_zone.h @@ -1,36 +1,43 @@ #ifndef __Z_ZONE__ #define __Z_ZONE__ + #include <stdio.h> -#define PU_STATIC 1 -#define PU_SOUND 2 -#define PU_MUSIC 3 -#define PU_DAVE 4 -#define PU_LEVEL 50 -#define PU_LEVSPEC 51 -#define PU_PURGELEVEL 100 -#define PU_CACHE 101 -void Z_Init (void); -void* Z_Malloc (int size, int tag, void *ptr); -void Z_Free (void *ptr); -void Z_FreeTags (int lowtag, int hightag); -void Z_DumpHeap (int lowtag, int hightag); -void Z_FileDumpHeap (FILE *f); -void Z_CheckHeap (void); -void Z_ChangeTag2 (void *ptr, int tag); -int Z_FreeMemory (void); -typedef struct memblock_s -{ - int size; - void** user; - int tag; - int id; - struct memblock_s* next; - struct memblock_s* prev; -} memblock_t; + +#define PU_STATIC 1 +#define PU_SOUND 2 +#define PU_MUSIC 3 +#define PU_DAVE 4 +#define PU_LEVEL 50 +#define PU_LEVSPEC 51 +#define PU_PURGELEVEL 100 +#define PU_CACHE 101 + +void Z_Init(void); +void* Z_Malloc(int size, int tag, void *ptr); +void Z_Free(void *ptr); +void Z_FreeTags(int lowtag, int hightag); +void Z_DumpHeap(int lowtag, int hightag); +void Z_FileDumpHeap(FILE *f); +void Z_CheckHeap(void); +void Z_ChangeTag2(void *ptr, int tag); +int Z_FreeMemory(void); + +typedef struct memblock_t memblock_t; + +struct memblock_t { + int size; + void** user; + int tag; + int id; + memblock_t* next; + memblock_t* prev; +}; + #define Z_ChangeTag(p,t) \ { \ - if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \ + if (((memblock_t *)((byte*)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \ I_Error("Z_CT at "__FILE__":%i",__LINE__); \ Z_ChangeTag2(p,t); \ }; + #endif