From bbbccb7b114e7bfd5fab0ac38df9c3ebf9959a08 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 16 Nov 2006 03:02:42 +0000 Subject: [PATCH] Hopefully the last of the formatting changes + sound support for Linux. Previous commit also fixes the mouse cursor grab issue. git-svn-id: https://svn.eduke32.com/eduke32@337 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile | 21 +- polymer/eduke32/Makefile.deps | 5 + polymer/eduke32/source/actors.c | 8834 ++++++------ polymer/eduke32/source/anim.c | 228 +- polymer/eduke32/source/astub.c | 3445 +++-- polymer/eduke32/source/config.c | 16 +- polymer/eduke32/source/game.c | 7764 +++++------ polymer/eduke32/source/gamedef.c | 5826 ++++---- polymer/eduke32/source/gameexec.c | 11502 ++++++++-------- polymer/eduke32/source/grpscan.c | 11 +- polymer/eduke32/source/grpscan.h | 2 +- polymer/eduke32/source/jaudiolib/_multivc.h | 13 +- .../source/jaudiolib/audiolib_fx_fmod.c | 766 +- .../source/jaudiolib/audiolib_fxstub.c | 294 +- .../source/jaudiolib/audiolib_musicstub.c | 360 +- polymer/eduke32/source/jaudiolib/debugio.h | 30 + polymer/eduke32/source/jaudiolib/dma.h | 83 + polymer/eduke32/source/jaudiolib/dpmi.h | 43 + polymer/eduke32/source/jaudiolib/dsl.c | 266 + polymer/eduke32/source/jaudiolib/dsl.h | 50 + polymer/eduke32/source/jaudiolib/dsoundout.c | 751 +- polymer/eduke32/source/jaudiolib/fx_man.c | 1136 +- polymer/eduke32/source/jaudiolib/interrup.h | 50 + polymer/eduke32/source/jaudiolib/ll_man.c | 94 +- polymer/eduke32/source/jaudiolib/midi.c | 2635 ++-- polymer/eduke32/source/jaudiolib/mpu401.c | 488 +- polymer/eduke32/source/jaudiolib/multivoc.c | 3640 ++--- polymer/eduke32/source/jaudiolib/music.c | 490 +- polymer/eduke32/source/jaudiolib/nodpmi.c | 50 + polymer/eduke32/source/jaudiolib/pitch.c | 186 +- polymer/eduke32/source/jaudiolib/platform.h | 61 + polymer/eduke32/source/jaudiolib/sdlmusic.c | 477 + polymer/eduke32/source/jaudiolib/sdlout.c | 228 +- polymer/eduke32/source/jaudiolib/unixglob.c | 151 + polymer/eduke32/source/jaudiolib/unixpitch.c | 213 + polymer/eduke32/source/jaudiolib/unixvoc.c | 2710 ++++ polymer/eduke32/source/jaudiolib/util.h | 12 + polymer/eduke32/source/menus.c | 7775 ++++++----- polymer/eduke32/source/namesdyn.c | 1570 +-- polymer/eduke32/source/osdcmds.c | 186 +- polymer/eduke32/source/player.c | 3076 ++--- polymer/eduke32/source/premap.c | 606 +- polymer/eduke32/source/savegame.c | 64 +- polymer/eduke32/source/sector.c | 3538 ++--- polymer/eduke32/source/sounds.c | 60 +- polymer/eduke32/source/startgtk.game.c | 44 +- polymer/eduke32/source/startwin.game.c | 476 +- 47 files changed, 37320 insertions(+), 33006 deletions(-) create mode 100755 polymer/eduke32/source/jaudiolib/debugio.h create mode 100755 polymer/eduke32/source/jaudiolib/dma.h create mode 100755 polymer/eduke32/source/jaudiolib/dpmi.h create mode 100755 polymer/eduke32/source/jaudiolib/dsl.c create mode 100755 polymer/eduke32/source/jaudiolib/dsl.h create mode 100755 polymer/eduke32/source/jaudiolib/interrup.h create mode 100755 polymer/eduke32/source/jaudiolib/nodpmi.c create mode 100755 polymer/eduke32/source/jaudiolib/platform.h create mode 100755 polymer/eduke32/source/jaudiolib/sdlmusic.c create mode 100755 polymer/eduke32/source/jaudiolib/unixglob.c create mode 100755 polymer/eduke32/source/jaudiolib/unixpitch.c create mode 100755 polymer/eduke32/source/jaudiolib/unixvoc.c create mode 100755 polymer/eduke32/source/jaudiolib/util.h diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index d1f849976..77e9eff25 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -66,9 +66,21 @@ JMACTOBJ=$(OBJ)/util_lib.$o \ $(OBJ)/mathutil.$o \ $(OBJ)/scriplib.$o -AUDIOLIB_FX_STUB=$(OBJ)/audiolib_fxstub.$o -AUDIOLIB_MUSIC_STUB=$(OBJ)/audiolib_musicstub.$o +AUDIOLIB_FX_SDL=$(OBJ)/mv_mix.$o \ + $(OBJ)/mv_mix16.$o \ + $(OBJ)/mvreverb.$o \ + $(OBJ)/ll_man.$o \ + $(OBJ)/fx_man.$o \ + $(OBJ)/dsl.$o \ + $(OBJ)/nodpmi.$o \ + $(OBJ)/unixpitch.$o \ + $(OBJ)/unixvoc.$o + +AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o \ + $(OBJ)/unixglob.$o + AUDIOLIB_JFAUD=$(OBJ)/jfaud_sounds.$o + AUDIOLIB_FX=$(OBJ)/mv_mix.$o \ $(OBJ)/mv_mix16.$o \ $(OBJ)/mvreverb.$o \ @@ -99,7 +111,7 @@ GAMEOBJS=$(OBJ)/game.$o \ $(OBJ)/testcd.$o \ $(OBJ)/osdfuncs.$o \ $(OBJ)/osdcmds.$o \ - $(OBJ)/grpscan.$o \ + $(OBJ)/grpscan.$o \ $(JMACTOBJ) EDITOROBJS=$(OBJ)/astub.$o @@ -113,11 +125,12 @@ endif ifeq ($(RENDERTYPE),SDL) OURCFLAGS+= $(subst -Dmain=SDL_main,,$(shell sdl-config --cflags)) + LIBS+= -lSDL_mixer ifneq (0,$(JFAUD)) AUDIOLIBOBJ=$(AUDIOLIB_JFAUD) else - AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_STUB) $(AUDIOLIB_FX_STUB) $(OBJ)/sounds.$o + AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_SDL) $(AUDIOLIB_FX_SDL) $(OBJ)/sounds.$o endif ifeq (1,$(HAVE_GTK2)) diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index 77cc1bcc1..30e40d87c 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -45,6 +45,11 @@ $(OBJ)/mathutil.$o: $(SRC)/jmact/mathutil.c $(SRC)/jmact/types.h $(OBJ)/scriplib.$o: $(SRC)/jmact/scriplib.c $(SRC)/jmact/scriplib.h $(SRC)/jmact/util_lib.h $(SRC)/jmact/_scrplib.h $(SRC)/jmact/types.h $(EINC)/compat.h # jAudioLib objects +$(OBJ)/dsl.$o: $(SRC)/jaudiolib/dsl.c $(SRC)/jaudiolib/util.h +$(OBJ)/nodpmi.$o: $(SRC)/jaudiolib/nodpmi.c $(SRC)/jaudiolib/dpmi.h +$(OBJ)/unixpitch.$o: $(SRC)/jaudiolib/unixpitch.c $(SRC)/jaudiolib/pitch.h +$(OBJ)/unixvoc.$o: $(SRC)/jaudiolib/unixvoc.c $(SRC)/jaudiolib/usrhooks.h $(SRC)/jaudiolib/linklist.h $(SRC)/jaudiolib/pitch.h $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/_multivc.h + $(OBJ)/audiolib_fxstub.$o: $(SRC)/jaudiolib/audiolib_fxstub.c $(SRC)/jaudiolib/fx_man.h $(OBJ)/audiolib_musicstub.$o: $(SRC)/jaudiolib/audiolib_musicstub.c $(SRC)/jaudiolib/music.h diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index e0d130405..2ed7d3256 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -117,37 +117,37 @@ void addweaponnoswitch(struct player_struct *p, short weapon) } switch (p->curr_weapon) { - case KNEE_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - break; - case SHOTGUN_WEAPON: - stopspritesound(SHOTGUN_COCK,p->i); - break; - case PISTOL_WEAPON: - stopspritesound(INSERT_CLIP,p->i); - break; - default: - stopspritesound(SELECT_WEAPON,p->i); - break; + case KNEE_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: + break; + case SHOTGUN_WEAPON: + stopspritesound(SHOTGUN_COCK,p->i); + break; + case PISTOL_WEAPON: + stopspritesound(INSERT_CLIP,p->i); + break; + default: + stopspritesound(SELECT_WEAPON,p->i); + break; } switch (weapon) { - case KNEE_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - break; - case SHOTGUN_WEAPON: - spritesound(SHOTGUN_COCK,p->i); - break; - case PISTOL_WEAPON: - spritesound(INSERT_CLIP,p->i); - break; - default: - spritesound(SELECT_WEAPON,p->i); - break; + case KNEE_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: + break; + case SHOTGUN_WEAPON: + spritesound(SHOTGUN_COCK,p->i); + break; + case PISTOL_WEAPON: + spritesound(INSERT_CLIP,p->i); + break; + default: + spritesound(SELECT_WEAPON,p->i); + break; } } @@ -832,32 +832,32 @@ void movefta(void) if (j) switch (dynamictostatic[s->picnum]) { - case RUBBERCAN__STATIC: - case EXPLODINGBARREL__STATIC: - case WOODENHORSE__STATIC: - case HORSEONSIDE__STATIC: - case CANWITHSOMETHING__STATIC: - case CANWITHSOMETHING2__STATIC: - case CANWITHSOMETHING3__STATIC: - case CANWITHSOMETHING4__STATIC: - case FIREBARREL__STATIC: - case FIREVASE__STATIC: - case NUKEBARREL__STATIC: - case NUKEBARRELDENTED__STATIC: - case NUKEBARRELLEAKED__STATIC: - case TRIPBOMB__STATIC: - if (sector[s->sectnum].ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; + case RUBBERCAN__STATIC: + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + case FIREBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TRIPBOMB__STATIC: + if (sector[s->sectnum].ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + s->shade = sector[s->sectnum].ceilingshade; + else s->shade = sector[s->sectnum].floorshade; - hittype[i].timetosleep = 0; - changespritestat(i,6); - break; - default: - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i,1); - break; + hittype[i].timetosleep = 0; + changespritestat(i,6); + break; + default: + hittype[i].timetosleep = 0; + check_fta_sounds(i); + changespritestat(i,1); + break; } else hittype[i].timetosleep = 0; } @@ -952,24 +952,24 @@ short ifhitbyweapon(short sn) switch (dynamictostatic[hittype[sn].picnum]) { - case RADIUSEXPLOSION__STATIC: - case RPG__STATIC: - case HYDRENT__STATIC: - case HEAVYHBOMB__STATIC: - case SEENINE__STATIC: - case OOZFILTER__STATIC: - case EXPLODINGBARREL__STATIC: - ps[p].posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; - ps[p].posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; - break; - default: - ps[p].posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<1; - ps[p].posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<1; - break; + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case HYDRENT__STATIC: + case HEAVYHBOMB__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + case EXPLODINGBARREL__STATIC: + ps[p].posxv += + hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; + ps[p].posyv += + hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; + break; + default: + ps[p].posxv += + hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<1; + ps[p].posyv += + hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<1; + break; } } else @@ -1225,85 +1225,85 @@ void movefx(void) switch (dynamictostatic[s->picnum]) { - case RESPAWN__STATIC: - if (sprite[i].extra == 66) + case RESPAWN__STATIC: + if (sprite[i].extra == 66) + { + j = spawn(i,SHT); + // sprite[j].pal = sprite[i].pal; + KILLIT(i); + } + else if (sprite[i].extra > (66-13)) + sprite[i].extra++; + break; + + case MUSICANDSFX__STATIC: + + ht = s->hitag; + + if (T2 != SoundToggle) + { + T2 = SoundToggle; + T1 = 0; + } + + if (s->lotag >= 1000 && s->lotag < 2000) + { + x = ldist(&sprite[ps[screenpeek].i],s); + if (x < ht && T1 == 0) { - j = spawn(i,SHT); - // sprite[j].pal = sprite[i].pal; - KILLIT(i); + FX_SetReverb(s->lotag - 1000); + T1 = 1; } - else if (sprite[i].extra > (66-13)) - sprite[i].extra++; - break; - - case MUSICANDSFX__STATIC: - - ht = s->hitag; - - if (T2 != SoundToggle) + if (x >= ht && T1 == 1) { - T2 = SoundToggle; + FX_SetReverb(0); + FX_SetReverbDelay(0); T1 = 0; } - - if (s->lotag >= 1000 && s->lotag < 2000) + } + else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < 9 && AmbienceToggle && sector[SECT].floorz != sector[SECT].ceilingz) + { + if ((soundm[s->lotag]&2)) { - x = ldist(&sprite[ps[screenpeek].i],s); - if (x < ht && T1 == 0) + x = dist(&sprite[ps[screenpeek].i],s); + if (x < ht && T1 == 0 && FX_VoiceAvailable(soundpr[s->lotag]-1)) { - FX_SetReverb(s->lotag - 1000); + if (numenvsnds == NumVoices) + { + j = headspritestat[11]; + while (j >= 0) + { + if (PN == MUSICANDSFX && j != i && sprite[j].lotag < 999 && hittype[j].temp_data[0] == 1 && dist(&sprite[j],&sprite[ps[screenpeek].i]) > x) + { + stopenvsound(sprite[j].lotag,j); + break; + } + j = nextspritestat[j]; + } + if (j == -1) goto BOLT; + } + spritesound(s->lotag,i); T1 = 1; } if (x >= ht && T1 == 1) { - FX_SetReverb(0); - FX_SetReverbDelay(0); T1 = 0; + stopenvsound(s->lotag,i); } } - else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < 9 && AmbienceToggle && sector[SECT].floorz != sector[SECT].ceilingz) + if ((soundm[s->lotag]&16)) { - if ((soundm[s->lotag]&2)) - { - x = dist(&sprite[ps[screenpeek].i],s); - if (x < ht && T1 == 0 && FX_VoiceAvailable(soundpr[s->lotag]-1)) - { - if (numenvsnds == NumVoices) + if (T5 > 0) T5--; + else for (p=connecthead;p>=0;p=connectpoint2[p]) + if (p == myconnectindex && ps[p].cursectnum == s->sectnum) { - j = headspritestat[11]; - while (j >= 0) - { - if (PN == MUSICANDSFX && j != i && sprite[j].lotag < 999 && hittype[j].temp_data[0] == 1 && dist(&sprite[j],&sprite[ps[screenpeek].i]) > x) - { - stopenvsound(sprite[j].lotag,j); - break; - } - j = nextspritestat[j]; - } - if (j == -1) goto BOLT; + j = s->lotag+((unsigned)global_random%(s->hitag+1)); + sound(j); + T5 = 26*40 + (global_random%(26*40)); } - spritesound(s->lotag,i); - T1 = 1; - } - if (x >= ht && T1 == 1) - { - T1 = 0; - stopenvsound(s->lotag,i); - } - } - if ((soundm[s->lotag]&16)) - { - if (T5 > 0) T5--; - else for (p=connecthead;p>=0;p=connectpoint2[p]) - if (p == myconnectindex && ps[p].cursectnum == s->sectnum) - { - j = s->lotag+((unsigned)global_random%(s->hitag+1)); - sound(j); - T5 = 26*40 + (global_random%(26*40)); - } - } } - break; + } + break; } BOLT: i = nexti; @@ -1445,14 +1445,14 @@ void movestandables(void) nextj = nextspritesect[j]; switch (sprite[j].statnum) { - case 1: - case 2: - case 6: - case 10: - s->ang = getangle(msx[t[4]+1]-s->x,msy[t[4]+1]-s->y); - setsprite(j,msx[t[4]+1],msy[t[4]+1],sprite[j].z); - t[0]++; - goto BOLT; + case 1: + case 2: + case 6: + case 10: + s->ang = getangle(msx[t[4]+1]-s->x,msy[t[4]+1]-s->y); + setsprite(j,msx[t[4]+1],msy[t[4]+1],sprite[j].z); + t[0]++; + goto BOLT; } j = nextj; } @@ -1521,10 +1521,10 @@ void movestandables(void) { switch (sprite[j].statnum) { - case 1: - case 6: - s->owner = j; - break; + case 1: + case 6: + s->owner = j; + break; } j = nextspritesect[j]; } @@ -2025,26 +2025,26 @@ DETONATE: { switch (sprite[j].lotag) { - case 2: - case 21: - case 31: - case 32: - case 36: - hittype[j].temp_data[0] = 1; - break; - case 3: - hittype[j].temp_data[4] = 1; - break; + case 2: + case 21: + case 31: + case 32: + case 36: + hittype[j].temp_data[0] = 1; + break; + case 3: + hittype[j].temp_data[4] = 1; + break; } } else if (sprite[j].statnum == 6) { switch (dynamictostatic[sprite[j].picnum]) { - case SEENINE__STATIC: - case OOZFILTER__STATIC: - sprite[j].shade = -31; - break; + case SEENINE__STATIC: + case OOZFILTER__STATIC: + sprite[j].shade = -31; + break; } } j = nextspritesect[j]; @@ -2066,287 +2066,287 @@ DETONATE: switch (dynamictostatic[switchpicnum]) { - case VIEWSCREEN__STATIC: - case VIEWSCREEN2__STATIC: + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: - if (s->xrepeat == 0) KILLIT(i); + if (s->xrepeat == 0) KILLIT(i); - p = findplayer(s, &x); + p = findplayer(s, &x); - if (x < 2048) - { - if (SP == 1) - camsprite = i; - } - else if (camsprite != -1 && T1 == 1) - { - camsprite = -1; - T1 = 0; - //loadtile(s->picnum); - //invalidatetile(s->picnum,-1,255); - walock[TILE_VIEWSCR] = 199; + if (x < 2048) + { + if (SP == 1) + camsprite = i; + } + else if (camsprite != -1 && T1 == 1) + { + camsprite = -1; + T1 = 0; + //loadtile(s->picnum); + //invalidatetile(s->picnum,-1,255); + walock[TILE_VIEWSCR] = 199; + } + + goto BOLT; + + case TRASH__STATIC: + + if (s->xvel == 0) s->xvel = 1; + IFMOVING + { + makeitfall(i); + if (TRAND&1) s->zvel -= 256; + if (klabs(s->xvel) < 48) + s->xvel += (TRAND&3); } + else KILLIT(i); + break; - goto BOLT; - - case TRASH__STATIC: - - if (s->xvel == 0) s->xvel = 1; - IFMOVING - { - makeitfall(i); - if (TRAND&1) s->zvel -= 256; - if (klabs(s->xvel) < 48) - s->xvel += (TRAND&3); - } - else KILLIT(i); - break; - - case SIDEBOLT1__STATIC: - // case SIDEBOLT1+1: - // case SIDEBOLT1+2: - // case SIDEBOLT1+3: - p = findplayer(s, &x); - if (x > 20480) goto BOLT; + case SIDEBOLT1__STATIC: + // case SIDEBOLT1+1: + // case SIDEBOLT1+2: + // case SIDEBOLT1+3: + p = findplayer(s, &x); + if (x > 20480) goto BOLT; CLEAR_THE_BOLT2: - if (t[2]) - { - t[2]--; - goto BOLT; - } - if ((s->xrepeat|s->yrepeat) == 0) - { - s->xrepeat=t[0]; - s->yrepeat=t[1]; - } - if ((TRAND&8) == 0) - { - t[0]=s->xrepeat; - t[1]=s->yrepeat; - t[2] = global_random&4; - s->xrepeat=s->yrepeat=0; - goto CLEAR_THE_BOLT2; - } - s->picnum++; - - if (l&1) s->cstat ^= 2; - - if ((TRAND&1) && sector[sect].floorpicnum == HURTRAIL) - spritesound(SHORT_CIRCUIT,i); - - if (s->picnum == SIDEBOLT1+4) s->picnum = SIDEBOLT1; - + if (t[2]) + { + t[2]--; goto BOLT; + } + if ((s->xrepeat|s->yrepeat) == 0) + { + s->xrepeat=t[0]; + s->yrepeat=t[1]; + } + if ((TRAND&8) == 0) + { + t[0]=s->xrepeat; + t[1]=s->yrepeat; + t[2] = global_random&4; + s->xrepeat=s->yrepeat=0; + goto CLEAR_THE_BOLT2; + } + s->picnum++; - case BOLT1__STATIC: - // case BOLT1+1: - // case BOLT1+2: - // case BOLT1+3: - p = findplayer(s, &x); - if (x > 20480) goto BOLT; + if (l&1) s->cstat ^= 2; - if (t[3] == 0) - t[3]=sector[sect].floorshade; + if ((TRAND&1) && sector[sect].floorpicnum == HURTRAIL) + spritesound(SHORT_CIRCUIT,i); + + if (s->picnum == SIDEBOLT1+4) s->picnum = SIDEBOLT1; + + goto BOLT; + + case BOLT1__STATIC: + // case BOLT1+1: + // case BOLT1+2: + // case BOLT1+3: + p = findplayer(s, &x); + if (x > 20480) goto BOLT; + + if (t[3] == 0) + t[3]=sector[sect].floorshade; CLEAR_THE_BOLT: - if (t[2]) - { - t[2]--; - sector[sect].floorshade = 20; - sector[sect].ceilingshade = 20; - goto BOLT; - } - if ((s->xrepeat|s->yrepeat) == 0) - { - s->xrepeat=t[0]; - s->yrepeat=t[1]; - } - else if ((TRAND&8) == 0) - { - t[0]=s->xrepeat; - t[1]=s->yrepeat; - t[2] = global_random&4; - s->xrepeat=s->yrepeat=0; - goto CLEAR_THE_BOLT; - } - s->picnum++; - - l = global_random&7; - s->xrepeat=l+8; - - if (l&1) s->cstat ^= 2; - - if (s->picnum == (BOLT1+1) && (TRAND&7) == 0 && sector[sect].floorpicnum == HURTRAIL) - spritesound(SHORT_CIRCUIT,i); - - if (s->picnum==BOLT1+4) s->picnum=BOLT1; - - if (s->picnum&1) - { - sector[sect].floorshade = 0; - sector[sect].ceilingshade = 0; - } - else - { - sector[sect].floorshade = 20; - sector[sect].ceilingshade = 20; - } + if (t[2]) + { + t[2]--; + sector[sect].floorshade = 20; + sector[sect].ceilingshade = 20; goto BOLT; + } + if ((s->xrepeat|s->yrepeat) == 0) + { + s->xrepeat=t[0]; + s->yrepeat=t[1]; + } + else if ((TRAND&8) == 0) + { + t[0]=s->xrepeat; + t[1]=s->yrepeat; + t[2] = global_random&4; + s->xrepeat=s->yrepeat=0; + goto CLEAR_THE_BOLT; + } + s->picnum++; - case WATERDRIP__STATIC: + l = global_random&7; + s->xrepeat=l+8; - if (t[1]) + if (l&1) s->cstat ^= 2; + + if (s->picnum == (BOLT1+1) && (TRAND&7) == 0 && sector[sect].floorpicnum == HURTRAIL) + spritesound(SHORT_CIRCUIT,i); + + if (s->picnum==BOLT1+4) s->picnum=BOLT1; + + if (s->picnum&1) + { + sector[sect].floorshade = 0; + sector[sect].ceilingshade = 0; + } + else + { + sector[sect].floorshade = 20; + sector[sect].ceilingshade = 20; + } + goto BOLT; + + case WATERDRIP__STATIC: + + if (t[1]) + { + t[1]--; + if (t[1] == 0) + s->cstat &= 32767; + } + else + { + makeitfall(i); + ssp(i,CLIPMASK0); + if (s->xvel > 0) s->xvel -= 2; + + if (s->zvel == 0) { - t[1]--; - if (t[1] == 0) - s->cstat &= 32767; - } - else - { - makeitfall(i); - ssp(i,CLIPMASK0); - if (s->xvel > 0) s->xvel -= 2; + s->cstat |= 32768; - if (s->zvel == 0) + if (s->pal != 2 && s->hitag == 0) + spritesound(SOMETHING_DRIPPING,i); + + if (sprite[s->owner].picnum != WATERDRIP) { - s->cstat |= 32768; - - if (s->pal != 2 && s->hitag == 0) - spritesound(SOMETHING_DRIPPING,i); - - if (sprite[s->owner].picnum != WATERDRIP) - { - KILLIT(i); - } - else - { - hittype[i].bposz = s->z = t[0]; - t[1] = 48+(TRAND&31); - } - } - } - - - goto BOLT; - - case DOORSHOCK__STATIC: - j = klabs(sector[sect].ceilingz-sector[sect].floorz)>>9; - s->yrepeat = j+4; - s->xrepeat = 16; - s->z = sector[sect].floorz; - goto BOLT; - - case TOUCHPLATE__STATIC: - if (t[1] == 1 && s->hitag >= 0) //Move the sector floor - { - x = sector[sect].floorz; - - if (t[3] == 1) - { - if (x >= t[2]) - { - sector[sect].floorz = x; - t[1] = 0; - } - else - { - sector[sect].floorz += sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) ps[p].posz += sector[sect].extra; - } + KILLIT(i); } else { - if (x <= s->z) - { - sector[sect].floorz = s->z; - t[1] = 0; - } - else - { - sector[sect].floorz -= sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) - ps[p].posz -= sector[sect].extra; - } - } - goto BOLT; - } - - if (t[5] == 1) goto BOLT; - - p = checkcursectnums(sect); - if (p >= 0 && (ps[p].on_ground || s->ang == 512)) - { - if (t[0] == 0 && !check_activator_motion(s->lotag)) - { - t[0] = 1; - t[1] = 1; - t[3] = !t[3]; - operatemasterswitches(s->lotag); - operateactivators(s->lotag,p); - if (s->hitag > 0) - { - s->hitag--; - if (s->hitag == 0) t[5] = 1; - } + hittype[i].bposz = s->z = t[0]; + t[1] = 48+(TRAND&31); } } - else t[0] = 0; + } - if (t[1] == 1) + + goto BOLT; + + case DOORSHOCK__STATIC: + j = klabs(sector[sect].ceilingz-sector[sect].floorz)>>9; + s->yrepeat = j+4; + s->xrepeat = 16; + s->z = sector[sect].floorz; + goto BOLT; + + case TOUCHPLATE__STATIC: + if (t[1] == 1 && s->hitag >= 0) //Move the sector floor + { + x = sector[sect].floorz; + + if (t[3] == 1) { - j = headspritestat[6]; - while (j >= 0) + if (x >= t[2]) { - if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) - { - hittype[j].temp_data[1] = 1; - hittype[j].temp_data[3] = t[3]; - } - j = nextspritestat[j]; + sector[sect].floorz = x; + t[1] = 0; + } + else + { + sector[sect].floorz += sector[sect].extra; + p = checkcursectnums(sect); + if (p >= 0) ps[p].posz += sector[sect].extra; + } + } + else + { + if (x <= s->z) + { + sector[sect].floorz = s->z; + t[1] = 0; + } + else + { + sector[sect].floorz -= sector[sect].extra; + p = checkcursectnums(sect); + if (p >= 0) + ps[p].posz -= sector[sect].extra; } } goto BOLT; + } - case CANWITHSOMETHING__STATIC: - case CANWITHSOMETHING2__STATIC: - case CANWITHSOMETHING3__STATIC: - case CANWITHSOMETHING4__STATIC: - makeitfall(i); - IFHIT + if (t[5] == 1) goto BOLT; + + p = checkcursectnums(sect); + if (p >= 0 && (ps[p].on_ground || s->ang == 512)) + { + if (t[0] == 0 && !check_activator_motion(s->lotag)) { - spritesound(VENT_BUST,i); - for (j=0;j<10;j++) - RANDOMSCRAP; - - if (s->lotag) spawn(i,s->lotag); - - KILLIT(i); + t[0] = 1; + t[1] = 1; + t[3] = !t[3]; + operatemasterswitches(s->lotag); + operateactivators(s->lotag,p); + if (s->hitag > 0) + { + s->hitag--; + if (s->hitag == 0) t[5] = 1; } - goto BOLT; + } + } + else t[0] = 0; - case EXPLODINGBARREL__STATIC: - case WOODENHORSE__STATIC: - case HORSEONSIDE__STATIC: - case FLOORFLAME__STATIC: - case FIREBARREL__STATIC: - case FIREVASE__STATIC: - case NUKEBARREL__STATIC: - case NUKEBARRELDENTED__STATIC: - case NUKEBARRELLEAKED__STATIC: - case TOILETWATER__STATIC: - case RUBBERCAN__STATIC: - case STEAM__STATIC: - case CEILINGSTEAM__STATIC: + if (t[1] == 1) + { + j = headspritestat[6]; + while (j >= 0) + { + if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) + { + hittype[j].temp_data[1] = 1; + hittype[j].temp_data[3] = t[3]; + } + j = nextspritestat[j]; + } + } + goto BOLT; + + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + makeitfall(i); + IFHIT + { + spritesound(VENT_BUST,i); + for (j=0;j<10;j++) + RANDOMSCRAP; + + if (s->lotag) spawn(i,s->lotag); + + KILLIT(i); + } + goto BOLT; + + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case FLOORFLAME__STATIC: + case FIREBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TOILETWATER__STATIC: + case RUBBERCAN__STATIC: + case STEAM__STATIC: + case CEILINGSTEAM__STATIC: + p = findplayer(s, &x); + execute(i,p,x); + goto BOLT; + case WATERBUBBLEMAKER__STATIC: p = findplayer(s, &x); - execute(i,p,x); - goto BOLT; - case WATERBUBBLEMAKER__STATIC: - p = findplayer(s, &x); - execute(i,p,x); - goto BOLT; + execute(i,p,x); + goto BOLT; } BOLT: @@ -2854,337 +2854,337 @@ void moveweapons(void) // here switch (dynamictostatic[s->picnum]) { - case RADIUSEXPLOSION__STATIC: - case KNEE__STATIC: - KILLIT(i); - case TONGUE__STATIC: - T1 = sintable[(T2)&2047]>>9; - T2 += 32; - if (T2 > 2047) KILLIT(i); + case RADIUSEXPLOSION__STATIC: + case KNEE__STATIC: + KILLIT(i); + case TONGUE__STATIC: + T1 = sintable[(T2)&2047]>>9; + T2 += 32; + if (T2 > 2047) KILLIT(i); - if (sprite[s->owner].statnum == MAXSTATUS) - if (badguy(&sprite[s->owner]) == 0) - KILLIT(i); + if (sprite[s->owner].statnum == MAXSTATUS) + if (badguy(&sprite[s->owner]) == 0) + KILLIT(i); - s->ang = sprite[s->owner].ang; - s->x = sprite[s->owner].x; - s->y = sprite[s->owner].y; - if (sprite[s->owner].picnum == APLAYER) - s->z = sprite[s->owner].z-(34<<8); - for (k=0;ksectnum, - s->x+((k*sintable[(s->ang+512)&2047])>>9), - s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),TONGUE,-40+(k<<1), - 8,8,0,0,0,i,5); - sprite[q].cstat = 128; - sprite[q].pal = 8; - } + s->ang = sprite[s->owner].ang; + s->x = sprite[s->owner].x; + s->y = sprite[s->owner].y; + if (sprite[s->owner].picnum == APLAYER) + s->z = sprite[s->owner].z-(34<<8); + for (k=0;ksectnum, s->x+((k*sintable[(s->ang+512)&2047])>>9), s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),INNERJAW,-40, - 32,32,0,0,0,i,5); + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),TONGUE,-40+(k<<1), + 8,8,0,0,0,i,5); sprite[q].cstat = 128; - if (T2 > 512 && T2 < (1024)) - sprite[q].picnum = INNERJAW+1; + sprite[q].pal = 8; + } + q = EGS(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),INNERJAW,-40, + 32,32,0,0,0,i,5); + sprite[q].cstat = 128; + if (T2 > 512 && T2 < (1024)) + sprite[q].picnum = INNERJAW+1; - goto BOLT; + goto BOLT; - case FREEZEBLAST__STATIC: - if (s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) - { - j = spawn(i,TRANSPORTERSTAR); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; - KILLIT(i); - } - case SHRINKSPARK__STATIC: + case FREEZEBLAST__STATIC: + if (s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; + KILLIT(i); + } + case SHRINKSPARK__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if (s->picnum == COOLEXPLOSION1) + if (!issoundplaying(i,WIERDSHOT_FLY)) + spritesound(WIERDSHOT_FLY,i); + + p = -1; + + if (s->picnum == RPG && sector[s->sectnum].lotag == 2) + { + k = s->xvel>>1; + ll = s->zvel>>1; + } + else + { + k = s->xvel; + ll = s->zvel; + } + + dax = s->x; + day = s->y; + daz = s->z; + + getglobalz(i); + qq = CLIPMASK1; + + switch (dynamictostatic[s->picnum]) + { case RPG__STATIC: - case FIRELASER__STATIC: - case SPIT__STATIC: - case COOLEXPLOSION1__STATIC: - - if (s->picnum == COOLEXPLOSION1) - if (!issoundplaying(i,WIERDSHOT_FLY)) - spritesound(WIERDSHOT_FLY,i); - - p = -1; - - if (s->picnum == RPG && sector[s->sectnum].lotag == 2) + if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - k = s->xvel>>1; - ll = s->zvel>>1; + j = spawn(i,SMALLSMOKE); + sprite[j].z += (1<<8); } - else + break; + } + + j = movesprite(i, + (k*(sintable[(s->ang+512)&2047]))>>14, + (k*(sintable[s->ang&2047]))>>14,ll,qq); + + if (s->picnum == RPG && s->yvel >= 0) + if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) + j = 49152|s->yvel; + + if (s->sectnum < 0) + { + KILLIT(i); + } + + if ((j&49152) != 49152) + if (s->picnum != FREEZEBLAST) { - k = s->xvel; - ll = s->zvel; - } - - dax = s->x; - day = s->y; - daz = s->z; - - getglobalz(i); - qq = CLIPMASK1; - - switch (dynamictostatic[s->picnum]) - { - case RPG__STATIC: - if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i,SMALLSMOKE); - sprite[j].z += (1<<8); - } - break; - } - - j = movesprite(i, - (k*(sintable[(s->ang+512)&2047]))>>14, - (k*(sintable[s->ang&2047]))>>14,ll,qq); - - if (s->picnum == RPG && s->yvel >= 0) - if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) - j = 49152|s->yvel; - - if (s->sectnum < 0) - { - KILLIT(i); - } - - if ((j&49152) != 49152) - if (s->picnum != FREEZEBLAST) + if (s->z < hittype[i].ceilingz) { - if (s->z < hittype[i].ceilingz) + j = 16384|(s->sectnum); + s->zvel = -1; + } + else + if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) || + (s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) { j = 16384|(s->sectnum); - s->zvel = -1; + if (sector[s->sectnum].lotag != 1) + s->zvel = 1; } - else - if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) || - (s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) - { - j = 16384|(s->sectnum); - if (sector[s->sectnum].lotag != 1) - s->zvel = 1; - } - } - - if (s->picnum == FIRELASER) - { - for (k=-3;k<2;k++) - { - x = EGS(s->sectnum, - s->x+((k*sintable[(s->ang+512)&2047])>>9), - s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),FIRELASER,-40+(k<<2), - s->xrepeat,s->yrepeat,0,0,0,s->owner,5); - - sprite[x].cstat = 128; - sprite[x].pal = s->pal; - } } - else if (s->picnum == SPIT) if (s->zvel < 6144) - s->zvel += gc-112; - if (j != 0) + if (s->picnum == FIRELASER) + { + for (k=-3;k<2;k++) { - if (s->picnum == COOLEXPLOSION1) - { - if ((j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) - goto BOLT; - s->xvel = 0; - s->zvel = 0; - } + x = EGS(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),FIRELASER,-40+(k<<2), + s->xrepeat,s->yrepeat,0,0,0,s->owner,5); - if ((j&49152) == 49152) - { - j &= (MAXSPRITES-1); + sprite[x].cstat = 128; + sprite[x].pal = s->pal; + } + } + else if (s->picnum == SPIT) if (s->zvel < 6144) + s->zvel += gc-112; - if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) - if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) - { - j = spawn(i,TRANSPORTERSTAR); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; + if (j != 0) + { + if (s->picnum == COOLEXPLOSION1) + { + if ((j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) + goto BOLT; + s->xvel = 0; + s->zvel = 0; + } - KILLIT(i); - } + if ((j&49152) == 49152) + { + j &= (MAXSPRITES-1); - checkhitsprite(j,i); - - if (sprite[j].picnum == APLAYER) + if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) + if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) { - p = sprite[j].yvel; - spritesound(PISTOL_BODYHIT,j); + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; - if (s->picnum == SPIT) + KILLIT(i); + } + + checkhitsprite(j,i); + + if (sprite[j].picnum == APLAYER) + { + p = sprite[j].yvel; + spritesound(PISTOL_BODYHIT,j); + + if (s->picnum == SPIT) + { + ps[p].horiz += 32; + ps[p].return_to_center = 8; + + if (ps[p].loogcnt == 0) { - ps[p].horiz += 32; - ps[p].return_to_center = 8; + if (!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); - if (ps[p].loogcnt == 0) + j = 3+(TRAND&3); + ps[p].numloogs = j; + ps[p].loogcnt = 24*4; + for (x=0;x < j;x++) { - if (!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,ps[p].i); - - j = 3+(TRAND&3); - ps[p].numloogs = j; - ps[p].loogcnt = 24*4; - for (x=0;x < j;x++) - { - ps[p].loogiex[x] = TRAND%xdim; - ps[p].loogiey[x] = TRAND%ydim; - } + ps[p].loogiex[x] = TRAND%xdim; + ps[p].loogiey[x] = TRAND%ydim; } } } } - else if ((j&49152) == 32768) - { - j &= (MAXWALLS-1); + } + else if ((j&49152) == 32768) + { + j &= (MAXWALLS-1); - if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) + if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) + { + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + s->owner = i; + spawn(i,TRANSPORTERSTAR); + goto BOLT; + } + else + { + setsprite(i,dax,day,daz); + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + if (s->picnum == FREEZEBLAST) { + if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) + { + s->extra >>= 1; + s->yvel--; + } + k = getangle( wall[wall[j].point2].x-wall[j].x, wall[wall[j].point2].y-wall[j].y); s->ang = ((k<<1) - s->ang)&2047; - s->owner = i; - spawn(i,TRANSPORTERSTAR); goto BOLT; } + } + } + else if ((j&49152) == 16384) + { + setsprite(i,dax,day,daz); + + if (s->zvel < 0) + { + if (sector[s->sectnum].ceilingstat&1) + if (sector[s->sectnum].ceilingpal == 0) + KILLIT(i); + + checkhitceiling(s->sectnum); + } + + if (s->picnum == FREEZEBLAST) + { + bounce(i); + ssp(i,qq); + s->extra >>= 1; + if (s->xrepeat > 8) + s->xrepeat -= 2; + if (s->yrepeat > 8) + s->yrepeat -= 2; + s->yvel--; + goto BOLT; + } + } + + if (s->picnum != SPIT) + { + if (s->picnum == RPG) + { + k = spawn(i,EXPLOSION2); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if (s->xrepeat < 10) + { + sprite[k].xrepeat = 6; + sprite[k].yrepeat = 6; + } + else if ((j&49152) == 16384) + { + if (s->zvel > 0) + spawn(i,EXPLOSION2BOT); + else + { + sprite[k].cstat |= 8; + sprite[k].z += (48<<8); + } + + } + } + else if (s->picnum == SHRINKSPARK) + { + spawn(i,SHRINKEREXPLOSION); + spritesound(SHRINKER_HIT,i); + hitradius(i,shrinkerblastradius,0,0,0,0); + } + else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; + if ((j&49152) == 16384) + { + if (s->zvel < 0) + { + sprite[k].cstat |= 8; + sprite[k].z += (72<<8); + } + + } + } + if (s->picnum == RPG) + { + spritesound(RPG_EXPLODE,i); + + if (s->xrepeat >= 10) + { + x = s->extra; + hitradius(i,rpgblastradius, x>>2,x>>1,x-(x>>2),x); + } else { - setsprite(i,dax,day,daz); - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); - - if (s->picnum == FREEZEBLAST) - { - if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) - { - s->extra >>= 1; - s->yvel--; - } - - k = getangle( - wall[wall[j].point2].x-wall[j].x, - wall[wall[j].point2].y-wall[j].y); - s->ang = ((k<<1) - s->ang)&2047; - goto BOLT; - } + x = s->extra+(global_random&3); + hitradius(i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); } } - else if ((j&49152) == 16384) - { - setsprite(i,dax,day,daz); - - if (s->zvel < 0) - { - if (sector[s->sectnum].ceilingstat&1) - if (sector[s->sectnum].ceilingpal == 0) - KILLIT(i); - - checkhitceiling(s->sectnum); - } - - if (s->picnum == FREEZEBLAST) - { - bounce(i); - ssp(i,qq); - s->extra >>= 1; - if (s->xrepeat > 8) - s->xrepeat -= 2; - if (s->yrepeat > 8) - s->yrepeat -= 2; - s->yvel--; - goto BOLT; - } - } - - if (s->picnum != SPIT) - { - if (s->picnum == RPG) - { - k = spawn(i,EXPLOSION2); - sprite[k].x = dax; - sprite[k].y = day; - sprite[k].z = daz; - - if (s->xrepeat < 10) - { - sprite[k].xrepeat = 6; - sprite[k].yrepeat = 6; - } - else if ((j&49152) == 16384) - { - if (s->zvel > 0) - spawn(i,EXPLOSION2BOT); - else - { - sprite[k].cstat |= 8; - sprite[k].z += (48<<8); - } - - } - } - else if (s->picnum == SHRINKSPARK) - { - spawn(i,SHRINKEREXPLOSION); - spritesound(SHRINKER_HIT,i); - hitradius(i,shrinkerblastradius,0,0,0,0); - } - else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) - { - k = spawn(i,EXPLOSION2); - sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; - if ((j&49152) == 16384) - { - if (s->zvel < 0) - { - sprite[k].cstat |= 8; - sprite[k].z += (72<<8); - } - - } - } - if (s->picnum == RPG) - { - spritesound(RPG_EXPLODE,i); - - if (s->xrepeat >= 10) - { - x = s->extra; - hitradius(i,rpgblastradius, x>>2,x>>1,x-(x>>2),x); - } - else - { - x = s->extra+(global_random&3); - hitradius(i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); - } - } - } - if (s->picnum != COOLEXPLOSION1) KILLIT(i); } - if (s->picnum == COOLEXPLOSION1) - { - s->shade++; - if (s->shade >= 40) KILLIT(i); - } - else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) - spawn(i,WATERBUBBLE); + if (s->picnum != COOLEXPLOSION1) KILLIT(i); + } + if (s->picnum == COOLEXPLOSION1) + { + s->shade++; + if (s->shade >= 40) KILLIT(i); + } + else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) + spawn(i,WATERBUBBLE); - goto BOLT; + goto BOLT; - case SHOTSPARK1__STATIC: - p = findplayer(s,&x); - execute(i,p,x); - goto BOLT; + case SHOTSPARK1__STATIC: + p = findplayer(s,&x); + execute(i,p,x); + goto BOLT; } } BOLT: @@ -3224,300 +3224,300 @@ void movetransports(void) switch (sprite[j].statnum) { - case 10: // Player + case 10: // Player - if (sprite[j].owner != -1) + if (sprite[j].owner != -1) + { + p = sprite[j].yvel; + + ps[p].on_warping_sector = 1; + + if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0) { - p = sprite[j].yvel; - - ps[p].on_warping_sector = 1; - - if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0) + if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) { - if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) + if (sprite[i].pal == 0) { - if (sprite[i].pal == 0) + spawn(i,TRANSPORTERBEAM); + spritesound(TELEPORTER,i); + } + + for (k=connecthead;k>=0;k=connectpoint2[k]) + if (ps[k].cursectnum == sprite[OW].sectnum) { - spawn(i,TRANSPORTERBEAM); - spritesound(TELEPORTER,i); + ps[k].frag_ps = p; + sprite[ps[k].i].extra = 0; } - for (k=connecthead;k>=0;k=connectpoint2[k]) - if (ps[k].cursectnum == sprite[OW].sectnum) - { - ps[k].frag_ps = p; - sprite[ps[k].i].extra = 0; - } + ps[p].ang = sprite[OW].ang; - ps[p].ang = sprite[OW].ang; - - if (sprite[OW].owner != OW) - { - T1 = 13; - hittype[OW].temp_data[0] = 13; - ps[p].transporter_hold = 13; - } - - ps[p].bobposx = ps[p].oposx = ps[p].posx = sprite[OW].x; - ps[p].bobposy = ps[p].oposy = ps[p].posy = sprite[OW].y; - ps[p].oposz = ps[p].posz = sprite[OW].z-PHEIGHT; - - changespritesect(j,sprite[OW].sectnum); - ps[p].cursectnum = sprite[j].sectnum; - - if (sprite[i].pal == 0) - { - k = spawn(OW,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); - } - - break; - } - } - else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; - - if (onfloorz == 0 && klabs(SZ-ps[p].posz) < 6144) - if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (sync[p].bits&1)) || - (ps[p].jetpack_on && (sync[p].bits&2))) + if (sprite[OW].owner != OW) { - ps[p].oposx = ps[p].posx += sprite[OW].x-SX; - ps[p].oposy = ps[p].posy += sprite[OW].y-SY; - - if (ps[p].jetpack_on && ((sync[p].bits&1) || ps[p].jetpack_on < 11)) - ps[p].posz = sprite[OW].z-6144; - else ps[p].posz = sprite[OW].z+6144; - ps[p].oposz = ps[p].posz; - - hittype[ps[p].i].bposx = ps[p].posx; - hittype[ps[p].i].bposy = ps[p].posy; - hittype[ps[p].i].bposz = ps[p].posz; - - changespritesect(j,sprite[OW].sectnum); - ps[p].cursectnum = sprite[OW].sectnum; - - break; + T1 = 13; + hittype[OW].temp_data[0] = 13; + ps[p].transporter_hold = 13; } - k = 0; + ps[p].bobposx = ps[p].oposx = ps[p].posx = sprite[OW].x; + ps[p].bobposy = ps[p].oposy = ps[p].posy = sprite[OW].y; + ps[p].oposz = ps[p].posz = sprite[OW].z-PHEIGHT; - if (onfloorz && sectlotag == 1 && ps[p].on_ground && ps[p].posz > (sector[sect].floorz-1080) && ((sync[p].bits&2) || ps[p].poszv > 2048)) - // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) - { - k = 1; - if (screenpeek == p) + changespritesect(j,sprite[OW].sectnum); + ps[p].cursectnum = sprite[j].sectnum; + + if (sprite[i].pal == 0) { - FX_StopAllSounds(); - clearsoundlocks(); + k = spawn(OW,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); } - if (sprite[ps[p].i].extra > 0) - spritesound(DUKE_UNDERWATER,j); - ps[p].oposz = ps[p].posz = - sector[sprite[OW].sectnum].ceilingz; - ps[p].posxv = 4096-(TRAND&8192); - ps[p].posyv = 4096-(TRAND&8192); - // ps[p].poszv += 1080; + break; } + } + else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; - if (onfloorz && sectlotag == 2 && ps[p].posz < (sector[sect].ceilingz+1080) && ps[p].poszv == 0) - { - k = 1; - // if( sprite[j].extra <= 0) break; - if (screenpeek == p) - { - FX_StopAllSounds(); - clearsoundlocks(); - } - spritesound(DUKE_GASP,j); - - ps[p].oposz = ps[p].posz = - sector[sprite[OW].sectnum].floorz; - - ps[p].jumping_toggle = 1; - ps[p].jumping_counter = 0; - // ps[p].poszv += 1024; - } - - if (k == 1) + if (onfloorz == 0 && klabs(SZ-ps[p].posz) < 6144) + if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (sync[p].bits&1)) || + (ps[p].jetpack_on && (sync[p].bits&2))) { ps[p].oposx = ps[p].posx += sprite[OW].x-SX; ps[p].oposy = ps[p].posy += sprite[OW].y-SY; - if (sprite[OW].owner != OW) - ps[p].transporter_hold = -2; - ps[p].cursectnum = sprite[OW].sectnum; + if (ps[p].jetpack_on && ((sync[p].bits&1) || ps[p].jetpack_on < 11)) + ps[p].posz = sprite[OW].z-6144; + else ps[p].posz = sprite[OW].z+6144; + ps[p].oposz = ps[p].posz; + + hittype[ps[p].i].bposx = ps[p].posx; + hittype[ps[p].i].bposy = ps[p].posy; + hittype[ps[p].i].bposz = ps[p].posz; changespritesect(j,sprite[OW].sectnum); - setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); + ps[p].cursectnum = sprite[OW].sectnum; - setpal(&ps[p]); - - if ((TRAND&255) < 32) - spawn(j,WATERSPLASH2); - - if (sectlotag == 1) - for (l = 0;l < 9;l++) - { - q = spawn(ps[p].i,WATERBUBBLE); - sprite[q].z += TRAND&16383; - } + break; } - } - break; - case 1: - if ((sprite[j].picnum == SHARK) - || (sprite[j].picnum == COMMANDER) - || (sprite[j].picnum == OCTABRAIN) - || ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum >= GREENSLIME+7)) - ) + k = 0; + + if (onfloorz && sectlotag == 1 && ps[p].on_ground && ps[p].posz > (sector[sect].floorz-1080) && ((sync[p].bits&2) || ps[p].poszv > 2048)) + // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) { - if (sprite[j].extra > 0) - goto JBOLT; - } - case 4: - case 5: - case 12: - case 13: - - ll = klabs(sprite[j].zvel); - - { - warpspriteto = 0; - if (ll && sectlotag == 2 && sprite[j].z < (sector[sect].ceilingz+ll)) - warpspriteto = 1; - - if (ll && sectlotag == 1 && sprite[j].z > (sector[sect].floorz-ll)) - warpspriteto = 1; - - if (sectlotag == 0 && (onfloorz || klabs(sprite[j].z-SZ) < 4096)) + k = 1; + if (screenpeek == p) { - if (sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != 5) - { - T1++; - goto BOLT; - } - warpspriteto = 1; + FX_StopAllSounds(); + clearsoundlocks(); } + if (sprite[ps[p].i].extra > 0) + spritesound(DUKE_UNDERWATER,j); + ps[p].oposz = ps[p].posz = + sector[sprite[OW].sectnum].ceilingz; - if (warpspriteto && checkspriteflags(j,SPRITE_FLAG_DECAL)) goto JBOLT; + ps[p].posxv = 4096-(TRAND&8192); + ps[p].posyv = 4096-(TRAND&8192); + // ps[p].poszv += 1080; + } - if (warpspriteto) switch (dynamictostatic[sprite[j].picnum]) + if (onfloorz && sectlotag == 2 && ps[p].posz < (sector[sect].ceilingz+1080) && ps[p].poszv == 0) + { + k = 1; + // if( sprite[j].extra <= 0) break; + if (screenpeek == p) + { + FX_StopAllSounds(); + clearsoundlocks(); + } + spritesound(DUKE_GASP,j); + + ps[p].oposz = ps[p].posz = + sector[sprite[OW].sectnum].floorz; + + ps[p].jumping_toggle = 1; + ps[p].jumping_counter = 0; + // ps[p].poszv += 1024; + } + + if (k == 1) + { + ps[p].oposx = ps[p].posx += sprite[OW].x-SX; + ps[p].oposy = ps[p].posy += sprite[OW].y-SY; + + if (sprite[OW].owner != OW) + ps[p].transporter_hold = -2; + ps[p].cursectnum = sprite[OW].sectnum; + + changespritesect(j,sprite[OW].sectnum); + setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); + + setpal(&ps[p]); + + if ((TRAND&255) < 32) + spawn(j,WATERSPLASH2); + + if (sectlotag == 1) + for (l = 0;l < 9;l++) { - case TRANSPORTERSTAR__STATIC: - case TRANSPORTERBEAM__STATIC: - case TRIPBOMB__STATIC: - case BULLETHOLE__STATIC: - case WATERSPLASH2__STATIC: - case BURNING__STATIC: - case BURNING2__STATIC: - case FIRE__STATIC: - case FIRE2__STATIC: - case TOILETWATER__STATIC: - case LASERLINE__STATIC: - goto JBOLT; - case PLAYERONWATER__STATIC: - if (sectlotag == 2) - { - sprite[j].cstat &= 32767; - break; - } - default: - if (sprite[j].statnum == 5 && !(sectlotag == 1 || sectlotag == 2)) - break; - - case WATERBUBBLE__STATIC: - // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) - // break; - - if (sectlotag > 0) - { - k = spawn(j,WATERSPLASH2); - if (sectlotag == 1 && sprite[j].statnum == 4) - { - sprite[k].xvel = sprite[j].xvel>>1; - sprite[k].ang = sprite[j].ang; - ssp(k,CLIPMASK0); - } - } - - switch (sectlotag) - { - case 0: - if (onfloorz) - { - if (sprite[j].statnum == 4 || (checkcursectnums(sect) == -1 && checkcursectnums(sprite[OW].sectnum) == -1)) - { - sprite[j].x += (sprite[OW].x-SX); - sprite[j].y += (sprite[OW].y-SY); - sprite[j].z -= SZ - sector[sprite[OW].sectnum].floorz; - sprite[j].ang = sprite[OW].ang; - - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; - - if (sprite[i].pal == 0) - { - k = spawn(i,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); - - k = spawn(OW,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); - } - - if (sprite[OW].owner != OW) - { - T1 = 13; - hittype[OW].temp_data[0] = 13; - } - - changespritesect(j,sprite[OW].sectnum); - } - } - else - { - sprite[j].x += (sprite[OW].x-SX); - sprite[j].y += (sprite[OW].y-SY); - sprite[j].z = sprite[OW].z+4096; - - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; - - changespritesect(j,sprite[OW].sectnum); - } - break; - case 1: - sprite[j].x += (sprite[OW].x-SX); - sprite[j].y += (sprite[OW].y-SY); - sprite[j].z = sector[sprite[OW].sectnum].ceilingz+ll; - - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; - - changespritesect(j,sprite[OW].sectnum); - - break; - case 2: - sprite[j].x += (sprite[OW].x-SX); - sprite[j].y += (sprite[OW].y-SY); - sprite[j].z = sector[sprite[OW].sectnum].floorz-ll; - - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; - - changespritesect(j,sprite[OW].sectnum); - - break; - } - - break; + q = spawn(ps[p].i,WATERBUBBLE); + sprite[q].z += TRAND&16383; } } - break; + } + break; + + case 1: + if ((sprite[j].picnum == SHARK) + || (sprite[j].picnum == COMMANDER) + || (sprite[j].picnum == OCTABRAIN) + || ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum >= GREENSLIME+7)) + ) + { + if (sprite[j].extra > 0) + goto JBOLT; + } + case 4: + case 5: + case 12: + case 13: + + ll = klabs(sprite[j].zvel); + + { + warpspriteto = 0; + if (ll && sectlotag == 2 && sprite[j].z < (sector[sect].ceilingz+ll)) + warpspriteto = 1; + + if (ll && sectlotag == 1 && sprite[j].z > (sector[sect].floorz-ll)) + warpspriteto = 1; + + if (sectlotag == 0 && (onfloorz || klabs(sprite[j].z-SZ) < 4096)) + { + if (sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != 5) + { + T1++; + goto BOLT; + } + warpspriteto = 1; + } + + if (warpspriteto && checkspriteflags(j,SPRITE_FLAG_DECAL)) goto JBOLT; + + if (warpspriteto) switch (dynamictostatic[sprite[j].picnum]) + { + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + case TRIPBOMB__STATIC: + case BULLETHOLE__STATIC: + case WATERSPLASH2__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + case FIRE__STATIC: + case FIRE2__STATIC: + case TOILETWATER__STATIC: + case LASERLINE__STATIC: + goto JBOLT; + case PLAYERONWATER__STATIC: + if (sectlotag == 2) + { + sprite[j].cstat &= 32767; + break; + } + default: + if (sprite[j].statnum == 5 && !(sectlotag == 1 || sectlotag == 2)) + break; + + case WATERBUBBLE__STATIC: + // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) + // break; + + if (sectlotag > 0) + { + k = spawn(j,WATERSPLASH2); + if (sectlotag == 1 && sprite[j].statnum == 4) + { + sprite[k].xvel = sprite[j].xvel>>1; + sprite[k].ang = sprite[j].ang; + ssp(k,CLIPMASK0); + } + } + + switch (sectlotag) + { + case 0: + if (onfloorz) + { + if (sprite[j].statnum == 4 || (checkcursectnums(sect) == -1 && checkcursectnums(sprite[OW].sectnum) == -1)) + { + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z -= SZ - sector[sprite[OW].sectnum].floorz; + sprite[j].ang = sprite[OW].ang; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + if (sprite[i].pal == 0) + { + k = spawn(i,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); + + k = spawn(OW,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); + } + + if (sprite[OW].owner != OW) + { + T1 = 13; + hittype[OW].temp_data[0] = 13; + } + + changespritesect(j,sprite[OW].sectnum); + } + } + else + { + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sprite[OW].z+4096; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + } + break; + case 1: + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sector[sprite[OW].sectnum].ceilingz+ll; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + + break; + case 2: + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sector[sprite[OW].sectnum].floorz-ll; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + + break; + } + + break; + } + } + break; } JBOLT: @@ -3560,916 +3560,870 @@ void moveactors(void) } switch (dynamictostatic[switchpicnum]) { - case DUCK__STATIC: - case TARGET__STATIC: - if (s->cstat&32) - { - t[0]++; - if (t[0] > 60) - { - t[0] = 0; - s->cstat = 128+257+16; - s->extra = 1; - } - } - else - { - j = ifhitbyweapon(i); - if (j >= 0) - { - s->cstat = 32+128; - k = 1; - - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].lotag == s->lotag && - sprite[j].picnum == s->picnum) - { - if ((sprite[j].hitag && !(sprite[j].cstat&32)) || - (!sprite[j].hitag && (sprite[j].cstat&32)) - ) - { - k = 0; - break; - } - } - - j = nextspritestat[j]; - } - - if (k == 1) - { - operateactivators(s->lotag,-1); - operateforcefields(i,s->lotag); - operatemasterswitches(s->lotag); - } - } - } - goto BOLT; - - case RESPAWNMARKERRED__STATIC: - case RESPAWNMARKERYELLOW__STATIC: - case RESPAWNMARKERGREEN__STATIC: - T1++; - if (T1 > respawnitemtime) - { - KILLIT(i); - } - if (T1 >= (respawnitemtime>>1) && T1 < ((respawnitemtime>>1)+(respawnitemtime>>2))) - PN = RESPAWNMARKERYELLOW; - else if (T1 > ((respawnitemtime>>1)+(respawnitemtime>>2))) - PN = RESPAWNMARKERGREEN; - makeitfall(i); - break; - - case HELECOPT__STATIC: - case DUKECAR__STATIC: - - s->z += s->zvel; + case DUCK__STATIC: + case TARGET__STATIC: + if (s->cstat&32) + { t[0]++; - - if (t[0] == 4) spritesound(WAR_AMBIENCE2,i); - - if (t[0] > (26*8)) + if (t[0] > 60) { - sound(RPG_EXPLODE); - for (j=0;j<32;j++) RANDOMSCRAP; - earthquaketime = 16; - KILLIT(i); + t[0] = 0; + s->cstat = 128+257+16; + s->extra = 1; } - else if ((t[0]&3) == 0) - spawn(i,EXPLOSION2); - ssp(i,CLIPMASK0); - break; - case RAT__STATIC: - makeitfall(i); - IFMOVING + } + else + { + j = ifhitbyweapon(i); + if (j >= 0) { - if ((TRAND&255) < 3) spritesound(RATTY,i); - s->ang += (TRAND&31)-15+(sintable[(t[0]<<8)&2047]>>11); - } - else - { - T1++; - if (T1 > 1) - { - KILLIT(i); - } - else s->ang = (TRAND&2047); - } - if (s->xvel < 128) - s->xvel+=2; - s->ang += (TRAND&3)-6; - break; - case QUEBALL__STATIC: - case STRIPEBALL__STATIC: - if (s->xvel) - { - j = headspritestat[0]; + s->cstat = 32+128; + k = 1; + + j = headspritestat[1]; while (j >= 0) { - nextj = nextspritestat[j]; - if (sprite[j].picnum == POCKET && ldist(&sprite[j],s) < 52) KILLIT(i); - j = nextj; - } - - j = clipmove(&s->x,&s->y,&s->z,&s->sectnum, - (((s->xvel*(sintable[(s->ang+512)&2047]))>>14)*TICSPERFRAME)<<11, - (((s->xvel*(sintable[s->ang&2047]))>>14)*TICSPERFRAME)<<11, - 24L,(4<<8),(4<<8),CLIPMASK1); - - if (j&49152) - { - if ((j&49152) == 32768) + if (sprite[j].lotag == s->lotag && + sprite[j].picnum == s->picnum) { - j &= (MAXWALLS-1); - k = getangle( - wall[wall[j].point2].x-wall[j].x, - wall[wall[j].point2].y-wall[j].y); - s->ang = ((k<<1) - s->ang)&2047; + if ((sprite[j].hitag && !(sprite[j].cstat&32)) || + (!sprite[j].hitag && (sprite[j].cstat&32)) + ) + { + k = 0; + break; + } } - else if ((j&49152) == 49152) - { - j &= (MAXSPRITES-1); - checkhitsprite(i,j); - } - } - s->xvel --; - if (s->xvel < 0) s->xvel = 0; - if (s->picnum == STRIPEBALL) - { - s->cstat = 257; - s->cstat |= 4&s->xvel; - s->cstat |= 8&s->xvel; - } - } - else - { - p = findplayer(s,&x); - if (x < 1596) - { - - // if(s->pal == 12) - { - j = getincangle(ps[p].ang,getangle(s->x-ps[p].posx,s->y-ps[p].posy)); - if (j > -64 && j < 64 && (sync[p].bits&(1<<29))) - if (ps[p].toggle_key_flag == 1) - { - a = headspritestat[1]; - while (a >= 0) - { - if (sprite[a].picnum == QUEBALL || sprite[a].picnum == STRIPEBALL) - { - j = getincangle(ps[p].ang,getangle(sprite[a].x-ps[p].posx,sprite[a].y-ps[p].posy)); - if (j > -64 && j < 64) - { - findplayer(&sprite[a],&l); - if (x > l) break; - } - } - a = nextspritestat[a]; - } - if (a == -1) - { - if (s->pal == 12) - s->xvel = 164; - else s->xvel = 140; - s->ang = ps[p].ang; - ps[p].toggle_key_flag = 2; - } - } - } - } - if (x < 512 && s->sectnum == ps[p].cursectnum) - { - s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); - s->xvel = 48; - } - } - - break; - case FORCESPHERE__STATIC: - - if (s->yvel == 0) - { - s->yvel = 1; - - for (l=512;l<(2048-512);l+= 128) - for (j=0;j<2048;j += 128) - { - k = spawn(i,FORCESPHERE); - sprite[k].cstat = 257+128; - sprite[k].clipdist = 64; - sprite[k].ang = j; - sprite[k].zvel = sintable[l&2047]>>5; - sprite[k].xvel = sintable[(l+512)&2047]>>9; - sprite[k].owner = i; - } - } - - if (t[3] > 0) - { - if (s->zvel < 6144) - s->zvel += 192; - s->z += s->zvel; - if (s->z > sector[sect].floorz) - s->z = sector[sect].floorz; - t[3]--; - if (t[3] == 0) - KILLIT(i); - } - else if (t[2] > 10) - { - j = headspritestat[5]; - while (j >= 0) - { - if (sprite[j].owner == i && sprite[j].picnum == FORCESPHERE) - hittype[j].temp_data[1] = 1+(TRAND&63); j = nextspritestat[j]; } - t[3] = 64; + + if (k == 1) + { + operateactivators(s->lotag,-1); + operateforcefields(i,s->lotag); + operatemasterswitches(s->lotag); + } + } + } + goto BOLT; + + case RESPAWNMARKERRED__STATIC: + case RESPAWNMARKERYELLOW__STATIC: + case RESPAWNMARKERGREEN__STATIC: + T1++; + if (T1 > respawnitemtime) + { + KILLIT(i); + } + if (T1 >= (respawnitemtime>>1) && T1 < ((respawnitemtime>>1)+(respawnitemtime>>2))) + PN = RESPAWNMARKERYELLOW; + else if (T1 > ((respawnitemtime>>1)+(respawnitemtime>>2))) + PN = RESPAWNMARKERGREEN; + makeitfall(i); + break; + + case HELECOPT__STATIC: + case DUKECAR__STATIC: + + s->z += s->zvel; + t[0]++; + + if (t[0] == 4) spritesound(WAR_AMBIENCE2,i); + + if (t[0] > (26*8)) + { + sound(RPG_EXPLODE); + for (j=0;j<32;j++) RANDOMSCRAP; + earthquaketime = 16; + KILLIT(i); + } + else if ((t[0]&3) == 0) + spawn(i,EXPLOSION2); + ssp(i,CLIPMASK0); + break; + case RAT__STATIC: + makeitfall(i); + IFMOVING + { + if ((TRAND&255) < 3) spritesound(RATTY,i); + s->ang += (TRAND&31)-15+(sintable[(t[0]<<8)&2047]>>11); + } + else + { + T1++; + if (T1 > 1) + { + KILLIT(i); + } + else s->ang = (TRAND&2047); + } + if (s->xvel < 128) + s->xvel+=2; + s->ang += (TRAND&3)-6; + break; + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + if (s->xvel) + { + j = headspritestat[0]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == POCKET && ldist(&sprite[j],s) < 52) KILLIT(i); + j = nextj; + } + + j = clipmove(&s->x,&s->y,&s->z,&s->sectnum, + (((s->xvel*(sintable[(s->ang+512)&2047]))>>14)*TICSPERFRAME)<<11, + (((s->xvel*(sintable[s->ang&2047]))>>14)*TICSPERFRAME)<<11, + 24L,(4<<8),(4<<8),CLIPMASK1); + + if (j&49152) + { + if ((j&49152) == 32768) + { + j &= (MAXWALLS-1); + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + } + else if ((j&49152) == 49152) + { + j &= (MAXSPRITES-1); + checkhitsprite(i,j); + } + } + s->xvel --; + if (s->xvel < 0) s->xvel = 0; + if (s->picnum == STRIPEBALL) + { + s->cstat = 257; + s->cstat |= 4&s->xvel; + s->cstat |= 8&s->xvel; + } + } + else + { + p = findplayer(s,&x); + + if (x < 1596) + { + + // if(s->pal == 12) + { + j = getincangle(ps[p].ang,getangle(s->x-ps[p].posx,s->y-ps[p].posy)); + if (j > -64 && j < 64 && (sync[p].bits&(1<<29))) + if (ps[p].toggle_key_flag == 1) + { + a = headspritestat[1]; + while (a >= 0) + { + if (sprite[a].picnum == QUEBALL || sprite[a].picnum == STRIPEBALL) + { + j = getincangle(ps[p].ang,getangle(sprite[a].x-ps[p].posx,sprite[a].y-ps[p].posy)); + if (j > -64 && j < 64) + { + findplayer(&sprite[a],&l); + if (x > l) break; + } + } + a = nextspritestat[a]; + } + if (a == -1) + { + if (s->pal == 12) + s->xvel = 164; + else s->xvel = 140; + s->ang = ps[p].ang; + ps[p].toggle_key_flag = 2; + } + } + } + } + if (x < 512 && s->sectnum == ps[p].cursectnum) + { + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + s->xvel = 48; + } + } + + break; + case FORCESPHERE__STATIC: + + if (s->yvel == 0) + { + s->yvel = 1; + + for (l=512;l<(2048-512);l+= 128) + for (j=0;j<2048;j += 128) + { + k = spawn(i,FORCESPHERE); + sprite[k].cstat = 257+128; + sprite[k].clipdist = 64; + sprite[k].ang = j; + sprite[k].zvel = sintable[l&2047]>>5; + sprite[k].xvel = sintable[(l+512)&2047]>>9; + sprite[k].owner = i; + } + } + + if (t[3] > 0) + { + if (s->zvel < 6144) + s->zvel += 192; + s->z += s->zvel; + if (s->z > sector[sect].floorz) + s->z = sector[sect].floorz; + t[3]--; + if (t[3] == 0) + KILLIT(i); + } + else if (t[2] > 10) + { + j = headspritestat[5]; + while (j >= 0) + { + if (sprite[j].owner == i && sprite[j].picnum == FORCESPHERE) + hittype[j].temp_data[1] = 1+(TRAND&63); + j = nextspritestat[j]; + } + t[3] = 64; + } + + goto BOLT; + + case RECON__STATIC: + + getglobalz(i); + + if (sector[s->sectnum].ceilingstat&1) + s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; + else s->shade += (sector[s->sectnum].floorshade-s->shade)>>1; + + if (s->z < sector[sect].ceilingz+(32<<8)) + s->z = sector[sect].ceilingz+(32<<8); + + if (ud.multimode < 2) + { + if (actor_tog == 1) + { + s->cstat = (short)32768; + goto BOLT; + } + else if (actor_tog == 2) s->cstat = 257; + } + IFHIT + { + if (s->extra < 0 && t[0] != -1) + { + t[0] = -1; + s->extra = 0; + } + spritesound(RECO_PAIN,i); + RANDOMSCRAP; + } + + if (t[0] == -1) + { + s->z += 1024; + t[2]++; + if ((t[2]&3) == 0) spawn(i,EXPLOSION2); + getglobalz(i); + s->ang += 96; + s->xvel = 128; + j = ssp(i,CLIPMASK0); + if (j != 1 || s->z > hittype[i].floorz) + { + for (l=0;l<16;l++) + RANDOMSCRAP; + spritesound(LASERTRIP_EXPLODE,i); + spawn(i,PIGCOP); + ps[myconnectindex].actors_killed++; + KILLIT(i); + } + goto BOLT; + } + else + { + if (s->z > hittype[i].floorz-(48<<8)) + s->z = hittype[i].floorz-(48<<8); + } + + p = findplayer(s,&x); + j = s->owner; + + // 3 = findplayerz, 4 = shoot + + if (t[0] >= 4) + { + t[2]++; + if ((t[2]&15) == 0) + { + a = s->ang; + s->ang = hittype[i].tempang; + spritesound(RECO_ATTACK,i); + shoot(i,FIRELASER); + s->ang = a; + } + if (t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) + { + t[0] = 0; + t[2] = 0; + } + else hittype[i].tempang += + getincangle(hittype[i].tempang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))/3; + } + else if (t[0] == 2 || t[0] == 3) + { + t[3] = 0; + if (s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + + if (t[0] == 2) + { + l = ps[p].posz-s->z; + if (klabs(l) < (48<<8)) t[0] = 3; + else s->z += ksgn(ps[p].posz-s->z)<<10; + } + else + { + t[2]++; + if (t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) + { + t[0] = 1; + t[2] = 0; + } + else if ((t[2]&15) == 0) + { + spritesound(RECO_ATTACK,i); + shoot(i,FIRELASER); + } + } + s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; + } + + if (t[0] != 2 && t[0] != 3) + { + l = ldist(&sprite[j],s); + if (l <= 1524) + { + a = s->ang; + s->xvel >>= 1; + } + else a = getangle(sprite[j].x-s->x,sprite[j].y-s->y); + + if (t[0] == 1 || t[0] == 4) // Found a locator and going with it + { + l = dist(&sprite[j],s); + + if (l <= 1524) + { + if (t[0] == 1) t[0] = 0; + else t[0] = 5; + } + else + { + // Control speed here + if (l > 1524) + { + if (s->xvel < 256) s->xvel += 32; + } + else + { + if (s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + } + } + + if (t[0] < 2) t[2]++; + + if (x < 6144 && t[0] < 2 && t[2] > (26*4)) + { + t[0] = 2+(TRAND&2); + t[2] = 0; + hittype[i].tempang = s->ang; + } + } + + if (t[0] == 0 || t[0] == 5) + { + if (t[0] == 0) + t[0] = 1; + else t[0] = 4; + j = s->owner = LocateTheLocator(s->hitag,-1); + if (j == -1) + { + s->hitag = j = hittype[i].temp_data[5]; + s->owner = LocateTheLocator(j,-1); + j = s->owner; + if (j == -1) KILLIT(i); + } + else s->hitag++; + } + + t[3] = getincangle(s->ang,a); + s->ang += t[3]>>3; + + if (s->z < sprite[j].z) + s->z += 1024; + else s->z -= 1024; + } + + if (!isspritemakingsound(i,RECO_ROAM)) + spritesound(RECO_ROAM,i); + + ssp(i,CLIPMASK0); + + goto BOLT; + + case OOZ__STATIC: + case OOZ2__STATIC: + + getglobalz(i); + + j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + if (j > 255) j = 255; + + x = 25-(j>>1); + if (x < 8) x = 8; + else if (x > 48) x = 48; + + s->yrepeat = j; + s->xrepeat = x; + s->z = hittype[i].floorz; + + goto BOLT; + + case GREENSLIME__STATIC: + // case GREENSLIME+1: + // case GREENSLIME+2: + // case GREENSLIME+3: + // case GREENSLIME+4: + // case GREENSLIME+5: + // case GREENSLIME+6: + // case GREENSLIME+7: + + // #ifndef VOLUMEONE + if (ud.multimode < 2) + { + if (actor_tog == 1) + { + s->cstat = (short)32768; + goto BOLT; + } + else if (actor_tog == 2) s->cstat = 257; + } + // #endif + + t[1]+=128; + + if (sector[sect].floorstat&1) + KILLIT(i); + + p = findplayer(s,&x); + + if (x > 20480) + { + hittype[i].timetosleep++; + if (hittype[i].timetosleep > SLEEPTIME) + { + hittype[i].timetosleep = 0; + changespritestat(i,2); + goto BOLT; + } + } + + if (t[0] == -5) // FROZEN + { + t[3]++; + if (t[3] > 280) + { + s->pal = 0; + t[0] = 0; + goto BOLT; + } + makeitfall(i); + s->cstat = 257; + s->picnum = GREENSLIME+2; + s->extra = 1; + s->pal = 1; + IFHIT + { + if (j == FREEZEBLAST) goto BOLT; + for (j=16; j >= 0 ;j--) + { + k = EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,TRAND&2047,32+(TRAND&63),1024-(TRAND&1023),i,5); + sprite[k].pal = 1; + } + spritesound(GLASS_BREAKING,i); + KILLIT(i); + } + else if (x < 1024 && ps[p].quick_kick == 0) + { + j = getincangle(ps[p].ang,getangle(SX-ps[p].posx,SY-ps[p].posy)); + if (j > -128 && j < 128) + ps[p].quick_kick = 14; } goto BOLT; - - case RECON__STATIC: - - getglobalz(i); - - if (sector[s->sectnum].ceilingstat&1) - s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; - else s->shade += (sector[s->sectnum].floorshade-s->shade)>>1; - - if (s->z < sector[sect].ceilingz+(32<<8)) - s->z = sector[sect].ceilingz+(32<<8); - - if (ud.multimode < 2) - { - if (actor_tog == 1) - { - s->cstat = (short)32768; - goto BOLT; - } - else if (actor_tog == 2) s->cstat = 257; - } - IFHIT - { - if (s->extra < 0 && t[0] != -1) - { - t[0] = -1; - s->extra = 0; - } - spritesound(RECO_PAIN,i); - RANDOMSCRAP; } - if (t[0] == -1) + if (x < 1596) + s->cstat = 0; + else s->cstat = 257; + + if (t[0] == -4) //On the player + { + if (sprite[ps[p].i].extra < 1) { - s->z += 1024; - t[2]++; - if ((t[2]&3) == 0) spawn(i,EXPLOSION2); - getglobalz(i); - s->ang += 96; - s->xvel = 128; - j = ssp(i,CLIPMASK0); - if (j != 1 || s->z > hittype[i].floorz) + t[0] = 0; + goto BOLT; + } + + setsprite(i,s->x,s->y,s->z); + + s->ang = ps[p].ang; + + if (((sync[p].bits&4) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0) + if (ps[p].quick_kick > 0 || (ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0)) { - for (l=0;l<16;l++) - RANDOMSCRAP; - spritesound(LASERTRIP_EXPLODE,i); - spawn(i,PIGCOP); - ps[myconnectindex].actors_killed++; + for (x=0;x<8;x++) + { + j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + sprite[j].pal = 6; + } + + spritesound(SLIM_DYING,i); + spritesound(SQUISHED,i); + if ((TRAND&255) < 32) + { + j = spawn(i,BLOODPOOL); + sprite[j].pal = 0; + } + ps[p].actors_killed ++; + t[0] = -3; + if (ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; KILLIT(i); } + + s->z = ps[p].posz+ps[p].pyoff-t[2]+(8<<8); + + s->z += (100-ps[p].horiz)<<4; + + if (t[2] > 512) + t[2] -= 128; + + if (t[2] < 348) + t[2] += 128; + + if (ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].ang = ps[p].oang; + + updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); + setpal(&ps[p]); + + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + if (t[3]>0) + { + short frames[] = {5,5,6,6,7,7,6,5}; + + s->picnum = GREENSLIME+frames[t[3]]; + + if (t[3] == 5) + { + sprite[ps[p].i].extra += -(5+(TRAND&3)); + spritesound(SLIM_ATTACK,i); + } + + if (t[3] < 7) t[3]++; + else t[3] = 0; + + } + else + { + s->picnum = GREENSLIME+5; + if (rnd(32)) + t[3] = 1; + } + + s->xrepeat = 20+(sintable[t[1]&2047]>>13); + s->yrepeat = 15+(sintable[t[1]&2047]>>13); + + s->x = ps[p].posx + (sintable[(ps[p].ang+512)&2047]>>7); + s->y = ps[p].posy + (sintable[ps[p].ang&2047]>>7); + + goto BOLT; + } + + else if (s->xvel < 64 && x < 768) + { + if (ps[p].somethingonplayer == -1) + { + ps[p].somethingonplayer = i; + if (t[0] == 3 || t[0] == 2) //Falling downward + t[2] = (12<<8); + else t[2] = -(13<<8); //Climbing up duke + t[0] = -4; + } + } + + IFHIT + { + spritesound(SLIM_DYING,i); + + ps[p].actors_killed ++; + if (ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; + + if (j == FREEZEBLAST) + { + spritesound(SOMETHINGFROZE,i); + t[0] = -5 ; + t[3] = 0 ; + goto BOLT; + } + + if ((TRAND&255) < 32) + { + j = spawn(i,BLOODPOOL); + sprite[j].pal = 0; + } + + for (x=0;x<8;x++) + { + j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + sprite[j].pal = 6; + } + t[0] = -3; + KILLIT(i); + } + // All weap + if (t[0] == -1) //Shrinking down + { + makeitfall(i); + + s->cstat &= 65535-8; + s->picnum = GREENSLIME+4; + + // if(s->yrepeat > 62) + // guts(s,JIBS6,5,myconnectindex); + + if (s->xrepeat > 32) s->xrepeat -= TRAND&7; + if (s->yrepeat > 16) s->yrepeat -= TRAND&7; + else + { + s->xrepeat = 40; + s->yrepeat = 16; + t[5] = -1; + t[0] = 0; + } + + goto BOLT; + } + else if (t[0] != -2) getglobalz(i); + + if (t[0] == -2) //On top of somebody + { + makeitfall(i); + sprite[t[5]].xvel = 0; + + l = sprite[t[5]].ang; + + s->z = sprite[t[5]].z; + s->x = sprite[t[5]].x+(sintable[(l+512)&2047]>>11); + s->y = sprite[t[5]].y+(sintable[l&2047]>>11); + + s->picnum = GREENSLIME+2+(global_random&1); + + if (s->yrepeat < 64) s->yrepeat+=2; + else + { + if (s->xrepeat < 32) s->xrepeat += 4; + else + { + t[0] = -1; + x = ldist(s,&sprite[t[5]]); + if (x < 768) + { + sprite[t[5]].xrepeat = 0; + + // JBF 20041129: a slimer eating another enemy really ought + // to decrease the maximum kill count by one. + if (sprite[t[5]].extra > 0) ps[myconnectindex].max_actors_killed--; + } + } + } + + goto BOLT; + } + + //Check randomly to see of there is an actor near + if (rnd(32)) + { + j = headspritesect[sect]; + while (j>=0) + { + switch (dynamictostatic[sprite[j].picnum]) + { + case LIZTROOP__STATIC: + case LIZMAN__STATIC: + case PIGCOP__STATIC: + case NEWBEAST__STATIC: + if (ldist(s,&sprite[j]) < 768 && (klabs(s->z-sprite[j].z)<8192)) //Gulp them + { + t[5] = j; + t[0] = -2; + t[1] = 0; + goto BOLT; + } + } + + j = nextspritesect[j]; + } + } + + //Moving on the ground or ceiling + + if (t[0] == 0 || t[0] == 2) + { + s->picnum = GREENSLIME; + + if ((TRAND&511) == 0) + spritesound(SLIM_ROAM,i); + + if (t[0]==2) + { + s->zvel = 0; + s->cstat &= (65535-8); + + if ((sector[sect].ceilingstat&1) || (hittype[i].ceilingz+6144) < s->z) + { + s->z += 2048; + t[0] = 3; + goto BOLT; + } + } + else + { + s->cstat |= 8; + makeitfall(i); + } + + if (everyothertime&1) ssp(i,CLIPMASK0); + + if (s->xvel > 96) + { + s->xvel -= 2; goto BOLT; } else { - if (s->z > hittype[i].floorz-(48<<8)) - s->z = hittype[i].floorz-(48<<8); + if (s->xvel < 32) s->xvel += 4; + s->xvel = 64 - (sintable[(t[1]+512)&2047]>>9); + + s->ang += getincangle(s->ang, + getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; + // TJR } - p = findplayer(s,&x); - j = s->owner; + s->xrepeat = 36 + (sintable[(t[1]+512)&2047]>>11); + s->yrepeat = 16 + (sintable[t[1]&2047]>>13); - // 3 = findplayerz, 4 = shoot - - if (t[0] >= 4) + if (rnd(4) && (sector[sect].ceilingstat&1) == 0 && + klabs(hittype[i].floorz-hittype[i].ceilingz) + < (192<<8)) { - t[2]++; - if ((t[2]&15) == 0) - { - a = s->ang; - s->ang = hittype[i].tempang; - spritesound(RECO_ATTACK,i); - shoot(i,FIRELASER); - s->ang = a; - } - if (t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) - { - t[0] = 0; - t[2] = 0; - } - else hittype[i].tempang += - getincangle(hittype[i].tempang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))/3; - } - else if (t[0] == 2 || t[0] == 3) - { - t[3] = 0; - if (s->xvel > 0) s->xvel -= 16; - else s->xvel = 0; - - if (t[0] == 2) - { - l = ps[p].posz-s->z; - if (klabs(l) < (48<<8)) t[0] = 3; - else s->z += ksgn(ps[p].posz-s->z)<<10; - } - else - { - t[2]++; - if (t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) - { - t[0] = 1; - t[2] = 0; - } - else if ((t[2]&15) == 0) - { - spritesound(RECO_ATTACK,i); - shoot(i,FIRELASER); - } - } - s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; + s->zvel = 0; + t[0]++; } - if (t[0] != 2 && t[0] != 3) - { - l = ldist(&sprite[j],s); - if (l <= 1524) - { - a = s->ang; - s->xvel >>= 1; - } - else a = getangle(sprite[j].x-s->x,sprite[j].y-s->y); - - if (t[0] == 1 || t[0] == 4) // Found a locator and going with it - { - l = dist(&sprite[j],s); - - if (l <= 1524) - { - if (t[0] == 1) t[0] = 0; - else t[0] = 5; - } - else - { - // Control speed here - if (l > 1524) - { - if (s->xvel < 256) s->xvel += 32; - } - else - { - if (s->xvel > 0) s->xvel -= 16; - else s->xvel = 0; - } - } - - if (t[0] < 2) t[2]++; - - if (x < 6144 && t[0] < 2 && t[2] > (26*4)) - { - t[0] = 2+(TRAND&2); - t[2] = 0; - hittype[i].tempang = s->ang; - } - } - - if (t[0] == 0 || t[0] == 5) - { - if (t[0] == 0) - t[0] = 1; - else t[0] = 4; - j = s->owner = LocateTheLocator(s->hitag,-1); - if (j == -1) - { - s->hitag = j = hittype[i].temp_data[5]; - s->owner = LocateTheLocator(j,-1); - j = s->owner; - if (j == -1) KILLIT(i); - } - else s->hitag++; - } - - t[3] = getincangle(s->ang,a); - s->ang += t[3]>>3; - - if (s->z < sprite[j].z) - s->z += 1024; - else s->z -= 1024; - } - - if (!isspritemakingsound(i,RECO_ROAM)) - spritesound(RECO_ROAM,i); - - ssp(i,CLIPMASK0); - - goto BOLT; - - case OOZ__STATIC: - case OOZ2__STATIC: - - getglobalz(i); - - j = (hittype[i].floorz-hittype[i].ceilingz)>>9; - if (j > 255) j = 255; - - x = 25-(j>>1); - if (x < 8) x = 8; - else if (x > 48) x = 48; - - s->yrepeat = j; - s->xrepeat = x; - s->z = hittype[i].floorz; - - goto BOLT; - - case GREENSLIME__STATIC: - // case GREENSLIME+1: - // case GREENSLIME+2: - // case GREENSLIME+3: - // case GREENSLIME+4: - // case GREENSLIME+5: - // case GREENSLIME+6: - // case GREENSLIME+7: - - // #ifndef VOLUMEONE - if (ud.multimode < 2) - { - if (actor_tog == 1) - { - s->cstat = (short)32768; - goto BOLT; - } - else if (actor_tog == 2) s->cstat = 257; - } - // #endif - - t[1]+=128; - - if (sector[sect].floorstat&1) - KILLIT(i); - - p = findplayer(s,&x); - - if (x > 20480) - { - hittype[i].timetosleep++; - if (hittype[i].timetosleep > SLEEPTIME) - { - hittype[i].timetosleep = 0; - changespritestat(i,2); - goto BOLT; - } - } - - if (t[0] == -5) // FROZEN - { - t[3]++; - if (t[3] > 280) - { - s->pal = 0; - t[0] = 0; - goto BOLT; - } - makeitfall(i); - s->cstat = 257; - s->picnum = GREENSLIME+2; - s->extra = 1; - s->pal = 1; - IFHIT - { - if (j == FREEZEBLAST) goto BOLT; - for (j=16; j >= 0 ;j--) - { - k = EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,TRAND&2047,32+(TRAND&63),1024-(TRAND&1023),i,5); - sprite[k].pal = 1; - } - spritesound(GLASS_BREAKING,i); - KILLIT(i); - } - else if (x < 1024 && ps[p].quick_kick == 0) - { - j = getincangle(ps[p].ang,getangle(SX-ps[p].posx,SY-ps[p].posy)); - if (j > -128 && j < 128) - ps[p].quick_kick = 14; - } - - goto BOLT; - } - - if (x < 1596) - s->cstat = 0; - else s->cstat = 257; - - if (t[0] == -4) //On the player - { - if (sprite[ps[p].i].extra < 1) - { - t[0] = 0; - goto BOLT; - } - - setsprite(i,s->x,s->y,s->z); - - s->ang = ps[p].ang; - - if (((sync[p].bits&4) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0) - if (ps[p].quick_kick > 0 || (ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0)) - { - for (x=0;x<8;x++) - { - j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); - sprite[j].pal = 6; - } - - spritesound(SLIM_DYING,i); - spritesound(SQUISHED,i); - if ((TRAND&255) < 32) - { - j = spawn(i,BLOODPOOL); - sprite[j].pal = 0; - } - ps[p].actors_killed ++; - t[0] = -3; - if (ps[p].somethingonplayer == i) - ps[p].somethingonplayer = -1; - KILLIT(i); - } - - s->z = ps[p].posz+ps[p].pyoff-t[2]+(8<<8); - - s->z += (100-ps[p].horiz)<<4; - - if (t[2] > 512) - t[2] -= 128; - - if (t[2] < 348) - t[2] += 128; - - if (ps[p].newowner >= 0) - { - ps[p].newowner = -1; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; - ps[p].ang = ps[p].oang; - - updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); - setpal(&ps[p]); - - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; - j = nextspritestat[j]; - } - } - - if (t[3]>0) - { - short frames[] = {5,5,6,6,7,7,6,5}; - - s->picnum = GREENSLIME+frames[t[3]]; - - if (t[3] == 5) - { - sprite[ps[p].i].extra += -(5+(TRAND&3)); - spritesound(SLIM_ATTACK,i); - } - - if (t[3] < 7) t[3]++; - else t[3] = 0; - - } - else - { - s->picnum = GREENSLIME+5; - if (rnd(32)) - t[3] = 1; - } - - s->xrepeat = 20+(sintable[t[1]&2047]>>13); - s->yrepeat = 15+(sintable[t[1]&2047]>>13); - - s->x = ps[p].posx + (sintable[(ps[p].ang+512)&2047]>>7); - s->y = ps[p].posy + (sintable[ps[p].ang&2047]>>7); - - goto BOLT; - } - - else if (s->xvel < 64 && x < 768) - { - if (ps[p].somethingonplayer == -1) - { - ps[p].somethingonplayer = i; - if (t[0] == 3 || t[0] == 2) //Falling downward - t[2] = (12<<8); - else t[2] = -(13<<8); //Climbing up duke - t[0] = -4; - } - } - - IFHIT - { - spritesound(SLIM_DYING,i); - - ps[p].actors_killed ++; - if (ps[p].somethingonplayer == i) - ps[p].somethingonplayer = -1; - - if (j == FREEZEBLAST) - { - spritesound(SOMETHINGFROZE,i); - t[0] = -5 ; - t[3] = 0 ; - goto BOLT; - } - - if ((TRAND&255) < 32) - { - j = spawn(i,BLOODPOOL); - sprite[j].pal = 0; - } - - for (x=0;x<8;x++) - { - j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); - sprite[j].pal = 6; - } - t[0] = -3; - KILLIT(i); } - // All weap - if (t[0] == -1) //Shrinking down + + if (t[0]==1) + { + s->picnum = GREENSLIME; + if (s->yrepeat < 40) s->yrepeat+=8; + if (s->xrepeat > 8) s->xrepeat-=4; + if (s->zvel > -(2048+1024)) + s->zvel -= 348; + s->z += s->zvel; + if (s->z < hittype[i].ceilingz+4096) { - makeitfall(i); - - s->cstat &= 65535-8; - s->picnum = GREENSLIME+4; - - // if(s->yrepeat > 62) - // guts(s,JIBS6,5,myconnectindex); - - if (s->xrepeat > 32) s->xrepeat -= TRAND&7; - if (s->yrepeat > 16) s->yrepeat -= TRAND&7; - else - { - s->xrepeat = 40; - s->yrepeat = 16; - t[5] = -1; - t[0] = 0; - } - - goto BOLT; + s->z = hittype[i].ceilingz+4096; + s->xvel = 0; + t[0] = 2; } - else if (t[0] != -2) getglobalz(i); + } - if (t[0] == -2) //On top of somebody + if (t[0]==3) + { + s->picnum = GREENSLIME+1; + + makeitfall(i); + + if (s->z > hittype[i].floorz-(8<<8)) { - makeitfall(i); - sprite[t[5]].xvel = 0; - - l = sprite[t[5]].ang; - - s->z = sprite[t[5]].z; - s->x = sprite[t[5]].x+(sintable[(l+512)&2047]>>11); - s->y = sprite[t[5]].y+(sintable[l&2047]>>11); - - s->picnum = GREENSLIME+2+(global_random&1); - - if (s->yrepeat < 64) s->yrepeat+=2; - else - { - if (s->xrepeat < 32) s->xrepeat += 4; - else - { - t[0] = -1; - x = ldist(s,&sprite[t[5]]); - if (x < 768) - { - sprite[t[5]].xrepeat = 0; - - // JBF 20041129: a slimer eating another enemy really ought - // to decrease the maximum kill count by one. - if (sprite[t[5]].extra > 0) ps[myconnectindex].max_actors_killed--; - } - } - } - - goto BOLT; + s->yrepeat-=4; + s->xrepeat+=2; } - - //Check randomly to see of there is an actor near - if (rnd(32)) + else { - j = headspritesect[sect]; - while (j>=0) - { - switch (dynamictostatic[sprite[j].picnum]) - { - case LIZTROOP__STATIC: - case LIZMAN__STATIC: - case PIGCOP__STATIC: - case NEWBEAST__STATIC: - if (ldist(s,&sprite[j]) < 768 && (klabs(s->z-sprite[j].z)<8192)) //Gulp them - { - t[5] = j; - t[0] = -2; - t[1] = 0; - goto BOLT; - } - } - - j = nextspritesect[j]; - } - } - - //Moving on the ground or ceiling - - if (t[0] == 0 || t[0] == 2) - { - s->picnum = GREENSLIME; - - if ((TRAND&511) == 0) - spritesound(SLIM_ROAM,i); - - if (t[0]==2) - { - s->zvel = 0; - s->cstat &= (65535-8); - - if ((sector[sect].ceilingstat&1) || (hittype[i].ceilingz+6144) < s->z) - { - s->z += 2048; - t[0] = 3; - goto BOLT; - } - } - else - { - s->cstat |= 8; - makeitfall(i); - } - - if (everyothertime&1) ssp(i,CLIPMASK0); - - if (s->xvel > 96) - { - s->xvel -= 2; - goto BOLT; - } - else - { - if (s->xvel < 32) s->xvel += 4; - s->xvel = 64 - (sintable[(t[1]+512)&2047]>>9); - - s->ang += getincangle(s->ang, - getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; - // TJR - } - - s->xrepeat = 36 + (sintable[(t[1]+512)&2047]>>11); - s->yrepeat = 16 + (sintable[t[1]&2047]>>13); - - if (rnd(4) && (sector[sect].ceilingstat&1) == 0 && - klabs(hittype[i].floorz-hittype[i].ceilingz) - < (192<<8)) - { - s->zvel = 0; - t[0]++; - } - - } - - if (t[0]==1) - { - s->picnum = GREENSLIME; - if (s->yrepeat < 40) s->yrepeat+=8; + if (s->yrepeat < (40-4)) s->yrepeat+=8; if (s->xrepeat > 8) s->xrepeat-=4; - if (s->zvel > -(2048+1024)) - s->zvel -= 348; - s->z += s->zvel; - if (s->z < hittype[i].ceilingz+4096) - { - s->z = hittype[i].ceilingz+4096; - s->xvel = 0; - t[0] = 2; - } } - if (t[0]==3) + if (s->z > hittype[i].floorz-2048) { - s->picnum = GREENSLIME+1; + s->z = hittype[i].floorz-2048; + t[0] = 0; + s->xvel = 0; + } + } + goto BOLT; - makeitfall(i); + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + j = spawn(i,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13)); + hittype[j].temp_data[0] = 3; - if (s->z > hittype[i].floorz-(8<<8)) - { - s->yrepeat-=4; - s->xrepeat+=2; - } - else - { - if (s->yrepeat < (40-4)) s->yrepeat+=8; - if (s->xrepeat > 8) s->xrepeat-=4; - } + case HEAVYHBOMB__STATIC: - if (s->z > hittype[i].floorz-2048) - { - s->z = hittype[i].floorz-2048; - t[0] = 0; - s->xvel = 0; - } + if ((s->cstat&32768)) + { + t[2]--; + if (t[2] <= 0) + { + spritesound(TELEPORTER,i); + spawn(i,TRANSPORTERSTAR); + s->cstat = 257; } goto BOLT; + } - case BOUNCEMINE__STATIC: - case MORTER__STATIC: - j = spawn(i,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13)); - hittype[j].temp_data[0] = 3; + p = findplayer(s,&x); - case HEAVYHBOMB__STATIC: + if (x < 1220) s->cstat &= ~257; + else s->cstat |= 257; - if ((s->cstat&32768)) - { - t[2]--; - if (t[2] <= 0) - { - spritesound(TELEPORTER,i); - spawn(i,TRANSPORTERSTAR); - s->cstat = 257; - } - goto BOLT; - } - - p = findplayer(s,&x); - - if (x < 1220) s->cstat &= ~257; - else s->cstat |= 257; - - if (t[3] == 0) - { - j = ifhitbyweapon(i); - if (j >= 0) - { - t[3] = 1; - t[4] = 0; - l = 0; - s->xvel = 0; - goto DETONATEB; - } - } - - if (s->picnum != BOUNCEMINE) - { - makeitfall(i); - - if (sector[sect].lotag != 1 && s->z >= hittype[i].floorz-(FOURSLEIGHT) && s->yvel < 3) - { - if (s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz)) - spritesound(PIPEBOMB_BOUNCE,i); - s->zvel = -((4-s->yvel)<<8); - if (sector[s->sectnum].lotag== 2) - s->zvel >>= 2; - s->yvel++; - } - if (s->z < hittype[i].ceilingz) // && sector[sect].lotag != 2 ) - { - s->z = hittype[i].ceilingz+(3<<8); - s->zvel = 0; - } - } - - j = movesprite(i, - (s->xvel*(sintable[(s->ang+512)&2047]))>>14, - (s->xvel*(sintable[s->ang&2047]))>>14, - s->zvel,CLIPMASK0); - - if (sector[SECT].lotag == 1 && s->zvel == 0) - { - s->z += (32<<8); - if (t[5] == 0) - { - t[5] = 1; - spawn(i,WATERSPLASH2); - } - } - else t[5] = 0; - - if (t[3] == 0 && (s->picnum == BOUNCEMINE || s->picnum == MORTER) && (j || x < 844)) + if (t[3] == 0) + { + j = ifhitbyweapon(i); + if (j >= 0) { t[3] = 1; t[4] = 0; @@ -4477,111 +4431,206 @@ void moveactors(void) s->xvel = 0; goto DETONATEB; } + } - if (sprite[s->owner].picnum == APLAYER) - l = sprite[s->owner].yvel; - else l = -1; + if (s->picnum != BOUNCEMINE) + { + makeitfall(i); - if (s->xvel > 0) + if (sector[sect].lotag != 1 && s->z >= hittype[i].floorz-(FOURSLEIGHT) && s->yvel < 3) { - s->xvel -= 5; - if (sector[sect].lotag == 2) - s->xvel -= 10; - - if (s->xvel < 0) - s->xvel = 0; - if (s->xvel&8) s->cstat ^= 4; + if (s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz)) + spritesound(PIPEBOMB_BOUNCE,i); + s->zvel = -((4-s->yvel)<<8); + if (sector[s->sectnum].lotag== 2) + s->zvel >>= 2; + s->yvel++; } - - if ((j&49152) == 32768) + if (s->z < hittype[i].ceilingz) // && sector[sect].lotag != 2 ) { - j &= (MAXWALLS-1); - - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); - - k = getangle( - wall[wall[j].point2].x-wall[j].x, - wall[wall[j].point2].y-wall[j].y); - - s->ang = ((k<<1) - s->ang)&2047; - s->xvel >>= 1; + s->z = hittype[i].ceilingz+(3<<8); + s->zvel = 0; } + } - // long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); + j = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); + + if (sector[SECT].lotag == 1 && s->zvel == 0) + { + s->z += (32<<8); + if (t[5] == 0) + { + t[5] = 1; + spawn(i,WATERSPLASH2); + } + } + else t[5] = 0; + + if (t[3] == 0 && (s->picnum == BOUNCEMINE || s->picnum == MORTER) && (j || x < 844)) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + + if (sprite[s->owner].picnum == APLAYER) + l = sprite[s->owner].yvel; + else l = -1; + + if (s->xvel > 0) + { + s->xvel -= 5; + if (sector[sect].lotag == 2) + s->xvel -= 10; + + if (s->xvel < 0) + s->xvel = 0; + if (s->xvel&8) s->cstat ^= 4; + } + + if ((j&49152) == 32768) + { + j &= (MAXWALLS-1); + + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + + s->ang = ((k<<1) - s->ang)&2047; + s->xvel >>= 1; + } + + // long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); DETONATEB: - // if(lPipeBombControl & PIPEBOMB_TIMER) - // { + // if(lPipeBombControl & PIPEBOMB_TIMER) + // { - if (s->picnum == HEAVYHBOMB && hittype[i].temp_data[6] == 1) + if (s->picnum == HEAVYHBOMB && hittype[i].temp_data[6] == 1) + { + /* if(s->extra >= 1) + { + s->extra--; + } + + if(s->extra <= 0) + s->lotag=911; + */ + + if (hittype[i].temp_data[7] >= 1) { - /* if(s->extra >= 1) - { - s->extra--; - } - - if(s->extra <= 0) - s->lotag=911; - */ - - if (hittype[i].temp_data[7] >= 1) - { - hittype[i].temp_data[7]--; - } - - if (hittype[i].temp_data[7] <= 0) - { - hittype[i].temp_data[6] = 3; - // s->extra = *actorscrptr[s->picnum]; - } + hittype[i].temp_data[7]--; } - // } - - if ((l >= 0 && ps[l].hbomb_on == 0 && hittype[i].temp_data[6] == 2) || t[3] == 1) - hittype[i].temp_data[6] = 3; - - if (hittype[i].temp_data[6] == 3) + if (hittype[i].temp_data[7] <= 0) { - t[4]++; + hittype[i].temp_data[6] = 3; + // s->extra = *actorscrptr[s->picnum]; + } + } + // } - if (t[4] == 2) + if ((l >= 0 && ps[l].hbomb_on == 0 && hittype[i].temp_data[6] == 2) || t[3] == 1) + hittype[i].temp_data[6] = 3; + + if (hittype[i].temp_data[6] == 3) + + { + t[4]++; + + if (t[4] == 2) + { + x = s->extra; + m = 0; + switch (dynamictostatic[s->picnum]) { - x = s->extra; - m = 0; - switch (dynamictostatic[s->picnum]) - { - case HEAVYHBOMB__STATIC: - m = pipebombblastradius; - break; - case MORTER__STATIC: - m = morterblastradius; - break; - case BOUNCEMINE__STATIC: - m = bouncemineblastradius; - break; - } - - hitradius(i, m,x>>2,x>>1,x-(x>>2),x); - spawn(i,EXPLOSION2); - if (s->zvel == 0) - spawn(i,EXPLOSION2BOT); - spritesound(PIPEBOMB_EXPLODE,i); - for (x=0;x<8;x++) - RANDOMSCRAP; + case HEAVYHBOMB__STATIC: + m = pipebombblastradius; + break; + case MORTER__STATIC: + m = morterblastradius; + break; + case BOUNCEMINE__STATIC: + m = bouncemineblastradius; + break; } - if (s->yrepeat) + hitradius(i, m,x>>2,x>>1,x-(x>>2),x); + spawn(i,EXPLOSION2); + if (s->zvel == 0) + spawn(i,EXPLOSION2BOT); + spritesound(PIPEBOMB_EXPLODE,i); + for (x=0;x<8;x++) + RANDOMSCRAP; + } + + if (s->yrepeat) + { + s->yrepeat = 0; + goto BOLT; + } + + if (t[4] > 20) + { + if (s->owner != i || ud.respawn_items == 0) { - s->yrepeat = 0; + KILLIT(i); + } + else + { + t[2] = respawnitemtime; + spawn(i,RESPAWNMARKERRED); + s->cstat = (short) 32768; + s->yrepeat = 9; goto BOLT; } - - if (t[4] > 20) + } + } + else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) + if (cansee(s->x,s->y,s->z-(8<<8),s->sectnum,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) + if (ps[p].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) { + if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY) && s->owner == i) + { + for (j=0;jpicnum) + goto BOLT; + + if (ps[p].weapreccnt < 255) + ps[p].weaprecs[ps[p].weapreccnt++] = s->picnum; + } + + addammo(HANDBOMB_WEAPON,&ps[p],1); + spritesound(DUKE_GET,ps[p].i); + + if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == ps[p].i) + { + /* addweapon(&ps[p],HANDBOMB_WEAPON); */ + if (!(ps[p].weaponswitch & 1) && *aplWeaponWorksLike[ps[p].curr_weapon] != HANDREMOTE_WEAPON) + addweaponnoswitch(&ps[p],HANDBOMB_WEAPON); + else addweapon(&ps[p],HANDBOMB_WEAPON); + } + + if (sprite[s->owner].picnum != APLAYER) + { + ps[p].pals[0] = 0; + ps[p].pals[1] = 32; + ps[p].pals[2] = 0; + ps[p].pals_time = 32; + } + if (s->owner != i || ud.respawn_items == 0) { + if (s->owner == i && (gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY)) + goto BOLT; KILLIT(i); } else @@ -4589,242 +4638,193 @@ DETONATEB: t[2] = respawnitemtime; spawn(i,RESPAWNMARKERRED); s->cstat = (short) 32768; - s->yrepeat = 9; - goto BOLT; } } - } - else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) - if (cansee(s->x,s->y,s->z-(8<<8),s->sectnum,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) - if (ps[p].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) - { - if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY) && s->owner == i) - { - for (j=0;jpicnum) - goto BOLT; - if (ps[p].weapreccnt < 255) - ps[p].weaprecs[ps[p].weapreccnt++] = s->picnum; - } + if (t[0] < 8) t[0]++; + goto BOLT; - addammo(HANDBOMB_WEAPON,&ps[p],1); - spritesound(DUKE_GET,ps[p].i); + case REACTORBURNT__STATIC: + case REACTOR2BURNT__STATIC: + goto BOLT; - if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == ps[p].i) - { - /* addweapon(&ps[p],HANDBOMB_WEAPON); */ - if (!(ps[p].weaponswitch & 1) && *aplWeaponWorksLike[ps[p].curr_weapon] != HANDREMOTE_WEAPON) - addweaponnoswitch(&ps[p],HANDBOMB_WEAPON); - else addweapon(&ps[p],HANDBOMB_WEAPON); - } + case REACTOR__STATIC: + case REACTOR2__STATIC: - if (sprite[s->owner].picnum != APLAYER) - { - ps[p].pals[0] = 0; - ps[p].pals[1] = 32; - ps[p].pals[2] = 0; - ps[p].pals_time = 32; - } - - if (s->owner != i || ud.respawn_items == 0) - { - if (s->owner == i && (gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY)) - goto BOLT; - KILLIT(i); - } - else - { - t[2] = respawnitemtime; - spawn(i,RESPAWNMARKERRED); - s->cstat = (short) 32768; - } - } - - if (t[0] < 8) t[0]++; - goto BOLT; - - case REACTORBURNT__STATIC: - case REACTOR2BURNT__STATIC: - goto BOLT; - - case REACTOR__STATIC: - case REACTOR2__STATIC: - - if (t[4] == 1) + if (t[4] == 1) + { + j = headspritesect[sect]; + while (j >= 0) { + switch (dynamictostatic[sprite[j].picnum]) + { + case SECTOREFFECTOR__STATIC: + if (sprite[j].lotag == 1) + { + sprite[j].lotag = (short) 65535; + sprite[j].hitag = (short) 65535; + } + break; + case REACTOR__STATIC: + sprite[j].picnum = REACTORBURNT; + break; + case REACTOR2__STATIC: + sprite[j].picnum = REACTOR2BURNT; + break; + case REACTORSPARK__STATIC: + case REACTOR2SPARK__STATIC: + sprite[j].cstat = (short) 32768; + break; + } + j = nextspritesect[j]; + } + goto BOLT; + } + + if (t[1] >= 20) + { + t[4] = 1; + goto BOLT; + } + + p = findplayer(s,&x); + + t[2]++; + if (t[2] == 4) t[2]=0; + + if (x < 4096) + { + if ((TRAND&255) < 16) + { + if (!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + + spritesound(SHORT_CIRCUIT,i); + + sprite[ps[p].i].extra --; + ps[p].pals_time = 32; + ps[p].pals[0] = 32; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + t[0] += 128; + if (t[3] == 0) + t[3] = 1; + } + else t[3] = 0; + + if (t[1]) + { + t[1]++; + + t[4] = s->z; + s->z = sector[sect].floorz-(TRAND%(sector[sect].floorz-sector[sect].ceilingz)); + + switch (t[1]) + { + case 3: + //Turn on all of those flashing sectoreffector. + hitradius(i, 4096, + impact_damage<<2, + impact_damage<<2, + impact_damage<<2, + impact_damage<<2); + /* + j = headspritestat[3]; + while(j>=0) + { + if( sprite[j].lotag == 3 ) + hittype[j].temp_data[4]=1; + else if(sprite[j].lotag == 12) + { + hittype[j].temp_data[4] = 1; + sprite[j].lotag = 3; + sprite[j].owner = 0; + hittype[j].temp_data[0] = s->shade; + } + j = nextspritestat[j]; + } + */ + j = headspritestat[6]; + while (j >= 0) + { + if (sprite[j].picnum == MASTERSWITCH) + if (sprite[j].hitag == s->hitag) + if (sprite[j].yvel == 0) + sprite[j].yvel = 1; + j = nextspritestat[j]; + } + break; + + case 4: + case 7: + case 10: + case 15: j = headspritesect[sect]; while (j >= 0) { - switch (dynamictostatic[sprite[j].picnum]) + l = nextspritesect[j]; + + if (j != i) { - case SECTOREFFECTOR__STATIC: - if (sprite[j].lotag == 1) - { - sprite[j].lotag = (short) 65535; - sprite[j].hitag = (short) 65535; - } - break; - case REACTOR__STATIC: - sprite[j].picnum = REACTORBURNT; - break; - case REACTOR2__STATIC: - sprite[j].picnum = REACTOR2BURNT; - break; - case REACTORSPARK__STATIC: - case REACTOR2SPARK__STATIC: - sprite[j].cstat = (short) 32768; - break; + deletesprite(j); + break; } - j = nextspritesect[j]; + j = l; } - goto BOLT; + break; } + for (x=0;x<16;x++) + RANDOMSCRAP; - if (t[1] >= 20) + s->z = t[4]; + t[4] = 0; + + } + else + { + IFHIT { - t[4] = 1; - goto BOLT; - } - - p = findplayer(s,&x); - - t[2]++; - if (t[2] == 4) t[2]=0; - - if (x < 4096) - { - if ((TRAND&255) < 16) - { - if (!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,ps[p].i); - - spritesound(SHORT_CIRCUIT,i); - - sprite[ps[p].i].extra --; - ps[p].pals_time = 32; - ps[p].pals[0] = 32; - ps[p].pals[1] = 0; - ps[p].pals[2] = 0; + for (x=0;x<32;x++) + RANDOMSCRAP; + if (s->extra < 0) + t[1] = 1; } - t[0] += 128; - if (t[3] == 0) - t[3] = 1; } - else t[3] = 0; + goto BOLT; - if (t[1]) - { - t[1]++; + case CAMERA1__STATIC: - t[4] = s->z; - s->z = sector[sect].floorz-(TRAND%(sector[sect].floorz-sector[sect].ceilingz)); - - switch (t[1]) - { - case 3: - //Turn on all of those flashing sectoreffector. - hitradius(i, 4096, - impact_damage<<2, - impact_damage<<2, - impact_damage<<2, - impact_damage<<2); - /* - j = headspritestat[3]; - while(j>=0) - { - if( sprite[j].lotag == 3 ) - hittype[j].temp_data[4]=1; - else if(sprite[j].lotag == 12) - { - hittype[j].temp_data[4] = 1; - sprite[j].lotag = 3; - sprite[j].owner = 0; - hittype[j].temp_data[0] = s->shade; - } - j = nextspritestat[j]; - } - */ - j = headspritestat[6]; - while (j >= 0) - { - if (sprite[j].picnum == MASTERSWITCH) - if (sprite[j].hitag == s->hitag) - if (sprite[j].yvel == 0) - sprite[j].yvel = 1; - j = nextspritestat[j]; - } - break; - - case 4: - case 7: - case 10: - case 15: - j = headspritesect[sect]; - while (j >= 0) - { - l = nextspritesect[j]; - - if (j != i) - { - deletesprite(j); - break; - } - j = l; - } - break; - } - for (x=0;x<16;x++) - RANDOMSCRAP; - - s->z = t[4]; - t[4] = 0; - - } - else + if (t[0] == 0) + { + t[1]+=8; + if (camerashitable) { IFHIT { - for (x=0;x<32;x++) - RANDOMSCRAP; - if (s->extra < 0) - t[1] = 1; - } - } - goto BOLT; - - case CAMERA1__STATIC: - - if (t[0] == 0) - { - t[1]+=8; - if (camerashitable) - { - IFHIT - { - t[0] = 1; // static - s->cstat = (short)32768; - for (x=0;x<5;x++) RANDOMSCRAP; - goto BOLT; - } - } - - if (s->hitag > 0) - { - if (t[1]hitag) - s->ang+=8; - else if (t[1]<(s->hitag*3)) - s->ang-=8; - else if (t[1] < (s->hitag<<2)) - s->ang+=8; - else - { - t[1]=8; - s->ang+=16; - } + t[0] = 1; // static + s->cstat = (short)32768; + for (x=0;x<5;x++) RANDOMSCRAP; + goto BOLT; } } - goto BOLT; + + if (s->hitag > 0) + { + if (t[1]hitag) + s->ang+=8; + else if (t[1]<(s->hitag*3)) + s->ang-=8; + else if (t[1] < (s->hitag<<2)) + s->ang+=8; + else + { + t[1]=8; + s->ang+=16; + } + } + } + goto BOLT; } @@ -4889,474 +4889,474 @@ void moveexplosions(void) // STATNUM 5 hittype[i].floorz = s->z = getflorzofslope(s->sectnum,s->x,s->y); else switch (dynamictostatic[switchpicnum]) { - case NEON1__STATIC: - case NEON2__STATIC: - case NEON3__STATIC: - case NEON4__STATIC: - case NEON5__STATIC: - case NEON6__STATIC: + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: - if ((global_random/(s->lotag+1)&31) > 4) s->shade = -127; - else s->shade = 127; - goto BOLT; + if ((global_random/(s->lotag+1)&31) > 4) s->shade = -127; + else s->shade = 127; + goto BOLT; - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: - if (t[0] == 7*26) goto BOLT; - s->z += 16+(TRAND&15); + if (t[0] == 7*26) goto BOLT; + s->z += 16+(TRAND&15); + t[0]++; + if ((t[0]%9) == 0) s->yrepeat++; + goto BOLT; + + case NUKEBUTTON__STATIC: + // case NUKEBUTTON+1: + // case NUKEBUTTON+2: + // case NUKEBUTTON+3: + + if (t[0]) + { t[0]++; - if ((t[0]%9) == 0) s->yrepeat++; - goto BOLT; - - case NUKEBUTTON__STATIC: - // case NUKEBUTTON+1: - // case NUKEBUTTON+2: - // case NUKEBUTTON+3: - - if (t[0]) + if (t[0] == 8) s->picnum = NUKEBUTTON+1; + else if (t[0] == 16) { - t[0]++; - if (t[0] == 8) s->picnum = NUKEBUTTON+1; - else if (t[0] == 16) - { - s->picnum = NUKEBUTTON+2; - ps[sprite[s->owner].yvel].fist_incs = 1; - } - if (ps[sprite[s->owner].yvel].fist_incs == 26) - s->picnum = NUKEBUTTON+3; + s->picnum = NUKEBUTTON+2; + ps[sprite[s->owner].yvel].fist_incs = 1; } - goto BOLT; + if (ps[sprite[s->owner].yvel].fist_incs == 26) + s->picnum = NUKEBUTTON+3; + } + goto BOLT; - case FORCESPHERE__STATIC: + case FORCESPHERE__STATIC: - l = s->xrepeat; - if (t[1] > 0) - { - t[1]--; - if (t[1] == 0) - { - KILLIT(i); - } - } - if (hittype[s->owner].temp_data[1] == 0) - { - if (t[0] < 64) - { - t[0]++; - l += 3; - } - } - else - if (t[0] > 64) - { - t[0]--; - l -= 3; - } - - s->x = sprite[s->owner].x; - s->y = sprite[s->owner].y; - s->z = sprite[s->owner].z; - s->ang += hittype[s->owner].temp_data[0]; - - if (l > 64) l = 64; - else if (l < 1) l = 1; - - s->xrepeat = l; - s->yrepeat = l; - s->shade = (l>>1)-48; - - for (j=t[0];j > 0;j--) - ssp(i,CLIPMASK0); - goto BOLT; - case WATERSPLASH2__STATIC: - - t[0]++; - if (t[0] == 1) - { - if (sector[sect].lotag != 1 && sector[sect].lotag != 2) - KILLIT(i); - /* else - { - l = getflorzofslope(sect,s->x,s->y)-s->z; - if( l > (16<<8) ) KILLIT(i); - } - else */ - if (!issoundplaying(i,ITEM_SPLASH)) - spritesound(ITEM_SPLASH,i); - } - if (t[0] == 3) - { - t[0] = 0; - t[1]++; - } - if (t[1] == 5) - deletesprite(i); - goto BOLT; - case FRAMEEFFECT1_13__STATIC: - if (PLUTOPAK) goto BOLT; // JBF: ideally this should never happen... - case FRAMEEFFECT1__STATIC: - - if (s->owner >= 0) - { - t[0]++; - - if (t[0] > 7) - { - KILLIT(i); - } - else if (t[0] > 4) - s->cstat |= 512+2; - else if (t[0] > 2) - s->cstat |= 2; - s->xoffset = sprite[s->owner].xoffset; - s->yoffset = sprite[s->owner].yoffset; - } - goto BOLT; - case INNERJAW__STATIC: - // case INNERJAW+1: - - p = findplayer(s,&x); - if (x < 512) - { - ps[p].pals_time = 32; - ps[p].pals[0] = 32; - ps[p].pals[1] = 0; - ps[p].pals[2] = 0; - sprite[ps[p].i].extra -= 4; - } - - case FIRELASER__STATIC: - if (s->extra != 999) - s->extra = 999; - else KILLIT(i); - break; - case TONGUE__STATIC: - KILLIT(i); - - case MONEY__STATIC: - case MAIL__STATIC: - case PAPER__STATIC: - - s->xvel = (TRAND&7)+(sintable[T1&2047]>>9); - T1 += (TRAND&63); - if ((T1&2047) > 512 && (T1&2047) < 1596) - { - if (sector[sect].lotag == 2) - { - if (s->zvel < 64) - s->zvel += (gc>>5)+(TRAND&7); - } - else - if (s->zvel < 144) - s->zvel += (gc>>5)+(TRAND&7); - } - - ssp(i,CLIPMASK0); - - if ((TRAND&3) == 0) - setsprite(i,s->x,s->y,s->z); - - if (s->sectnum == -1) KILLIT(i); - l = getflorzofslope(s->sectnum,s->x,s->y); - - if (s->z > l) - { - s->z = l; - - insertspriteq(i); - PN ++; - - j = headspritestat[5]; - while (j >= 0) - { - if (sprite[j].picnum == BLOODPOOL) - if (ldist(s,&sprite[j]) < 348) - { - s->pal = 2; - break; - } - j = nextspritestat[j]; - } - } - - break; - - case JIBS1__STATIC: - case JIBS2__STATIC: - case JIBS3__STATIC: - case JIBS4__STATIC: - case JIBS5__STATIC: - case JIBS6__STATIC: - case HEADJIB1__STATIC: - case ARMJIB1__STATIC: - case LEGJIB1__STATIC: - case LIZMANHEAD1__STATIC: - case LIZMANARM1__STATIC: - case LIZMANLEG1__STATIC: - case DUKETORSO__STATIC: - case DUKEGUN__STATIC: - case DUKELEG__STATIC: - - if (s->xvel > 0) s->xvel--; - else s->xvel = 0; - - if (t[5] < 30*10) - t[5]++; - else + l = s->xrepeat; + if (t[1] > 0) + { + t[1]--; + if (t[1] == 0) { KILLIT(i); } - - - if (s->zvel > 1024 && s->zvel < 1280) + } + if (hittype[s->owner].temp_data[1] == 0) + { + if (t[0] < 64) { - setsprite(i,s->x,s->y,s->z); - sect = s->sectnum; + t[0]++; + l += 3; + } + } + else + if (t[0] > 64) + { + t[0]--; + l -= 3; } - l = getflorzofslope(sect,s->x,s->y); - x = getceilzofslope(sect,s->x,s->y); - if (x == l || sect < 0 || sect >= MAXSECTORS) KILLIT(i); + s->x = sprite[s->owner].x; + s->y = sprite[s->owner].y; + s->z = sprite[s->owner].z; + s->ang += hittype[s->owner].temp_data[0]; - if (s->z < l-(2<<8)) + if (l > 64) l = 64; + else if (l < 1) l = 1; + + s->xrepeat = l; + s->yrepeat = l; + s->shade = (l>>1)-48; + + for (j=t[0];j > 0;j--) + ssp(i,CLIPMASK0); + goto BOLT; + case WATERSPLASH2__STATIC: + + t[0]++; + if (t[0] == 1) + { + if (sector[sect].lotag != 1 && sector[sect].lotag != 2) + KILLIT(i); + /* else + { + l = getflorzofslope(sect,s->x,s->y)-s->z; + if( l > (16<<8) ) KILLIT(i); + } + else */ + if (!issoundplaying(i,ITEM_SPLASH)) + spritesound(ITEM_SPLASH,i); + } + if (t[0] == 3) + { + t[0] = 0; + t[1]++; + } + if (t[1] == 5) + deletesprite(i); + goto BOLT; + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) goto BOLT; // JBF: ideally this should never happen... + case FRAMEEFFECT1__STATIC: + + if (s->owner >= 0) + { + t[0]++; + + if (t[0] > 7) { - if (t[1] < 2) t[1]++; - else if (sector[sect].lotag != 2) - { - t[1] = 0; - if (s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN) - { - if (t[0] > 6) t[0] = 0; - else t[0]++; - } - else - { - if (t[0] > 2) - t[0] = 0; - else t[0]++; - } - } + KILLIT(i); + } + else if (t[0] > 4) + s->cstat |= 512+2; + else if (t[0] > 2) + s->cstat |= 2; + s->xoffset = sprite[s->owner].xoffset; + s->yoffset = sprite[s->owner].yoffset; + } + goto BOLT; + case INNERJAW__STATIC: + // case INNERJAW+1: - if (s->zvel < 6144) - { - if (sector[sect].lotag == 2) - { - if (s->zvel < 1024) - s->zvel += 48; - else s->zvel = 1024; - } - else s->zvel += gc-50; - } + p = findplayer(s,&x); + if (x < 512) + { + ps[p].pals_time = 32; + ps[p].pals[0] = 32; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + sprite[ps[p].i].extra -= 4; + } - s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; - s->y += (s->xvel*sintable[s->ang&2047])>>14; - s->z += s->zvel; + case FIRELASER__STATIC: + if (s->extra != 999) + s->extra = 999; + else KILLIT(i); + break; + case TONGUE__STATIC: + KILLIT(i); + case MONEY__STATIC: + case MAIL__STATIC: + case PAPER__STATIC: + + s->xvel = (TRAND&7)+(sintable[T1&2047]>>9); + T1 += (TRAND&63); + if ((T1&2047) > 512 && (T1&2047) < 1596) + { + if (sector[sect].lotag == 2) + { + if (s->zvel < 64) + s->zvel += (gc>>5)+(TRAND&7); } else + if (s->zvel < 144) + s->zvel += (gc>>5)+(TRAND&7); + } + + ssp(i,CLIPMASK0); + + if ((TRAND&3) == 0) + setsprite(i,s->x,s->y,s->z); + + if (s->sectnum == -1) KILLIT(i); + l = getflorzofslope(s->sectnum,s->x,s->y); + + if (s->z > l) + { + s->z = l; + + insertspriteq(i); + PN ++; + + j = headspritestat[5]; + while (j >= 0) { - if (t[2] == 0) - { - if (s->sectnum == -1) + if (sprite[j].picnum == BLOODPOOL) + if (ldist(s,&sprite[j]) < 348) { - KILLIT(i); + s->pal = 2; + break; } - if ((sector[s->sectnum].floorstat&2)) - { - KILLIT(i); - } - t[2]++; - } - l = getflorzofslope(s->sectnum,s->x,s->y); + j = nextspritestat[j]; + } + } - s->z = l-(2<<8); - s->xvel = 0; + break; - if (s->picnum == JIBS6) + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case ARMJIB1__STATIC: + case LEGJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKETORSO__STATIC: + case DUKEGUN__STATIC: + case DUKELEG__STATIC: + + if (s->xvel > 0) s->xvel--; + else s->xvel = 0; + + if (t[5] < 30*10) + t[5]++; + else + { + KILLIT(i); + } + + + if (s->zvel > 1024 && s->zvel < 1280) + { + setsprite(i,s->x,s->y,s->z); + sect = s->sectnum; + } + + l = getflorzofslope(sect,s->x,s->y); + x = getceilzofslope(sect,s->x,s->y); + if (x == l || sect < 0 || sect >= MAXSECTORS) KILLIT(i); + + if (s->z < l-(2<<8)) + { + if (t[1] < 2) t[1]++; + else if (sector[sect].lotag != 2) + { + t[1] = 0; + if (s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN) { - t[1]++; - if ((t[1]&3) == 0 && t[0] < 7) - t[0]++; - if (t[1] > 20) KILLIT(i); + if (t[0] > 6) t[0] = 0; + else t[0]++; } else { - s->picnum = JIBS6; - t[0] = 0; - t[1] = 0; + if (t[0] > 2) + t[0] = 0; + else t[0]++; } - } - goto BOLT; - case BLOODPOOL__STATIC: - case PUKE__STATIC: - - if (t[0] == 0) + if (s->zvel < 6144) { - t[0] = 1; - if (sector[sect].floorstat&2) + if (sector[sect].lotag == 2) + { + if (s->zvel < 1024) + s->zvel += 48; + else s->zvel = 1024; + } + else s->zvel += gc-50; + } + + s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; + s->y += (s->xvel*sintable[s->ang&2047])>>14; + s->z += s->zvel; + + } + else + { + if (t[2] == 0) + { + if (s->sectnum == -1) + { + KILLIT(i); + } + if ((sector[s->sectnum].floorstat&2)) { KILLIT(i); } - else insertspriteq(i); - } - - makeitfall(i); - - p = findplayer(s,&x); - - s->z = hittype[i].floorz-(FOURSLEIGHT); - - if (t[2] < 32) - { t[2]++; - if (hittype[i].picnum == TIRE) - { - if (s->xrepeat < 64 && s->yrepeat < 64) - { - s->xrepeat += TRAND&3; - s->yrepeat += TRAND&3; - } - } - else - { - if (s->xrepeat < 32 && s->yrepeat < 32) - { - s->xrepeat += TRAND&3; - s->yrepeat += TRAND&3; - } - } } + l = getflorzofslope(s->sectnum,s->x,s->y); - if (x < 844 && s->xrepeat > 6 && s->yrepeat > 6) - { - if (s->pal == 0 && (TRAND&255) < 16 && s->picnum != PUKE) - { - if (ps[p].boot_amount > 0) - ps[p].boot_amount--; - else - { - if (!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,ps[p].i); - sprite[ps[p].i].extra --; - ps[p].pals_time = 32; - ps[p].pals[0] = 16; - ps[p].pals[1] = 0; - ps[p].pals[2] = 0; - } - } + s->z = l-(2<<8); + s->xvel = 0; - if (t[1] == 1) goto BOLT; - t[1] = 1; - - if (hittype[i].picnum == TIRE) - ps[p].footprintcount = 10; - else ps[p].footprintcount = 3; - - ps[p].footprintpal = s->pal; - ps[p].footprintshade = s->shade; - - if (t[2] == 32) - { - s->xrepeat -= 6; - s->yrepeat -= 6; - } - } - else t[1] = 0; - goto BOLT; - - case BURNING__STATIC: - case BURNING2__STATIC: - case FECES__STATIC: - case WATERBUBBLE__STATIC: - case SMALLSMOKE__STATIC: - case EXPLOSION2__STATIC: - case SHRINKEREXPLOSION__STATIC: - case EXPLOSION2BOT__STATIC: - case BLOOD__STATIC: - case LASERSITE__STATIC: - case FORCERIPPLE__STATIC: - case TRANSPORTERSTAR__STATIC: - case TRANSPORTERBEAM__STATIC: - p = findplayer(s,&x); - execute(i,p,x); - goto BOLT; - - case SHELL__STATIC: - case SHOTGUNSHELL__STATIC: - - ssp(i,CLIPMASK0); - - if (sect < 0 || (sector[sect].floorz + 256) < s->z) KILLIT(i); - - if (sector[sect].lotag == 2) + if (s->picnum == JIBS6) { t[1]++; - if (t[1] > 8) - { - t[1] = 0; + if ((t[1]&3) == 0 && t[0] < 7) t[0]++; - t[0] &= 3; - } - if (s->zvel < 128) s->zvel += (gc/13); // 8 - else s->zvel -= 64; - if (s->xvel > 0) - s->xvel -= 4; - else s->xvel = 0; + if (t[1] > 20) KILLIT(i); } else { - t[1]++; - if (t[1] > 3) + s->picnum = JIBS6; + t[0] = 0; + t[1] = 0; + } + + } + goto BOLT; + + case BLOODPOOL__STATIC: + case PUKE__STATIC: + + if (t[0] == 0) + { + t[0] = 1; + if (sector[sect].floorstat&2) + { + KILLIT(i); + } + else insertspriteq(i); + } + + makeitfall(i); + + p = findplayer(s,&x); + + s->z = hittype[i].floorz-(FOURSLEIGHT); + + if (t[2] < 32) + { + t[2]++; + if (hittype[i].picnum == TIRE) + { + if (s->xrepeat < 64 && s->yrepeat < 64) { - t[1] = 0; - t[0]++; - t[0] &= 3; + s->xrepeat += TRAND&3; + s->yrepeat += TRAND&3; } - if (s->zvel < 512) s->zvel += (gc/3); // 52; - if (s->xvel > 0) - s->xvel --; - // else KILLIT(i); } - - goto BOLT; - - case GLASSPIECES__STATIC: - // case GLASSPIECES+1: - // case GLASSPIECES+2: - - makeitfall(i); - - if (s->zvel > 4096) s->zvel = 4096; - if (sect < 0) KILLIT(i); - - if (s->z == hittype[i].floorz-(FOURSLEIGHT) && t[0] < 3) + else { - s->zvel = -((3-t[0])<<8)-(TRAND&511); - if (sector[sect].lotag == 2) - s->zvel >>= 1; - s->xrepeat >>= 1; - s->yrepeat >>= 1; - if (rnd(96)) - setsprite(i,s->x,s->y,s->z); - t[0]++;//Number of bounces + if (s->xrepeat < 32 && s->yrepeat < 32) + { + s->xrepeat += TRAND&3; + s->yrepeat += TRAND&3; + } } - else if (t[0] == 3) KILLIT(i); + } + if (x < 844 && s->xrepeat > 6 && s->yrepeat > 6) + { + if (s->pal == 0 && (TRAND&255) < 16 && s->picnum != PUKE) + { + if (ps[p].boot_amount > 0) + ps[p].boot_amount--; + else + { + if (!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + sprite[ps[p].i].extra --; + ps[p].pals_time = 32; + ps[p].pals[0] = 16; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + } + + if (t[1] == 1) goto BOLT; + t[1] = 1; + + if (hittype[i].picnum == TIRE) + ps[p].footprintcount = 10; + else ps[p].footprintcount = 3; + + ps[p].footprintpal = s->pal; + ps[p].footprintshade = s->shade; + + if (t[2] == 32) + { + s->xrepeat -= 6; + s->yrepeat -= 6; + } + } + else t[1] = 0; + goto BOLT; + + case BURNING__STATIC: + case BURNING2__STATIC: + case FECES__STATIC: + case WATERBUBBLE__STATIC: + case SMALLSMOKE__STATIC: + case EXPLOSION2__STATIC: + case SHRINKEREXPLOSION__STATIC: + case EXPLOSION2BOT__STATIC: + case BLOOD__STATIC: + case LASERSITE__STATIC: + case FORCERIPPLE__STATIC: + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + p = findplayer(s,&x); + execute(i,p,x); + goto BOLT; + + case SHELL__STATIC: + case SHOTGUNSHELL__STATIC: + + ssp(i,CLIPMASK0); + + if (sect < 0 || (sector[sect].floorz + 256) < s->z) KILLIT(i); + + if (sector[sect].lotag == 2) + { + t[1]++; + if (t[1] > 8) + { + t[1] = 0; + t[0]++; + t[0] &= 3; + } + if (s->zvel < 128) s->zvel += (gc/13); // 8 + else s->zvel -= 64; if (s->xvel > 0) - { - s->xvel -= 2; - s->cstat = ((s->xvel&3)<<2); - } + s->xvel -= 4; else s->xvel = 0; + } + else + { + t[1]++; + if (t[1] > 3) + { + t[1] = 0; + t[0]++; + t[0] &= 3; + } + if (s->zvel < 512) s->zvel += (gc/3); // 52; + if (s->xvel > 0) + s->xvel --; + // else KILLIT(i); + } - ssp(i,CLIPMASK0); + goto BOLT; - goto BOLT; + case GLASSPIECES__STATIC: + // case GLASSPIECES+1: + // case GLASSPIECES+2: + + makeitfall(i); + + if (s->zvel > 4096) s->zvel = 4096; + if (sect < 0) KILLIT(i); + + if (s->z == hittype[i].floorz-(FOURSLEIGHT) && t[0] < 3) + { + s->zvel = -((3-t[0])<<8)-(TRAND&511); + if (sector[sect].lotag == 2) + s->zvel >>= 1; + s->xrepeat >>= 1; + s->yrepeat >>= 1; + if (rnd(96)) + setsprite(i,s->x,s->y,s->z); + t[0]++;//Number of bounces + } + else if (t[0] == 3) KILLIT(i); + + if (s->xvel > 0) + { + s->xvel -= 2; + s->cstat = ((s->xvel&3)<<2); + } + else s->xvel = 0; + + ssp(i,CLIPMASK0); + + goto BOLT; } IFWITHIN(SCRAP6,SCRAP5+3) @@ -5439,725 +5439,1003 @@ void moveeffectors(void) //STATNUM 3 switch (st) { - case 0: + case 0: + { + long zchange = 0; + + zchange = 0; + + j = s->owner; + + if (sprite[j].lotag == (short) 65535) + KILLIT(i); + + q = sc->extra>>3; + l = 0; + + if (sc->lotag == 30) { - long zchange = 0; + q >>= 2; - zchange = 0; - - j = s->owner; - - if (sprite[j].lotag == (short) 65535) - KILLIT(i); - - q = sc->extra>>3; - l = 0; - - if (sc->lotag == 30) + if (sprite[i].extra == 1) { - q >>= 2; - - if (sprite[i].extra == 1) + if (hittype[i].tempang < 256) { - if (hittype[i].tempang < 256) - { - hittype[i].tempang += 4; - if (hittype[i].tempang >= 256) - callsound(s->sectnum,i); - if (s->clipdist) l = 1; - else l = -1; - } - else hittype[i].tempang = 256; - - if (sc->floorz > s->z) //z's are touching - { - sc->floorz -= 512; - zchange = -512; - if (sc->floorz < s->z) - sc->floorz = s->z; - } - - else if (sc->floorz < s->z) //z's are touching - { - sc->floorz += 512; - zchange = 512; - if (sc->floorz > s->z) - sc->floorz = s->z; - } + hittype[i].tempang += 4; + if (hittype[i].tempang >= 256) + callsound(s->sectnum,i); + if (s->clipdist) l = 1; + else l = -1; } - else if (sprite[i].extra == 3) + else hittype[i].tempang = 256; + + if (sc->floorz > s->z) //z's are touching { - if (hittype[i].tempang > 0) - { - hittype[i].tempang -= 4; - if (hittype[i].tempang <= 0) - callsound(s->sectnum,i); - if (s->clipdist) l = -1; - else l = 1; - } - else hittype[i].tempang = 0; - - if (sc->floorz > T4) //z's are touching - { - sc->floorz -= 512; - zchange = -512; - if (sc->floorz < T4) - sc->floorz = T4; - } - - else if (sc->floorz < T4) //z's are touching - { - sc->floorz += 512; - zchange = 512; - if (sc->floorz > T4) - sc->floorz = T4; - } + sc->floorz -= 512; + zchange = -512; + if (sc->floorz < s->z) + sc->floorz = s->z; } - s->ang += (l*q); - t[2] += (l*q); + else if (sc->floorz < s->z) //z's are touching + { + sc->floorz += 512; + zchange = 512; + if (sc->floorz > s->z) + sc->floorz = s->z; + } } - else + else if (sprite[i].extra == 3) { - if (hittype[j].temp_data[0] == 0) break; - if (hittype[j].temp_data[0] == 2) KILLIT(i); + if (hittype[i].tempang > 0) + { + hittype[i].tempang -= 4; + if (hittype[i].tempang <= 0) + callsound(s->sectnum,i); + if (s->clipdist) l = -1; + else l = 1; + } + else hittype[i].tempang = 0; - if (sprite[j].ang > 1024) - l = -1; - else l = 1; - if (t[3] == 0) - t[3] = ldist(s,&sprite[j]); - s->xvel = t[3]; - s->x = sprite[j].x; - s->y = sprite[j].y; - s->ang += (l*q); - t[2] += (l*q); + if (sc->floorz > T4) //z's are touching + { + sc->floorz -= 512; + zchange = -512; + if (sc->floorz < T4) + sc->floorz = T4; + } + + else if (sc->floorz < T4) //z's are touching + { + sc->floorz += 512; + zchange = 512; + if (sc->floorz > T4) + sc->floorz = T4; + } } - if (l && (sc->floorstat&64)) - { - for (p=connecthead;p>=0;p=connectpoint2[p]) - { - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1) - { + s->ang += (l*q); + t[2] += (l*q); + } + else + { + if (hittype[j].temp_data[0] == 0) break; + if (hittype[j].temp_data[0] == 2) KILLIT(i); - ps[p].ang += (l*q); - ps[p].ang &= 2047; - - ps[p].posz += zchange; - - rotatepoint(sprite[j].x,sprite[j].y, - ps[p].posx,ps[p].posy,(q*l), - &m,&x); - - ps[p].bobposx += m-ps[p].posx; - ps[p].bobposy += x-ps[p].posy; - - ps[p].posx = m; - ps[p].posy = x; - - if (sprite[ps[p].i].extra <= 0) - { - sprite[ps[p].i].x = m; - sprite[ps[p].i].y = x; - } - } - } - - p = headspritesect[s->sectnum]; - while (p >= 0) - { - if (sprite[p].statnum != 3 && sprite[p].statnum != 4) - if (sprite[p].picnum != LASERLINE) - { - if (sprite[p].picnum == APLAYER && sprite[p].owner >= 0) - { - p = nextspritesect[p]; - continue; - } - - sprite[p].ang += (l*q); - sprite[p].ang &= 2047; - - sprite[p].z += zchange; - - rotatepoint(sprite[j].x,sprite[j].y, - sprite[p].x,sprite[p].y,(q*l), - &sprite[p].x,&sprite[p].y); - - } - p = nextspritesect[p]; - } - - } - - ms(i); + if (sprite[j].ang > 1024) + l = -1; + else l = 1; + if (t[3] == 0) + t[3] = ldist(s,&sprite[j]); + s->xvel = t[3]; + s->x = sprite[j].x; + s->y = sprite[j].y; + s->ang += (l*q); + t[2] += (l*q); } - break; - case 1: //Nothing for now used as the pivot - if (s->owner == -1) //Init + if (l && (sc->floorstat&64)) + { + for (p=connecthead;p>=0;p=connectpoint2[p]) { - s->owner = i; - - j = headspritestat[3]; - while (j >= 0) + if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1) { - if (sprite[j].lotag == 19 && sprite[j].hitag == sh) + + ps[p].ang += (l*q); + ps[p].ang &= 2047; + + ps[p].posz += zchange; + + rotatepoint(sprite[j].x,sprite[j].y, + ps[p].posx,ps[p].posy,(q*l), + &m,&x); + + ps[p].bobposx += m-ps[p].posx; + ps[p].bobposy += x-ps[p].posy; + + ps[p].posx = m; + ps[p].posy = x; + + if (sprite[ps[p].i].extra <= 0) { - t[0] = 0; - break; + sprite[ps[p].i].x = m; + sprite[ps[p].i].y = x; } - j = nextspritestat[j]; } } - break; - case 6: - k = sc->extra; - - if (t[4] > 0) + p = headspritesect[s->sectnum]; + while (p >= 0) { - t[4]--; - if (t[4] >= (k-(k>>3))) - s->xvel -= (k>>5); - if (t[4] > ((k>>1)-1) && t[4] < (k-(k>>3))) - s->xvel = 0; - if (t[4] < (k>>1)) - s->xvel += (k>>5); - if (t[4] < ((k>>1)-(k>>3))) - { - t[4] = 0; - s->xvel = k; - } + if (sprite[p].statnum != 3 && sprite[p].statnum != 4) + if (sprite[p].picnum != LASERLINE) + { + if (sprite[p].picnum == APLAYER && sprite[p].owner >= 0) + { + p = nextspritesect[p]; + continue; + } + + sprite[p].ang += (l*q); + sprite[p].ang &= 2047; + + sprite[p].z += zchange; + + rotatepoint(sprite[j].x,sprite[j].y, + sprite[p].x,sprite[p].y,(q*l), + &sprite[p].x,&sprite[p].y); + + } + p = nextspritesect[p]; } - else s->xvel = k; + + } + + ms(i); + } + + break; + case 1: //Nothing for now used as the pivot + if (s->owner == -1) //Init + { + s->owner = i; j = headspritestat[3]; while (j >= 0) { - if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) + if (sprite[j].lotag == 19 && sprite[j].hitag == sh) { - sprite[j].xvel = s->xvel; - // if( t[4] == 1 ) - { - if (hittype[j].temp_data[5] == 0) - hittype[j].temp_data[5] = dist(&sprite[j],s); - x = ksgn(dist(&sprite[j],s)-hittype[j].temp_data[5]); - if (sprite[j].extra) - x = -x; - s->xvel += x; - } - hittype[j].temp_data[4] = t[4]; + t[0] = 0; + break; } j = nextspritestat[j]; } - x = 0; + } + + break; + case 6: + k = sc->extra; + + if (t[4] > 0) + { + t[4]--; + if (t[4] >= (k-(k>>3))) + s->xvel -= (k>>5); + if (t[4] > ((k>>1)-1) && t[4] < (k-(k>>3))) + s->xvel = 0; + if (t[4] < (k>>1)) + s->xvel += (k>>5); + if (t[4] < ((k>>1)-(k>>3))) + { + t[4] = 0; + s->xvel = k; + } + } + else s->xvel = k; + + j = headspritestat[3]; + while (j >= 0) + { + if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) + { + sprite[j].xvel = s->xvel; + // if( t[4] == 1 ) + { + if (hittype[j].temp_data[5] == 0) + hittype[j].temp_data[5] = dist(&sprite[j],s); + x = ksgn(dist(&sprite[j],s)-hittype[j].temp_data[5]); + if (sprite[j].extra) + x = -x; + s->xvel += x; + } + hittype[j].temp_data[4] = t[4]; + } + j = nextspritestat[j]; + } + x = 0; - case 14: + case 14: + if (s->owner==-1) + s->owner = LocateTheLocator((short)t[3],(short)t[0]); + + if (s->owner == -1) + { + Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %ld.\n",t[3]); + gameexit(tempbuf); + } + + j = ldist(&sprite[s->owner],s); + + if (j < 1024L) + { + if (st==6) + if (sprite[s->owner].hitag&1) + t[4]=sc->extra; //Slow it down + t[3]++; + s->owner = LocateTheLocator(t[3],t[0]); if (s->owner==-1) - s->owner = LocateTheLocator((short)t[3],(short)t[0]); - - if (s->owner == -1) { - Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %ld.\n",t[3]); - gameexit(tempbuf); + t[3]=0; + s->owner = LocateTheLocator(0,t[0]); } + } - j = ldist(&sprite[s->owner],s); + if (s->xvel) + { + x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + q = getincangle(s->ang,x)>>3; - if (j < 1024L) + t[2] += q; + s->ang += q; + + if (s->xvel == sc->extra) { - if (st==6) - if (sprite[s->owner].hitag&1) - t[4]=sc->extra; //Slow it down - t[3]++; - s->owner = LocateTheLocator(t[3],t[0]); - if (s->owner==-1) + if ((sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) { - t[3]=0; - s->owner = LocateTheLocator(0,t[0]); + if (!issoundplaying(i,hittype[i].lastvx)) + spritesound(hittype[i].lastvx,i); } - } - - if (s->xvel) - { - x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); - q = getincangle(s->ang,x)>>3; - - t[2] += q; - s->ang += q; - - if (s->xvel == sc->extra) + else if (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat&1) && rnd(8)) { - if ((sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) + p = findplayer(s,&x); + if (x < 20480) { - if (!issoundplaying(i,hittype[i].lastvx)) - spritesound(hittype[i].lastvx,i); - } - else if (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat&1) && rnd(8)) - { - p = findplayer(s,&x); - if (x < 20480) - { - j = s->ang; - s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); - shoot(i,RPG); - s->ang = j; - } - } - } - - if (s->xvel <= 64 && (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) - stopspritesound(hittype[i].lastvx,i); - - if ((sc->floorz-sc->ceilingz) < (108<<8)) - { - if (ud.clipping == 0 && s->xvel >= 192) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[ps[p].i].extra > 0) - { - k = ps[p].cursectnum; - updatesector(ps[p].posx,ps[p].posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) - { - ps[p].posx = s->x; - ps[p].posy = s->y; - ps[p].cursectnum = s->sectnum; - - setsprite(ps[p].i,s->x,s->y,s->z); - quickkill(&ps[p]); - } - } - } - - m = (s->xvel*sintable[(s->ang+512)&2047])>>14; - x = (s->xvel*sintable[s->ang&2047])>>14; - - for (p = connecthead;p >= 0;p=connectpoint2[p]) - if (sector[ps[p].cursectnum].lotag != 2) - { - if (po[p].os == s->sectnum) - { - po[p].ox += m; - po[p].oy += x; - } - - if (s->sectnum == sprite[ps[p].i].sectnum) - { - rotatepoint(s->x,s->y,ps[p].posx,ps[p].posy,q,&ps[p].posx,&ps[p].posy); - - ps[p].posx += m; - ps[p].posy += x; - - ps[p].bobposx += m; - ps[p].bobposy += x; - - ps[p].ang += q; - - if (numplayers > 1) - { - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; - } - if (sprite[ps[p].i].extra <= 0) - { - sprite[ps[p].i].x = ps[p].posx; - sprite[ps[p].i].y = ps[p].posy; - } - } - } - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].statnum != 10 && sector[sprite[j].sectnum].lotag != 2 && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) - { - rotatepoint(s->x,s->y, - sprite[j].x,sprite[j].y,q, - &sprite[j].x,&sprite[j].y); - - sprite[j].x+= m; - sprite[j].y+= x; - - sprite[j].ang+=q; - - if (numplayers > 1) - { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - } - } - j = nextspritesect[j]; - } - - ms(i); - setsprite(i,s->x,s->y,s->z); - - if ((sc->floorz-sc->ceilingz) < (108<<8)) - { - if (ud.clipping == 0 && s->xvel >= 192) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[ps[p].i].extra > 0) - { - k = ps[p].cursectnum; - updatesector(ps[p].posx,ps[p].posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) - { - ps[p].oposx = ps[p].posx = s->x; - ps[p].oposy = ps[p].posy = s->y; - ps[p].cursectnum = s->sectnum; - - setsprite(ps[p].i,s->x,s->y,s->z); - quickkill(&ps[p]); - } - } - - j = headspritesect[sprite[OW].sectnum]; - while (j >= 0) - { - l = nextspritesect[j]; - if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) - { - k = sprite[j].sectnum; - updatesector(sprite[j].x,sprite[j].y,&k); - if (sprite[j].extra >= 0 && k == s->sectnum) - { - gutsdir(&sprite[j],JIBS6,72,myconnectindex); - spritesound(SQUISHED,i); - deletesprite(j); - } - } - j = l; + j = s->ang; + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + shoot(i,RPG); + s->ang = j; } } } - break; + if (s->xvel <= 64 && (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) + stopspritesound(hittype[i].lastvx,i); - case 30: - if (s->owner == -1) + if ((sc->floorz-sc->ceilingz) < (108<<8)) { - t[3] = !t[3]; - s->owner = LocateTheLocator(t[3],t[0]); - } - else - { - - if (t[4] == 1) // Starting to go - { - if (ldist(&sprite[s->owner],s) < (2048-128)) - t[4] = 2; - else - { - if (s->xvel == 0) - operateactivators(s->hitag+(!t[3]),-1); - if (s->xvel < 256) - s->xvel += 16; - } - } - if (t[4] == 2) - { - l = FindDistance2D(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); - - if (l <= 128) - s->xvel = 0; - - if (s->xvel > 0) - s->xvel -= 16; - else - { - s->xvel = 0; - operateactivators(s->hitag+(short)t[3],-1); - s->owner = -1; - s->ang += 1024; - t[4] = 0; - operateforcefields(i,s->hitag); - - j = headspritesect[s->sectnum]; - while (j >= 0) + if (ud.clipping == 0 && s->xvel >= 192) + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (sprite[ps[p].i].extra > 0) { - if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - } - j = nextspritesect[j]; - } + ps[p].posx = s->x; + ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; - } - } + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } } - if (s->xvel) - { - l = (s->xvel*sintable[(s->ang+512)&2047])>>14; - x = (s->xvel*sintable[s->ang&2047])>>14; + m = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; - if ((sc->floorz-sc->ceilingz) < (108<<8)) - if (ud.clipping == 0) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[ps[p].i].extra > 0) - { - k = ps[p].cursectnum; - updatesector(ps[p].posx,ps[p].posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) - { - ps[p].posx = s->x; - ps[p].posy = s->y; - ps[p].cursectnum = s->sectnum; - - setsprite(ps[p].i,s->x,s->y,s->z); - quickkill(&ps[p]); - } - } - - for (p = connecthead;p >= 0;p = connectpoint2[p]) + for (p = connecthead;p >= 0;p=connectpoint2[p]) + if (sector[ps[p].cursectnum].lotag != 2) { - if (sprite[ps[p].i].sectnum == s->sectnum) + if (po[p].os == s->sectnum) { - ps[p].posx += l; + po[p].ox += m; + po[p].oy += x; + } + + if (s->sectnum == sprite[ps[p].i].sectnum) + { + rotatepoint(s->x,s->y,ps[p].posx,ps[p].posy,q,&ps[p].posx,&ps[p].posy); + + ps[p].posx += m; ps[p].posy += x; + ps[p].bobposx += m; + ps[p].bobposy += x; + + ps[p].ang += q; + if (numplayers > 1) { ps[p].oposx = ps[p].posx; ps[p].oposy = ps[p].posy; } - - ps[p].bobposx += l; - ps[p].bobposy += x; - } - - if (po[p].os == s->sectnum) - { - po[p].ox += l; - po[p].oy += x; + if (sprite[ps[p].i].extra <= 0) + { + sprite[ps[p].i].x = ps[p].posx; + sprite[ps[p].i].y = ps[p].posy; + } } } + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].statnum != 10 && sector[sprite[j].sectnum].lotag != 2 && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + { + rotatepoint(s->x,s->y, + sprite[j].x,sprite[j].y,q, + &sprite[j].x,&sprite[j].y); - j = headspritesect[s->sectnum]; + sprite[j].x+= m; + sprite[j].y+= x; + + sprite[j].ang+=q; + + if (numplayers > 1) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + } + j = nextspritesect[j]; + } + + ms(i); + setsprite(i,s->x,s->y,s->z); + + if ((sc->floorz-sc->ceilingz) < (108<<8)) + { + if (ud.clipping == 0 && s->xvel >= 192) + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) + { + ps[p].oposx = ps[p].posx = s->x; + ps[p].oposy = ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + j = headspritesect[sprite[OW].sectnum]; while (j >= 0) { - if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + l = nextspritesect[j]; + if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { - if (numplayers < 2) + k = sprite[j].sectnum; + updatesector(sprite[j].x,sprite[j].y,&k); + if (sprite[j].extra >= 0 && k == s->sectnum) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - } - - sprite[j].x += l; - sprite[j].y += x; - - if (numplayers > 1) - { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + gutsdir(&sprite[j],JIBS6,72,myconnectindex); + spritesound(SQUISHED,i); + deletesprite(j); } } - j = nextspritesect[j]; - } - - ms(i); - setsprite(i,s->x,s->y,s->z); - - if ((sc->floorz-sc->ceilingz) < (108<<8)) - { - if (ud.clipping == 0) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[ps[p].i].extra > 0) - { - k = ps[p].cursectnum; - updatesector(ps[p].posx,ps[p].posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) - { - ps[p].posx = s->x; - ps[p].posy = s->y; - - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; - - ps[p].cursectnum = s->sectnum; - - setsprite(ps[p].i,s->x,s->y,s->z); - quickkill(&ps[p]); - } - } - - j = headspritesect[sprite[OW].sectnum]; - while (j >= 0) - { - l = nextspritesect[j]; - if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) - { - // if(sprite[j].sectnum != s->sectnum) - { - k = sprite[j].sectnum; - updatesector(sprite[j].x,sprite[j].y,&k); - if (sprite[j].extra >= 0 && k == s->sectnum) - { - gutsdir(&sprite[j],JIBS6,24,myconnectindex); - spritesound(SQUISHED,j); - deletesprite(j); - } - } - - } - j = l; - } + j = l; } } + } - break; + break; + case 30: + if (s->owner == -1) + { + t[3] = !t[3]; + s->owner = LocateTheLocator(t[3],t[0]); + } + else + { - case 2://Quakes - if (t[4] > 0 && t[0] == 0) + if (t[4] == 1) // Starting to go { - if (t[4] < sh) - t[4]++; - else t[0] = 1; - } - - if (t[0] > 0) - { - t[0]++; - - s->xvel = 3; - - if (t[0] > 96) - { - t[0] = -1; //Stop the quake - t[4] = -1; - KILLIT(i); - } + if (ldist(&sprite[s->owner],s) < (2048-128)) + t[4] = 2; else { - if ((t[0]&31) == 8) + if (s->xvel == 0) + operateactivators(s->hitag+(!t[3]),-1); + if (s->xvel < 256) + s->xvel += 16; + } + } + if (t[4] == 2) + { + l = FindDistance2D(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + + if (l <= 128) + s->xvel = 0; + + if (s->xvel > 0) + s->xvel -= 16; + else + { + s->xvel = 0; + operateactivators(s->hitag+(short)t[3],-1); + s->owner = -1; + s->ang += 1024; + t[4] = 0; + operateforcefields(i,s->hitag); + + j = headspritesect[s->sectnum]; + while (j >= 0) { - earthquaketime = 48; - spritesound(EARTHQUAKE,ps[screenpeek].i); + if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + j = nextspritesect[j]; } - if (klabs(sc->floorheinum-t[5]) < 8) - sc->floorheinum = t[5]; - else sc->floorheinum += (ksgn(t[5]-sc->floorheinum)<<4); + } + } + } + + if (s->xvel) + { + l = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + if ((sc->floorz-sc->ceilingz) < (108<<8)) + if (ud.clipping == 0) + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) + { + ps[p].posx = s->x; + ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + for (p = connecthead;p >= 0;p = connectpoint2[p]) + { + if (sprite[ps[p].i].sectnum == s->sectnum) + { + ps[p].posx += l; + ps[p].posy += x; + + if (numplayers > 1) + { + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + } + + ps[p].bobposx += l; + ps[p].bobposy += x; } - m = (s->xvel*sintable[(s->ang+512)&2047])>>14; - x = (s->xvel*sintable[s->ang&2047])>>14; + if (po[p].os == s->sectnum) + { + po[p].ox += l; + po[p].oy += x; + } + } - - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + { + if (numplayers < 2) { - ps[p].posx += m; - ps[p].posy += x; - - ps[p].bobposx += m; - ps[p].bobposy += x; + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; } - j = headspritesect[s->sectnum]; + sprite[j].x += l; + sprite[j].y += x; + + if (numplayers > 1) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + } + j = nextspritesect[j]; + } + + ms(i); + setsprite(i,s->x,s->y,s->z); + + if ((sc->floorz-sc->ceilingz) < (108<<8)) + { + if (ud.clipping == 0) + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) + { + ps[p].posx = s->x; + ps[p].posy = s->y; + + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + j = headspritesect[sprite[OW].sectnum]; while (j >= 0) { - nextj = nextspritesect[j]; - - if (sprite[j].picnum != SECTOREFFECTOR) + l = nextspritesect[j]; + if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { - sprite[j].x+=m; - sprite[j].y+=x; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + // if(sprite[j].sectnum != s->sectnum) + { + k = sprite[j].sectnum; + updatesector(sprite[j].x,sprite[j].y,&k); + if (sprite[j].extra >= 0 && k == s->sectnum) + { + gutsdir(&sprite[j],JIBS6,24,myconnectindex); + spritesound(SQUISHED,j); + deletesprite(j); + } + } + } - j = nextj; + j = l; } + } + } + + break; + + + case 2://Quakes + if (t[4] > 0 && t[0] == 0) + { + if (t[4] < sh) + t[4]++; + else t[0] = 1; + } + + if (t[0] > 0) + { + t[0]++; + + s->xvel = 3; + + if (t[0] > 96) + { + t[0] = -1; //Stop the quake + t[4] = -1; + KILLIT(i); + } + else + { + if ((t[0]&31) == 8) + { + earthquaketime = 48; + spritesound(EARTHQUAKE,ps[screenpeek].i); + } + + if (klabs(sc->floorheinum-t[5]) < 8) + sc->floorheinum = t[5]; + else sc->floorheinum += (ksgn(t[5]-sc->floorheinum)<<4); + } + + m = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) + { + ps[p].posx += m; + ps[p].posy += x; + + ps[p].bobposx += m; + ps[p].bobposy += x; + } + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + nextj = nextspritesect[j]; + + if (sprite[j].picnum != SECTOREFFECTOR) + { + sprite[j].x+=m; + sprite[j].y+=x; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + } + j = nextj; + } + ms(i); + setsprite(i,s->x,s->y,s->z); + } + break; + + //Flashing sector lights after reactor EXPLOSION2 + + case 3: + + if (t[4] == 0) break; + p = findplayer(s,&x); + + // if(t[5] > 0) { t[5]--; break; } + + if ((global_random/(sh+1)&31) < 4 && !t[2]) + { + // t[5] = 4+(global_random&7); + sc->ceilingpal = s->owner>>8; + sc->floorpal = s->owner&0xff; + t[0] = s->shade + (global_random&15); + } + else + { + // t[5] = 4+(global_random&3); + sc->ceilingpal = s->pal; + sc->floorpal = s->pal; + t[0] = t[3]; + } + + sc->ceilingshade = t[0]; + sc->floorshade = t[0]; + + wal = &wall[sc->wallptr]; + + for (x=sc->wallnum;x > 0;x--,wal++) + { + if (wal->hitag != 1) + { + wal->shade = t[0]; + if ((wal->cstat&2) && wal->nextwall >= 0) + { + wall[wal->nextwall].shade = wal->shade; + } + } + } + + break; + + case 4: + + if ((global_random/(sh+1)&31) < 4) + { + t[1] = s->shade + (global_random&15);//Got really bright + t[0] = s->shade + (global_random&15); + sc->ceilingpal = s->owner>>8; + sc->floorpal = s->owner&0xff; + j = 1; + } + else + { + t[1] = t[2]; + t[0] = t[3]; + + sc->ceilingpal = s->pal; + sc->floorpal = s->pal; + + j = 0; + } + + sc->floorshade = t[1]; + sc->ceilingshade = t[1]; + + wal = &wall[sc->wallptr]; + + for (x=sc->wallnum;x > 0; x--,wal++) + { + if (j) wal->pal = (s->owner&0xff); + else wal->pal = s->pal; + + if (wal->hitag != 1) + { + wal->shade = t[0]; + if ((wal->cstat&2) && wal->nextwall >= 0) + wall[wal->nextwall].shade = wal->shade; + } + } + + j = headspritesect[SECT]; + while (j >= 0) + { + if (sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + { + if (sc->ceilingstat&1) + sprite[j].shade = sc->ceilingshade; + else sprite[j].shade = sc->floorshade; + } + + j = nextspritesect[j]; + } + + if (t[4]) KILLIT(i); + + break; + + //BOSS + case 5: + p = findplayer(s,&x); + if (x < 8192) + { + j = s->ang; + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + shoot(i,FIRELASER); + s->ang = j; + } + + if (s->owner==-1) //Start search + { + t[4]=0; + l = 0x7fffffff; + while (1) //Find the shortest dist + { + s->owner = LocateTheLocator((short)t[4],-1); //t[0] hold sectnum + + if (s->owner==-1) break; + + m = ldist(&sprite[ps[p].i],&sprite[s->owner]); + + if (l > m) + { + q = s->owner; + l = m; + } + + t[4]++; + } + + s->owner = q; + s->zvel = ksgn(sprite[q].z-s->z)<<4; + } + + if (ldist(&sprite[s->owner],s) < 1024) + { + short ta; + ta = s->ang; + s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); + s->ang = ta; + s->owner = -1; + goto BOLT; + + } + else s->xvel=256; + + x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + q = getincangle(s->ang,x)>>3; + s->ang += q; + + if (rnd(32)) + { + t[2]+=q; + sc->ceilingshade = 127; + } + else + { + t[2] += + getincangle(t[2]+512,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; + sc->ceilingshade = 0; + } + IFHIT + { + t[3]++; + if (t[3] == 5) + { + s->zvel += 1024; + FTA(7,&ps[myconnectindex]); + } + } + + s->z += s->zvel; + sc->ceilingz += s->zvel; + sector[t[0]].ceilingz += s->zvel; + ms(i); + setsprite(i,s->x,s->y,s->z); + break; + + + case 8: + case 9: + + // work only if its moving + + j = -1; + + if (hittype[i].temp_data[4]) + { + hittype[i].temp_data[4]++; + if (hittype[i].temp_data[4] > 8) KILLIT(i); + j = 1; + } + else j = getanimationgoal(&sc->ceilingz); + + if (j >= 0) + { + short sn; + + if ((sc->lotag&0x8000) || hittype[i].temp_data[4]) + x = -t[3]; + else + x = t[3]; + + if (st == 9) x = -x; + + j = headspritestat[3]; + while (j >= 0) + { + if (((sprite[j].lotag) == st) && (sprite[j].hitag) == sh) + { + sn = sprite[j].sectnum; + m = sprite[j].shade; + + wal = &wall[sector[sn].wallptr]; + + for (l=sector[sn].wallnum;l>0;l--,wal++) + { + if (wal->hitag != 1) + { + wal->shade+=x; + + if (wal->shade < m) + wal->shade = m; + else if (wal->shade > hittype[j].temp_data[2]) + wal->shade = hittype[j].temp_data[2]; + + if (wal->nextwall >= 0) + if (wall[wal->nextwall].hitag != 1) + wall[wal->nextwall].shade = wal->shade; + } + } + + sector[sn].floorshade += x; + sector[sn].ceilingshade += x; + + if (sector[sn].floorshade < m) + sector[sn].floorshade = m; + else if (sector[sn].floorshade > hittype[j].temp_data[0]) + sector[sn].floorshade = hittype[j].temp_data[0]; + + if (sector[sn].ceilingshade < m) + sector[sn].ceilingshade = m; + else if (sector[sn].ceilingshade > hittype[j].temp_data[1]) + sector[sn].ceilingshade = hittype[j].temp_data[1]; + + } + j = nextspritestat[j]; + } + } + break; + case 10: + + if ((sc->lotag&0xff) == 27 || (sc->floorz > sc->ceilingz && (sc->lotag&0xff) != 23) || sc->lotag == (short) 32791) + { + j = 1; + + if ((sc->lotag&0xff) != 27) + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0) + if (s->sectnum == sprite[ps[p].i].sectnum) + j = 0; + + if (j == 1) + { + if (t[0] > sh) + switch (sector[s->sectnum].lotag) + { + case 20: + case 21: + case 22: + case 26: + if (getanimationgoal(§or[s->sectnum].ceilingz) >= 0) + break; + default: + activatebysector(s->sectnum,i); + t[0] = 0; + break; + } + else t[0]++; + } + } + else t[0]=0; + break; + case 11: //Swingdoor + + if (t[5] > 0) + { + t[5]--; + break; + } + + if (t[4]) + { + short startwall,endwall; + + startwall = sc->wallptr; + endwall = startwall+sc->wallnum; + + for (j=startwall;j= 0) + { + if (sprite[k].extra > 0 && badguy(&sprite[k]) && clipinsidebox(sprite[k].x,sprite[k].y,j,256L) == 1) + goto BOLT; + k = nextspritestat[k]; + } + + k = headspritestat[10]; + while (k >= 0) + { + if (sprite[k].owner >= 0 && clipinsidebox(sprite[k].x,sprite[k].y,j,144L) == 1) + { + t[5] = 8; // Delay + k = (SP>>3)*t[3]; + t[2]-=k; + t[4]-=k; + ms(i); + setsprite(i,s->x,s->y,s->z); + goto BOLT; + } + k = nextspritestat[k]; + } + } + + k = (SP>>3)*t[3]; + t[2]+=k; + t[4]+=k; + ms(i); + setsprite(i,s->x,s->y,s->z); + + if (t[4] <= -511 || t[4] >= 512) + { + t[4] = 0; + t[2] &= 0xffffff00; ms(i); setsprite(i,s->x,s->y,s->z); + break; } - break; - - //Flashing sector lights after reactor EXPLOSION2 - - case 3: - - if (t[4] == 0) break; - p = findplayer(s,&x); - - // if(t[5] > 0) { t[5]--; break; } - - if ((global_random/(sh+1)&31) < 4 && !t[2]) - { - // t[5] = 4+(global_random&7); - sc->ceilingpal = s->owner>>8; - sc->floorpal = s->owner&0xff; - t[0] = s->shade + (global_random&15); - } - else - { - // t[5] = 4+(global_random&3); - sc->ceilingpal = s->pal; - sc->floorpal = s->pal; - t[0] = t[3]; - } - - sc->ceilingshade = t[0]; - sc->floorshade = t[0]; + } + break; + case 12: + if (t[0] == 3 || t[3] == 1) //Lights going off + { + sc->floorpal = 0; + sc->ceilingpal = 0; wal = &wall[sc->wallptr]; - - for (x=sc->wallnum;x > 0;x--,wal++) - { + for (j = sc->wallnum;j > 0; j--, wal++) if (wal->hitag != 1) { - wal->shade = t[0]; - if ((wal->cstat&2) && wal->nextwall >= 0) - { - wall[wal->nextwall].shade = wal->shade; - } + wal->shade = t[1]; + wal->pal = 0; } - } - - break; - - case 4: - - if ((global_random/(sh+1)&31) < 4) - { - t[1] = s->shade + (global_random&15);//Got really bright - t[0] = s->shade + (global_random&15); - sc->ceilingpal = s->owner>>8; - sc->floorpal = s->owner&0xff; - j = 1; - } - else - { - t[1] = t[2]; - t[0] = t[3]; - - sc->ceilingpal = s->pal; - sc->floorpal = s->pal; - - j = 0; - } sc->floorshade = t[1]; - sc->ceilingshade = t[1]; - - wal = &wall[sc->wallptr]; - - for (x=sc->wallnum;x > 0; x--,wal++) - { - if (j) wal->pal = (s->owner&0xff); - else wal->pal = s->pal; - - if (wal->hitag != 1) - { - wal->shade = t[0]; - if ((wal->cstat&2) && wal->nextwall >= 0) - wall[wal->nextwall].shade = wal->shade; - } - } + sc->ceilingshade = t[2]; + t[0]=0; j = headspritesect[SECT]; while (j >= 0) @@ -6168,1273 +6446,933 @@ void moveeffectors(void) //STATNUM 3 sprite[j].shade = sc->ceilingshade; else sprite[j].shade = sc->floorshade; } - j = nextspritesect[j]; - } - - if (t[4]) KILLIT(i); - - break; - - //BOSS - case 5: - p = findplayer(s,&x); - if (x < 8192) - { - j = s->ang; - s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); - shoot(i,FIRELASER); - s->ang = j; - } - - if (s->owner==-1) //Start search - { - t[4]=0; - l = 0x7fffffff; - while (1) //Find the shortest dist - { - s->owner = LocateTheLocator((short)t[4],-1); //t[0] hold sectnum - - if (s->owner==-1) break; - - m = ldist(&sprite[ps[p].i],&sprite[s->owner]); - - if (l > m) - { - q = s->owner; - l = m; - } - - t[4]++; - } - - s->owner = q; - s->zvel = ksgn(sprite[q].z-s->z)<<4; - } - - if (ldist(&sprite[s->owner],s) < 1024) - { - short ta; - ta = s->ang; - s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); - s->ang = ta; - s->owner = -1; - goto BOLT; } - else s->xvel=256; - x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); - q = getincangle(s->ang,x)>>3; - s->ang += q; - - if (rnd(32)) - { - t[2]+=q; - sc->ceilingshade = 127; - } - else - { - t[2] += - getincangle(t[2]+512,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; - sc->ceilingshade = 0; - } - IFHIT - { - t[3]++; - if (t[3] == 5) - { - s->zvel += 1024; - FTA(7,&ps[myconnectindex]); - } + if (t[3] == 1) KILLIT(i); } - - s->z += s->zvel; - sc->ceilingz += s->zvel; - sector[t[0]].ceilingz += s->zvel; - ms(i); - setsprite(i,s->x,s->y,s->z); - break; - - - case 8: - case 9: - - // work only if its moving - - j = -1; - - if (hittype[i].temp_data[4]) + if (t[0] == 1) //Lights flickering on + { + if (sc->floorshade > s->shade) { - hittype[i].temp_data[4]++; - if (hittype[i].temp_data[4] > 8) KILLIT(i); - j = 1; - } - else j = getanimationgoal(&sc->ceilingz); + sc->floorpal = s->pal; + sc->ceilingpal = s->pal; - if (j >= 0) - { - short sn; - - if ((sc->lotag&0x8000) || hittype[i].temp_data[4]) - x = -t[3]; - else - x = t[3]; - - if (st == 9) x = -x; - - j = headspritestat[3]; - while (j >= 0) - { - if (((sprite[j].lotag) == st) && (sprite[j].hitag) == sh) - { - sn = sprite[j].sectnum; - m = sprite[j].shade; - - wal = &wall[sector[sn].wallptr]; - - for (l=sector[sn].wallnum;l>0;l--,wal++) - { - if (wal->hitag != 1) - { - wal->shade+=x; - - if (wal->shade < m) - wal->shade = m; - else if (wal->shade > hittype[j].temp_data[2]) - wal->shade = hittype[j].temp_data[2]; - - if (wal->nextwall >= 0) - if (wall[wal->nextwall].hitag != 1) - wall[wal->nextwall].shade = wal->shade; - } - } - - sector[sn].floorshade += x; - sector[sn].ceilingshade += x; - - if (sector[sn].floorshade < m) - sector[sn].floorshade = m; - else if (sector[sn].floorshade > hittype[j].temp_data[0]) - sector[sn].floorshade = hittype[j].temp_data[0]; - - if (sector[sn].ceilingshade < m) - sector[sn].ceilingshade = m; - else if (sector[sn].ceilingshade > hittype[j].temp_data[1]) - sector[sn].ceilingshade = hittype[j].temp_data[1]; - - } - j = nextspritestat[j]; - } - } - break; - case 10: - - if ((sc->lotag&0xff) == 27 || (sc->floorz > sc->ceilingz && (sc->lotag&0xff) != 23) || sc->lotag == (short) 32791) - { - j = 1; - - if ((sc->lotag&0xff) != 27) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0) - if (s->sectnum == sprite[ps[p].i].sectnum) - j = 0; - - if (j == 1) - { - if (t[0] > sh) - switch (sector[s->sectnum].lotag) - { - case 20: - case 21: - case 22: - case 26: - if (getanimationgoal(§or[s->sectnum].ceilingz) >= 0) - break; - default: - activatebysector(s->sectnum,i); - t[0] = 0; - break; - } - else t[0]++; - } - } - else t[0]=0; - break; - case 11: //Swingdoor - - if (t[5] > 0) - { - t[5]--; - break; - } - - if (t[4]) - { - short startwall,endwall; - - startwall = sc->wallptr; - endwall = startwall+sc->wallnum; - - for (j=startwall;j= 0) - { - if (sprite[k].extra > 0 && badguy(&sprite[k]) && clipinsidebox(sprite[k].x,sprite[k].y,j,256L) == 1) - goto BOLT; - k = nextspritestat[k]; - } - - k = headspritestat[10]; - while (k >= 0) - { - if (sprite[k].owner >= 0 && clipinsidebox(sprite[k].x,sprite[k].y,j,144L) == 1) - { - t[5] = 8; // Delay - k = (SP>>3)*t[3]; - t[2]-=k; - t[4]-=k; - ms(i); - setsprite(i,s->x,s->y,s->z); - goto BOLT; - } - k = nextspritestat[k]; - } - } - - k = (SP>>3)*t[3]; - t[2]+=k; - t[4]+=k; - ms(i); - setsprite(i,s->x,s->y,s->z); - - if (t[4] <= -511 || t[4] >= 512) - { - t[4] = 0; - t[2] &= 0xffffff00; - ms(i); - setsprite(i,s->x,s->y,s->z); - break; - } - } - break; - case 12: - if (t[0] == 3 || t[3] == 1) //Lights going off - { - sc->floorpal = 0; - sc->ceilingpal = 0; + sc->floorshade -= 2; + sc->ceilingshade -= 2; wal = &wall[sc->wallptr]; - for (j = sc->wallnum;j > 0; j--, wal++) + for (j=sc->wallnum;j>0;j--,wal++) if (wal->hitag != 1) { - wal->shade = t[1]; - wal->pal = 0; + wal->pal = s->pal; + wal->shade -= 2; } - - sc->floorshade = t[1]; - sc->ceilingshade = t[2]; - t[0]=0; - - j = headspritesect[SECT]; - while (j >= 0) - { - if (sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) - { - if (sc->ceilingstat&1) - sprite[j].shade = sc->ceilingshade; - else sprite[j].shade = sc->floorshade; - } - j = nextspritesect[j]; - - } - - if (t[3] == 1) KILLIT(i); } - if (t[0] == 1) //Lights flickering on + else t[0] = 2; + + j = headspritesect[SECT]; + while (j >= 0) { - if (sc->floorshade > s->shade) + if (sprite[j].cstat&16) { - sc->floorpal = s->pal; - sc->ceilingpal = s->pal; - - sc->floorshade -= 2; - sc->ceilingshade -= 2; - - wal = &wall[sc->wallptr]; - for (j=sc->wallnum;j>0;j--,wal++) - if (wal->hitag != 1) - { - wal->pal = s->pal; - wal->shade -= 2; - } - } - else t[0] = 2; - - j = headspritesect[SECT]; - while (j >= 0) - { - if (sprite[j].cstat&16) - { - if (sc->ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) - sprite[j].shade = sc->ceilingshade; - else sprite[j].shade = sc->floorshade; - } - j = nextspritesect[j]; + if (sc->ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + sprite[j].shade = sc->ceilingshade; + else sprite[j].shade = sc->floorshade; } + j = nextspritesect[j]; } - break; + } + break; - case 13: - if (t[2]) + case 13: + if (t[2]) + { + j = (SP<<5)|1; + + if (s->ang == 512) { - j = (SP<<5)|1; - - if (s->ang == 512) + if (s->owner) { - if (s->owner) - { - if (klabs(t[0]-sc->ceilingz) >= j) - sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; - else sc->ceilingz = t[0]; - } - else - { - if (klabs(t[1]-sc->floorz) >= j) - sc->floorz += ksgn(t[1]-sc->floorz)*j; - else sc->floorz = t[1]; - } + if (klabs(t[0]-sc->ceilingz) >= j) + sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; + else sc->ceilingz = t[0]; } else { if (klabs(t[1]-sc->floorz) >= j) sc->floorz += ksgn(t[1]-sc->floorz)*j; else sc->floorz = t[1]; - if (klabs(t[0]-sc->ceilingz) >= j) - sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; - sc->ceilingz = t[0]; - } - - if (t[3] == 1) - { - //Change the shades - - t[3]++; - sc->ceilingstat ^= 1; - - if (s->ang == 512) - { - wal = &wall[sc->wallptr]; - for (j=sc->wallnum;j>0;j--,wal++) - wal->shade = s->shade; - - sc->floorshade = s->shade; - - if (ps[0].one_parallax_sectnum >= 0) - { - sc->ceilingpicnum = - sector[ps[0].one_parallax_sectnum].ceilingpicnum; - sc->ceilingshade = - sector[ps[0].one_parallax_sectnum].ceilingshade; - } - } - } - t[2]++; - if (t[2] > 256) - KILLIT(i); - } - - - if (t[2] == 4 && s->ang != 512) - for (x=0;x<7;x++) RANDOMSCRAP; - break; - - - case 15: - - if (t[4]) - { - s->xvel = 16; - - if (t[4] == 1) //Opening - { - if (t[3] >= (SP>>3)) - { - t[4] = 0; //Turn off the sliders - callsound(s->sectnum,i); - break; - } - t[3]++; - } - else if (t[4] == 2) - { - if (t[3]<1) - { - t[4] = 0; - callsound(s->sectnum,i); - break; - } - t[3]--; - } - - ms(i); - setsprite(i,s->x,s->y,s->z); - } - break; - - case 16: //Reactor - - t[2]+=32; - if (sc->floorzceilingz) s->shade=0; - - else if (sc->ceilingz < t[3]) - { - - //The following code check to see if - //there is any other sprites in the sector. - //If there isn't, then kill this sectoreffector - //itself..... - - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].picnum == REACTOR || sprite[j].picnum == REACTOR2) - break; - j = nextspritesect[j]; - } - if (j == -1) - { - KILLIT(i); - } - else s->shade=1; - } - - if (s->shade) sc->ceilingz+=1024; - else sc->ceilingz-=512; - - ms(i); - setsprite(i,s->x,s->y,s->z); - - break; - - case 17: - - q = t[0]*(SP<<2); - - sc->ceilingz += q; - sc->floorz += q; - - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].statnum == 10 && sprite[j].owner >= 0) - { - p = sprite[j].yvel; - if (numplayers < 2) - ps[p].oposz = ps[p].posz; - ps[p].posz += q; - ps[p].truefz += q; - ps[p].truecz += q; - if (numplayers > 1) - ps[p].oposz = ps[p].posz; - } - if (sprite[j].statnum != 3) - { - hittype[j].bposz = sprite[j].z; - sprite[j].z += q; - } - - hittype[j].floorz = sc->floorz; - hittype[j].ceilingz = sc->ceilingz; - - j = nextspritesect[j]; - } - - if (t[0]) if (t[0]) //If in motion - { - if (klabs(sc->floorz-t[2]) <= SP) - { - activatewarpelevators(i,0); - break; - } - - if (t[0]==-1) - { - if (sc->floorz > t[3]) - break; - } - else if (sc->ceilingz < t[4]) break; - - if (t[1] == 0) break; - t[1] = 0; - - j = headspritestat[3]; - while (j >= 0) - { - if (i != j && (sprite[j].lotag) == 17) - if ((sc->hitag-t[0]) == - (sector[sprite[j].sectnum].hitag) - && sh == (sprite[j].hitag)) - break; - j = nextspritestat[j]; - } - - if (j == -1) break; - - k = headspritesect[s->sectnum]; - while (k >= 0) - { - nextk = nextspritesect[k]; - - if (sprite[k].statnum == 10 && sprite[k].owner >= 0) - { - p = sprite[k].yvel; - - ps[p].posx += sprite[j].x-s->x; - ps[p].posy += sprite[j].y-s->y; - ps[p].posz = sector[sprite[j].sectnum].floorz-(sc->floorz-ps[p].posz); - - hittype[k].floorz = sector[sprite[j].sectnum].floorz; - hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; - - ps[p].bobposx = ps[p].oposx = ps[p].posx; - ps[p].bobposy = ps[p].oposy = ps[p].posy; - ps[p].oposz = ps[p].posz; - - ps[p].truefz = hittype[k].floorz; - ps[p].truecz = hittype[k].ceilingz; - ps[p].bobcounter = 0; - - changespritesect(k,sprite[j].sectnum); - ps[p].cursectnum = sprite[j].sectnum; - } - else if (sprite[k].statnum != 3) - { - sprite[k].x += - sprite[j].x-s->x; - sprite[k].y += - sprite[j].y-s->y; - sprite[k].z = sector[sprite[j].sectnum].floorz- - (sc->floorz-sprite[k].z); - - hittype[k].bposx = sprite[k].x; - hittype[k].bposy = sprite[k].y; - hittype[k].bposz = sprite[k].z; - - changespritesect(k,sprite[j].sectnum); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - - hittype[k].floorz = sector[sprite[j].sectnum].floorz; - hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; - - } - k = nextk; - } - } - break; - - case 18: - if (t[0]) - { - if (s->pal) - { - if (s->ang == 512) - { - sc->ceilingz -= sc->extra; - if (sc->ceilingz <= t[1]) - { - sc->ceilingz = t[1]; - KILLIT(i); - } - } - else - { - sc->floorz += sc->extra; - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (ps[sprite[j].yvel].on_ground == 1) - ps[sprite[j].yvel].posz += sc->extra; - if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) - { - hittype[j].bposz = sprite[j].z += sc->extra; - hittype[j].floorz = sc->floorz; - } - j = nextspritesect[j]; - } - if (sc->floorz >= t[1]) - { - sc->floorz = t[1]; - KILLIT(i); - } - } - } - else - { - if (s->ang == 512) - { - sc->ceilingz += sc->extra; - if (sc->ceilingz >= s->z) - { - sc->ceilingz = s->z; - KILLIT(i); - } - } - else - { - sc->floorz -= sc->extra; - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (ps[sprite[j].yvel].on_ground == 1) - ps[sprite[j].yvel].posz -= sc->extra; - if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) - { - hittype[j].bposz = sprite[j].z -= sc->extra; - hittype[j].floorz = sc->floorz; - } - j = nextspritesect[j]; - } - if (sc->floorz <= s->z) - { - sc->floorz = s->z; - KILLIT(i); - } - } - } - - t[2]++; - if (t[2] >= s->hitag) - { - t[2] = 0; - t[0] = 0; } } - break; - - case 19: //Battlestar galactia shields - - if (t[0]) + else { - if (t[0] == 1) - { - t[0]++; - x = sc->wallptr; - q = x+sc->wallnum; - for (j=x;j= 0) - { - wall[wall[j].nextwall].overpicnum = 0; - wall[wall[j].nextwall].cstat &= (128+32+8+4+2); - } - } - } - - if (sc->ceilingz < sc->floorz) - sc->ceilingz += SP; - else - { - sc->ceilingz = sc->floorz; - - j = headspritestat[3]; - while (j >= 0) - { - if (sprite[j].lotag == 0 && sprite[j].hitag==sh) - { - q = sprite[sprite[j].owner].sectnum; - sector[sprite[j].sectnum].floorpal = sector[sprite[j].sectnum].ceilingpal = - sector[q].floorpal; - sector[sprite[j].sectnum].floorshade = sector[sprite[j].sectnum].ceilingshade = - sector[q].floorshade; - - hittype[sprite[j].owner].temp_data[0] = 2; - } - j = nextspritestat[j]; - } - KILLIT(i); - } + if (klabs(t[1]-sc->floorz) >= j) + sc->floorz += ksgn(t[1]-sc->floorz)*j; + else sc->floorz = t[1]; + if (klabs(t[0]-sc->ceilingz) >= j) + sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; + sc->ceilingz = t[0]; } - else //Not hit yet + + if (t[3] == 1) { - IFHITSECT + //Change the shades + + t[3]++; + sc->ceilingstat ^= 1; + + if (s->ang == 512) { - FTA(8,&ps[myconnectindex]); + wal = &wall[sc->wallptr]; + for (j=sc->wallnum;j>0;j--,wal++) + wal->shade = s->shade; - l = headspritestat[3]; - while (l >= 0) - { - x = sprite[l].lotag&0x7fff; - switch (x) - { - case 0: - if (sprite[l].hitag == sh) - { - q = sprite[l].sectnum; - sector[q].floorshade = - sector[q].ceilingshade = - sprite[sprite[l].owner].shade; - sector[q].floorpal = - sector[q].ceilingpal = - sprite[sprite[l].owner].pal; - } - break; + sc->floorshade = s->shade; - case 1: - case 12: - // case 18: - case 19: - - if (sh == sprite[l].hitag) - if (hittype[l].temp_data[0] == 0) - { - hittype[l].temp_data[0] = 1; //Shut them all on - sprite[l].owner = i; - } - - break; - } - l = nextspritestat[l]; + if (ps[0].one_parallax_sectnum >= 0) + { + sc->ceilingpicnum = + sector[ps[0].one_parallax_sectnum].ceilingpicnum; + sc->ceilingshade = + sector[ps[0].one_parallax_sectnum].ceilingshade; } } } + t[2]++; + if (t[2] > 256) + KILLIT(i); + } - break; - case 20: //Extend-o-bridge + if (t[2] == 4 && s->ang != 512) + for (x=0;x<7;x++) RANDOMSCRAP; + break; - if (t[0] == 0) break; - if (t[0] == 1) s->xvel = 8; - else s->xvel = -8; - if (s->xvel) //Moving + case 15: + + if (t[4]) + { + s->xvel = 16; + + if (t[4] == 1) //Opening { - x = (s->xvel*sintable[(s->ang+512)&2047])>>14; - l = (s->xvel*sintable[s->ang&2047])>>14; - - t[3] += s->xvel; - - s->x += x; - s->y += l; - - if (t[3] <= 0 || (t[3]>>6) >= (SP>>6)) + if (t[3] >= (SP>>3)) { - s->x -= x; - s->y -= l; - t[0] = 0; + t[4] = 0; //Turn off the sliders callsound(s->sectnum,i); break; } - - j = headspritesect[s->sectnum]; - while (j >= 0) + t[3]++; + } + else if (t[4] == 2) + { + if (t[3]<1) { - nextj = nextspritesect[j]; - - if (sprite[j].statnum != 3 && sprite[j].zvel == 0) - { - sprite[j].x += x; - sprite[j].y += l; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); - if (sector[sprite[j].sectnum].floorstat&2) - if (sprite[j].statnum == 2) - makeitfall(j); - } - j = nextj; - } - - dragpoint((short)t[1],wall[t[1]].x+x,wall[t[1]].y+l); - dragpoint((short)t[2],wall[t[2]].x+x,wall[t[2]].y+l); - - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) - { - ps[p].posx += x; - ps[p].posy += l; - - ps[p].oposx = ps[p].posx; - ps[p].oposy = ps[p].posy; - - setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); - } - - sc->floorxpanning-=x>>3; - sc->floorypanning-=l>>3; - - sc->ceilingxpanning-=x>>3; - sc->ceilingypanning-=l>>3; - } - - break; - - case 21: // Cascading effect - - if (t[0] == 0) break; - - if (s->ang == 1536) - l = (long) &sc->ceilingz; - else - l = (long) &sc->floorz; - - if (t[0] == 1) //Decide if the s->sectnum should go up or down - { - s->zvel = ksgn(s->z-*(long *)l) * (SP<<4); - t[0]++; - } - - if (sc->extra == 0) - { - *(long *)l += s->zvel; - - if (klabs(*(long *)l-s->z) < 1024) - { - *(long *)l = s->z; - KILLIT(i); //All done - } - } - else sc->extra--; - break; - - case 22: - - if (t[1]) - { - if (getanimationgoal(§or[t[0]].ceilingz) >= 0) - sc->ceilingz += sc->extra*9; - else t[1] = 0; - } - break; - - case 24: - case 34: - - if (t[4]) break; - - x = (SP*sintable[(s->ang+512)&2047])>>18; - l = (SP*sintable[s->ang&2047])>>18; - - k = 0; - - j = headspritesect[s->sectnum]; - while (j >= 0) - { - nextj = nextspritesect[j]; - if (sprite[j].zvel >= 0) - switch (sprite[j].statnum) - { - case 5: - switch (dynamictostatic[sprite[j].picnum]) - { - case BLOODPOOL__STATIC: - case PUKE__STATIC: - case FOOTPRINTS__STATIC: - case FOOTPRINTS2__STATIC: - case FOOTPRINTS3__STATIC: - case FOOTPRINTS4__STATIC: - case BULLETHOLE__STATIC: - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - sprite[j].xrepeat = sprite[j].yrepeat = 0; - j = nextj; - continue; - case LASERLINE__STATIC: - j = nextj; - continue; - } - case 6: - if (sprite[j].picnum == TRIPBOMB) break; - case 1: - case 0: - if ( - sprite[j].picnum == BOLT1 || - sprite[j].picnum == BOLT1+1 || - sprite[j].picnum == BOLT1+2 || - sprite[j].picnum == BOLT1+3 || - sprite[j].picnum == SIDEBOLT1 || - sprite[j].picnum == SIDEBOLT1+1 || - sprite[j].picnum == SIDEBOLT1+2 || - sprite[j].picnum == SIDEBOLT1+3 || - wallswitchcheck(j) - ) - break; - - if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE+3))) - { - if (sprite[j].z > (hittype[j].floorz-(16<<8))) - { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - - sprite[j].x += x>>2; - sprite[j].y += l>>2; - - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); - - if (sector[sprite[j].sectnum].floorstat&2) - if (sprite[j].statnum == 2) - makeitfall(j); - } - } - break; - } - j = nextj; - } - - p = myconnectindex; - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) - if (klabs(ps[p].posz-ps[p].truefz) < PHEIGHT+(9<<8)) - { - fricxv += x<<3; - fricyv += l<<3; - } - - sc->floorxpanning += SP>>7; - - break; - - case 35: - if (sc->ceilingz > s->z) - for (j = 0;j < 8;j++) - { - s->ang += TRAND&511; - k = spawn(i,SMALLSMOKE); - sprite[k].xvel = 96+(TRAND&127); - ssp(k,CLIPMASK0); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - if (rnd(16)) - spawn(i,EXPLOSION2); - } - - switch (t[0]) - { - case 0: - sc->ceilingz += s->yvel; - if (sc->ceilingz > sc->floorz) - sc->floorz = sc->ceilingz; - if (sc->ceilingz > s->z+(32<<8)) - t[0]++; + t[4] = 0; + callsound(s->sectnum,i); break; - case 1: - sc->ceilingz-=(s->yvel<<2); - if (sc->ceilingz < t[4]) - { - sc->ceilingz = t[4]; - t[0] = 0; - } - break; - } - break; - - case 25: //PISTONS - - if (t[4] == 0) break; - - if (sc->floorz <= sc->ceilingz) - s->shade = 0; - else if (sc->ceilingz <= t[3]) - s->shade = 1; - - if (s->shade) - { - sc->ceilingz += SP<<4; - if (sc->ceilingz > sc->floorz) - sc->ceilingz = sc->floorz; - } - else - { - sc->ceilingz -= SP<<4; - if (sc->ceilingz < t[3]) - sc->ceilingz = t[3]; - } - - break; - - case 26: - - s->xvel = 32; - l = (s->xvel*sintable[(s->ang+512)&2047])>>14; - x = (s->xvel*sintable[s->ang&2047])>>14; - - s->shade++; - if (s->shade > 7) - { - s->x = t[3]; - s->y = t[4]; - sc->floorz -= ((s->zvel*s->shade)-s->zvel); - s->shade = 0; - } - else - sc->floorz += s->zvel; - - j = headspritesect[s->sectnum]; - while (j >= 0) - { - nextj = nextspritesect[j]; - if (sprite[j].statnum != 3 && sprite[j].statnum != 10) - { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - - sprite[j].x += l; - sprite[j].y += x; - - sprite[j].z += s->zvel; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); } - j = nextj; + t[3]--; } - p = myconnectindex; - if (sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) - { - fricxv += l<<5; - fricyv += x<<5; - } - - for (p = connecthead;p >= 0;p = connectpoint2[p]) - if (sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) - ps[p].posz += s->zvel; - ms(i); setsprite(i,s->x,s->y,s->z); + } + break; - break; + case 16: //Reactor + t[2]+=32; + if (sc->floorzceilingz) s->shade=0; - case 27: + else if (sc->ceilingz < t[3]) + { - if (ud.recstat == 0 || !ud.democams) break; + //The following code check to see if + //there is any other sprites in the sector. + //If there isn't, then kill this sectoreffector + //itself..... - hittype[i].tempang = s->ang; - - p = findplayer(s,&x); - if (sprite[ps[p].i].extra > 0 && myconnectindex == screenpeek) + j = headspritesect[s->sectnum]; + while (j >= 0) { - if (t[0] < 0) - { - ud.camerasprite = i; - t[0]++; - } - else if (ud.recstat == 2 && ps[p].newowner == -1) - { - if (cansee(s->x,s->y,s->z,SECT,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) - { - if (x < (long)((unsigned)sh)) - { - ud.camerasprite = i; - t[0] = 999; - s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; - SP = 100+((s->z-ps[p].posz)/257); - - } - else if (t[0] == 999) - { - if (ud.camerasprite == i) - t[0] = 0; - else t[0] = -10; - ud.camerasprite = i; - - } - } - else - { - s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); - - if (t[0] == 999) - { - if (ud.camerasprite == i) - t[0] = 0; - else t[0] = -20; - ud.camerasprite = i; - } - } - } - } - break; - case 28: - if (t[5] > 0) - { - t[5]--; - break; - } - - if (T1 == 0) - { - p = findplayer(s,&x); - if (x > 15500) + if (sprite[j].picnum == REACTOR || sprite[j].picnum == REACTOR2) break; - T1 = 1; - T2 = 64 + (TRAND&511); - T3 = 0; + j = nextspritesect[j]; + } + if (j == -1) + { + KILLIT(i); + } + else s->shade=1; + } + + if (s->shade) sc->ceilingz+=1024; + else sc->ceilingz-=512; + + ms(i); + setsprite(i,s->x,s->y,s->z); + + break; + + case 17: + + q = t[0]*(SP<<2); + + sc->ceilingz += q; + sc->floorz += q; + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].statnum == 10 && sprite[j].owner >= 0) + { + p = sprite[j].yvel; + if (numplayers < 2) + ps[p].oposz = ps[p].posz; + ps[p].posz += q; + ps[p].truefz += q; + ps[p].truecz += q; + if (numplayers > 1) + ps[p].oposz = ps[p].posz; + } + if (sprite[j].statnum != 3) + { + hittype[j].bposz = sprite[j].z; + sprite[j].z += q; + } + + hittype[j].floorz = sc->floorz; + hittype[j].ceilingz = sc->ceilingz; + + j = nextspritesect[j]; + } + + if (t[0]) if (t[0]) //If in motion + { + if (klabs(sc->floorz-t[2]) <= SP) + { + activatewarpelevators(i,0); + break; + } + + if (t[0]==-1) + { + if (sc->floorz > t[3]) + break; + } + else if (sc->ceilingz < t[4]) break; + + if (t[1] == 0) break; + t[1] = 0; + + j = headspritestat[3]; + while (j >= 0) + { + if (i != j && (sprite[j].lotag) == 17) + if ((sc->hitag-t[0]) == + (sector[sprite[j].sectnum].hitag) + && sh == (sprite[j].hitag)) + break; + j = nextspritestat[j]; + } + + if (j == -1) break; + + k = headspritesect[s->sectnum]; + while (k >= 0) + { + nextk = nextspritesect[k]; + + if (sprite[k].statnum == 10 && sprite[k].owner >= 0) + { + p = sprite[k].yvel; + + ps[p].posx += sprite[j].x-s->x; + ps[p].posy += sprite[j].y-s->y; + ps[p].posz = sector[sprite[j].sectnum].floorz-(sc->floorz-ps[p].posz); + + hittype[k].floorz = sector[sprite[j].sectnum].floorz; + hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + + ps[p].bobposx = ps[p].oposx = ps[p].posx; + ps[p].bobposy = ps[p].oposy = ps[p].posy; + ps[p].oposz = ps[p].posz; + + ps[p].truefz = hittype[k].floorz; + ps[p].truecz = hittype[k].ceilingz; + ps[p].bobcounter = 0; + + changespritesect(k,sprite[j].sectnum); + ps[p].cursectnum = sprite[j].sectnum; + } + else if (sprite[k].statnum != 3) + { + sprite[k].x += + sprite[j].x-s->x; + sprite[k].y += + sprite[j].y-s->y; + sprite[k].z = sector[sprite[j].sectnum].floorz- + (sc->floorz-sprite[k].z); + + hittype[k].bposx = sprite[k].x; + hittype[k].bposy = sprite[k].y; + hittype[k].bposz = sprite[k].z; + + changespritesect(k,sprite[j].sectnum); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + + hittype[k].floorz = sector[sprite[j].sectnum].floorz; + hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + + } + k = nextk; + } + } + break; + + case 18: + if (t[0]) + { + if (s->pal) + { + if (s->ang == 512) + { + sc->ceilingz -= sc->extra; + if (sc->ceilingz <= t[1]) + { + sc->ceilingz = t[1]; + KILLIT(i); + } + } + else + { + sc->floorz += sc->extra; + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if (ps[sprite[j].yvel].on_ground == 1) + ps[sprite[j].yvel].posz += sc->extra; + if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z += sc->extra; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + if (sc->floorz >= t[1]) + { + sc->floorz = t[1]; + KILLIT(i); + } + } } else { - T3++; - if (T3 > T2) + if (s->ang == 512) { - T1 = 0; - ps[screenpeek].visibility = ud.const_visibility; - break; - } - else if (T3 == (T2>>1)) - spritesound(THUNDER,i); - else if (T3 == (T2>>3)) - spritesound(LIGHTNING_SLAP,i); - else if (T3 == (T2>>2)) - { - j = headspritestat[0]; - while (j >= 0) + sc->ceilingz += sc->extra; + if (sc->ceilingz >= s->z) { - if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) - sprite[j].cstat |= 32768; - j = nextspritestat[j]; + sc->ceilingz = s->z; + KILLIT(i); } } - else if (T3 > (T2>>3) && T3 < (T2>>2)) + else { - if (cansee(s->x,s->y,s->z,s->sectnum,ps[screenpeek].posx,ps[screenpeek].posy,ps[screenpeek].posz,ps[screenpeek].cursectnum)) - j = 1; - else j = 0; - - if (rnd(192) && (T3&1)) - { - if (j) - ps[screenpeek].visibility = 0; - } - else if (j) - ps[screenpeek].visibility = ud.const_visibility; - - j = headspritestat[0]; + sc->floorz -= sc->extra; + j = headspritesect[s->sectnum]; while (j >= 0) { - if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) + if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if (ps[sprite[j].yvel].on_ground == 1) + ps[sprite[j].yvel].posz -= sc->extra; + if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - if (rnd(32) && (T3&1)) - { - sprite[j].cstat &= 32767; - spawn(j,SMALLSMOKE); - - p = findplayer(s,&x); - x = ldist(&sprite[ps[p].i], &sprite[j]); - if (x < 768) - { - if (!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,ps[p].i); - spritesound(SHORT_CIRCUIT,ps[p].i); - sprite[ps[p].i].extra -= 8+(TRAND&7); - ps[p].pals_time = 32; - ps[p].pals[0] = 16; - ps[p].pals[1] = 0; - ps[p].pals[2] = 0; - } - break; - } - else sprite[j].cstat |= 32768; + hittype[j].bposz = sprite[j].z -= sc->extra; + hittype[j].floorz = sc->floorz; } - - j = nextspritestat[j]; + j = nextspritesect[j]; + } + if (sc->floorz <= s->z) + { + sc->floorz = s->z; + KILLIT(i); } } } - break; - case 29: - s->hitag += 64; - l = mulscale12((long)s->yvel,sintable[s->hitag&2047]); - sc->floorz = s->z + l; - break; - case 31: // True Drop Floor + + t[2]++; + if (t[2] >= s->hitag) + { + t[2] = 0; + t[0] = 0; + } + } + break; + + case 19: //Battlestar galactia shields + + if (t[0]) + { if (t[0] == 1) { - // Choose dir - - if (t[3] > 0) - { - t[3]--; - break; - } - - if (t[2] == 1) // Retract - { - if (SA != 1536) + t[0]++; + x = sc->wallptr; + q = x+sc->wallnum; + for (j=x;jfloorz - s->z) < SP) + wall[j].cstat &= (128+32+8+4+2); + wall[j].overpicnum = 0; + if (wall[j].nextwall >= 0) { - sc->floorz = s->z; - t[2] = 0; - t[0] = 0; - t[3] = s->hitag; - callsound(s->sectnum,i); - } - else - { - l = ksgn(s->z-sc->floorz)*SP; - sc->floorz += l; - - j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (ps[sprite[j].yvel].on_ground == 1) - ps[sprite[j].yvel].posz += l; - if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) - { - hittype[j].bposz = sprite[j].z += l; - hittype[j].floorz = sc->floorz; - } - j = nextspritesect[j]; - } + wall[wall[j].nextwall].overpicnum = 0; + wall[wall[j].nextwall].cstat &= (128+32+8+4+2); } } - else - { - if (klabs(sc->floorz - t[1]) < SP) - { - sc->floorz = t[1]; - callsound(s->sectnum,i); - t[2] = 0; - t[0] = 0; - t[3] = s->hitag; - } - else - { - l = ksgn(t[1]-sc->floorz)*SP; - sc->floorz += l; + } - j = headspritesect[s->sectnum]; - while (j >= 0) + if (sc->ceilingz < sc->floorz) + sc->ceilingz += SP; + else + { + sc->ceilingz = sc->floorz; + + j = headspritestat[3]; + while (j >= 0) + { + if (sprite[j].lotag == 0 && sprite[j].hitag==sh) + { + q = sprite[sprite[j].owner].sectnum; + sector[sprite[j].sectnum].floorpal = sector[sprite[j].sectnum].ceilingpal = + sector[q].floorpal; + sector[sprite[j].sectnum].floorshade = sector[sprite[j].sectnum].ceilingshade = + sector[q].floorshade; + + hittype[sprite[j].owner].temp_data[0] = 2; + } + j = nextspritestat[j]; + } + KILLIT(i); + } + } + else //Not hit yet + { + IFHITSECT + { + FTA(8,&ps[myconnectindex]); + + l = headspritestat[3]; + while (l >= 0) + { + x = sprite[l].lotag&0x7fff; + switch (x) + { + case 0: + if (sprite[l].hitag == sh) + { + q = sprite[l].sectnum; + sector[q].floorshade = + sector[q].ceilingshade = + sprite[sprite[l].owner].shade; + sector[q].floorpal = + sector[q].ceilingpal = + sprite[sprite[l].owner].pal; + } + break; + + case 1: + case 12: + // case 18: + case 19: + + if (sh == sprite[l].hitag) + if (hittype[l].temp_data[0] == 0) { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (ps[sprite[j].yvel].on_ground == 1) - ps[sprite[j].yvel].posz += l; - if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) - { - hittype[j].bposz = sprite[j].z += l; - hittype[j].floorz = sc->floorz; - } - j = nextspritesect[j]; + hittype[l].temp_data[0] = 1; //Shut them all on + sprite[l].owner = i; } + + break; + } + l = nextspritestat[l]; + } + } + } + + break; + + case 20: //Extend-o-bridge + + if (t[0] == 0) break; + if (t[0] == 1) s->xvel = 8; + else s->xvel = -8; + + if (s->xvel) //Moving + { + x = (s->xvel*sintable[(s->ang+512)&2047])>>14; + l = (s->xvel*sintable[s->ang&2047])>>14; + + t[3] += s->xvel; + + s->x += x; + s->y += l; + + if (t[3] <= 0 || (t[3]>>6) >= (SP>>6)) + { + s->x -= x; + s->y -= l; + t[0] = 0; + callsound(s->sectnum,i); + break; + } + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + nextj = nextspritesect[j]; + + if (sprite[j].statnum != 3 && sprite[j].zvel == 0) + { + sprite[j].x += x; + sprite[j].y += l; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + if (sector[sprite[j].sectnum].floorstat&2) + if (sprite[j].statnum == 2) + makeitfall(j); + } + j = nextj; + } + + dragpoint((short)t[1],wall[t[1]].x+x,wall[t[1]].y+l); + dragpoint((short)t[2],wall[t[2]].x+x,wall[t[2]].y+l); + + for (p=connecthead;p>=0;p=connectpoint2[p]) + if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) + { + ps[p].posx += x; + ps[p].posy += l; + + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + + setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); + } + + sc->floorxpanning-=x>>3; + sc->floorypanning-=l>>3; + + sc->ceilingxpanning-=x>>3; + sc->ceilingypanning-=l>>3; + } + + break; + + case 21: // Cascading effect + + if (t[0] == 0) break; + + if (s->ang == 1536) + l = (long) &sc->ceilingz; + else + l = (long) &sc->floorz; + + if (t[0] == 1) //Decide if the s->sectnum should go up or down + { + s->zvel = ksgn(s->z-*(long *)l) * (SP<<4); + t[0]++; + } + + if (sc->extra == 0) + { + *(long *)l += s->zvel; + + if (klabs(*(long *)l-s->z) < 1024) + { + *(long *)l = s->z; + KILLIT(i); //All done + } + } + else sc->extra--; + break; + + case 22: + + if (t[1]) + { + if (getanimationgoal(§or[t[0]].ceilingz) >= 0) + sc->ceilingz += sc->extra*9; + else t[1] = 0; + } + break; + + case 24: + case 34: + + if (t[4]) break; + + x = (SP*sintable[(s->ang+512)&2047])>>18; + l = (SP*sintable[s->ang&2047])>>18; + + k = 0; + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + nextj = nextspritesect[j]; + if (sprite[j].zvel >= 0) + switch (sprite[j].statnum) + { + case 5: + switch (dynamictostatic[sprite[j].picnum]) + { + case BLOODPOOL__STATIC: + case PUKE__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + case BULLETHOLE__STATIC: + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + sprite[j].xrepeat = sprite[j].yrepeat = 0; + j = nextj; + continue; + case LASERLINE__STATIC: + j = nextj; + continue; + } + case 6: + if (sprite[j].picnum == TRIPBOMB) break; + case 1: + case 0: + if ( + sprite[j].picnum == BOLT1 || + sprite[j].picnum == BOLT1+1 || + sprite[j].picnum == BOLT1+2 || + sprite[j].picnum == BOLT1+3 || + sprite[j].picnum == SIDEBOLT1 || + sprite[j].picnum == SIDEBOLT1+1 || + sprite[j].picnum == SIDEBOLT1+2 || + sprite[j].picnum == SIDEBOLT1+3 || + wallswitchcheck(j) + ) + break; + + if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE+3))) + { + if (sprite[j].z > (hittype[j].floorz-(16<<8))) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + + sprite[j].x += x>>2; + sprite[j].y += l>>2; + + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + + if (sector[sprite[j].sectnum].floorstat&2) + if (sprite[j].statnum == 2) + makeitfall(j); } } break; } + j = nextj; + } - if ((s->ang&2047) == 1536) + p = myconnectindex; + if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) + if (klabs(ps[p].posz-ps[p].truefz) < PHEIGHT+(9<<8)) + { + fricxv += x<<3; + fricyv += l<<3; + } + + sc->floorxpanning += SP>>7; + + break; + + case 35: + if (sc->ceilingz > s->z) + for (j = 0;j < 8;j++) + { + s->ang += TRAND&511; + k = spawn(i,SMALLSMOKE); + sprite[k].xvel = 96+(TRAND&127); + ssp(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + if (rnd(16)) + spawn(i,EXPLOSION2); + } + + switch (t[0]) + { + case 0: + sc->ceilingz += s->yvel; + if (sc->ceilingz > sc->floorz) + sc->floorz = sc->ceilingz; + if (sc->ceilingz > s->z+(32<<8)) + t[0]++; + break; + case 1: + sc->ceilingz-=(s->yvel<<2); + if (sc->ceilingz < t[4]) + { + sc->ceilingz = t[4]; + t[0] = 0; + } + break; + } + break; + + case 25: //PISTONS + + if (t[4] == 0) break; + + if (sc->floorz <= sc->ceilingz) + s->shade = 0; + else if (sc->ceilingz <= t[3]) + s->shade = 1; + + if (s->shade) + { + sc->ceilingz += SP<<4; + if (sc->ceilingz > sc->floorz) + sc->ceilingz = sc->floorz; + } + else + { + sc->ceilingz -= SP<<4; + if (sc->ceilingz < t[3]) + sc->ceilingz = t[3]; + } + + break; + + case 26: + + s->xvel = 32; + l = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + s->shade++; + if (s->shade > 7) + { + s->x = t[3]; + s->y = t[4]; + sc->floorz -= ((s->zvel*s->shade)-s->zvel); + s->shade = 0; + } + else + sc->floorz += s->zvel; + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + nextj = nextspritesect[j]; + if (sprite[j].statnum != 3 && sprite[j].statnum != 10) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + + sprite[j].x += l; + sprite[j].y += x; + + sprite[j].z += s->zvel; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + } + j = nextj; + } + + p = myconnectindex; + if (sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) + { + fricxv += l<<5; + fricyv += x<<5; + } + + for (p = connecthead;p >= 0;p = connectpoint2[p]) + if (sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) + ps[p].posz += s->zvel; + + ms(i); + setsprite(i,s->x,s->y,s->z); + + break; + + + case 27: + + if (ud.recstat == 0 || !ud.democams) break; + + hittype[i].tempang = s->ang; + + p = findplayer(s,&x); + if (sprite[ps[p].i].extra > 0 && myconnectindex == screenpeek) + { + if (t[0] < 0) + { + ud.camerasprite = i; + t[0]++; + } + else if (ud.recstat == 2 && ps[p].newowner == -1) + { + if (cansee(s->x,s->y,s->z,SECT,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) { - if (klabs(s->z-sc->floorz) < SP) + if (x < (long)((unsigned)sh)) { - callsound(s->sectnum,i); + ud.camerasprite = i; + t[0] = 999; + s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; + SP = 100+((s->z-ps[p].posz)/257); + + } + else if (t[0] == 999) + { + if (ud.camerasprite == i) + t[0] = 0; + else t[0] = -10; + ud.camerasprite = i; + + } + } + else + { + s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); + + if (t[0] == 999) + { + if (ud.camerasprite == i) + t[0] = 0; + else t[0] = -20; + ud.camerasprite = i; + } + } + } + } + break; + case 28: + if (t[5] > 0) + { + t[5]--; + break; + } + + if (T1 == 0) + { + p = findplayer(s,&x); + if (x > 15500) + break; + T1 = 1; + T2 = 64 + (TRAND&511); + T3 = 0; + } + else + { + T3++; + if (T3 > T2) + { + T1 = 0; + ps[screenpeek].visibility = ud.const_visibility; + break; + } + else if (T3 == (T2>>1)) + spritesound(THUNDER,i); + else if (T3 == (T2>>3)) + spritesound(LIGHTNING_SLAP,i); + else if (T3 == (T2>>2)) + { + j = headspritestat[0]; + while (j >= 0) + { + if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) + sprite[j].cstat |= 32768; + j = nextspritestat[j]; + } + } + else if (T3 > (T2>>3) && T3 < (T2>>2)) + { + if (cansee(s->x,s->y,s->z,s->sectnum,ps[screenpeek].posx,ps[screenpeek].posy,ps[screenpeek].posz,ps[screenpeek].cursectnum)) + j = 1; + else j = 0; + + if (rnd(192) && (T3&1)) + { + if (j) + ps[screenpeek].visibility = 0; + } + else if (j) + ps[screenpeek].visibility = ud.const_visibility; + + j = headspritestat[0]; + while (j >= 0) + { + if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) + { + if (rnd(32) && (T3&1)) + { + sprite[j].cstat &= 32767; + spawn(j,SMALLSMOKE); + + p = findplayer(s,&x); + x = ldist(&sprite[ps[p].i], &sprite[j]); + if (x < 768) + { + if (!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + spritesound(SHORT_CIRCUIT,ps[p].i); + sprite[ps[p].i].extra -= 8+(TRAND&7); + ps[p].pals_time = 32; + ps[p].pals[0] = 16; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + break; + } + else sprite[j].cstat |= 32768; + } + + j = nextspritestat[j]; + } + } + } + break; + case 29: + s->hitag += 64; + l = mulscale12((long)s->yvel,sintable[s->hitag&2047]); + sc->floorz = s->z + l; + break; + case 31: // True Drop Floor + if (t[0] == 1) + { + // Choose dir + + if (t[3] > 0) + { + t[3]--; + break; + } + + if (t[2] == 1) // Retract + { + if (SA != 1536) + { + if (klabs(sc->floorz - s->z) < SP) + { + sc->floorz = s->z; + t[2] = 0; t[0] = 0; - t[2] = 1; t[3] = s->hitag; + callsound(s->sectnum,i); } else { @@ -7458,182 +7396,244 @@ void moveeffectors(void) //STATNUM 3 } else { - if (klabs(sc->floorz-t[1]) < SP) + if (klabs(sc->floorz - t[1]) < SP) { - t[0] = 0; + sc->floorz = t[1]; callsound(s->sectnum,i); - t[2] = 1; + t[2] = 0; + t[0] = 0; t[3] = s->hitag; } else { - l = ksgn(s->z-t[1])*SP; - sc->floorz -= l; + l = ksgn(t[1]-sc->floorz)*SP; + sc->floorz += l; j = headspritesect[s->sectnum]; while (j >= 0) { if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) if (ps[sprite[j].yvel].on_ground == 1) - ps[sprite[j].yvel].posz -= l; + ps[sprite[j].yvel].posz += l; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z -= l; + hittype[j].bposz = sprite[j].z += l; hittype[j].floorz = sc->floorz; } j = nextspritesect[j]; } } } + break; } - break; - case 32: // True Drop Ceiling - if (t[0] == 1) + if ((s->ang&2047) == 1536) { - // Choose dir - - if (t[2] == 1) // Retract + if (klabs(s->z-sc->floorz) < SP) { - if (SA != 1536) - { - if (klabs(sc->ceilingz - s->z) < - (SP<<1)) - { - sc->ceilingz = s->z; - callsound(s->sectnum,i); - t[2] = 0; - t[0] = 0; - } - else sc->ceilingz += - ksgn(s->z-sc->ceilingz)*SP; - } - else - { - if (klabs(sc->ceilingz - t[1]) < - (SP<<1)) - { - sc->ceilingz = t[1]; - callsound(s->sectnum,i); - t[2] = 0; - t[0] = 0; - } - else sc->ceilingz += - ksgn(t[1]-sc->ceilingz)*SP; - } - break; + callsound(s->sectnum,i); + t[0] = 0; + t[2] = 1; + t[3] = s->hitag; } - - if ((s->ang&2047) == 1536) + else { - if (klabs(sc->ceilingz-s->z) < + l = ksgn(s->z-sc->floorz)*SP; + sc->floorz += l; + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if (ps[sprite[j].yvel].on_ground == 1) + ps[sprite[j].yvel].posz += l; + if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z += l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + else + { + if (klabs(sc->floorz-t[1]) < SP) + { + t[0] = 0; + callsound(s->sectnum,i); + t[2] = 1; + t[3] = s->hitag; + } + else + { + l = ksgn(s->z-t[1])*SP; + sc->floorz -= l; + + j = headspritesect[s->sectnum]; + while (j >= 0) + { + if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if (ps[sprite[j].yvel].on_ground == 1) + ps[sprite[j].yvel].posz -= l; + if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z -= l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + } + break; + + case 32: // True Drop Ceiling + if (t[0] == 1) + { + // Choose dir + + if (t[2] == 1) // Retract + { + if (SA != 1536) + { + if (klabs(sc->ceilingz - s->z) < (SP<<1)) { - t[0] = 0; - t[2] = !t[2]; - callsound(s->sectnum,i); sc->ceilingz = s->z; + callsound(s->sectnum,i); + t[2] = 0; + t[0] = 0; } else sc->ceilingz += ksgn(s->z-sc->ceilingz)*SP; } else { - if (klabs(sc->ceilingz-t[1]) < (SP<<1)) + if (klabs(sc->ceilingz - t[1]) < + (SP<<1)) { - t[0] = 0; - t[2] = !t[2]; + sc->ceilingz = t[1]; callsound(s->sectnum,i); + t[2] = 0; + t[0] = 0; } - else sc->ceilingz -= ksgn(s->z-t[1])*SP; + else sc->ceilingz += + ksgn(t[1]-sc->ceilingz)*SP; } + break; } - break; - case 33: - if (earthquaketime > 0 && (TRAND&7) == 0) - RANDOMSCRAP; - break; - case 36: - - if (t[0]) + if ((s->ang&2047) == 1536) { - if (t[0] == 1) - shoot(i,sc->extra); - else if (t[0] == 26*5) - t[0] = 0; - t[0]++; - } - break; - - case 128: //SE to control glass breakage - - wal = &wall[t[2]]; - - if (wal->cstat|32) - { - wal->cstat &= (255-32); - wal->cstat |= 16; - if (wal->nextwall >= 0) + if (klabs(sc->ceilingz-s->z) < + (SP<<1)) { - wall[wal->nextwall].cstat &= (255-32); - wall[wal->nextwall].cstat |= 16; + t[0] = 0; + t[2] = !t[2]; + callsound(s->sectnum,i); + sc->ceilingz = s->z; } + else sc->ceilingz += + ksgn(s->z-sc->ceilingz)*SP; } - else break; - - wal->overpicnum++; - if (wal->nextwall >= 0) - wall[wal->nextwall].overpicnum++; - - if (t[0] < t[1]) t[0]++; else { - wal->cstat &= (128+32+8+4+2); - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat &= (128+32+8+4+2); - KILLIT(i); + if (klabs(sc->ceilingz-t[1]) < (SP<<1)) + { + t[0] = 0; + t[2] = !t[2]; + callsound(s->sectnum,i); + } + else sc->ceilingz -= ksgn(s->z-t[1])*SP; } - break; + } + break; - case 130: - if (t[0] > 80) + case 33: + if (earthquaketime > 0 && (TRAND&7) == 0) + RANDOMSCRAP; + break; + case 36: + + if (t[0]) + { + if (t[0] == 1) + shoot(i,sc->extra); + else if (t[0] == 26*5) + t[0] = 0; + t[0]++; + } + break; + + case 128: //SE to control glass breakage + + wal = &wall[t[2]]; + + if (wal->cstat|32) + { + wal->cstat &= (255-32); + wal->cstat |= 16; + if (wal->nextwall >= 0) { - KILLIT(i); + wall[wal->nextwall].cstat &= (255-32); + wall[wal->nextwall].cstat |= 16; } - else t[0]++; + } + else break; - x = sc->floorz-sc->ceilingz; + wal->overpicnum++; + if (wal->nextwall >= 0) + wall[wal->nextwall].overpicnum++; - if (rnd(64)) - { - k = spawn(i,EXPLOSION2); - sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&7); - sprite[k].z = sc->floorz-(TRAND%x); - sprite[k].ang += 256-(TRAND%511); - sprite[k].xvel = TRAND&127; - ssp(k,CLIPMASK0); - } - break; - case 131: - if (t[0] > 40) - { - KILLIT(i); - } - else t[0]++; + if (t[0] < t[1]) t[0]++; + else + { + wal->cstat &= (128+32+8+4+2); + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat &= (128+32+8+4+2); + KILLIT(i); + } + break; - x = sc->floorz-sc->ceilingz; + case 130: + if (t[0] > 80) + { + KILLIT(i); + } + else t[0]++; - if (rnd(32)) - { - k = spawn(i,EXPLOSION2); - sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&3); - sprite[k].z = sc->floorz-(TRAND%x); - sprite[k].ang += 256-(TRAND%511); - sprite[k].xvel = TRAND&127; - ssp(k,CLIPMASK0); - } - break; + x = sc->floorz-sc->ceilingz; + + if (rnd(64)) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&7); + sprite[k].z = sc->floorz-(TRAND%x); + sprite[k].ang += 256-(TRAND%511); + sprite[k].xvel = TRAND&127; + ssp(k,CLIPMASK0); + } + break; + case 131: + if (t[0] > 40) + { + KILLIT(i); + } + else t[0]++; + + x = sc->floorz-sc->ceilingz; + + if (rnd(32)) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&3); + sprite[k].z = sc->floorz-(TRAND%x); + sprite[k].ang += 256-(TRAND%511); + sprite[k].xvel = TRAND&127; + ssp(k,CLIPMASK0); + } + break; } BOLT: i = nexti; diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index 606a8888f..ff8bf1b3c 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -27,64 +27,64 @@ void endanimsounds(long fr) { switch (ud.volume_number) { - case 0: - break; + case 0: + break; + case 1: + switch (fr) + { case 1: - switch (fr) - { - case 1: - sound(WIND_AMBIENCE); - break; - case 26: - sound(ENDSEQVOL2SND1); - break; - case 36: - sound(ENDSEQVOL2SND2); - break; - case 54: - sound(THUD); - break; - case 62: - sound(ENDSEQVOL2SND3); - break; - case 75: - sound(ENDSEQVOL2SND4); - break; - case 81: - sound(ENDSEQVOL2SND5); - break; - case 115: - sound(ENDSEQVOL2SND6); - break; - case 124: - sound(ENDSEQVOL2SND7); - break; - } + sound(WIND_AMBIENCE); break; - case 2: - switch (fr) - { - case 1: - sound(WIND_REPEAT); - break; - case 98: - sound(DUKE_GRUNT); - break; - case 82+20: - sound(THUD); - sound(SQUISHED); - break; - case 104+20: - sound(ENDSEQVOL3SND3); - break; - case 114+20: - sound(ENDSEQVOL3SND2); - break; - case 158: - sound(PIPEBOMB_EXPLODE); - break; - } + case 26: + sound(ENDSEQVOL2SND1); break; + case 36: + sound(ENDSEQVOL2SND2); + break; + case 54: + sound(THUD); + break; + case 62: + sound(ENDSEQVOL2SND3); + break; + case 75: + sound(ENDSEQVOL2SND4); + break; + case 81: + sound(ENDSEQVOL2SND5); + break; + case 115: + sound(ENDSEQVOL2SND6); + break; + case 124: + sound(ENDSEQVOL2SND7); + break; + } + break; + case 2: + switch (fr) + { + case 1: + sound(WIND_REPEAT); + break; + case 98: + sound(DUKE_GRUNT); + break; + case 82+20: + sound(THUD); + sound(SQUISHED); + break; + case 104+20: + sound(ENDSEQVOL3SND3); + break; + case 114+20: + sound(ENDSEQVOL3SND2); + break; + case 158: + sound(PIPEBOMB_EXPLODE); + break; + } + break; } } @@ -92,12 +92,12 @@ void logoanimsounds(long fr) { switch (fr) { - case 1: - sound(FLY_BY); - break; - case 19: - sound(PIPEBOMB_EXPLODE); - break; + case 1: + sound(FLY_BY); + break; + case 19: + sound(PIPEBOMB_EXPLODE); + break; } } @@ -105,16 +105,16 @@ void intro4animsounds(long fr) { switch (fr) { - case 1: - sound(INTRO4_B); - break; - case 12: - case 34: - sound(SHORT_CIRCUIT); - break; - case 18: - sound(INTRO4_5); - break; + case 1: + sound(INTRO4_B); + break; + case 12: + case 34: + sound(SHORT_CIRCUIT); + break; + case 18: + sound(INTRO4_5); + break; } } @@ -122,18 +122,18 @@ void first4animsounds(long fr) { switch (fr) { - case 1: - sound(INTRO4_1); - break; - case 12: - sound(INTRO4_2); - break; - case 7: - sound(INTRO4_3); - break; - case 26: - sound(INTRO4_4); - break; + case 1: + sound(INTRO4_1); + break; + case 12: + sound(INTRO4_2); + break; + case 7: + sound(INTRO4_3); + break; + case 26: + sound(INTRO4_4); + break; } } @@ -141,9 +141,9 @@ void intro42animsounds(long fr) { switch (fr) { - case 10: - sound(INTRO4_6); - break; + case 10: + sound(INTRO4_6); + break; } } @@ -151,12 +151,12 @@ void endanimvol41(long fr) { switch (fr) { - case 3: - sound(DUKE_UNDERWATER); - break; - case 35: - sound(VOL4ENDSND1); - break; + case 3: + sound(DUKE_UNDERWATER); + break; + case 35: + sound(VOL4ENDSND1); + break; } } @@ -164,18 +164,18 @@ void endanimvol42(long fr) { switch (fr) { - case 11: - sound(DUKE_UNDERWATER); - break; - case 20: - sound(VOL4ENDSND1); - break; - case 39: - sound(VOL4ENDSND2); - break; - case 50: - FX_StopAllSounds(); - break; + case 11: + sound(DUKE_UNDERWATER); + break; + case 20: + sound(VOL4ENDSND1); + break; + case 39: + sound(VOL4ENDSND2); + break; + case 50: + FX_StopAllSounds(); + break; } } @@ -183,16 +183,16 @@ void endanimvol43(long fr) { switch (fr) { - case 1: - sound(BOSS4_DEADSPEECH); - break; - case 40: - sound(VOL4ENDSND1); - sound(DUKE_UNDERWATER); - break; - case 50: - sound(BIGBANG); - break; + case 1: + sound(BOSS4_DEADSPEECH); + break; + case 40: + sound(VOL4ENDSND1); + sound(DUKE_UNDERWATER); + break; + case 50: + sound(BIGBANG); + break; } } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 51135e086..72911e813 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -219,43 +219,43 @@ void ExtLoadMap(const char *mapname) { switch (sector[i].ceilingpicnum) { - case MOONSKY1 : - case BIGORBIT1 : // orbit - case LA : // la city - sky=sector[i].ceilingpicnum; - break; + case MOONSKY1 : + case BIGORBIT1 : // orbit + case LA : // la city + sky=sector[i].ceilingpicnum; + break; } } switch (sky) { - case MOONSKY1 : - // earth mountian mountain sun - pskyoff[6]=1; - pskyoff[1]=2; - pskyoff[4]=2; - pskyoff[2]=3; - break; + case MOONSKY1 : + // earth mountian mountain sun + pskyoff[6]=1; + pskyoff[1]=2; + pskyoff[4]=2; + pskyoff[2]=3; + break; - case BIGORBIT1 : // orbit - // earth1 2 3 moon/sun - pskyoff[5]=1; - pskyoff[6]=2; - pskyoff[7]=3; - pskyoff[2]=4; - break; + case BIGORBIT1 : // orbit + // earth1 2 3 moon/sun + pskyoff[5]=1; + pskyoff[6]=2; + pskyoff[7]=3; + pskyoff[2]=4; + break; - case LA : // la city - // earth1 2 3 moon/sun - pskyoff[0]=1; - pskyoff[1]=2; - pskyoff[2]=1; - pskyoff[3]=3; - pskyoff[4]=4; - pskyoff[5]=0; - pskyoff[6]=2; - pskyoff[7]=3; - break; + case LA : // la city + // earth1 2 3 moon/sun + pskyoff[0]=1; + pskyoff[1]=2; + pskyoff[2]=1; + pskyoff[3]=3; + pskyoff[4]=4; + pskyoff[5]=0; + pskyoff[6]=2; + pskyoff[7]=3; + break; } pskybits=3; @@ -285,72 +285,72 @@ const char *ExtGetSectorCaption(short sectnum) { switch (sector[sectnum].lotag) { - case 1 : - Bsprintf(lo,"1 WATER (SE 7)"); - break; - case 2 : - Bsprintf(lo,"2 UNDERWATER (SE 7)"); - break; - case 9 : - Bsprintf(lo,"9 STAR TREK DOORS"); - break; - case 15 : - Bsprintf(lo,"15 ELEVATOR TRANSPORT (SE 17)"); - break; - case 16 : - Bsprintf(lo,"16 ELEVATOR PLATFORM DOWN"); - break; - case 17 : - Bsprintf(lo,"17 ELEVATOR PLATFORM UP"); - break; - case 18 : - Bsprintf(lo,"18 ELEVATOR DOWN"); - break; - case 19 : - Bsprintf(lo,"19 ELEVATOR UP"); - break; - case 20 : - Bsprintf(lo,"20 CEILING DOOR"); - break; - case 21 : - Bsprintf(lo,"21 FLOOR DOOR"); - break; - case 22 : - Bsprintf(lo,"22 SPLIT DOOR"); - break; - case 23 : - Bsprintf(lo,"23 SWING DOOR (SE 11)"); - break; - case 25 : - Bsprintf(lo,"25 SLIDE DOOR (SE 15)"); - break; - case 26 : - Bsprintf(lo,"26 SPLIT STAR TREK DOOR"); - break; - case 27 : - Bsprintf(lo,"27 BRIDGE (SE 20)"); - break; - case 28 : - Bsprintf(lo,"28 DROP FLOOR (SE 21)"); - break; - case 29 : - Bsprintf(lo,"29 TEETH DOOR (SE 22)"); - break; - case 30 : - Bsprintf(lo,"30 ROTATE RISE BRIDGE"); - break; - case 31 : - Bsprintf(lo,"31 2 WAY TRAIN (SE=30)"); - break; - case 32767 : - Bsprintf(lo,"32767 SECRET ROOM"); - break; - case 65535 : - Bsprintf(lo,"65535 END OF LEVEL"); - break; - default : - Bsprintf(lo,"%hu",sector[sectnum].lotag); - break; + case 1 : + Bsprintf(lo,"1 WATER (SE 7)"); + break; + case 2 : + Bsprintf(lo,"2 UNDERWATER (SE 7)"); + break; + case 9 : + Bsprintf(lo,"9 STAR TREK DOORS"); + break; + case 15 : + Bsprintf(lo,"15 ELEVATOR TRANSPORT (SE 17)"); + break; + case 16 : + Bsprintf(lo,"16 ELEVATOR PLATFORM DOWN"); + break; + case 17 : + Bsprintf(lo,"17 ELEVATOR PLATFORM UP"); + break; + case 18 : + Bsprintf(lo,"18 ELEVATOR DOWN"); + break; + case 19 : + Bsprintf(lo,"19 ELEVATOR UP"); + break; + case 20 : + Bsprintf(lo,"20 CEILING DOOR"); + break; + case 21 : + Bsprintf(lo,"21 FLOOR DOOR"); + break; + case 22 : + Bsprintf(lo,"22 SPLIT DOOR"); + break; + case 23 : + Bsprintf(lo,"23 SWING DOOR (SE 11)"); + break; + case 25 : + Bsprintf(lo,"25 SLIDE DOOR (SE 15)"); + break; + case 26 : + Bsprintf(lo,"26 SPLIT STAR TREK DOOR"); + break; + case 27 : + Bsprintf(lo,"27 BRIDGE (SE 20)"); + break; + case 28 : + Bsprintf(lo,"28 DROP FLOOR (SE 21)"); + break; + case 29 : + Bsprintf(lo,"29 TEETH DOOR (SE 22)"); + break; + case 30 : + Bsprintf(lo,"30 ROTATE RISE BRIDGE"); + break; + case 31 : + Bsprintf(lo,"31 2 WAY TRAIN (SE=30)"); + break; + case 32767 : + Bsprintf(lo,"32767 SECRET ROOM"); + break; + case 65535 : + Bsprintf(lo,"65535 END OF LEVEL"); + break; + default : + Bsprintf(lo,"%hu",sector[sectnum].lotag); + break; } if (sector[sectnum].lotag > 10000 && sector[sectnum].lotag < 32767) Bsprintf(lo,"%d 1 TIME SOUND",sector[sectnum].lotag); @@ -386,108 +386,108 @@ const char *SectorEffectorText(short spritenum) { switch (sprite[spritenum].lotag) { - case 0: - Bsprintf(tempbuf,"SE: ROTATED SECTOR"); - break; - case 1: - Bsprintf(tempbuf,"SE: PIVOT SPRITE FOR SE 0"); - break; - case 2: - Bsprintf(tempbuf,"SE: EARTHQUAKE"); - break; - case 3: - Bsprintf(tempbuf,"SE: RANDOM LIGHTS AFTER SHOT OUT"); - break; - case 4: - Bsprintf(tempbuf,"SE: RANDOM LIGHTS"); - break; - case 6: - Bsprintf(tempbuf,"SE: SUBWAY"); - break; - case 7: - Bsprintf(tempbuf,"SE: TRANSPORT"); - break; - case 8: - Bsprintf(tempbuf,"SE: UP OPEN DOOR LIGHTS"); - break; - case 9: - Bsprintf(tempbuf,"SE: DOWN OPEN DOOR LIGHTS"); - break; - case 10: - Bsprintf(tempbuf,"SE: DOOR AUTO CLOSE (H=DELAY)"); - break; - case 11: - Bsprintf(tempbuf,"SE: ROTATE SECTOR DOOR"); - break; - case 12: - Bsprintf(tempbuf,"SE: LIGHT SWITCH"); - break; - case 13: - Bsprintf(tempbuf,"SE: EXPLOSIVE"); - break; - case 14: - Bsprintf(tempbuf,"SE: SUBWAY CAR"); - break; - case 15: - Bsprintf(tempbuf,"SE: SLIDE DOOR (ST 25)"); - break; - case 16: - Bsprintf(tempbuf,"SE: ROTATE REACTOR SECTOR"); - break; - case 17: - Bsprintf(tempbuf,"SE: ELEVATOR TRANSPORT (ST 15)"); - break; - case 18: - Bsprintf(tempbuf,"SE: INCREMENTAL SECTOR RISE/FALL"); - break; - case 19: - Bsprintf(tempbuf,"SE: CEILING FALL ON EXPLOSION"); - break; - case 20: - Bsprintf(tempbuf,"SE: BRIDGE (ST 27)"); - break; - case 21: - Bsprintf(tempbuf,"SE: DROP FLOOR (ST 28)"); - break; - case 22: - Bsprintf(tempbuf,"SE: TEETH DOOR (ST 29)"); - break; - case 23: - Bsprintf(tempbuf,"SE: 1-WAY SE7 DESTINATION (H=SE 7)"); - break; - case 24: - Bsprintf(tempbuf,"SE: CONVAYER BELT"); - break; - case 25: - Bsprintf(tempbuf,"SE: ENGINE"); - break; - case 28: - Bsprintf(tempbuf,"SE: LIGHTNING (H= TILE#4890)"); - break; - case 27: - Bsprintf(tempbuf,"SE: CAMERA FOR PLAYBACK"); - break; - case 29: - Bsprintf(tempbuf,"SE: FLOAT"); - break; - case 30: - Bsprintf(tempbuf,"SE: 2 WAY TRAIN (ST=31)"); - break; - case 31: - Bsprintf(tempbuf,"SE: FLOOR RISE"); - break; - case 32: - Bsprintf(tempbuf,"SE: CEILING FALL"); - break; - case 33: - Bsprintf(tempbuf,"SE: SPAWN JIB W/QUAKE"); - break; - case 36: - Bsprintf(tempbuf,"SE: SKRINK RAY SHOOTER"); - break; - default: - SpriteName(spritenum,tempbuf); - break; + case 0: + Bsprintf(tempbuf,"SE: ROTATED SECTOR"); + break; + case 1: + Bsprintf(tempbuf,"SE: PIVOT SPRITE FOR SE 0"); + break; + case 2: + Bsprintf(tempbuf,"SE: EARTHQUAKE"); + break; + case 3: + Bsprintf(tempbuf,"SE: RANDOM LIGHTS AFTER SHOT OUT"); + break; + case 4: + Bsprintf(tempbuf,"SE: RANDOM LIGHTS"); + break; + case 6: + Bsprintf(tempbuf,"SE: SUBWAY"); + break; + case 7: + Bsprintf(tempbuf,"SE: TRANSPORT"); + break; + case 8: + Bsprintf(tempbuf,"SE: UP OPEN DOOR LIGHTS"); + break; + case 9: + Bsprintf(tempbuf,"SE: DOWN OPEN DOOR LIGHTS"); + break; + case 10: + Bsprintf(tempbuf,"SE: DOOR AUTO CLOSE (H=DELAY)"); + break; + case 11: + Bsprintf(tempbuf,"SE: ROTATE SECTOR DOOR"); + break; + case 12: + Bsprintf(tempbuf,"SE: LIGHT SWITCH"); + break; + case 13: + Bsprintf(tempbuf,"SE: EXPLOSIVE"); + break; + case 14: + Bsprintf(tempbuf,"SE: SUBWAY CAR"); + break; + case 15: + Bsprintf(tempbuf,"SE: SLIDE DOOR (ST 25)"); + break; + case 16: + Bsprintf(tempbuf,"SE: ROTATE REACTOR SECTOR"); + break; + case 17: + Bsprintf(tempbuf,"SE: ELEVATOR TRANSPORT (ST 15)"); + break; + case 18: + Bsprintf(tempbuf,"SE: INCREMENTAL SECTOR RISE/FALL"); + break; + case 19: + Bsprintf(tempbuf,"SE: CEILING FALL ON EXPLOSION"); + break; + case 20: + Bsprintf(tempbuf,"SE: BRIDGE (ST 27)"); + break; + case 21: + Bsprintf(tempbuf,"SE: DROP FLOOR (ST 28)"); + break; + case 22: + Bsprintf(tempbuf,"SE: TEETH DOOR (ST 29)"); + break; + case 23: + Bsprintf(tempbuf,"SE: 1-WAY SE7 DESTINATION (H=SE 7)"); + break; + case 24: + Bsprintf(tempbuf,"SE: CONVAYER BELT"); + break; + case 25: + Bsprintf(tempbuf,"SE: ENGINE"); + break; + case 28: + Bsprintf(tempbuf,"SE: LIGHTNING (H= TILE#4890)"); + break; + case 27: + Bsprintf(tempbuf,"SE: CAMERA FOR PLAYBACK"); + break; + case 29: + Bsprintf(tempbuf,"SE: FLOAT"); + break; + case 30: + Bsprintf(tempbuf,"SE: 2 WAY TRAIN (ST=31)"); + break; + case 31: + Bsprintf(tempbuf,"SE: FLOOR RISE"); + break; + case 32: + Bsprintf(tempbuf,"SE: CEILING FALL"); + break; + case 33: + Bsprintf(tempbuf,"SE: SPAWN JIB W/QUAKE"); + break; + case 36: + Bsprintf(tempbuf,"SE: SKRINK RAY SHOOTER"); + break; + default: + SpriteName(spritenum,tempbuf); + break; } return (tempbuf); } @@ -504,41 +504,41 @@ const char *ExtGetSpriteCaption(short spritenum) { switch (sprite[spritenum].picnum) { - case FIRSTGUNSPRITE: - case CHAINGUNSPRITE : - case RPGSPRITE: - case FREEZESPRITE: - case SHRINKERSPRITE: - case HEAVYHBOMB: - case TRIPBOMBSPRITE: - case SHOTGUNSPRITE: - case DEVISTATORSPRITE: - case FREEZEAMMO: - case AMMO: - case BATTERYAMMO: - case DEVISTATORAMMO: - case RPGAMMO: - case GROWAMMO: - case CRYSTALAMMO: - case HBOMBAMMO: - case AMMOLOTS: - case SHOTGUNAMMO: - case COLA: - case SIXPAK: - case FIRSTAID: - case SHIELD: - case STEROIDS: - case AIRTANK: - case JETPACK: - case HEATSENSOR: - case ACCESSCARD: - case BOOTS: - break; - default: - { - tempbuf[0] = 0; - return(tempbuf); - } + case FIRSTGUNSPRITE: + case CHAINGUNSPRITE : + case RPGSPRITE: + case FREEZESPRITE: + case SHRINKERSPRITE: + case HEAVYHBOMB: + case TRIPBOMBSPRITE: + case SHOTGUNSPRITE: + case DEVISTATORSPRITE: + case FREEZEAMMO: + case AMMO: + case BATTERYAMMO: + case DEVISTATORAMMO: + case RPGAMMO: + case GROWAMMO: + case CRYSTALAMMO: + case HBOMBAMMO: + case AMMOLOTS: + case SHOTGUNAMMO: + case COLA: + case SIXPAK: + case FIRSTAID: + case SHIELD: + case STEROIDS: + case AIRTANK: + case JETPACK: + case HEATSENSOR: + case ACCESSCARD: + case BOOTS: + break; + default: + { + tempbuf[0] = 0; + return(tempbuf); + } } } @@ -625,48 +625,48 @@ void ExtShowSectorData(short sectnum) //F5 { switch (sprite[i].picnum) { - case RECON: - case DRONE: - case LIZTROOPONTOILET: - case LIZTROOPSTAYPUT: - case LIZTROOPSHOOT: - case LIZTROOPJETPACK: - case LIZTROOPDUCKING: - case LIZTROOPRUNNING: - case LIZTROOP: - case OCTABRAIN: - case OCTABRAINSTAYPUT: - case COMMANDER: - case COMMANDERSTAYPUT: - case EGG: - case PIGCOP: - case PIGCOPSTAYPUT: - case PIGCOPDIVE: - case LIZMAN: - case LIZMANSTAYPUT: - case LIZMANSPITTING: - case LIZMANFEEDING: - case LIZMANJUMP: - case ORGANTIC: - case BOSS1: - case BOSS2: - case BOSS3: - case GREENSLIME: - case ROTATEGUN: - case TANK: - case NEWBEAST: - case BOSS4: - if (sprite[i].lotag<=1) totalactors1++; - if (sprite[i].lotag<=2) totalactors2++; - if (sprite[i].lotag<=3) totalactors3++; - if (sprite[i].lotag<=4) totalactors4++; - break; + case RECON: + case DRONE: + case LIZTROOPONTOILET: + case LIZTROOPSTAYPUT: + case LIZTROOPSHOOT: + case LIZTROOPJETPACK: + case LIZTROOPDUCKING: + case LIZTROOPRUNNING: + case LIZTROOP: + case OCTABRAIN: + case OCTABRAINSTAYPUT: + case COMMANDER: + case COMMANDERSTAYPUT: + case EGG: + case PIGCOP: + case PIGCOPSTAYPUT: + case PIGCOPDIVE: + case LIZMAN: + case LIZMANSTAYPUT: + case LIZMANSPITTING: + case LIZMANFEEDING: + case LIZMANJUMP: + case ORGANTIC: + case BOSS1: + case BOSS2: + case BOSS3: + case GREENSLIME: + case ROTATEGUN: + case TANK: + case NEWBEAST: + case BOSS4: + if (sprite[i].lotag<=1) totalactors1++; + if (sprite[i].lotag<=2) totalactors2++; + if (sprite[i].lotag<=3) totalactors3++; + if (sprite[i].lotag<=4) totalactors4++; + break; - case RESPAWN: - totalrespawn++; + case RESPAWN: + totalrespawn++; - default: - break; + default: + break; } } } @@ -801,43 +801,43 @@ void ExtShowWallData(short wallnum) //F6 if (sprite[i].statnum==0) switch (sprite[i].picnum) { - //LOTAG - case ACTIVATOR: - case ACTIVATORLOCKED: - case TOUCHPLATE: - case MASTERSWITCH: - case RESPAWN: - case ACCESSSWITCH: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACEDOORSWITCH: - case SPACELIGHTSWITCH: - case FRANKENSTINESWITCH: - case MULTISWITCH: - case DIPSWITCH: - case DIPSWITCH2: - case TECHSWITCH: - case DIPSWITCH3: - case ACCESSSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - case PULLSWITCH: - case ALIENSWITCH: - if (sprite[i].lotag>nextfreetag) nextfreetag=1+sprite[i].lotag; - break; + //LOTAG + case ACTIVATOR: + case ACTIVATORLOCKED: + case TOUCHPLATE: + case MASTERSWITCH: + case RESPAWN: + case ACCESSSWITCH: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACEDOORSWITCH: + case SPACELIGHTSWITCH: + case FRANKENSTINESWITCH: + case MULTISWITCH: + case DIPSWITCH: + case DIPSWITCH2: + case TECHSWITCH: + case DIPSWITCH3: + case ACCESSSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + case PULLSWITCH: + case ALIENSWITCH: + if (sprite[i].lotag>nextfreetag) nextfreetag=1+sprite[i].lotag; + break; - //HITAG - case SEENINE: - case OOZFILTER: - case SECTOREFFECTOR: - if (sprite[i].lotag==10 || sprite[i].lotag==27 || sprite[i].lotag==28 || sprite[i].lotag==29) - break; - else - if (sprite[i].hitag>nextfreetag) nextfreetag=1+sprite[i].hitag; - break; - default: + //HITAG + case SEENINE: + case OOZFILTER: + case SECTOREFFECTOR: + if (sprite[i].lotag==10 || sprite[i].lotag==27 || sprite[i].lotag==28 || sprite[i].lotag==29) break; + else + if (sprite[i].hitag>nextfreetag) nextfreetag=1+sprite[i].hitag; + break; + default: + break; } @@ -853,86 +853,86 @@ void ExtShowWallData(short wallnum) //F6 if (sprite[i].pal!=0) switch (sprite[i].picnum) { - case LIZTROOP : - case LIZTROOPRUNNING : - case LIZTROOPSTAYPUT : - case LIZTROOPSHOOT : - case LIZTROOPJETPACK : - case LIZTROOPONTOILET : - case LIZTROOPDUCKING : - numsprite[LIZTROOP]++; - break; - case BOSS1: - case BOSS1STAYPUT: - case BOSS1SHOOT: - case BOSS1LOB: - case BOSSTOP: - multisprite[BOSS1]++; - break; - case BOSS2: - multisprite[BOSS2]++; - break; - case BOSS3: - multisprite[BOSS3]++; - break; + case LIZTROOP : + case LIZTROOPRUNNING : + case LIZTROOPSTAYPUT : + case LIZTROOPSHOOT : + case LIZTROOPJETPACK : + case LIZTROOPONTOILET : + case LIZTROOPDUCKING : + numsprite[LIZTROOP]++; + break; + case BOSS1: + case BOSS1STAYPUT: + case BOSS1SHOOT: + case BOSS1LOB: + case BOSSTOP: + multisprite[BOSS1]++; + break; + case BOSS2: + multisprite[BOSS2]++; + break; + case BOSS3: + multisprite[BOSS3]++; + break; - default: - break; + default: + break; } else switch (sprite[i].picnum) { - case LIZTROOP : - case LIZTROOPRUNNING : - case LIZTROOPSTAYPUT : - case LIZTROOPSHOOT : - case LIZTROOPJETPACK : - case LIZTROOPONTOILET : - case LIZTROOPDUCKING : - numsprite[LIZTROOP]++; - break; - case PIGCOP: - case PIGCOPSTAYPUT: - case PIGCOPDIVE: - numsprite[PIGCOP]++; - break; - case LIZMAN: - case LIZMANSTAYPUT: - case LIZMANSPITTING: - case LIZMANFEEDING: - case LIZMANJUMP: - numsprite[LIZMAN]++; - break; - case BOSS1: - case BOSS1STAYPUT: - case BOSS1SHOOT: - case BOSS1LOB: - case BOSSTOP: - numsprite[BOSS1]++; - break; - case COMMANDER: - case COMMANDERSTAYPUT: - numsprite[COMMANDER]++; - break; - case OCTABRAIN: - case OCTABRAINSTAYPUT: - numsprite[OCTABRAIN]++; - break; - case RECON: - case DRONE: - case ROTATEGUN: - case EGG: - case ORGANTIC: - case GREENSLIME: - case BOSS2: - case BOSS3: - case TANK: - case NEWBEAST: - case BOSS4: + case LIZTROOP : + case LIZTROOPRUNNING : + case LIZTROOPSTAYPUT : + case LIZTROOPSHOOT : + case LIZTROOPJETPACK : + case LIZTROOPONTOILET : + case LIZTROOPDUCKING : + numsprite[LIZTROOP]++; + break; + case PIGCOP: + case PIGCOPSTAYPUT: + case PIGCOPDIVE: + numsprite[PIGCOP]++; + break; + case LIZMAN: + case LIZMANSTAYPUT: + case LIZMANSPITTING: + case LIZMANFEEDING: + case LIZMANJUMP: + numsprite[LIZMAN]++; + break; + case BOSS1: + case BOSS1STAYPUT: + case BOSS1SHOOT: + case BOSS1LOB: + case BOSSTOP: + numsprite[BOSS1]++; + break; + case COMMANDER: + case COMMANDERSTAYPUT: + numsprite[COMMANDER]++; + break; + case OCTABRAIN: + case OCTABRAINSTAYPUT: + numsprite[OCTABRAIN]++; + break; + case RECON: + case DRONE: + case ROTATEGUN: + case EGG: + case ORGANTIC: + case GREENSLIME: + case BOSS2: + case BOSS3: + case TANK: + case NEWBEAST: + case BOSS4: - numsprite[sprite[i].picnum]++; - default: - break; + numsprite[sprite[i].picnum]++; + default: + break; }// end switch }// end if @@ -978,57 +978,57 @@ void ExtShowWallData(short wallnum) //F6 { switch (sprite[i].hitag) { - case LIZTROOP : - case LIZTROOPRUNNING : - case LIZTROOPSTAYPUT : - case LIZTROOPSHOOT : - case LIZTROOPJETPACK : - case LIZTROOPONTOILET : - case LIZTROOPDUCKING : - numsprite[LIZTROOP]++; - break; - case PIGCOP: - case PIGCOPSTAYPUT: - case PIGCOPDIVE: - numsprite[PIGCOP]++; - break; - case LIZMAN: - case LIZMANSTAYPUT: - case LIZMANSPITTING: - case LIZMANFEEDING: - case LIZMANJUMP: - numsprite[LIZMAN]++; - break; - case BOSS1: - case BOSS1STAYPUT: - case BOSS1SHOOT: - case BOSS1LOB: - case BOSSTOP: - if (sprite[i].pal!=0) multisprite[BOSS1]++; - else numsprite[BOSS1]++; - break; - case COMMANDER: - case COMMANDERSTAYPUT: - numsprite[COMMANDER]++; - break; - case OCTABRAIN: - case OCTABRAINSTAYPUT: - numsprite[OCTABRAIN]++; - break; - case RECON: - case DRONE: - case ROTATEGUN: - case EGG: - case ORGANTIC: - case GREENSLIME: - case BOSS2: - case BOSS3: - case TANK: - case NEWBEAST: - case BOSS4: - numsprite[sprite[i].hitag]++; - default: - break; + case LIZTROOP : + case LIZTROOPRUNNING : + case LIZTROOPSTAYPUT : + case LIZTROOPSHOOT : + case LIZTROOPJETPACK : + case LIZTROOPONTOILET : + case LIZTROOPDUCKING : + numsprite[LIZTROOP]++; + break; + case PIGCOP: + case PIGCOPSTAYPUT: + case PIGCOPDIVE: + numsprite[PIGCOP]++; + break; + case LIZMAN: + case LIZMANSTAYPUT: + case LIZMANSPITTING: + case LIZMANFEEDING: + case LIZMANJUMP: + numsprite[LIZMAN]++; + break; + case BOSS1: + case BOSS1STAYPUT: + case BOSS1SHOOT: + case BOSS1LOB: + case BOSSTOP: + if (sprite[i].pal!=0) multisprite[BOSS1]++; + else numsprite[BOSS1]++; + break; + case COMMANDER: + case COMMANDERSTAYPUT: + numsprite[COMMANDER]++; + break; + case OCTABRAIN: + case OCTABRAINSTAYPUT: + numsprite[OCTABRAIN]++; + break; + case RECON: + case DRONE: + case ROTATEGUN: + case EGG: + case ORGANTIC: + case GREENSLIME: + case BOSS2: + case BOSS3: + case TANK: + case NEWBEAST: + case BOSS4: + numsprite[sprite[i].hitag]++; + default: + break; }//end switch }// end if }// end for @@ -1378,17 +1378,17 @@ void ExtSE40Code(long x,long y,long z,long a,long h) int t = sprite[i].lotag; switch (t) { - // case 40: - // case 41: - // ExtSE40Draw(i,x,y,z,a,h); - // break; - case 42: - case 43: - case 44: - case 45: - if (cursectnum == sprite[i].sectnum) - ExtSE40Draw(i,x,y,z,a,h); - break; + // case 40: + // case 41: + // ExtSE40Draw(i,x,y,z,a,h); + // break; + case 42: + case 43: + case 44: + case 45: + if (cursectnum == sprite[i].sectnum) + ExtSE40Draw(i,x,y,z,a,h); + break; } i++; } @@ -1577,15 +1577,15 @@ void m32_showmouse(void) switch (whitecol) { - case 1: // Shadow Warrior - col = whitecol+mousecol; - break; - case 31: // Duke Nukem 3D - col = whitecol-mousecol; - break; - default: - col = whitecol; - break; + case 1: // Shadow Warrior + col = whitecol+mousecol; + break; + case 31: // Duke Nukem 3D + col = whitecol-mousecol; + break; + default: + col = whitecol; + break; } if (col != whitecol) @@ -1740,37 +1740,37 @@ void Keys3d(void) char msgbuf[2048]; switch (searchstat) { - case 0: - case 4: + case 0: + case 4: + { + long dax, day, dist; + dax = wall[searchwall].x-wall[wall[searchwall].point2].x; + day = wall[searchwall].y-wall[wall[searchwall].point2].y; + dist = ksqrt(dax*dax+day*day); + Bsprintf(msgbuf,"Wall %d: length:%ld lo:%d hi:%d",searchwall,dist,wall[searchwall].lotag,wall[searchwall].hitag); + _message(msgbuf); + break; + } + case 1: + Bsprintf(msgbuf,"Sector %d ceiling: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); + _message(msgbuf); + break; + case 2: + Bsprintf(msgbuf,"Sector %d floor: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); + _message(msgbuf); + break; + case 3: + { + if (strlen(names[sprite[searchwall].picnum]) > 0) { - long dax, day, dist; - dax = wall[searchwall].x-wall[wall[searchwall].point2].x; - day = wall[searchwall].y-wall[wall[searchwall].point2].y; - dist = ksqrt(dax*dax+day*day); - Bsprintf(msgbuf,"Wall %d: length:%ld lo:%d hi:%d",searchwall,dist,wall[searchwall].lotag,wall[searchwall].hitag); - _message(msgbuf); - break; - } - case 1: - Bsprintf(msgbuf,"Sector %d ceiling: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); - _message(msgbuf); - break; - case 2: - Bsprintf(msgbuf,"Sector %d floor: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); - _message(msgbuf); - break; - case 3: - { - if (strlen(names[sprite[searchwall].picnum]) > 0) - { - if (sprite[searchwall].picnum==SECTOREFFECTOR) - Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d",searchwall,SectorEffectorText(searchwall),sprite[searchwall].lotag,sprite[searchwall].hitag); - else Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d ex:%d",searchwall,names[sprite[searchwall].picnum],sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); - } - else Bsprintf(msgbuf,"Sprite %d picnum %d: lo:%d hi:%d ex:%d",searchwall,sprite[searchwall].picnum,sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); - _message(msgbuf); - break; + if (sprite[searchwall].picnum==SECTOREFFECTOR) + Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d",searchwall,SectorEffectorText(searchwall),sprite[searchwall].lotag,sprite[searchwall].hitag); + else Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d ex:%d",searchwall,names[sprite[searchwall].picnum],sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); } + else Bsprintf(msgbuf,"Sprite %d picnum %d: lo:%d hi:%d ex:%d",searchwall,sprite[searchwall].picnum,sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); + _message(msgbuf); + break; + } } } @@ -1794,14 +1794,14 @@ void Keys3d(void) keystatus[0x0e] = 0; switch (searchstat) { - case 0: - case 4: - wall[searchwall].cstat = 0; - break; - // case 1: case 2: sector[searchsector].cstat = 0; break; - case 3: - sprite[searchwall].cstat = 0; - break; + case 0: + case 4: + wall[searchwall].cstat = 0; + break; + // case 1: case 2: sector[searchsector].cstat = 0; break; + case 3: + sprite[searchwall].cstat = 0; + break; } } @@ -1984,33 +1984,33 @@ void Keys3d(void) { switch (searchstat) { - case 1: - strcpy(tempbuf,"Sector ceilingz: "); - sector[searchsector].ceilingz = getnumber256(tempbuf,sector[searchsector].ceilingz,8388608,1); - if (!(sector[searchsector].ceilingstat&2)) - sector[searchsector].ceilingheinum = 0; + case 1: + strcpy(tempbuf,"Sector ceilingz: "); + sector[searchsector].ceilingz = getnumber256(tempbuf,sector[searchsector].ceilingz,8388608,1); + if (!(sector[searchsector].ceilingstat&2)) + sector[searchsector].ceilingheinum = 0; - strcpy(tempbuf,"Sector ceiling slope: "); - sector[searchsector].ceilingheinum = getnumber256(tempbuf,sector[searchsector].ceilingheinum,8388608,1); - break; - case 2: - strcpy(tempbuf,"Sector floorz: "); - sector[searchsector].floorz = getnumber256(tempbuf,sector[searchsector].floorz,8388608,1); - if (!(sector[searchsector].floorstat&2)) - sector[searchsector].floorheinum = 0; - strcpy(tempbuf,"Sector floor slope: "); - sector[searchsector].floorheinum = getnumber256(tempbuf,sector[searchsector].floorheinum,8388608,1); - break; - case 3: - strcpy(tempbuf,"Sprite x: "); - sprite[searchwall].x = getnumber256(tempbuf,sprite[searchwall].x,131072,1); - strcpy(tempbuf,"Sprite y: "); - sprite[searchwall].y = getnumber256(tempbuf,sprite[searchwall].y,131072,1); - strcpy(tempbuf,"Sprite z: "); - sprite[searchwall].z = getnumber256(tempbuf,sprite[searchwall].z,8388608,1); - strcpy(tempbuf,"Sprite angle: "); - sprite[searchwall].ang = getnumber256(tempbuf,sprite[searchwall].ang,2048L,0); - break; + strcpy(tempbuf,"Sector ceiling slope: "); + sector[searchsector].ceilingheinum = getnumber256(tempbuf,sector[searchsector].ceilingheinum,8388608,1); + break; + case 2: + strcpy(tempbuf,"Sector floorz: "); + sector[searchsector].floorz = getnumber256(tempbuf,sector[searchsector].floorz,8388608,1); + if (!(sector[searchsector].floorstat&2)) + sector[searchsector].floorheinum = 0; + strcpy(tempbuf,"Sector floor slope: "); + sector[searchsector].floorheinum = getnumber256(tempbuf,sector[searchsector].floorheinum,8388608,1); + break; + case 3: + strcpy(tempbuf,"Sprite x: "); + sprite[searchwall].x = getnumber256(tempbuf,sprite[searchwall].x,131072,1); + strcpy(tempbuf,"Sprite y: "); + sprite[searchwall].y = getnumber256(tempbuf,sprite[searchwall].y,131072,1); + strcpy(tempbuf,"Sprite z: "); + sprite[searchwall].z = getnumber256(tempbuf,sprite[searchwall].z,8388608,1); + strcpy(tempbuf,"Sprite angle: "); + sprite[searchwall].ang = getnumber256(tempbuf,sprite[searchwall].ang,2048L,0); + break; } if (sector[searchsector].ceilingheinum == 0) sector[searchsector].ceilingstat &= ~2; @@ -2042,23 +2042,23 @@ void Keys3d(void) { switch (searchstat) { - case 0: - case 4: - strcpy(buffer,"Wall extra: "); - wall[searchwall].extra = getnumber256(buffer,(long)wall[searchwall].extra,65536L,1); - break; - case 1: - strcpy(buffer,"Sector extra: "); - sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); - break; - case 2: - strcpy(buffer,"Sector extra: "); - sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); - break; - case 3: - strcpy(buffer,"Sprite extra: "); - sprite[searchwall].extra = getnumber256(buffer,(long)sprite[searchwall].extra,65536L,1); - break; + case 0: + case 4: + strcpy(buffer,"Wall extra: "); + wall[searchwall].extra = getnumber256(buffer,(long)wall[searchwall].extra,65536L,1); + break; + case 1: + strcpy(buffer,"Sector extra: "); + sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + break; + case 2: + strcpy(buffer,"Sector extra: "); + sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + break; + case 3: + strcpy(buffer,"Sprite extra: "); + sprite[searchwall].extra = getnumber256(buffer,(long)sprite[searchwall].extra,65536L,1); + break; } asksave = 1; keystatus[KEYSC_M] = 0; @@ -2181,23 +2181,23 @@ void Keys3d(void) { switch (searchstat) { - case 0: - case 4: - strcpy(buffer,"Wall hitag: "); - wall[searchwall].hitag = getnumber256(buffer,(long)wall[searchwall].hitag,65536L,0); - break; - case 1: - strcpy(buffer,"Sector hitag: "); - sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); - break; - case 2: - strcpy(buffer,"Sector hitag: "); - sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); - break; - case 3: - strcpy(buffer,"Sprite hitag: "); - sprite[searchwall].hitag = getnumber256(buffer,(long)sprite[searchwall].hitag,65536L,0); - break; + case 0: + case 4: + strcpy(buffer,"Wall hitag: "); + wall[searchwall].hitag = getnumber256(buffer,(long)wall[searchwall].hitag,65536L,0); + break; + case 1: + strcpy(buffer,"Sector hitag: "); + sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + break; + case 2: + strcpy(buffer,"Sector hitag: "); + sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + break; + case 3: + strcpy(buffer,"Sprite hitag: "); + sprite[searchwall].hitag = getnumber256(buffer,(long)sprite[searchwall].hitag,65536L,0); + break; } } @@ -2497,51 +2497,51 @@ void Keys3d(void) j = i = (keystatus[KEYSC_EQUAL]|(bstatus&32))?1:-1; switch (searchstat) { - case 0: - while (!tilesizx[wall[searchwall].picnum]||!tilesizy[wall[searchwall].picnum]||j) - { - if (wall[searchwall].picnum+i >= MAXTILES) wall[searchwall].picnum = 0; - else if (wall[searchwall].picnum+i < 0) wall[searchwall].picnum = MAXTILES-1; - else wall[searchwall].picnum += i; - j = 0; - } - break; - case 1: - while (!tilesizx[sector[searchsector].ceilingpicnum]||!tilesizy[sector[searchsector].ceilingpicnum]||j) - { - if (sector[searchsector].ceilingpicnum+i >= MAXTILES) sector[searchsector].ceilingpicnum = 0; - else if (sector[searchsector].ceilingpicnum+i < 0) sector[searchsector].ceilingpicnum = MAXTILES-1; - else sector[searchsector].ceilingpicnum += i; - j = 0; - } - break; - case 2: - while (!tilesizx[sector[searchsector].floorpicnum]||!tilesizy[sector[searchsector].floorpicnum]||j) - { - if (sector[searchsector].floorpicnum+i >= MAXTILES) sector[searchsector].floorpicnum = 0; - else if (sector[searchsector].floorpicnum+i < 0) sector[searchsector].floorpicnum = MAXTILES-1; - else sector[searchsector].floorpicnum += i; - j = 0; - } - break; - case 3: - while (!tilesizx[sprite[searchwall].picnum]||!tilesizy[sprite[searchwall].picnum]||j) - { - if (sprite[searchwall].picnum+i >= MAXTILES) sprite[searchwall].picnum = 0; - else if (sprite[searchwall].picnum+i < 0) sprite[searchwall].picnum = MAXTILES-1; - else sprite[searchwall].picnum += i; - j = 0; - } - break; - case 4: - while (!tilesizx[wall[searchwall].overpicnum]||!tilesizy[wall[searchwall].overpicnum]||j) - { - if (wall[searchwall].overpicnum+i >= MAXTILES) wall[searchwall].overpicnum = 0; - else if (wall[searchwall].overpicnum+i < 0) wall[searchwall].overpicnum = MAXTILES-1; - else wall[searchwall].overpicnum += i; - j = 0; - } - break; + case 0: + while (!tilesizx[wall[searchwall].picnum]||!tilesizy[wall[searchwall].picnum]||j) + { + if (wall[searchwall].picnum+i >= MAXTILES) wall[searchwall].picnum = 0; + else if (wall[searchwall].picnum+i < 0) wall[searchwall].picnum = MAXTILES-1; + else wall[searchwall].picnum += i; + j = 0; + } + break; + case 1: + while (!tilesizx[sector[searchsector].ceilingpicnum]||!tilesizy[sector[searchsector].ceilingpicnum]||j) + { + if (sector[searchsector].ceilingpicnum+i >= MAXTILES) sector[searchsector].ceilingpicnum = 0; + else if (sector[searchsector].ceilingpicnum+i < 0) sector[searchsector].ceilingpicnum = MAXTILES-1; + else sector[searchsector].ceilingpicnum += i; + j = 0; + } + break; + case 2: + while (!tilesizx[sector[searchsector].floorpicnum]||!tilesizy[sector[searchsector].floorpicnum]||j) + { + if (sector[searchsector].floorpicnum+i >= MAXTILES) sector[searchsector].floorpicnum = 0; + else if (sector[searchsector].floorpicnum+i < 0) sector[searchsector].floorpicnum = MAXTILES-1; + else sector[searchsector].floorpicnum += i; + j = 0; + } + break; + case 3: + while (!tilesizx[sprite[searchwall].picnum]||!tilesizy[sprite[searchwall].picnum]||j) + { + if (sprite[searchwall].picnum+i >= MAXTILES) sprite[searchwall].picnum = 0; + else if (sprite[searchwall].picnum+i < 0) sprite[searchwall].picnum = MAXTILES-1; + else sprite[searchwall].picnum += i; + j = 0; + } + break; + case 4: + while (!tilesizx[wall[searchwall].overpicnum]||!tilesizy[wall[searchwall].overpicnum]||j) + { + if (wall[searchwall].overpicnum+i >= MAXTILES) wall[searchwall].overpicnum = 0; + else if (wall[searchwall].overpicnum+i < 0) wall[searchwall].overpicnum = MAXTILES-1; + else wall[searchwall].overpicnum += i; + j = 0; + } + break; } asksave = 1; keystatus[KEYSC_DASH] = keystatus[KEYSC_EQUAL] = 0; @@ -2634,18 +2634,18 @@ void Keys3d(void) i = ((i>>3)&1)+((i>>7)&2); //3-x,8-y switch (i) { - case 0: - i = 1; - break; - case 1: - i = 3; - break; - case 2: - i = 0; - break; - case 3: - i = 2; - break; + case 0: + i = 1; + break; + case 1: + i = 3; + break; + case 2: + i = 0; + break; + case 3: + i = 2; + break; } i = ((i&1)<<3)+((i&2)<<7); wall[searchwall].cstat &= ~0x0108; @@ -2658,30 +2658,30 @@ void Keys3d(void) i = (i&0x4)+((i>>4)&3); switch (i) { - case 0: - i = 6; - break; - case 6: - i = 3; - break; - case 3: - i = 5; - break; - case 5: - i = 1; - break; - case 1: - i = 7; - break; - case 7: - i = 2; - break; - case 2: - i = 4; - break; - case 4: - i = 0; - break; + case 0: + i = 6; + break; + case 6: + i = 3; + break; + case 3: + i = 5; + break; + case 5: + i = 1; + break; + case 1: + i = 7; + break; + case 7: + i = 2; + break; + case 2: + i = 4; + break; + case 4: + i = 0; + break; } i = (i&0x4)+((i&3)<<4); sector[searchsector].ceilingstat &= ~0x34; @@ -2694,30 +2694,30 @@ void Keys3d(void) i = (i&0x4)+((i>>4)&3); switch (i) { - case 0: - i = 6; - break; - case 6: - i = 3; - break; - case 3: - i = 5; - break; - case 5: - i = 1; - break; - case 1: - i = 7; - break; - case 7: - i = 2; - break; - case 2: - i = 4; - break; - case 4: - i = 0; - break; + case 0: + i = 6; + break; + case 6: + i = 3; + break; + case 3: + i = 5; + break; + case 5: + i = 1; + break; + case 1: + i = 7; + break; + case 7: + i = 2; + break; + case 2: + i = 4; + break; + case 4: + i = 0; + break; } i = (i&0x4)+((i&3)<<4); sector[searchsector].floorstat &= ~0x34; @@ -2737,18 +2737,18 @@ void Keys3d(void) i = ((i>>2)&3); switch (i) { - case 0: - i = 1; - break; - case 1: - i = 3; - break; - case 2: - i = 0; - break; - case 3: - i = 2; - break; + case 0: + i = 1; + break; + case 1: + i = 3; + break; + case 2: + i = 0; + break; + case 3: + i = 2; + break; } i <<= 2; sprite[searchwall].cstat &= ~0xc; @@ -3103,30 +3103,30 @@ void Keys3d(void) enddrawing(); switch (i) { - case 8: - Bsprintf(tempbuf,"%d",autosave); - break; - case 9: - Bsprintf(tempbuf,"%s",SKILLMODE[skill]); - break; - case 10: - Bsprintf(tempbuf,"%d",tabgraphic); - break; - case 11: - Bsprintf(tempbuf,"%d",framerateon); - break; - case 12: - Bsprintf(tempbuf,"%s",SPRDSPMODE[nosprites]); - break; - case 13: - Bsprintf(tempbuf,"%d",shadepreview); - break; - case 14: - Bsprintf(tempbuf,"%d",purpleon); - break; - default : - sprintf(tempbuf," "); - break; + case 8: + Bsprintf(tempbuf,"%d",autosave); + break; + case 9: + Bsprintf(tempbuf,"%s",SKILLMODE[skill]); + break; + case 10: + Bsprintf(tempbuf,"%d",tabgraphic); + break; + case 11: + Bsprintf(tempbuf,"%d",framerateon); + break; + case 12: + Bsprintf(tempbuf,"%s",SPRDSPMODE[nosprites]); + break; + case 13: + Bsprintf(tempbuf,"%d",shadepreview); + break; + case 14: + Bsprintf(tempbuf,"%d",purpleon); + break; + default : + sprintf(tempbuf," "); + break; } begindrawing(); if (!strcmp(tempbuf,"0")) @@ -3229,39 +3229,39 @@ void Keys3d(void) keystatus[0x2e] = 0; switch (searchstat) { - case 0: - case 4: - for (i=0;iltextptr; switch (tokn) { - case T_LOADGRP: + case T_LOADGRP: + { + char *fn; + if (!scriptfile_getstring(script,&fn)) { - char *fn; - if (!scriptfile_getstring(script,&fn)) - { - int j = initgroupfile(fn); + int j = initgroupfile(fn); - if (j == -1) - initprintf("Could not find GRP file %s.\n",fn); - else - initprintf("Using GRP file %s.\n",fn); - } + if (j == -1) + initprintf("Could not find GRP file %s.\n",fn); + else + initprintf("Using GRP file %s.\n",fn); } + } + break; + case T_EOF: + return(0); + default: break; - case T_EOF: - return(0); - default: - break; } } @@ -4558,8 +4557,8 @@ void ExtAnalyzeSprites(void) if (nosprites==1||nosprites==3) switch (tspr->picnum) { - case SEENINE : - tspr->xrepeat=0; + case SEENINE : + tspr->xrepeat=0; } if (shadepreview && !(tspr->cstat & 16)) @@ -4581,93 +4580,93 @@ void ExtAnalyzeSprites(void) switch (tspr->picnum) { - // 5-frame walk - case 1550 : // Shark - frames=5; - // 2-frame walk - case 1445 : // duke kick - case LIZTROOPDUCKING : - case 2030 : // pig shot - case OCTABRAIN : - case PIGCOPDIVE : - case 2190 : // liz capt shot - case BOSS1SHOOT : - case BOSS1LOB : - case LIZTROOPSHOOT : - if (frames==0) frames=2; + // 5-frame walk + case 1550 : // Shark + frames=5; + // 2-frame walk + case 1445 : // duke kick + case LIZTROOPDUCKING : + case 2030 : // pig shot + case OCTABRAIN : + case PIGCOPDIVE : + case 2190 : // liz capt shot + case BOSS1SHOOT : + case BOSS1LOB : + case LIZTROOPSHOOT : + if (frames==0) frames=2; - // 4-frame walk - case 1491 : // duke crawl - case LIZTROOP : - case LIZTROOPRUNNING : - case PIGCOP : - case LIZMAN : - case BOSS1 : - case BOSS2 : - case BOSS3 : - case BOSS4 : - case NEWBEAST: - if (frames==0) frames=4; - case LIZTROOPJETPACK : - case DRONE : - case COMMANDER : - case TANK : - case RECON : - if (frames==0) frames = 10; - case CAMERA1: - case APLAYER : - if (frames==0) frames=1; - case GREENSLIME : - case EGG : - case PIGCOPSTAYPUT : - case LIZMANSTAYPUT: - case LIZTROOPSTAYPUT : - case LIZMANSPITTING : - case LIZMANFEEDING : - case LIZMANJUMP : - if (skill!=4) - { - if (tspr->lotag>skill+1) - { - tspr->xrepeat=0; - break; - } - } - if (nosprites==2||nosprites==3) + // 4-frame walk + case 1491 : // duke crawl + case LIZTROOP : + case LIZTROOPRUNNING : + case PIGCOP : + case LIZMAN : + case BOSS1 : + case BOSS2 : + case BOSS3 : + case BOSS4 : + case NEWBEAST: + if (frames==0) frames=4; + case LIZTROOPJETPACK : + case DRONE : + case COMMANDER : + case TANK : + case RECON : + if (frames==0) frames = 10; + case CAMERA1: + case APLAYER : + if (frames==0) frames=1; + case GREENSLIME : + case EGG : + case PIGCOPSTAYPUT : + case LIZMANSTAYPUT: + case LIZTROOPSTAYPUT : + case LIZMANSPITTING : + case LIZMANFEEDING : + case LIZMANJUMP : + if (skill!=4) + { + if (tspr->lotag>skill+1) { tspr->xrepeat=0; - // tspr->cstat|=32768; + break; } - // else tspr->cstat&=32767; + } + if (nosprites==2||nosprites==3) + { + tspr->xrepeat=0; + // tspr->cstat|=32768; + } + // else tspr->cstat&=32767; - if (frames!=0) + if (frames!=0) + { + if (frames==10) frames=0; + k = getangle(tspr->x-posx,tspr->y-posy); + k = (((tspr->ang+3072+128-k)&2047)>>8)&7; + //This guy has only 5 pictures for 8 angles (3 are x-flipped) + if (k <= 4) { - if (frames==10) frames=0; - k = getangle(tspr->x-posx,tspr->y-posy); - k = (((tspr->ang+3072+128-k)&2047)>>8)&7; - //This guy has only 5 pictures for 8 angles (3 are x-flipped) - if (k <= 4) - { - tspr->picnum += k; - tspr->cstat &= ~4; //clear x-flipping bit - } - else - { - tspr->picnum += 8-k; - tspr->cstat |= 4; //set x-flipping bit - } + tspr->picnum += k; + tspr->cstat &= ~4; //clear x-flipping bit } + else + { + tspr->picnum += 8-k; + tspr->cstat |= 4; //set x-flipping bit + } + } - if (frames==2) tspr->picnum+=((((4-(totalclock>>5)))&1)*5); - if (frames==4) tspr->picnum+=((((4-(totalclock>>5)))&3)*5); - if (frames==5) tspr->picnum+=(((totalclock>>5)%5))*5; + if (frames==2) tspr->picnum+=((((4-(totalclock>>5)))&1)*5); + if (frames==4) tspr->picnum+=((((4-(totalclock>>5)))&3)*5); + if (frames==5) tspr->picnum+=(((totalclock>>5)%5))*5; - if (tilesizx[tspr->picnum] == 0) - tspr->picnum -= 5; //Hack, for actors + if (tilesizx[tspr->picnum] == 0) + tspr->picnum -= 5; //Hack, for actors - break; - default: - break; + break; + default: + break; } } @@ -5023,152 +5022,152 @@ void EditSectorData(short sectnum) { switch (row) { - case 0: - for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].ceilingstat); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Flags: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingstat = (short)getnumber16(edittext,(long)sector[sectnum].ceilingstat,32768L,0); - } - break; - case 1: - for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].ceilingxpanning,sector[sectnum].ceilingypanning); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Sector (%d) Ceiling X Pan: ",sectnum); - printmessage16(edittext); - sector[sectnum].ceilingxpanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingxpanning,256L,0); - Bsprintf(edittext,"Sector (%d) Ceiling Y Pan: ",sectnum); - printmessage16(edittext); - sector[sectnum].ceilingypanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingypanning,256L,0); - } - break; - case 2: - for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].ceilingshade); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Shade: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingshade = (char)getnumber16(edittext,(long)sector[sectnum].ceilingshade,128L,1); - } - break; + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].ceilingstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Flags: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingstat = (short)getnumber16(edittext,(long)sector[sectnum].ceilingstat,32768L,0); + } + break; + case 1: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].ceilingxpanning,sector[sectnum].ceilingypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sector (%d) Ceiling X Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].ceilingxpanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingxpanning,256L,0); + Bsprintf(edittext,"Sector (%d) Ceiling Y Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].ceilingypanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingypanning,256L,0); + } + break; + case 2: + for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].ceilingshade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Shade: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingshade = (char)getnumber16(edittext,(long)sector[sectnum].ceilingshade,128L,1); + } + break; - case 3: - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].ceilingz); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Z-coordinate: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingz = getnumber16(edittext,sector[sectnum].ceilingz,8388608,1); //2147483647L,-2147483648L - } - break; + case 3: + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].ceilingz); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Z-coordinate: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingz = getnumber16(edittext,sector[sectnum].ceilingz,8388608,1); //2147483647L,-2147483648L + } + break; - case 4: - for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].ceilingpicnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Tile Number: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingpicnum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingpicnum,MAXTILES,0); - } - break; + case 4: + for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].ceilingpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Tile Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingpicnum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingpicnum,MAXTILES,0); + } + break; - case 5: - for (i=Bsprintf(disptext,"Ceiling heinum: %d",sector[sectnum].ceilingheinum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Heinum: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingheinum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingheinum,32768L,1); - } - break; + case 5: + for (i=Bsprintf(disptext,"Ceiling heinum: %d",sector[sectnum].ceilingheinum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Heinum: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingheinum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingheinum,32768L,1); + } + break; - case 6: - for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].ceilingpal); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Ceiling Palookup Number: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].ceilingpal = (char)getnumber16(edittext,(long)sector[sectnum].ceilingpal,MAXPALOOKUPS,0); - } - break; + case 6: + for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].ceilingpal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Palookup Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingpal = (char)getnumber16(edittext,(long)sector[sectnum].ceilingpal,MAXPALOOKUPS,0); + } + break; } } if (col == 2) { switch (row) { - case 0: - for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].floorstat); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Floor Flags: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorstat = (short)getnumber16(edittext,(long)sector[sectnum].floorstat,1024L,0); - } - break; + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].floorstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Flags: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorstat = (short)getnumber16(edittext,(long)sector[sectnum].floorstat,1024L,0); + } + break; - case 1: - for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].floorxpanning,sector[sectnum].floorypanning); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Sector (%d) Floor X Pan: ",sectnum); - printmessage16(edittext); - sector[sectnum].floorxpanning = (char)getnumber16(edittext,(long)sector[sectnum].floorxpanning,256L,0); - Bsprintf(edittext,"Sector (%d) Floor Y Pan: ",sectnum); - printmessage16(edittext); - sector[sectnum].floorypanning = (char)getnumber16(edittext,(long)sector[sectnum].floorypanning,256L,0); - } - break; + case 1: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].floorxpanning,sector[sectnum].floorypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sector (%d) Floor X Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].floorxpanning = (char)getnumber16(edittext,(long)sector[sectnum].floorxpanning,256L,0); + Bsprintf(edittext,"Sector (%d) Floor Y Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].floorypanning = (char)getnumber16(edittext,(long)sector[sectnum].floorypanning,256L,0); + } + break; - case 2: - for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].floorshade); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Floor Shade: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorshade = (char)getnumber16(edittext,(long)sector[sectnum].floorshade,65536L,1L); - } - break; + case 2: + for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].floorshade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Shade: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorshade = (char)getnumber16(edittext,(long)sector[sectnum].floorshade,65536L,1L); + } + break; - case 3: - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].floorz); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Floor Z-coordinate: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorz = getnumber16(edittext,sector[sectnum].floorz,8388608L,1); //2147483647L,-2147483648L - } - break; + case 3: + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].floorz); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Z-coordinate: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorz = getnumber16(edittext,sector[sectnum].floorz,8388608L,1); //2147483647L,-2147483648L + } + break; - case 4: - for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].floorpicnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Floor Tile Number: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorpicnum = (short)getnumber16(edittext,(long)sector[sectnum].floorpicnum,MAXTILES,0); - } - break; - case 5: - for (i=Bsprintf(disptext,"Floor heinum: %d",sector[sectnum].floorheinum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Flooring Heinum: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorheinum = (short)getnumber16(edittext,(long)sector[sectnum].floorheinum,32768L,1); - } - break; - case 6: - for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].floorpal); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sector (%d) Floor Palookup Number: ",sectnum); - if (editval) - { - printmessage16(edittext); - sector[sectnum].floorpal = (char)getnumber16(edittext,(long)sector[sectnum].floorpal,MAXPALOOKUPS,0); - } - break; + case 4: + for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].floorpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Tile Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorpicnum = (short)getnumber16(edittext,(long)sector[sectnum].floorpicnum,MAXTILES,0); + } + break; + case 5: + for (i=Bsprintf(disptext,"Floor heinum: %d",sector[sectnum].floorheinum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Flooring Heinum: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorheinum = (short)getnumber16(edittext,(long)sector[sectnum].floorheinum,32768L,1); + } + break; + case 6: + for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].floorpal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Palookup Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorpal = (char)getnumber16(edittext,(long)sector[sectnum].floorpal,MAXPALOOKUPS,0); + } + break; } } printext16(xpos,ypos+row*8,11,1,disptext,0); @@ -5229,76 +5228,76 @@ void EditWallData(short wallnum) } switch (row) { - case 0: - for (i=Bsprintf(disptext,"Flags (hex): %x",wall[wallnum].cstat); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Wall (%d) Flags: ",wallnum); - if (editval) - { - printmessage16(edittext); - wall[wallnum].cstat = (short)getnumber16(edittext,(long)wall[wallnum].cstat,1024L,0); - } - break; - case 1: - for (i=Bsprintf(disptext,"Shade: %d",wall[wallnum].shade); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Wall (%d) Shade: ",wallnum); - if (editval) - { - printmessage16(edittext); - wall[wallnum].shade = (char)getnumber16(edittext,(long)wall[wallnum].shade,127,1); - } - break; - case 2: - for (i=Bsprintf(disptext,"Pal: %d",wall[wallnum].pal); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Wall (%d) Pal: ",wallnum); - if (editval) - { - printmessage16(edittext); - wall[wallnum].pal = (char)getnumber16(edittext,(long)wall[wallnum].pal,MAXPALOOKUPS,0); - } - break; - case 3: - for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Wall (%d) X Repeat: ",wallnum); - printmessage16(edittext); - wall[wallnum].xrepeat = (char)getnumber16(edittext,(long)wall[wallnum].xrepeat,256L,0); - Bsprintf(edittext,"Wall (%d) Y Repeat: ",wallnum); - printmessage16(edittext); - wall[wallnum].yrepeat = (char)getnumber16(edittext,(long)wall[wallnum].yrepeat,256L,0); - } - break; - case 4: - for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",wall[wallnum].xpanning,wall[wallnum].ypanning); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Wall (%d) X Pan: ",wallnum); - printmessage16(edittext); - wall[wallnum].xpanning = (char)getnumber16(edittext,(long)wall[wallnum].xpanning,256L,0); - Bsprintf(edittext,"Wall (%d) Y Pan: ",wallnum); - printmessage16(edittext); - wall[wallnum].ypanning = (char)getnumber16(edittext,(long)wall[wallnum].ypanning,256L,0); - } - break; - case 5: - for (i=Bsprintf(disptext,"Tile number: %d",wall[wallnum].picnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Wall (%d) Tile number: ",wallnum); - if (editval) - { - printmessage16(edittext); - wall[wallnum].picnum = (short)getnumber16(edittext,(long)wall[wallnum].picnum,MAXTILES,0); - } - break; + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",wall[wallnum].cstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Flags: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].cstat = (short)getnumber16(edittext,(long)wall[wallnum].cstat,1024L,0); + } + break; + case 1: + for (i=Bsprintf(disptext,"Shade: %d",wall[wallnum].shade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Shade: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].shade = (char)getnumber16(edittext,(long)wall[wallnum].shade,127,1); + } + break; + case 2: + for (i=Bsprintf(disptext,"Pal: %d",wall[wallnum].pal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Pal: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].pal = (char)getnumber16(edittext,(long)wall[wallnum].pal,MAXPALOOKUPS,0); + } + break; + case 3: + for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Wall (%d) X Repeat: ",wallnum); + printmessage16(edittext); + wall[wallnum].xrepeat = (char)getnumber16(edittext,(long)wall[wallnum].xrepeat,256L,0); + Bsprintf(edittext,"Wall (%d) Y Repeat: ",wallnum); + printmessage16(edittext); + wall[wallnum].yrepeat = (char)getnumber16(edittext,(long)wall[wallnum].yrepeat,256L,0); + } + break; + case 4: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",wall[wallnum].xpanning,wall[wallnum].ypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Wall (%d) X Pan: ",wallnum); + printmessage16(edittext); + wall[wallnum].xpanning = (char)getnumber16(edittext,(long)wall[wallnum].xpanning,256L,0); + Bsprintf(edittext,"Wall (%d) Y Pan: ",wallnum); + printmessage16(edittext); + wall[wallnum].ypanning = (char)getnumber16(edittext,(long)wall[wallnum].ypanning,256L,0); + } + break; + case 5: + for (i=Bsprintf(disptext,"Tile number: %d",wall[wallnum].picnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Tile number: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].picnum = (short)getnumber16(edittext,(long)wall[wallnum].picnum,MAXTILES,0); + } + break; - case 6: - for (i=Bsprintf(disptext,"OverTile number: %d",wall[wallnum].overpicnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Wall (%d) OverTile number: ",wallnum); - if (editval) - { - printmessage16(edittext); - wall[wallnum].overpicnum = (short)getnumber16(edittext,(long)wall[wallnum].overpicnum,MAXTILES,0); - } - break; + case 6: + for (i=Bsprintf(disptext,"OverTile number: %d",wall[wallnum].overpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) OverTile number: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].overpicnum = (short)getnumber16(edittext,(long)wall[wallnum].overpicnum,MAXTILES,0); + } + break; } printext16(xpos,ypos+row*8,11,1,disptext,0); if (editval) @@ -5360,28 +5359,28 @@ void EditSpriteData(short spritenum) { switch (col) { - case 1: - { - printext16(xpos,ypos+row*8,11,0,disptext,0); - col = 0; - xpos = 8; - rowmax = 4; - dispwidth = 23; - disptext[dispwidth] = 0; - if (row > rowmax) row = rowmax; - } - break; - case 2: - { - printext16(xpos,ypos+row*8,11,0,disptext,0); - col = 1; - xpos = 200; - rowmax = 5; - dispwidth = 24; - disptext[dispwidth] = 0; - if (row > rowmax) row = rowmax; - } - break; + case 1: + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 0; + xpos = 8; + rowmax = 4; + dispwidth = 23; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + break; + case 2: + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 1; + xpos = 200; + rowmax = 5; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + break; } keystatus[0xcb] = 0; } @@ -5389,28 +5388,28 @@ void EditSpriteData(short spritenum) { switch (col) { - case 0: - { - printext16(xpos,ypos+row*8,11,0,disptext,0); - col = 1; - xpos = 200; - rowmax = 5; - dispwidth = 24; - disptext[dispwidth] = 0; - if (row > rowmax) row = rowmax; - } - break; - case 1: - { - printext16(xpos,ypos+row*8,11,0,disptext,0); - col = 2; - xpos = 400; - rowmax = 6; - dispwidth = 26; - disptext[dispwidth] = 0; - if (row > rowmax) row = rowmax; - } - break; + case 0: + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 1; + xpos = 200; + rowmax = 5; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + break; + case 1: + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 2; + xpos = 400; + rowmax = 6; + dispwidth = 26; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + break; } keystatus[0xcd] = 0; } @@ -5421,235 +5420,235 @@ void EditSpriteData(short spritenum) } switch (col) { + case 0: + { + switch (row) + { case 0: { - switch (row) + for (i=Bsprintf(disptext,"X-coordinate: %ld",sprite[spritenum].x); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) X-coordinate: ",spritenum); + if (editval) { - case 0: - { - for (i=Bsprintf(disptext,"X-coordinate: %ld",sprite[spritenum].x); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) X-coordinate: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].x = getnumber16(edittext,sprite[spritenum].x,131072,1); - } - } - break; - case 1: - { - for (i=Bsprintf(disptext,"Y-coordinate: %ld",sprite[spritenum].y); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Y-coordinate: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].y = getnumber16(edittext,sprite[spritenum].y,131072,1); - } - } - break; - case 2: - { - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sprite[spritenum].z); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Z-coordinate: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].z = getnumber16(edittext,sprite[spritenum].z,8388608,1); //2147483647L,-2147483648L - } - } - break; - case 3: - { - for (i=Bsprintf(disptext,"Sectnum: %d",sprite[spritenum].sectnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Sectnum: ",spritenum); - if (editval) - { - printmessage16(edittext); - i = getnumber16(edittext,sprite[spritenum].sectnum,MAXSECTORS-1,0); - if (i != sprite[spritenum].sectnum) - changespritesect(spritenum,i); - } - } - break; - case 4: - { - for (i=Bsprintf(disptext,"Statnum: %d",sprite[spritenum].statnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Statnum: ",spritenum); - if (editval) - { - printmessage16(edittext); - i = getnumber16(edittext,sprite[spritenum].statnum,MAXSTATUS-1,0); - if (i != sprite[spritenum].statnum) - changespritestat(spritenum,i); - } - } - break; + printmessage16(edittext); + sprite[spritenum].x = getnumber16(edittext,sprite[spritenum].x,131072,1); } } break; case 1: { - switch (row) + for (i=Bsprintf(disptext,"Y-coordinate: %ld",sprite[spritenum].y); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Y-coordinate: ",spritenum); + if (editval) { - case 0: - { - for (i=Bsprintf(disptext,"Flags (hex): %x",sprite[spritenum].cstat); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Flags: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].cstat = (short)getnumber16(edittext,(long)sprite[spritenum].cstat,32768L,0); - } - } - break; - case 1: - { - for (i=Bsprintf(disptext,"Shade: %d",sprite[spritenum].shade); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Shade: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].shade = (char)getnumber16(edittext,(long)sprite[spritenum].shade,127,1); - } - } - break; - case 2: - { - for (i=Bsprintf(disptext,"Pal: %d",sprite[spritenum].pal); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Pal: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].pal = (char)getnumber16(edittext,(long)sprite[spritenum].pal,MAXPALOOKUPS,0); - } - } - break; - case 3: - { - for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",sprite[spritenum].xrepeat,sprite[spritenum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Sprite (%d) X Repeat: ",spritenum); - printmessage16(edittext); - sprite[spritenum].xrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].xrepeat,256L,0); - Bsprintf(edittext,"Sprite (%d) Y Repeat: ",spritenum); - printmessage16(edittext); - sprite[spritenum].yrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].yrepeat,256L,0); - } - } - break; - case 4: - { - for (i=Bsprintf(disptext,"(X,Y)offset: %d, %d",sprite[spritenum].xoffset,sprite[spritenum].yoffset); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - Bsprintf(edittext,"Sprite (%d) X Offset: ",spritenum); - printmessage16(edittext); - sprite[spritenum].xoffset = (char)getnumber16(edittext,(long)sprite[spritenum].xoffset,128L,1); - Bsprintf(edittext,"Sprite (%d) Y Offset: ",spritenum); - printmessage16(edittext); - sprite[spritenum].yoffset = (char)getnumber16(edittext,(long)sprite[spritenum].yoffset,128L,1); - } - } - break; - case 5: - { - for (i=Bsprintf(disptext,"Tile number: %d",sprite[spritenum].picnum); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Tile number: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].picnum = (short)getnumber16(edittext,(long)sprite[spritenum].picnum,MAXTILES,0); - } - } - break; + printmessage16(edittext); + sprite[spritenum].y = getnumber16(edittext,sprite[spritenum].y,131072,1); } } break; case 2: { - switch (row) + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sprite[spritenum].z); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Z-coordinate: ",spritenum); + if (editval) { - case 0: - { - for (i=Bsprintf(disptext,"Angle (2048 degrees): %d",sprite[spritenum].ang); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Angle: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].ang = (short)getnumber16(edittext,(long)sprite[spritenum].ang,2048L,0); - } - } - break; - case 1: - { - for (i=Bsprintf(disptext,"X-Velocity: %d",sprite[spritenum].xvel); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) X-Velocity: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].xvel = getnumber16(edittext,(long)sprite[spritenum].xvel,32767,1); - } - } - break; - case 2: - { - for (i=Bsprintf(disptext,"Y-Velocity: %d",sprite[spritenum].yvel); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Y-Velocity: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].yvel = getnumber16(edittext,(long)sprite[spritenum].yvel,32767,1); - } - } - break; - case 3: - { - for (i=Bsprintf(disptext,"Z-Velocity: %d",sprite[spritenum].zvel); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Z-Velocity: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].zvel = getnumber16(edittext,(long)sprite[spritenum].zvel,32767,1); - } - } - break; - case 4: - { - for (i=Bsprintf(disptext,"Owner: %d",sprite[spritenum].owner); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Owner: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].owner = getnumber16(edittext,(long)sprite[spritenum].owner,MAXSPRITES,0); - } - } - break; - case 5: - { - for (i=Bsprintf(disptext,"Clipdist: %d",sprite[spritenum].clipdist); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Clipdist: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].clipdist = (char)getnumber16(edittext,(long)sprite[spritenum].clipdist,255,0); - } - } - break; - case 6: - { - for (i=Bsprintf(disptext,"Extra: %d",sprite[spritenum].extra); i < dispwidth; i++) disptext[i] = ' '; - Bsprintf(edittext,"Sprite (%d) Extra: ",spritenum); - if (editval) - { - printmessage16(edittext); - sprite[spritenum].extra = getnumber16(edittext,(long)sprite[spritenum].extra,32767,1); - } - } - break; + printmessage16(edittext); + sprite[spritenum].z = getnumber16(edittext,sprite[spritenum].z,8388608,1); //2147483647L,-2147483648L } } break; + case 3: + { + for (i=Bsprintf(disptext,"Sectnum: %d",sprite[spritenum].sectnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Sectnum: ",spritenum); + if (editval) + { + printmessage16(edittext); + i = getnumber16(edittext,sprite[spritenum].sectnum,MAXSECTORS-1,0); + if (i != sprite[spritenum].sectnum) + changespritesect(spritenum,i); + } + } + break; + case 4: + { + for (i=Bsprintf(disptext,"Statnum: %d",sprite[spritenum].statnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Statnum: ",spritenum); + if (editval) + { + printmessage16(edittext); + i = getnumber16(edittext,sprite[spritenum].statnum,MAXSTATUS-1,0); + if (i != sprite[spritenum].statnum) + changespritestat(spritenum,i); + } + } + break; + } + } + break; + case 1: + { + switch (row) + { + case 0: + { + for (i=Bsprintf(disptext,"Flags (hex): %x",sprite[spritenum].cstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Flags: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].cstat = (short)getnumber16(edittext,(long)sprite[spritenum].cstat,32768L,0); + } + } + break; + case 1: + { + for (i=Bsprintf(disptext,"Shade: %d",sprite[spritenum].shade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Shade: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].shade = (char)getnumber16(edittext,(long)sprite[spritenum].shade,127,1); + } + } + break; + case 2: + { + for (i=Bsprintf(disptext,"Pal: %d",sprite[spritenum].pal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Pal: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].pal = (char)getnumber16(edittext,(long)sprite[spritenum].pal,MAXPALOOKUPS,0); + } + } + break; + case 3: + { + for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",sprite[spritenum].xrepeat,sprite[spritenum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sprite (%d) X Repeat: ",spritenum); + printmessage16(edittext); + sprite[spritenum].xrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].xrepeat,256L,0); + Bsprintf(edittext,"Sprite (%d) Y Repeat: ",spritenum); + printmessage16(edittext); + sprite[spritenum].yrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].yrepeat,256L,0); + } + } + break; + case 4: + { + for (i=Bsprintf(disptext,"(X,Y)offset: %d, %d",sprite[spritenum].xoffset,sprite[spritenum].yoffset); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sprite (%d) X Offset: ",spritenum); + printmessage16(edittext); + sprite[spritenum].xoffset = (char)getnumber16(edittext,(long)sprite[spritenum].xoffset,128L,1); + Bsprintf(edittext,"Sprite (%d) Y Offset: ",spritenum); + printmessage16(edittext); + sprite[spritenum].yoffset = (char)getnumber16(edittext,(long)sprite[spritenum].yoffset,128L,1); + } + } + break; + case 5: + { + for (i=Bsprintf(disptext,"Tile number: %d",sprite[spritenum].picnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Tile number: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].picnum = (short)getnumber16(edittext,(long)sprite[spritenum].picnum,MAXTILES,0); + } + } + break; + } + } + break; + case 2: + { + switch (row) + { + case 0: + { + for (i=Bsprintf(disptext,"Angle (2048 degrees): %d",sprite[spritenum].ang); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Angle: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].ang = (short)getnumber16(edittext,(long)sprite[spritenum].ang,2048L,0); + } + } + break; + case 1: + { + for (i=Bsprintf(disptext,"X-Velocity: %d",sprite[spritenum].xvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) X-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].xvel = getnumber16(edittext,(long)sprite[spritenum].xvel,32767,1); + } + } + break; + case 2: + { + for (i=Bsprintf(disptext,"Y-Velocity: %d",sprite[spritenum].yvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Y-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].yvel = getnumber16(edittext,(long)sprite[spritenum].yvel,32767,1); + } + } + break; + case 3: + { + for (i=Bsprintf(disptext,"Z-Velocity: %d",sprite[spritenum].zvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Z-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].zvel = getnumber16(edittext,(long)sprite[spritenum].zvel,32767,1); + } + } + break; + case 4: + { + for (i=Bsprintf(disptext,"Owner: %d",sprite[spritenum].owner); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Owner: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].owner = getnumber16(edittext,(long)sprite[spritenum].owner,MAXSPRITES,0); + } + } + break; + case 5: + { + for (i=Bsprintf(disptext,"Clipdist: %d",sprite[spritenum].clipdist); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Clipdist: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].clipdist = (char)getnumber16(edittext,(long)sprite[spritenum].clipdist,255,0); + } + } + break; + case 6: + { + for (i=Bsprintf(disptext,"Extra: %d",sprite[spritenum].extra); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Extra: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].extra = getnumber16(edittext,(long)sprite[spritenum].extra,32767,1); + } + } + break; + } + } + break; } printext16(xpos,ypos+row*8,11,1,disptext,0); @@ -5822,229 +5821,229 @@ void FuncMenu(void) } switch (col) { + case 0: + switch (row) + { case 0: - switch (row) + { + for (i=Bsprintf(disptext,"Replace invalid tiles"); i < dispwidth; i++) disptext[i] = ' '; + if (editval) { - case 0: + j = 0; + for (i=0;i= 0) - { - for (j=0;j= 0) { - for (i=Bsprintf(disptext,"Global visibility divide"); i < dispwidth; i++) disptext[i] = ' '; - if (editval) - { - j=getnumber16("Visibility divisor: ",1,127,0); - if (j!=1) - { - for (i=0;i>4)/j; - } - printmessage16("Visibility adjusted"); - } - else printmessage16("Aborted"); - } + for (j=0;j>4)/j; + } + printmessage16("Visibility adjusted"); + } + else printmessage16("Aborted"); + } + } + break; + } + break; } printext16(xpos,ypos+row*8,11,1,disptext,0); enddrawing(); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index a0beed5fd..b3ce1ee3b 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -190,14 +190,14 @@ char * CONFIG_AnalogNumToName(int32 func) { switch (func) { - case analog_turning: - return "analog_turning"; - case analog_strafing: - return "analog_strafing"; - case analog_moving: - return "analog_moving"; - case analog_lookingupanddown: - return "analog_lookingupanddown"; + case analog_turning: + return "analog_turning"; + case analog_strafing: + return "analog_strafing"; + case analog_moving: + return "analog_moving"; + case analog_lookingupanddown: + return "analog_lookingupanddown"; } return NULL; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1657aba24..473ea073a 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -484,421 +484,421 @@ void getpackets(void) { switch (packbuf[0]) { - case 254: - //slaves in M/S mode only send to master - if (myconnectindex == connecthead) - { - //Master re-transmits message to all others - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) - sendpacket(i,packbuf,packbufleng); - } - /* - j = packbuf[1]; - playerquitflag[j] = 0; - - j = -1; - for(i=connecthead;i>=0;i=connectpoint2[i]) - { - if (playerquitflag[i]) { j = i; continue; } - - if (i == connecthead) connecthead = connectpoint2[connecthead]; - else connectpoint2[j] = connectpoint2[i]; - - numplayers--; - ud.multimode--; - - Bsprintf(buf,"%s is history!",ud.user_name[i]); - adduserquote(buf); - - if (numplayers < 2) - sound(GENERIC_AMBIENCE17); - - if(i == 0 && networkmode == 0) */ - gameexit("Game aborted from menu; disconnected."); - // } - - break; - - case 9: - //slaves in M/S mode only send to master - if (myconnectindex == connecthead) - { - //Master re-transmits message to all others - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) - sendpacket(i,packbuf,packbufleng); - } - - Bstrcpy(boardfilename,packbuf+1); - boardfilename[packbufleng-1] = 0; - if (boardfilename[0] != 0) - { - if ((i = kopen4load(boardfilename,0)) < 0) - { - Bmemset(boardfilename,0,sizeof(boardfilename)); - sendboardname(); - } - else kclose(i); - } - - if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) - ud.m_level_number = 0; - - break; - - case 18: // map vote - - if (myconnectindex == connecthead) - { - //Master re-transmits message to all others - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) - sendpacket(i,packbuf,packbufleng); - } - - switch (packbuf[1]) - { - case 0: - if (voting == myconnectindex && gotvote[packbuf[2]] == 0) - { - gotvote[packbuf[2]] = 1; - votes[packbuf[2]] = packbuf[3]; - Bsprintf(tempbuf,"GOT VOTE FROM %s",ud.user_name[packbuf[2]]); - adduserquote(tempbuf); - } - break; - - case 1: // call map vote - voting = packbuf[2]; - vote_episode = packbuf[3]; - vote_map = packbuf[4]; - Bsprintf(tempbuf,"%s HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)",ud.user_name[packbuf[2]],level_names[packbuf[3]*11 + packbuf[4]],packbuf[3]+1,packbuf[4]+1); - adduserquote(tempbuf); - Bsprintf(tempbuf,"PRESS F1 TO VOTE YES, F2 TO VOTE NO"); - adduserquote(tempbuf); - Bmemset(votes,0,sizeof(votes)); - Bmemset(gotvote,0,sizeof(gotvote)); - gotvote[voting] = votes[voting] = 1; - break; - - case 2: // cancel map vote - if (voting == packbuf[2]) - { - voting = -1; - i = 0; - for (j=0;j=0;i=connectpoint2[i]) - if (i != other) sendpacket(i,packbuf,packbufleng); + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) + sendpacket(i,packbuf,packbufleng); + } + /* + j = packbuf[1]; + playerquitflag[j] = 0; - multiflag = 2; - multiwhat = 0; - multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit - multipos = packbuf[1]; - loadplayer(multipos); - multiflag = 0; + j = -1; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i]) { j = i; continue; } + + if (i == connecthead) connecthead = connectpoint2[connecthead]; + else connectpoint2[j] = connectpoint2[i]; + + numplayers--; + ud.multimode--; + + Bsprintf(buf,"%s is history!",ud.user_name[i]); + adduserquote(buf); + + if (numplayers < 2) + sound(GENERIC_AMBIENCE17); + + if(i == 0 && networkmode == 0) */ + gameexit("Game aborted from menu; disconnected."); + // } + + break; + + case 9: + //slaves in M/S mode only send to master + if (myconnectindex == connecthead) + { + //Master re-transmits message to all others + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) + sendpacket(i,packbuf,packbufleng); + } + + Bstrcpy(boardfilename,packbuf+1); + boardfilename[packbufleng-1] = 0; + if (boardfilename[0] != 0) + { + if ((i = kopen4load(boardfilename,0)) < 0) + { + Bmemset(boardfilename,0,sizeof(boardfilename)); + sendboardname(); + } + else kclose(i); + } + + if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) + ud.m_level_number = 0; + + break; + + case 18: // map vote + + if (myconnectindex == connecthead) + { + //Master re-transmits message to all others + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) + sendpacket(i,packbuf,packbufleng); + } + + switch (packbuf[1]) + { + case 0: + if (voting == myconnectindex && gotvote[packbuf[2]] == 0) + { + gotvote[packbuf[2]] = 1; + votes[packbuf[2]] = packbuf[3]; + Bsprintf(tempbuf,"GOT VOTE FROM %s",ud.user_name[packbuf[2]]); + adduserquote(tempbuf); + } break; - case 0: //[0] (receive master sync buffer) - j = 1; - if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) + case 1: // call map vote + voting = packbuf[2]; + vote_episode = packbuf[3]; + vote_map = packbuf[4]; + Bsprintf(tempbuf,"%s HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)",ud.user_name[packbuf[2]],level_names[packbuf[3]*11 + packbuf[4]],packbuf[3]+1,packbuf[4]+1); + adduserquote(tempbuf); + Bsprintf(tempbuf,"PRESS F1 TO VOTE YES, F2 TO VOTE NO"); + adduserquote(tempbuf); + Bmemset(votes,0,sizeof(votes)); + Bmemset(gotvote,0,sizeof(gotvote)); + gotvote[voting] = votes[voting] = 1; + break; + + case 2: // cancel map vote + if (voting == packbuf[2]) + { + voting = -1; + i = 0; + for (j=0;j=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + multiflag = 2; + multiwhat = 0; + multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit + multipos = packbuf[1]; + loadplayer(multipos); + multiflag = 0; + break; + case 0: //[0] (receive master sync buffer) + j = 1; + + if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i] == 0) continue; + if (i == myconnectindex) + otherminlag = (long)((signed char)packbuf[j]); + j++; + } + + osyn = (input *)&inputfifo[(movefifoend[connecthead]-1)&(MOVEFIFOSIZ-1)][0]; + nsyn = (input *)&inputfifo[(movefifoend[connecthead])&(MOVEFIFOSIZ-1)][0]; + + k = j; + for (i=connecthead;i>=0;i=connectpoint2[i]) + j += playerquitflag[i]+playerquitflag[i]; + for (i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i] == 0) continue; + + l = packbuf[k++]; + l += (long)(packbuf[k++]<<8); + + if (i == myconnectindex) + { + j += ((l&1)<<1)+(l&2)+((l&4)>>2)+((l&8)>>3)+((l&16)>>4)+((l&32)>>5)+((l&64)>>6)+((l&128)>>7)+((l&256)>>8)+((l&512)>>9)+((l&1024)>>10)+((l&2048)>>11); + continue; + } + + copybufbyte(&osyn[i],&nsyn[i],sizeof(input)); + if (l&1) nsyn[i].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (l&2) nsyn[i].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (l&4) nsyn[i].avel = (signed char)packbuf[j++]; + if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((long)packbuf[j++])); + if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((long)packbuf[j++])<<8); + if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16); + if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (l&128) nsyn[i].horz = (signed char)packbuf[j++]; + if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((long)packbuf[j++])); + if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((long)packbuf[j++])<<8); + if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((long)packbuf[j++])<<16); + if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((long)packbuf[j++])<<24); + + if (nsyn[i].bits&(1<<26)) playerquitflag[i] = 0; + movefifoend[i]++; + } + + while (j != packbufleng) + { + for (i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + { + syncval[i][syncvalhead[i]&(MOVEFIFOSIZ-1)] = packbuf[j]; + syncvalhead[i]++; + } + j++; + } + + for (i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + for (j=1;j=0;i=connectpoint2[i]) + if (i != other) + sendpacket(i,packbuf,packbufleng); + } + else if (((long)packbuf[1]) != myconnectindex) + { + //Master re-transmits message not intended for master + sendpacket((long)packbuf[1],packbuf,packbufleng); + break; + } + } + + Bstrcpy(recbuf,packbuf+2); + recbuf[packbufleng-2] = 0; + + adduserquote(recbuf); + sound(EXITMENUSOUND); + + pus = NUMPAGES; + pub = NUMPAGES; + + break; + + case 5: + //Slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + if (vote_map != -1 || vote_episode != -1 || voting != -1) + adduserquote("VOTE SUCCEEDED"); + + ud.m_level_number = ud.level_number = packbuf[1]; + ud.m_volume_number = ud.volume_number = packbuf[2]; + ud.m_player_skill = ud.player_skill = packbuf[3]; + ud.m_monsters_off = ud.monsters_off = packbuf[4]; + ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; + ud.m_respawn_items = ud.respawn_items = packbuf[6]; + ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; + ud.m_coop = packbuf[8]; + ud.m_marker = ud.marker = packbuf[9]; + ud.m_ffire = ud.ffire = packbuf[10]; + ud.m_noexits = ud.noexits = packbuf[11]; + + for (i=connecthead;i>=0;i=connectpoint2[i]) + { + resetweapons(i); + resetinventory(i); + } + + newgame(ud.volume_number,ud.level_number,ud.player_skill); + ud.coop = ud.m_coop; + + if (enterlevel(MODE_GAME)) backtomenu(); + + break; + case 6: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + if (packbuf[2] != BYTEVERSION) + gameexit("\nYou cannot play Duke with different versions."); + + other = packbuf[1]; + + for (i=3;packbuf[i];i++) + ud.user_name[other][i-3] = packbuf[i]; + ud.user_name[other][i-3] = 0; + i++; + + j = i; //This used to be Duke packet #9... now concatenated with Duke packet #6 + for (;i-j<10;i++) ud.wchoice[other][i-j] = packbuf[i]; + + ps[other].aim_mode = packbuf[i++]; + ps[other].auto_aim = packbuf[i++]; + ps[other].weaponswitch = packbuf[i++]; + ps[other].palookup = ud.pcolor[other] = packbuf[i++]; + ud.pteam[other] = packbuf[i++]; + + /* if(ps[other].team != j && sprite[ps[other].i].picnum == APLAYER) + { + hittype[ps[other].i].extra = 1000; + hittype[ps[other].i].picnum = APLAYERTOP; + } */ + + break; + case 7: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + if (numlumps == 0) break; + + if (SoundToggle == 0 || ud.lockout == 1 || FXDevice < 0) + break; + rtsptr = (char *)RTS_GetSound(packbuf[1]-1); + if (*rtsptr == 'C') + FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]); + else + FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]); + rtsplaying = 7; + break; + + case 16: + movefifoend[other] = movefifoplc = movefifosendplc = fakemovefifoplc = 0; + syncvalhead[other] = syncvaltottail = 0L; + case 17: + j = 1; + + if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) + if (other == connecthead) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) { - if (playerquitflag[i] == 0) continue; if (i == myconnectindex) otherminlag = (long)((signed char)packbuf[j]); j++; } - osyn = (input *)&inputfifo[(movefifoend[connecthead]-1)&(MOVEFIFOSIZ-1)][0]; - nsyn = (input *)&inputfifo[(movefifoend[connecthead])&(MOVEFIFOSIZ-1)][0]; + osyn = (input *)&inputfifo[(movefifoend[other]-1)&(MOVEFIFOSIZ-1)][0]; + nsyn = (input *)&inputfifo[(movefifoend[other])&(MOVEFIFOSIZ-1)][0]; - k = j; - for (i=connecthead;i>=0;i=connectpoint2[i]) - j += playerquitflag[i]+playerquitflag[i]; - for (i=connecthead;i>=0;i=connectpoint2[i]) - { - if (playerquitflag[i] == 0) continue; + copybufbyte(&osyn[other],&nsyn[other],sizeof(input)); + k = packbuf[j++]; + k += (long)(packbuf[j++]<<8); - l = packbuf[k++]; - l += (long)(packbuf[k++]<<8); + if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (k&4) nsyn[other].avel = (signed char)packbuf[j++]; + if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++])); + if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8); + if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16); + if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; + if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++])); + if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8); + if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16); + if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24); + movefifoend[other]++; - if (i == myconnectindex) - { - j += ((l&1)<<1)+(l&2)+((l&4)>>2)+((l&8)>>3)+((l&16)>>4)+((l&32)>>5)+((l&64)>>6)+((l&128)>>7)+((l&256)>>8)+((l&512)>>9)+((l&1024)>>10)+((l&2048)>>11); - continue; - } - - copybufbyte(&osyn[i],&nsyn[i],sizeof(input)); - if (l&1) nsyn[i].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; - if (l&2) nsyn[i].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; - if (l&4) nsyn[i].avel = (signed char)packbuf[j++]; - if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((long)packbuf[j++])); - if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((long)packbuf[j++])<<8); - if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16); - if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24); - if (l&128) nsyn[i].horz = (signed char)packbuf[j++]; - if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((long)packbuf[j++])); - if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((long)packbuf[j++])<<8); - if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((long)packbuf[j++])<<16); - if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((long)packbuf[j++])<<24); - - if (nsyn[i].bits&(1<<26)) playerquitflag[i] = 0; - movefifoend[i]++; - } - - while (j != packbufleng) - { - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - { - syncval[i][syncvalhead[i]&(MOVEFIFOSIZ-1)] = packbuf[j]; - syncvalhead[i]++; - } - j++; - } - - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - for (j=1;j packbufleng) + initprintf("INVALID GAME PACKET!!! (packet %d, %ld too many bytes)\n",packbuf[0],j-packbufleng); - for (i=1;i=0;i=connectpoint2[i]) - if (i != other) - sendpacket(i,packbuf,packbufleng); - } - else if (((long)packbuf[1]) != myconnectindex) - { - //Master re-transmits message not intended for master - sendpacket((long)packbuf[1],packbuf,packbufleng); - break; - } - } - - Bstrcpy(recbuf,packbuf+2); - recbuf[packbufleng-2] = 0; - - adduserquote(recbuf); - sound(EXITMENUSOUND); - - pus = NUMPAGES; - pub = NUMPAGES; - - break; - - case 5: - //Slaves in M/S mode only send to master - //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) sendpacket(i,packbuf,packbufleng); - - if (vote_map != -1 || vote_episode != -1 || voting != -1) - adduserquote("VOTE SUCCEEDED"); - - ud.m_level_number = ud.level_number = packbuf[1]; - ud.m_volume_number = ud.volume_number = packbuf[2]; - ud.m_player_skill = ud.player_skill = packbuf[3]; - ud.m_monsters_off = ud.monsters_off = packbuf[4]; - ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; - ud.m_respawn_items = ud.respawn_items = packbuf[6]; - ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; - ud.m_coop = packbuf[8]; - ud.m_marker = ud.marker = packbuf[9]; - ud.m_ffire = ud.ffire = packbuf[10]; - ud.m_noexits = ud.noexits = packbuf[11]; - - for (i=connecthead;i>=0;i=connectpoint2[i]) - { - resetweapons(i); - resetinventory(i); - } - - newgame(ud.volume_number,ud.level_number,ud.player_skill); - ud.coop = ud.m_coop; - - if (enterlevel(MODE_GAME)) backtomenu(); - - break; - case 6: - //slaves in M/S mode only send to master - //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) sendpacket(i,packbuf,packbufleng); - - if (packbuf[2] != BYTEVERSION) - gameexit("\nYou cannot play Duke with different versions."); - - other = packbuf[1]; - - for (i=3;packbuf[i];i++) - ud.user_name[other][i-3] = packbuf[i]; - ud.user_name[other][i-3] = 0; - i++; - - j = i; //This used to be Duke packet #9... now concatenated with Duke packet #6 - for (;i-j<10;i++) ud.wchoice[other][i-j] = packbuf[i]; - - ps[other].aim_mode = packbuf[i++]; - ps[other].auto_aim = packbuf[i++]; - ps[other].weaponswitch = packbuf[i++]; - ps[other].palookup = ud.pcolor[other] = packbuf[i++]; - ud.pteam[other] = packbuf[i++]; - - /* if(ps[other].team != j && sprite[ps[other].i].picnum == APLAYER) - { - hittype[ps[other].i].extra = 1000; - hittype[ps[other].i].picnum = APLAYERTOP; - } */ - - break; - case 7: - //slaves in M/S mode only send to master - //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (i != other) sendpacket(i,packbuf,packbufleng); - - if (numlumps == 0) break; - - if (SoundToggle == 0 || ud.lockout == 1 || FXDevice < 0) - break; - rtsptr = (char *)RTS_GetSound(packbuf[1]-1); - if (*rtsptr == 'C') - FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]); - else - FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]); - rtsplaying = 7; - break; - - case 16: - movefifoend[other] = movefifoplc = movefifosendplc = fakemovefifoplc = 0; - syncvalhead[other] = syncvaltottail = 0L; - case 17: - j = 1; - - if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) - if (other == connecthead) - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - { - if (i == myconnectindex) - otherminlag = (long)((signed char)packbuf[j]); - j++; - } - - osyn = (input *)&inputfifo[(movefifoend[other]-1)&(MOVEFIFOSIZ-1)][0]; - nsyn = (input *)&inputfifo[(movefifoend[other])&(MOVEFIFOSIZ-1)][0]; - - copybufbyte(&osyn[other],&nsyn[other],sizeof(input)); - k = packbuf[j++]; - k += (long)(packbuf[j++]<<8); - - if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; - if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; - if (k&4) nsyn[other].avel = (signed char)packbuf[j++]; - if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++])); - if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24); - if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; - if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++])); - if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24); - movefifoend[other]++; - - for (i=1;i packbufleng) - initprintf("INVALID GAME PACKET!!! (packet %d, %ld too many bytes)\n",packbuf[0],j-packbufleng); - - while (j != packbufleng) - { - syncval[other][syncvalhead[other]&(MOVEFIFOSIZ-1)] = packbuf[j++]; - syncvalhead[other]++; - } - - break; - case 127: - break; - - case 250: - playerreadyflag[other]++; - break; - case 255: - gameexit(" "); - break; + case 250: + playerreadyflag[other]++; + break; + case 255: + gameexit(" "); + break; } } } @@ -1304,64 +1304,64 @@ void check_fta_sounds(short i) if (sprite[i].extra > 0) switch (dynamictostatic[PN]) { - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - spritesound(PRED_RECOG,i); - break; - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - spritesound(CAPT_RECOG,i); - break; - case PIGCOP__STATIC: - case PIGCOPDIVE__STATIC: - spritesound(PIG_RECOG,i); - break; - case RECON__STATIC: - spritesound(RECO_RECOG,i); - break; - case DRONE__STATIC: - spritesound(DRON_RECOG,i); - break; - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - spritesound(COMM_RECOG,i); - break; - case ORGANTIC__STATIC: - spritesound(TURR_RECOG,i); - break; - case OCTABRAIN__STATIC: - case OCTABRAINSTAYPUT__STATIC: - spritesound(OCTA_RECOG,i); - break; - case BOSS1__STATIC: - sound(BOS1_RECOG); - break; - case BOSS2__STATIC: - if (sprite[i].pal == 1) - sound(BOS2_RECOG); - else sound(WHIPYOURASS); - break; - case BOSS3__STATIC: - if (sprite[i].pal == 1) - sound(BOS3_RECOG); - else sound(RIPHEADNECK); - break; - case BOSS4__STATIC: - case BOSS4STAYPUT__STATIC: - if (sprite[i].pal == 1) - sound(BOS4_RECOG); - sound(BOSS4_FIRSTSEE); - break; - case GREENSLIME__STATIC: - spritesound(SLIM_RECOG,i); - break; + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + spritesound(PRED_RECOG,i); + break; + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + spritesound(CAPT_RECOG,i); + break; + case PIGCOP__STATIC: + case PIGCOPDIVE__STATIC: + spritesound(PIG_RECOG,i); + break; + case RECON__STATIC: + spritesound(RECO_RECOG,i); + break; + case DRONE__STATIC: + spritesound(DRON_RECOG,i); + break; + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + spritesound(COMM_RECOG,i); + break; + case ORGANTIC__STATIC: + spritesound(TURR_RECOG,i); + break; + case OCTABRAIN__STATIC: + case OCTABRAINSTAYPUT__STATIC: + spritesound(OCTA_RECOG,i); + break; + case BOSS1__STATIC: + sound(BOS1_RECOG); + break; + case BOSS2__STATIC: + if (sprite[i].pal == 1) + sound(BOS2_RECOG); + else sound(WHIPYOURASS); + break; + case BOSS3__STATIC: + if (sprite[i].pal == 1) + sound(BOS3_RECOG); + else sound(RIPHEADNECK); + break; + case BOSS4__STATIC: + case BOSS4STAYPUT__STATIC: + if (sprite[i].pal == 1) + sound(BOS4_RECOG); + sound(BOSS4_FIRSTSEE); + break; + case GREENSLIME__STATIC: + spritesound(SLIM_RECOG,i); + break; } } @@ -1369,14 +1369,14 @@ inline short inventory(spritetype *s) { switch (dynamictostatic[s->picnum]) { - case FIRSTAID__STATIC: - case STEROIDS__STATIC: - case HEATSENSOR__STATIC: - case BOOTS__STATIC: - case JETPACK__STATIC: - case HOLODUKE__STATIC: - case AIRTANK__STATIC: - return 1; + case FIRSTAID__STATIC: + case STEROIDS__STATIC: + case HEATSENSOR__STATIC: + case BOOTS__STATIC: + case JETPACK__STATIC: + case HOLODUKE__STATIC: + case AIRTANK__STATIC: + return 1; } return 0; } @@ -1409,44 +1409,44 @@ inline short badguypic(short pn) switch (dynamictostatic[pn]) { - case SHARK__STATIC: - case RECON__STATIC: - case DRONE__STATIC: - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSTAYPUT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - case OCTABRAIN__STATIC: - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - case PIGCOP__STATIC: - case EGG__STATIC: - case PIGCOPSTAYPUT__STATIC: - case PIGCOPDIVE__STATIC: - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - case ORGANTIC__STATIC: - case BOSS1__STATIC: - case BOSS2__STATIC: - case BOSS3__STATIC: - case BOSS4__STATIC: - //case GREENSLIME: - //case GREENSLIME+1: - //case GREENSLIME+2: - //case GREENSLIME+3: - //case GREENSLIME+4: - //case GREENSLIME+5: - //case GREENSLIME+6: - //case GREENSLIME+7: - case RAT__STATIC: - case ROTATEGUN__STATIC: - return 1; + case SHARK__STATIC: + case RECON__STATIC: + case DRONE__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + case PIGCOP__STATIC: + case EGG__STATIC: + case PIGCOPSTAYPUT__STATIC: + case PIGCOPDIVE__STATIC: + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + case ORGANTIC__STATIC: + case BOSS1__STATIC: + case BOSS2__STATIC: + case BOSS3__STATIC: + case BOSS4__STATIC: + //case GREENSLIME: + //case GREENSLIME+1: + //case GREENSLIME+2: + //case GREENSLIME+3: + //case GREENSLIME+4: + //case GREENSLIME+5: + //case GREENSLIME+6: + //case GREENSLIME+7: + case RAT__STATIC: + case ROTATEGUN__STATIC: + return 1; } return 0; } @@ -1834,27 +1834,27 @@ void displayinventory(struct player_struct *p) { switch (n&(1<inven_icon) { - case 1: - i = FIRSTAID_ICON; - break; - case 2: - i = STEROIDS_ICON; - break; - case 3: - i = HOLODUKE_ICON; - break; - case 4: - i = JETPACK_ICON; - break; - case 5: - i = HEAT_ICON; - break; - case 6: - i = AIRTANK_ICON; - break; - case 7: - i = BOOT_ICON; - break; - default: - i = -1; + case 1: + i = FIRSTAID_ICON; + break; + case 2: + i = STEROIDS_ICON; + break; + case 3: + i = HOLODUKE_ICON; + break; + case 4: + i = JETPACK_ICON; + break; + case 5: + i = HEAT_ICON; + break; + case 6: + i = AIRTANK_ICON; + break; + case 7: + i = BOOT_ICON; + break; + default: + i = -1; } if (i >= 0) rotatesprite(sbarx(231-o),sbary(200-21),sbarsc(65536L),0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1); @@ -1986,30 +1986,30 @@ void coolgaugetext(short snum) j = 0x80000000; switch (p->inven_icon) { - case 1: - i = p->firstaid_amount; - break; - case 2: - i = ((p->steroids_amount+3)>>2); - break; - case 3: - i = ((p->holoduke_amount+15)/24); - j = p->holoduke_on; - break; - case 4: - i = ((p->jetpack_amount+15)>>4); - j = p->jetpack_on; - break; - case 5: - i = p->heat_amount/12; - j = p->heat_on; - break; - case 6: - i = ((p->scuba_amount+63)>>6); - break; - case 7: - i = (p->boot_amount>>1); - break; + case 1: + i = p->firstaid_amount; + break; + case 2: + i = ((p->steroids_amount+3)>>2); + break; + case 3: + i = ((p->holoduke_amount+15)/24); + j = p->holoduke_on; + break; + case 4: + i = ((p->jetpack_amount+15)>>4); + j = p->jetpack_on; + break; + case 5: + i = p->heat_amount/12; + j = p->heat_on; + break; + case 6: + i = ((p->scuba_amount+63)>>6); + break; + case 7: + i = (p->boot_amount>>1); + break; } invennum(284-30-o,200-6,(char)i,0,10+permbit); if (j > 0) minitext(288-30-o,180,"ON",0,10+16+permbit + 256); @@ -2241,27 +2241,27 @@ void coolgaugetext(short snum) { switch (p->inven_icon) { - case 1: - i = FIRSTAID_ICON; - break; - case 2: - i = STEROIDS_ICON; - break; - case 3: - i = HOLODUKE_ICON; - break; - case 4: - i = JETPACK_ICON; - break; - case 5: - i = HEAT_ICON; - break; - case 6: - i = AIRTANK_ICON; - break; - case 7: - i = BOOT_ICON; - break; + case 1: + i = FIRSTAID_ICON; + break; + case 2: + i = STEROIDS_ICON; + break; + case 3: + i = HOLODUKE_ICON; + break; + case 4: + i = JETPACK_ICON; + break; + case 5: + i = HEAT_ICON; + break; + case 6: + i = AIRTANK_ICON; + break; + case 7: + i = BOOT_ICON; + break; } rotatesprite(sbarx(231-o),sbary(SBY+13),sbarsc(65536L),0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1); minitext(292-30-o,SBY+24,"%",6,10+16+permbit + 256); @@ -2271,17 +2271,17 @@ void coolgaugetext(short snum) { switch (p->inven_icon) { - case 3: - j = p->holoduke_on; - break; - case 4: - j = p->jetpack_on; - break; - case 5: - j = p->heat_on; - break; - default: - j = 0x80000000; + case 3: + j = p->holoduke_on; + break; + case 4: + j = p->jetpack_on; + break; + case 5: + j = p->heat_on; + break; + default: + j = 0x80000000; } if (j > 0) minitext(288-30-o,SBY+14,"ON",0,10+16+permbit + 256); else if ((unsigned long)j != 0x80000000) minitext(284-30-o,SBY+14,"OFF",2,10+16+permbit + 256); @@ -2290,27 +2290,27 @@ void coolgaugetext(short snum) { switch (p->inven_icon) { - case 1: - i = p->firstaid_amount; - break; - case 2: - i = ((p->steroids_amount+3)>>2); - break; - case 3: - i = ((p->holoduke_amount+15)/24); - break; - case 4: - i = ((p->jetpack_amount+15)>>4); - break; - case 5: - i = p->heat_amount/12; - break; - case 6: - i = ((p->scuba_amount+63)>>6); - break; - case 7: - i = (p->boot_amount>>1); - break; + case 1: + i = p->firstaid_amount; + break; + case 2: + i = ((p->steroids_amount+3)>>2); + break; + case 3: + i = ((p->holoduke_amount+15)/24); + break; + case 4: + i = ((p->jetpack_amount+15)>>4); + break; + case 5: + i = p->heat_amount/12; + break; + case 6: + i = ((p->scuba_amount+63)>>6); + break; + case 7: + i = (p->boot_amount>>1); + break; } invennum(284-30-o,SBY+28,(char)i,0,10+permbit); } @@ -2935,95 +2935,48 @@ void drawoverheadmap(long cposx, long cposy, long czoom, short cang) if ((spr->cstat&257) != 0) switch (spr->cstat&48) { - case 0: - break; + case 0: + break; - ox = sprx-cposx; - oy = spry-cposy; - x1 = dmulscale16(ox,xvect,-oy,yvect); - y1 = dmulscale16(oy,xvect2,ox,yvect2); + ox = sprx-cposx; + oy = spry-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); - ox = (sintable[(spr->ang+512)&2047]>>7); - oy = (sintable[(spr->ang)&2047]>>7); - x2 = dmulscale16(ox,xvect,-oy,yvect); - y2 = dmulscale16(oy,xvect,ox,yvect); + ox = (sintable[(spr->ang+512)&2047]>>7); + oy = (sintable[(spr->ang)&2047]>>7); + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect,ox,yvect); - x3 = mulscale16(x2,yxaspect); - y3 = mulscale16(y2,yxaspect); + x3 = mulscale16(x2,yxaspect); + y3 = mulscale16(y2,yxaspect); - drawline256(x1-x2+(xdim<<11),y1-y3+(ydim<<11), - x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); - drawline256(x1-y2+(xdim<<11),y1+x3+(ydim<<11), - x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); - drawline256(x1+y2+(xdim<<11),y1-x3+(ydim<<11), - x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); - break; - - case 16: - if (spr->picnum == LASERLINE) - { - x1 = sprx; - y1 = spry; - tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - if ((spr->cstat&4) > 0) xoff = -xoff; - k = spr->ang; - l = spr->xrepeat; - dax = sintable[k&2047]*l; - day = sintable[(k+1536)&2047]*l; - l = tilesizx[tilenum]; - k = (l>>1)+xoff; - x1 -= mulscale16(dax,k); - x2 = x1+mulscale16(dax,l); - y1 -= mulscale16(day,k); - y2 = y1+mulscale16(day,l); - - ox = x1-cposx; - oy = y1-cposy; - x1 = dmulscale16(ox,xvect,-oy,yvect); - y1 = dmulscale16(oy,xvect2,ox,yvect2); - - ox = x2-cposx; - oy = y2-cposy; - x2 = dmulscale16(ox,xvect,-oy,yvect); - y2 = dmulscale16(oy,xvect2,ox,yvect2); - - drawline256(x1+(xdim<<11),y1+(ydim<<11), - x2+(xdim<<11),y2+(ydim<<11),col); - } - - break; - - case 32: + drawline256(x1-x2+(xdim<<11),y1-y3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1-y2+(xdim<<11),y1+x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1+y2+(xdim<<11),y1-x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + break; + case 16: + if (spr->picnum == LASERLINE) + { + x1 = sprx; + y1 = spry; tilenum = spr->picnum; xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); if ((spr->cstat&4) > 0) xoff = -xoff; - if ((spr->cstat&8) > 0) yoff = -yoff; - k = spr->ang; - cosang = sintable[(k+512)&2047]; - sinang = sintable[k]; - xspan = tilesizx[tilenum]; - xrepeat = spr->xrepeat; - yspan = tilesizy[tilenum]; - yrepeat = spr->yrepeat; - - dax = ((xspan>>1)+xoff)*xrepeat; - day = ((yspan>>1)+yoff)*yrepeat; - x1 = sprx + dmulscale16(sinang,dax,cosang,day); - y1 = spry + dmulscale16(sinang,day,-cosang,dax); - l = xspan*xrepeat; - x2 = x1 - mulscale16(sinang,l); - y2 = y1 + mulscale16(cosang,l); - l = yspan*yrepeat; - k = -mulscale16(cosang,l); - x3 = x2+k; - x4 = x1+k; - k = -mulscale16(sinang,l); - y3 = y2+k; - y4 = y1+k; + l = spr->xrepeat; + dax = sintable[k&2047]*l; + day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; + k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); + x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); + y2 = y1+mulscale16(day,l); ox = x1-cposx; oy = y1-cposy; @@ -3035,29 +2988,76 @@ void drawoverheadmap(long cposx, long cposy, long czoom, short cang) x2 = dmulscale16(ox,xvect,-oy,yvect); y2 = dmulscale16(oy,xvect2,ox,yvect2); - ox = x3-cposx; - oy = y3-cposy; - x3 = dmulscale16(ox,xvect,-oy,yvect); - y3 = dmulscale16(oy,xvect2,ox,yvect2); - - ox = x4-cposx; - oy = y4-cposy; - x4 = dmulscale16(ox,xvect,-oy,yvect); - y4 = dmulscale16(oy,xvect2,ox,yvect2); - drawline256(x1+(xdim<<11),y1+(ydim<<11), x2+(xdim<<11),y2+(ydim<<11),col); + } - drawline256(x2+(xdim<<11),y2+(ydim<<11), - x3+(xdim<<11),y3+(ydim<<11),col); + break; - drawline256(x3+(xdim<<11),y3+(ydim<<11), - x4+(xdim<<11),y4+(ydim<<11),col); + case 32: - drawline256(x4+(xdim<<11),y4+(ydim<<11), - x1+(xdim<<11),y1+(ydim<<11),col); + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + if ((spr->cstat&8) > 0) yoff = -yoff; - break; + k = spr->ang; + cosang = sintable[(k+512)&2047]; + sinang = sintable[k]; + xspan = tilesizx[tilenum]; + xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; + yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; + day = ((yspan>>1)+yoff)*yrepeat; + x1 = sprx + dmulscale16(sinang,dax,cosang,day); + y1 = spry + dmulscale16(sinang,day,-cosang,dax); + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); + x3 = x2+k; + x4 = x1+k; + k = -mulscale16(sinang,l); + y3 = y2+k; + y4 = y1+k; + + ox = x1-cposx; + oy = y1-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x2-cposx; + oy = y2-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x3-cposx; + oy = y3-cposy; + x3 = dmulscale16(ox,xvect,-oy,yvect); + y3 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x4-cposx; + oy = y4-cposy; + x4 = dmulscale16(ox,xvect,-oy,yvect); + y4 = dmulscale16(oy,xvect2,ox,yvect2); + + drawline256(x1+(xdim<<11),y1+(ydim<<11), + x2+(xdim<<11),y2+(ydim<<11),col); + + drawline256(x2+(xdim<<11),y2+(ydim<<11), + x3+(xdim<<11),y3+(ydim<<11),col); + + drawline256(x3+(xdim<<11),y3+(ydim<<11), + x4+(xdim<<11),y4+(ydim<<11),col); + + drawline256(x4+(xdim<<11),y4+(ydim<<11), + x1+(xdim<<11),y1+(ydim<<11),col); + + break; } } } @@ -3224,12 +3224,12 @@ void displayrest(long smoothratio) { switch (ud.show_help) { - case 1: - rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); - break; - case 2: - rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); - break; + case 1: + rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + case 2: + rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; } if (KB_KeyPressed(sc_Escape)) @@ -3509,15 +3509,15 @@ void drawbackground(void) switch (ud.m_volume_number) { - default: - dapicnum = BIGHOLE; - break; - case 1: - dapicnum = BIGHOLE; - break; - case 2: - dapicnum = BIGHOLE; - break; + default: + dapicnum = BIGHOLE; + break; + case 1: + dapicnum = BIGHOLE; + break; + case 2: + dapicnum = BIGHOLE; + break; } if (tilesizx[dapicnum] == 0 || tilesizy[dapicnum] == 0) @@ -3794,17 +3794,17 @@ static void se40code(long x,long y,long z,long a,long h, long smoothratio) int t = sprite[i].lotag; switch (t) { - // case 40: - // case 41: - // SE40_Draw(i,x,y,a,smoothratio); - // break; - case 42: - case 43: - case 44: - case 45: - if (ps[screenpeek].cursectnum == sprite[i].sectnum) - SE40_Draw(i,x,y,z,a,h,smoothratio); - break; + // case 40: + // case 41: + // SE40_Draw(i,x,y,a,smoothratio); + // break; + case 42: + case 43: + case 44: + case 45: + if (ps[screenpeek].cursectnum == sprite[i].sectnum) + SE40_Draw(i,x,y,z,a,h,smoothratio); + break; } i = nextspritestat[i]; } @@ -4259,47 +4259,47 @@ char wallswitchcheck(short i) { switch (dynamictostatic[PN-j]) { - case HANDPRINTSWITCH__STATIC: - //case HANDPRINTSWITCH+1: - case ALIENSWITCH__STATIC: - //case ALIENSWITCH+1: - case MULTISWITCH__STATIC: - //case MULTISWITCH+1: - //case MULTISWITCH+2: - //case MULTISWITCH+3: - //case ACCESSSWITCH: - //case ACCESSSWITCH2: - case PULLSWITCH__STATIC: - //case PULLSWITCH+1: - case HANDSWITCH__STATIC: - //case HANDSWITCH+1: - case SLOTDOOR__STATIC: - //case SLOTDOOR+1: - case LIGHTSWITCH__STATIC: - //case LIGHTSWITCH+1: - case SPACELIGHTSWITCH__STATIC: - //case SPACELIGHTSWITCH+1: - case SPACEDOORSWITCH__STATIC: - //case SPACEDOORSWITCH+1: - case FRANKENSTINESWITCH__STATIC: - //case FRANKENSTINESWITCH+1: - case LIGHTSWITCH2__STATIC: - //case LIGHTSWITCH2+1: - case POWERSWITCH1__STATIC: - //case POWERSWITCH1+1: - case LOCKSWITCH1__STATIC: - //case LOCKSWITCH1+1: - case POWERSWITCH2__STATIC: - //case POWERSWITCH2+1: - case DIPSWITCH__STATIC: - //case DIPSWITCH+1: - case DIPSWITCH2__STATIC: - //case DIPSWITCH2+1: - case TECHSWITCH__STATIC: - //case TECHSWITCH+1: - case DIPSWITCH3__STATIC: - //case DIPSWITCH3+1: - return 1; + case HANDPRINTSWITCH__STATIC: + //case HANDPRINTSWITCH+1: + case ALIENSWITCH__STATIC: + //case ALIENSWITCH+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + //case ACCESSSWITCH: + //case ACCESSSWITCH2: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + case DIPSWITCH__STATIC: + //case DIPSWITCH+1: + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case TECHSWITCH__STATIC: + //case TECHSWITCH+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + return 1; } } return 0; @@ -4427,230 +4427,461 @@ short spawn(short j, short pn) } else switch (dynamictostatic[sp->picnum]) { - default: - if (actorscrptr[sp->picnum]) + default: + if (actorscrptr[sp->picnum]) + { + if (j == -1 && sp->lotag > ud.player_skill) { - if (j == -1 && sp->lotag > ud.player_skill) + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + + // Init the size + if (sp->xrepeat == 0 || sp->yrepeat == 0) + sp->xrepeat = sp->yrepeat = 1; + + if (actortype[sp->picnum] & 3) + { + if (ud.monsters_off == 1) { sp->xrepeat=sp->yrepeat=0; changespritestat(i,5); break; } - // Init the size - if (sp->xrepeat == 0 || sp->yrepeat == 0) - sp->xrepeat = sp->yrepeat = 1; + makeitfall(i); - if (actortype[sp->picnum] & 3) + if (actortype[sp->picnum] & 2) + hittype[i].actorstayput = sp->sectnum; + + ps[myconnectindex].max_actors_killed++; + sp->clipdist = 80; + if (j >= 0) { - if (ud.monsters_off == 1) + if (sprite[j].picnum == RESPAWN) + hittype[i].tempang = sprite[i].pal = sprite[j].pal; + changespritestat(i,1); + } + else changespritestat(i,2); + } + else + { + sp->clipdist = 40; + sp->owner = i; + changespritestat(i,1); + } + + hittype[i].timetosleep = 0; + + if (j >= 0) + sp->ang = sprite[j].ang; + } + break; + case FOF__STATIC: + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + case WATERSPLASH2__STATIC: + if (j >= 0) + { + setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z); + sp->xrepeat = sp->yrepeat = 8+(TRAND&7); + } + else sp->xrepeat = sp->yrepeat = 16+(TRAND&15); + + sp->shade = -16; + sp->cstat |= 128; + if (j >= 0) + { + if (sector[sprite[j].sectnum].lotag == 2) + { + sp->z = getceilzofslope(SECT,SX,SY)+(16<<8); + sp->cstat |= 8; + } + else if (sector[sprite[j].sectnum].lotag == 1) + sp->z = getflorzofslope(SECT,SX,SY); + } + + if (sector[sect].floorpicnum == FLOORSLIME || + sector[sect].ceilingpicnum == FLOORSLIME) + sp->pal = 7; + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: + case DOMELITE__STATIC: + if (sp->picnum != WATERSPLASH2) + sp->cstat |= 257; + case NUKEBUTTON__STATIC: + if (sp->picnum == DOMELITE) + sp->cstat |= 257; + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case ARMJIB1__STATIC: + case LEGJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKETORSO__STATIC: + case DUKEGUN__STATIC: + case DUKELEG__STATIC: + changespritestat(i,5); + break; + case TONGUE__STATIC: + if (j >= 0) + sp->ang = sprite[j].ang; + sp->z -= 38<<8; + sp->zvel = 256-(TRAND&511); + sp->xvel = 64-(TRAND&127); + changespritestat(i,4); + break; + case NATURALLIGHTNING__STATIC: + sp->cstat &= ~257; + sp->cstat |= 32768; + break; + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + if (j == -1) break; + if (sp->picnum == TRANSPORTERBEAM) + { + sp->xrepeat = 31; + sp->yrepeat = 1; + sp->z = sector[sprite[j].sectnum].floorz-(40<<8); + } + else + { + if (sprite[j].statnum == 4) + { + sp->xrepeat = 8; + sp->yrepeat = 8; + } + else + { + sp->xrepeat = 48; + sp->yrepeat = 64; + if (sprite[j].statnum == 10 || badguy(&sprite[j])) + sp->z -= (32<<8); + } + } + + sp->shade = -127; + sp->cstat = 128|2; + sp->ang = sprite[j].ang; + + sp->xvel = 128; + changespritestat(i,5); + ssp(i,CLIPMASK0); + setsprite(i,sp->x,sp->y,sp->z); + break; + + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) break; + case FRAMEEFFECT1__STATIC: + if (j >= 0) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + T2 = sprite[j].picnum; + } + else sp->xrepeat = sp->yrepeat = 0; + + changespritestat(i,5); + + break; + + case LASERLINE__STATIC: + sp->yrepeat = 6; + sp->xrepeat = 32; + + if (lasermode == 1) + sp->cstat = 16 + 2; + else if (lasermode == 0 || lasermode == 2) + sp->cstat = 16; + else + { + sp->xrepeat = 0; + sp->yrepeat = 0; + } + + if (j >= 0) sp->ang = hittype[j].temp_data[5]+512; + changespritestat(i,5); + break; + + case FORCESPHERE__STATIC: + if (j == -1) + { + sp->cstat = (short) 32768; + changespritestat(i,2); + } + else + { + sp->xrepeat = sp->yrepeat = 1; + changespritestat(i,5); + } + break; + + case BLOOD__STATIC: + sp->xrepeat = sp->yrepeat = 16; + sp->z -= (26<<8); + if (j >= 0 && sprite[j].pal == 6) + sp->pal = 6; + changespritestat(i,5); + break; + case BLOODPOOL__STATIC: + case PUKE__STATIC: + { + short s1; + s1 = sp->sectnum; + + updatesector(sp->x+108,sp->y+108,&s1); + if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-108,sp->y-108,&s1); + if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x+108,sp->y-108,&s1); + if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-108,sp->y+108,&s1); + if (s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) { - sp->xrepeat=sp->yrepeat=0; + sp->xrepeat = sp->yrepeat = 0; changespritestat(i,5); break; } - makeitfall(i); - if (actortype[sp->picnum] & 2) - hittype[i].actorstayput = sp->sectnum; - - ps[myconnectindex].max_actors_killed++; - sp->clipdist = 80; - if (j >= 0) - { - if (sprite[j].picnum == RESPAWN) - hittype[i].tempang = sprite[i].pal = sprite[j].pal; - changespritestat(i,1); - } - else changespritestat(i,2); } else { - sp->clipdist = 40; - sp->owner = i; - changespritestat(i,1); + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; } - hittype[i].timetosleep = 0; - if (j >= 0) - sp->ang = sprite[j].ang; } - break; - case FOF__STATIC: + else + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + + + } + else + { sp->xrepeat = sp->yrepeat = 0; changespritestat(i,5); break; - case WATERSPLASH2__STATIC: - if (j >= 0) - { - setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z); - sp->xrepeat = sp->yrepeat = 8+(TRAND&7); - } - else sp->xrepeat = sp->yrepeat = 16+(TRAND&15); + } - sp->shade = -16; - sp->cstat |= 128; - if (j >= 0) - { - if (sector[sprite[j].sectnum].lotag == 2) - { - sp->z = getceilzofslope(SECT,SX,SY)+(16<<8); - sp->cstat |= 8; - } - else if (sector[sprite[j].sectnum].lotag == 1) - sp->z = getflorzofslope(SECT,SX,SY); - } - if (sector[sect].floorpicnum == FLOORSLIME || - sector[sect].ceilingpicnum == FLOORSLIME) - sp->pal = 7; - case NEON1__STATIC: - case NEON2__STATIC: - case NEON3__STATIC: - case NEON4__STATIC: - case NEON5__STATIC: - case NEON6__STATIC: - case DOMELITE__STATIC: - if (sp->picnum != WATERSPLASH2) - sp->cstat |= 257; - case NUKEBUTTON__STATIC: - if (sp->picnum == DOMELITE) - sp->cstat |= 257; - case JIBS1__STATIC: - case JIBS2__STATIC: - case JIBS3__STATIC: - case JIBS4__STATIC: - case JIBS5__STATIC: - case JIBS6__STATIC: - case HEADJIB1__STATIC: - case ARMJIB1__STATIC: - case LEGJIB1__STATIC: - case LIZMANHEAD1__STATIC: - case LIZMANARM1__STATIC: - case LIZMANLEG1__STATIC: - case DUKETORSO__STATIC: - case DUKEGUN__STATIC: - case DUKELEG__STATIC: + } + + if (sector[SECT].lotag == 1) + { + changespritestat(i,5); + break; + } + + if (j >= 0 && sp->picnum != PUKE) + { + if (sprite[j].pal == 1) + sp->pal = 1; + else if (sprite[j].pal != 6 && sprite[j].picnum != NUKEBARREL && sprite[j].picnum != TIRE) + { + if (sprite[j].picnum == FECES) + sp->pal = 7; // Brown + else sp->pal = 2; // Red + } + else sp->pal = 0; // green + + if (sprite[j].picnum == TIRE) + sp->shade = 127; + } + sp->cstat |= 32; + case FECES__STATIC: + if (j >= 0) + sp->xrepeat = sp->yrepeat = 1; + changespritestat(i,5); + break; + + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + sp->cstat |= 16; + sp->xrepeat = 7+(TRAND&7); + sp->yrepeat = 7+(TRAND&7); + sp->z -= (16<<8); + if (j >= 0 && sprite[j].pal == 6) + sp->pal = 6; + insertspriteq(i); + changespritestat(i,5); + break; + + case TRIPBOMB__STATIC: + if (sp->lotag > ud.player_skill) + { + sp->xrepeat=sp->yrepeat=0; changespritestat(i,5); break; - case TONGUE__STATIC: - if (j >= 0) - sp->ang = sprite[j].ang; - sp->z -= 38<<8; - sp->zvel = 256-(TRAND&511); - sp->xvel = 64-(TRAND&127); - changespritestat(i,4); - break; - case NATURALLIGHTNING__STATIC: - sp->cstat &= ~257; - sp->cstat |= 32768; - break; - case TRANSPORTERSTAR__STATIC: - case TRANSPORTERBEAM__STATIC: - if (j == -1) break; - if (sp->picnum == TRANSPORTERBEAM) - { - sp->xrepeat = 31; - sp->yrepeat = 1; - sp->z = sector[sprite[j].sectnum].floorz-(40<<8); - } - else - { - if (sprite[j].statnum == 4) - { - sp->xrepeat = 8; - sp->yrepeat = 8; - } - else - { - sp->xrepeat = 48; - sp->yrepeat = 64; - if (sprite[j].statnum == 10 || badguy(&sprite[j])) - sp->z -= (32<<8); - } - } + } - sp->shade = -127; - sp->cstat = 128|2; - sp->ang = sprite[j].ang; + sp->xrepeat=4; + sp->yrepeat=5; - sp->xvel = 128; + sp->owner = i; + sp->hitag = i; + + sp->xvel = 16; + ssp(i,CLIPMASK0); + hittype[i].temp_data[0] = 17; + hittype[i].temp_data[2] = 0; + hittype[i].temp_data[5] = sp->ang; + + case SPACEMARINE__STATIC: + if (sp->picnum == SPACEMARINE) + { + sp->extra = 20; + sp->cstat |= 257; + } + changespritestat(i,2); + break; + + case HYDRENT__STATIC: + case PANNEL1__STATIC: + case PANNEL2__STATIC: + case SATELITE__STATIC: + case FUELPOD__STATIC: + case SOLARPANNEL__STATIC: + case ANTENNA__STATIC: + case GRATE1__STATIC: + case CHAIR1__STATIC: + case CHAIR2__STATIC: + case CHAIR3__STATIC: + case BOTTLE1__STATIC: + case BOTTLE2__STATIC: + case BOTTLE3__STATIC: + case BOTTLE4__STATIC: + case BOTTLE5__STATIC: + case BOTTLE6__STATIC: + case BOTTLE7__STATIC: + case BOTTLE8__STATIC: + case BOTTLE10__STATIC: + case BOTTLE11__STATIC: + case BOTTLE12__STATIC: + case BOTTLE13__STATIC: + case BOTTLE14__STATIC: + case BOTTLE15__STATIC: + case BOTTLE16__STATIC: + case BOTTLE17__STATIC: + case BOTTLE18__STATIC: + case BOTTLE19__STATIC: + case OCEANSPRITE1__STATIC: + case OCEANSPRITE2__STATIC: + case OCEANSPRITE3__STATIC: + case OCEANSPRITE5__STATIC: + case MONK__STATIC: + case INDY__STATIC: + case LUKE__STATIC: + case JURYGUY__STATIC: + case SCALE__STATIC: + case VACUUM__STATIC: + case FANSPRITE__STATIC: + case CACTUS__STATIC: + case CACTUSBROKE__STATIC: + case HANGLIGHT__STATIC: + case FETUS__STATIC: + case FETUSBROKE__STATIC: + case CAMERALIGHT__STATIC: + case MOVIECAMERA__STATIC: + case IVUNIT__STATIC: + case POT1__STATIC: + case POT2__STATIC: + case POT3__STATIC: + case TRIPODCAMERA__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case SUSHIPLATE5__STATIC: + case WAITTOBESEATED__STATIC: + case VASE__STATIC: + case PIPE1__STATIC: + case PIPE2__STATIC: + case PIPE3__STATIC: + case PIPE4__STATIC: + case PIPE5__STATIC: + case PIPE6__STATIC: + sp->clipdist = 32; + sp->cstat |= 257; + case OCEANSPRITE4__STATIC: + changespritestat(i,0); + break; + case FEMMAG1__STATIC: + case FEMMAG2__STATIC: + sp->cstat &= ~257; + changespritestat(i,0); + break; + case DUKETAG__STATIC: + case SIGN1__STATIC: + case SIGN2__STATIC: + if (ud.multimode < 2 && sp->pal) + { + sp->xrepeat = sp->yrepeat = 0; changespritestat(i,5); - ssp(i,CLIPMASK0); - setsprite(i,sp->x,sp->y,sp->z); - break; - - case FRAMEEFFECT1_13__STATIC: - if (PLUTOPAK) break; - case FRAMEEFFECT1__STATIC: - if (j >= 0) - { - sp->xrepeat = sprite[j].xrepeat; - sp->yrepeat = sprite[j].yrepeat; - T2 = sprite[j].picnum; - } - else sp->xrepeat = sp->yrepeat = 0; - - changespritestat(i,5); - - break; - - case LASERLINE__STATIC: - sp->yrepeat = 6; - sp->xrepeat = 32; - - if (lasermode == 1) - sp->cstat = 16 + 2; - else if (lasermode == 0 || lasermode == 2) - sp->cstat = 16; - else - { - sp->xrepeat = 0; - sp->yrepeat = 0; - } - - if (j >= 0) sp->ang = hittype[j].temp_data[5]+512; - changespritestat(i,5); - break; - - case FORCESPHERE__STATIC: - if (j == -1) - { - sp->cstat = (short) 32768; - changespritestat(i,2); - } - else - { - sp->xrepeat = sp->yrepeat = 1; - changespritestat(i,5); - } - break; - - case BLOOD__STATIC: - sp->xrepeat = sp->yrepeat = 16; - sp->z -= (26<<8); - if (j >= 0 && sprite[j].pal == 6) - sp->pal = 6; - changespritestat(i,5); - break; - case BLOODPOOL__STATIC: - case PUKE__STATIC: + } + else sp->pal = 0; + break; + case MASKWALL1__STATIC: + case MASKWALL2__STATIC: + case MASKWALL3__STATIC: + case MASKWALL4__STATIC: + case MASKWALL5__STATIC: + case MASKWALL6__STATIC: + case MASKWALL7__STATIC: + case MASKWALL8__STATIC: + case MASKWALL9__STATIC: + case MASKWALL10__STATIC: + case MASKWALL11__STATIC: + case MASKWALL12__STATIC: + case MASKWALL13__STATIC: + case MASKWALL14__STATIC: + case MASKWALL15__STATIC: + j = sp->cstat&60; + sp->cstat = j|1; + changespritestat(i,0); + break; + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if (j >= 0) { short s1; s1 = sp->sectnum; - updatesector(sp->x+108,sp->y+108,&s1); + updatesector(sp->x+84,sp->y+84,&s1); if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) { - updatesector(sp->x-108,sp->y-108,&s1); + updatesector(sp->x-84,sp->y-84,&s1); if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) { - updatesector(sp->x+108,sp->y-108,&s1); + updatesector(sp->x+84,sp->y-84,&s1); if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) { - updatesector(sp->x-108,sp->y+108,&s1); + updatesector(sp->x-84,sp->y+84,&s1); if (s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) { sp->xrepeat = sp->yrepeat = 0; @@ -4663,7 +4894,6 @@ short spawn(short j, short pn) else { sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); break; } @@ -4672,7 +4902,6 @@ short spawn(short j, short pn) else { sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); break; } @@ -4681,1501 +4910,1272 @@ short spawn(short j, short pn) else { sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); break; } - + sp->cstat = 32+((ps[sprite[j].yvel].footprintcount&1)<<2); + sp->ang = sprite[j].ang; } - if (sector[SECT].lotag == 1) + sp->z = sector[sect].floorz; + if (sector[sect].lotag != 1 && sector[sect].lotag != 2) + sp->xrepeat = sp->yrepeat = 32; + + insertspriteq(i); + changespritestat(i,5); + break; + + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + case TOUGHGAL__STATIC: + sp->yvel = sp->hitag; + sp->hitag = -1; + if (sp->picnum == PODFEM1) sp->extra <<= 1; + case BLOODYPOLE__STATIC: + + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + + if (sp->picnum == QUEBALL || sp->picnum == STRIPEBALL) { - changespritestat(i,5); - break; + sp->cstat = 256; + sp->clipdist = 8; } - - if (j >= 0 && sp->picnum != PUKE) + else { - if (sprite[j].pal == 1) - sp->pal = 1; - else if (sprite[j].pal != 6 && sprite[j].picnum != NUKEBARREL && sprite[j].picnum != TIRE) - { - if (sprite[j].picnum == FECES) - sp->pal = 7; // Brown - else sp->pal = 2; // Red - } - else sp->pal = 0; // green - - if (sprite[j].picnum == TIRE) - sp->shade = 127; - } - sp->cstat |= 32; - case FECES__STATIC: - if (j >= 0) - sp->xrepeat = sp->yrepeat = 1; - changespritestat(i,5); - break; - - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - sp->cstat |= 16; - sp->xrepeat = 7+(TRAND&7); - sp->yrepeat = 7+(TRAND&7); - sp->z -= (16<<8); - if (j >= 0 && sprite[j].pal == 6) - sp->pal = 6; - insertspriteq(i); - changespritestat(i,5); - break; - - case TRIPBOMB__STATIC: - if (sp->lotag > ud.player_skill) - { - sp->xrepeat=sp->yrepeat=0; - changespritestat(i,5); - break; - } - - sp->xrepeat=4; - sp->yrepeat=5; - - sp->owner = i; - sp->hitag = i; - - sp->xvel = 16; - ssp(i,CLIPMASK0); - hittype[i].temp_data[0] = 17; - hittype[i].temp_data[2] = 0; - hittype[i].temp_data[5] = sp->ang; - - case SPACEMARINE__STATIC: - if (sp->picnum == SPACEMARINE) - { - sp->extra = 20; - sp->cstat |= 257; - } - changespritestat(i,2); - break; - - case HYDRENT__STATIC: - case PANNEL1__STATIC: - case PANNEL2__STATIC: - case SATELITE__STATIC: - case FUELPOD__STATIC: - case SOLARPANNEL__STATIC: - case ANTENNA__STATIC: - case GRATE1__STATIC: - case CHAIR1__STATIC: - case CHAIR2__STATIC: - case CHAIR3__STATIC: - case BOTTLE1__STATIC: - case BOTTLE2__STATIC: - case BOTTLE3__STATIC: - case BOTTLE4__STATIC: - case BOTTLE5__STATIC: - case BOTTLE6__STATIC: - case BOTTLE7__STATIC: - case BOTTLE8__STATIC: - case BOTTLE10__STATIC: - case BOTTLE11__STATIC: - case BOTTLE12__STATIC: - case BOTTLE13__STATIC: - case BOTTLE14__STATIC: - case BOTTLE15__STATIC: - case BOTTLE16__STATIC: - case BOTTLE17__STATIC: - case BOTTLE18__STATIC: - case BOTTLE19__STATIC: - case OCEANSPRITE1__STATIC: - case OCEANSPRITE2__STATIC: - case OCEANSPRITE3__STATIC: - case OCEANSPRITE5__STATIC: - case MONK__STATIC: - case INDY__STATIC: - case LUKE__STATIC: - case JURYGUY__STATIC: - case SCALE__STATIC: - case VACUUM__STATIC: - case FANSPRITE__STATIC: - case CACTUS__STATIC: - case CACTUSBROKE__STATIC: - case HANGLIGHT__STATIC: - case FETUS__STATIC: - case FETUSBROKE__STATIC: - case CAMERALIGHT__STATIC: - case MOVIECAMERA__STATIC: - case IVUNIT__STATIC: - case POT1__STATIC: - case POT2__STATIC: - case POT3__STATIC: - case TRIPODCAMERA__STATIC: - case SUSHIPLATE1__STATIC: - case SUSHIPLATE2__STATIC: - case SUSHIPLATE3__STATIC: - case SUSHIPLATE4__STATIC: - case SUSHIPLATE5__STATIC: - case WAITTOBESEATED__STATIC: - case VASE__STATIC: - case PIPE1__STATIC: - case PIPE2__STATIC: - case PIPE3__STATIC: - case PIPE4__STATIC: - case PIPE5__STATIC: - case PIPE6__STATIC: - sp->clipdist = 32; sp->cstat |= 257; - case OCEANSPRITE4__STATIC: - changespritestat(i,0); - break; - case FEMMAG1__STATIC: - case FEMMAG2__STATIC: - sp->cstat &= ~257; - changespritestat(i,0); - break; - case DUKETAG__STATIC: - case SIGN1__STATIC: - case SIGN2__STATIC: - if (ud.multimode < 2 && sp->pal) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - } - else sp->pal = 0; - break; - case MASKWALL1__STATIC: - case MASKWALL2__STATIC: - case MASKWALL3__STATIC: - case MASKWALL4__STATIC: - case MASKWALL5__STATIC: - case MASKWALL6__STATIC: - case MASKWALL7__STATIC: - case MASKWALL8__STATIC: - case MASKWALL9__STATIC: - case MASKWALL10__STATIC: - case MASKWALL11__STATIC: - case MASKWALL12__STATIC: - case MASKWALL13__STATIC: - case MASKWALL14__STATIC: - case MASKWALL15__STATIC: - j = sp->cstat&60; - sp->cstat = j|1; - changespritestat(i,0); - break; - case FOOTPRINTS__STATIC: - case FOOTPRINTS2__STATIC: - case FOOTPRINTS3__STATIC: - case FOOTPRINTS4__STATIC: - if (j >= 0) - { - short s1; - s1 = sp->sectnum; + sp->clipdist = 32; + } - updatesector(sp->x+84,sp->y+84,&s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) - { - updatesector(sp->x-84,sp->y-84,&s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) - { - updatesector(sp->x+84,sp->y-84,&s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) - { - updatesector(sp->x-84,sp->y+84,&s1); - if (s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } + changespritestat(i,2); + break; + case DUKELYINGDEAD__STATIC: + if (j >= 0 && sprite[j].picnum == APLAYER) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + sp->shade = sprite[j].shade; + sp->pal = ps[sprite[j].yvel].palookup; + } + case DUKECAR__STATIC: + case HELECOPT__STATIC: + // if(sp->picnum == HELECOPT || sp->picnum == DUKECAR) sp->xvel = 1024; + sp->cstat = 0; + sp->extra = 1; + sp->xvel = 292; + sp->zvel = 360; + case RESPAWNMARKERRED__STATIC: + case BLIMP__STATIC: - } - else - { - sp->xrepeat = sp->yrepeat = 0; - break; - } - - - } - else - { - sp->xrepeat = sp->yrepeat = 0; - break; - } - - - } - else - { - sp->xrepeat = sp->yrepeat = 0; - break; - } - - sp->cstat = 32+((ps[sprite[j].yvel].footprintcount&1)<<2); - sp->ang = sprite[j].ang; - } - - sp->z = sector[sect].floorz; - if (sector[sect].lotag != 1 && sector[sect].lotag != 2) - sp->xrepeat = sp->yrepeat = 32; - - insertspriteq(i); - changespritestat(i,5); - break; - - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case PODFEM1__STATIC: - case NAKED1__STATIC: - case STATUE__STATIC: - case TOUGHGAL__STATIC: + if (sp->picnum == RESPAWNMARKERRED) + { + sp->xrepeat = sp->yrepeat = 24; + if (j >= 0) sp->z = hittype[j].floorz; // -(1<<4); + } + else + { + sp->cstat |= 257; + sp->clipdist = 128; + } + case MIKE__STATIC: + if (sp->picnum == MIKE) + { sp->yvel = sp->hitag; - sp->hitag = -1; - if (sp->picnum == PODFEM1) sp->extra <<= 1; - case BLOODYPOLE__STATIC: + sp->hitag = 0; + } + case WEATHERWARN__STATIC: + changespritestat(i,1); + break; - case QUEBALL__STATIC: - case STRIPEBALL__STATIC: + case SPOTLITE__STATIC: + T1 = sp->x; + T2 = sp->y; + break; + case BULLETHOLE__STATIC: + sp->xrepeat = sp->yrepeat = 3; + sp->cstat = 16+(krand()&12); + insertspriteq(i); + case MONEY__STATIC: + case MAIL__STATIC: + case PAPER__STATIC: + if (sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER) + { + hittype[i].temp_data[0] = TRAND&2047; + sp->cstat = TRAND&12; + sp->xrepeat = sp->yrepeat = 8; + sp->ang = TRAND&2047; + } + changespritestat(i,5); + break; - if (sp->picnum == QUEBALL || sp->picnum == STRIPEBALL) + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + sp->owner = i; + sp->lotag = 1; + sp->extra = 1; + changespritestat(i,6); + break; + + case SHELL__STATIC: //From the player + case SHOTGUNSHELL__STATIC: + if (j >= 0) + { + short snum,a; + + if (sprite[j].picnum == APLAYER) { - sp->cstat = 256; - sp->clipdist = 8; + snum = sprite[j].yvel; + a = ps[snum].ang-(TRAND&63)+8; //Fine tune + + T1 = TRAND&1; + if (sp->picnum == SHOTGUNSHELL) + sp->z = (6<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); + else sp->z = (3<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); + sp->zvel = -(TRAND&255); } else { - sp->cstat |= 257; - sp->clipdist = 32; + a = sp->ang; + sp->z = sprite[j].z-PHEIGHT+(3<<8); } - changespritestat(i,2); - break; + sp->x = sprite[j].x+(sintable[(a+512)&2047]>>7); + sp->y = sprite[j].y+(sintable[a&2047]>>7); - case DUKELYINGDEAD__STATIC: - if (j >= 0 && sprite[j].picnum == APLAYER) - { - sp->xrepeat = sprite[j].xrepeat; - sp->yrepeat = sprite[j].yrepeat; - sp->shade = sprite[j].shade; - sp->pal = ps[sprite[j].yvel].palookup; - } - case DUKECAR__STATIC: - case HELECOPT__STATIC: - // if(sp->picnum == HELECOPT || sp->picnum == DUKECAR) sp->xvel = 1024; - sp->cstat = 0; - sp->extra = 1; - sp->xvel = 292; - sp->zvel = 360; - case RESPAWNMARKERRED__STATIC: - case BLIMP__STATIC: + sp->shade = -8; - if (sp->picnum == RESPAWNMARKERRED) + if (sp->yvel == 1 || NAM) { - sp->xrepeat = sp->yrepeat = 24; - if (j >= 0) sp->z = hittype[j].floorz; // -(1<<4); + sp->ang = a+512; + sp->xvel = 30; } else { - sp->cstat |= 257; - sp->clipdist = 128; - } - case MIKE__STATIC: - if (sp->picnum == MIKE) - { - sp->yvel = sp->hitag; - sp->hitag = 0; - } - case WEATHERWARN__STATIC: - changespritestat(i,1); - break; - - case SPOTLITE__STATIC: - T1 = sp->x; - T2 = sp->y; - break; - case BULLETHOLE__STATIC: - sp->xrepeat = sp->yrepeat = 3; - sp->cstat = 16+(krand()&12); - insertspriteq(i); - case MONEY__STATIC: - case MAIL__STATIC: - case PAPER__STATIC: - if (sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER) - { - hittype[i].temp_data[0] = TRAND&2047; - sp->cstat = TRAND&12; - sp->xrepeat = sp->yrepeat = 8; - sp->ang = TRAND&2047; - } - changespritestat(i,5); - break; - - case VIEWSCREEN__STATIC: - case VIEWSCREEN2__STATIC: - sp->owner = i; - sp->lotag = 1; - sp->extra = 1; - changespritestat(i,6); - break; - - case SHELL__STATIC: //From the player - case SHOTGUNSHELL__STATIC: - if (j >= 0) - { - short snum,a; - - if (sprite[j].picnum == APLAYER) - { - snum = sprite[j].yvel; - a = ps[snum].ang-(TRAND&63)+8; //Fine tune - - T1 = TRAND&1; - if (sp->picnum == SHOTGUNSHELL) - sp->z = (6<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); - else sp->z = (3<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); - sp->zvel = -(TRAND&255); - } - else - { - a = sp->ang; - sp->z = sprite[j].z-PHEIGHT+(3<<8); - } - - sp->x = sprite[j].x+(sintable[(a+512)&2047]>>7); - sp->y = sprite[j].y+(sintable[a&2047]>>7); - - sp->shade = -8; - - if (sp->yvel == 1 || NAM) - { - sp->ang = a+512; - sp->xvel = 30; - } - else - { - sp->ang = a-512; - sp->xvel = 20; - } - sp->xrepeat=sp->yrepeat=4; - - changespritestat(i,5); - } - break; - - case RESPAWN__STATIC: - sp->extra = 66-13; - case MUSICANDSFX__STATIC: - if (ud.multimode < 2 && sp->pal == 1) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } - sp->cstat = (short)32768; - changespritestat(i,11); - break; - - case EXPLOSION2__STATIC: - case EXPLOSION2BOT__STATIC: - case BURNING__STATIC: - case BURNING2__STATIC: - case SMALLSMOKE__STATIC: - case SHRINKEREXPLOSION__STATIC: - case COOLEXPLOSION1__STATIC: - - if (j >= 0) - { - sp->ang = sprite[j].ang; - sp->shade = -64; - sp->cstat = 128|(TRAND&4); - } - - if (sp->picnum == EXPLOSION2 || sp->picnum == EXPLOSION2BOT) - { - sp->xrepeat = 48; - sp->yrepeat = 48; - sp->shade = -127; - sp->cstat |= 128; - } - else if (sp->picnum == SHRINKEREXPLOSION) - { - sp->xrepeat = 32; - sp->yrepeat = 32; - } - else if (sp->picnum == SMALLSMOKE) - { - // 64 "money" - sp->xrepeat = 24; - sp->yrepeat = 24; - } - else if (sp->picnum == BURNING || sp->picnum == BURNING2) - { - sp->xrepeat = 4; - sp->yrepeat = 4; - } - - if (j >= 0) - { - x = getflorzofslope(sp->sectnum,sp->x,sp->y); - if (sp->z > x-(12<<8)) - sp->z = x-(12<<8); + sp->ang = a-512; + sp->xvel = 20; } + sp->xrepeat=sp->yrepeat=4; changespritestat(i,5); + } + break; - break; - - case PLAYERONWATER__STATIC: - if (j >= 0) - { - sp->xrepeat = sprite[j].xrepeat; - sp->yrepeat = sprite[j].yrepeat; - sp->zvel = 128; - if (sector[sp->sectnum].lotag != 2) - sp->cstat |= 32768; - } - changespritestat(i,13); - break; - - case APLAYER__STATIC: + case RESPAWN__STATIC: + sp->extra = 66-13; + case MUSICANDSFX__STATIC: + if (ud.multimode < 2 && sp->pal == 1) + { sp->xrepeat = sp->yrepeat = 0; - //j = ud.coop; - //if(j == 2) j = 0; - j=(gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSPAWN) / GAMETYPE_FLAG_COOPSPAWN ; - if (ud.multimode < 2 || (ud.multimode > 1 && j != sp->lotag)) - changespritestat(i,5); - else - changespritestat(i,10); - break; - case WATERBUBBLE__STATIC: - if (j >= 0 && sprite[j].picnum == APLAYER) - sp->z -= (16<<8); - if (sp->picnum == WATERBUBBLE) - { - if (j >= 0) - sp->ang = sprite[j].ang; - sp->xrepeat = sp->yrepeat = 4; - } - else sp->xrepeat = sp->yrepeat = 32; - changespritestat(i,5); break; + } + sp->cstat = (short)32768; + changespritestat(i,11); + break; - case CRANE__STATIC: + case EXPLOSION2__STATIC: + case EXPLOSION2BOT__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + case SMALLSMOKE__STATIC: + case SHRINKEREXPLOSION__STATIC: + case COOLEXPLOSION1__STATIC: - sp->cstat |= 64|257; - - sp->picnum += 2; - sp->z = sector[sect].ceilingz+(48<<8); - T5 = tempwallptr; - - msx[tempwallptr] = sp->x; - msy[tempwallptr] = sp->y; - msx[tempwallptr+2] = sp->z; - - s = headspritestat[0]; - while (s >= 0) - { - if (sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag)) - { - msy[tempwallptr+2] = s; - - T2 = sprite[s].sectnum; - - sprite[s].xrepeat = 48; - sprite[s].yrepeat = 128; - - msx[tempwallptr+1] = sprite[s].x; - msy[tempwallptr+1] = sprite[s].y; - - sprite[s].x = sp->x; - sprite[s].y = sp->y; - sprite[s].z = sp->z; - sprite[s].shade = sp->shade; - - setsprite(s,sprite[s].x,sprite[s].y,sprite[s].z); - break; - } - s = nextspritestat[s]; - } - - tempwallptr += 3; - sp->owner = -1; - sp->extra = 8; - changespritestat(i,6); - break; - - case WATERDRIP__STATIC: - if ((j >= 0 && sprite[j].statnum == 10) || sprite[j].statnum == 1) - { - sp->shade = 32; - if (sprite[j].pal != 1) - { - sp->pal = 2; - sp->z -= (18<<8); - } - else sp->z -= (13<<8); - sp->ang = getangle(ps[connecthead].posx-sp->x,ps[connecthead].posy-sp->y); - sp->xvel = 48-(TRAND&31); - ssp(i,CLIPMASK0); - } - else if (j == -1) - { - sp->z += (4<<8); - T1 = sp->z; - T2 = TRAND&127; - } - case TRASH__STATIC: - - if (sp->picnum != WATERDRIP) - sp->ang = TRAND&2047; - - case WATERDRIPSPLASH__STATIC: + if (j >= 0) + { + sp->ang = sprite[j].ang; + sp->shade = -64; + sp->cstat = 128|(TRAND&4); + } + if (sp->picnum == EXPLOSION2 || sp->picnum == EXPLOSION2BOT) + { + sp->xrepeat = 48; + sp->yrepeat = 48; + sp->shade = -127; + sp->cstat |= 128; + } + else if (sp->picnum == SHRINKEREXPLOSION) + { + sp->xrepeat = 32; + sp->yrepeat = 32; + } + else if (sp->picnum == SMALLSMOKE) + { + // 64 "money" sp->xrepeat = 24; sp->yrepeat = 24; + } + else if (sp->picnum == BURNING || sp->picnum == BURNING2) + { + sp->xrepeat = 4; + sp->yrepeat = 4; + } + if (j >= 0) + { + x = getflorzofslope(sp->sectnum,sp->x,sp->y); + if (sp->z > x-(12<<8)) + sp->z = x-(12<<8); + } - changespritestat(i,6); - break; + changespritestat(i,5); - case PLUG__STATIC: - sp->lotag = 9999; - changespritestat(i,6); - break; - case TOUCHPLATE__STATIC: - T3 = sector[sect].floorz; - if (sector[sect].lotag != 1 && sector[sect].lotag != 2) - sector[sect].floorz = sp->z; - if (sp->pal && ud.multimode > 1) - { - sp->xrepeat=sp->yrepeat=0; - changespritestat(i,5); - break; - } - case WATERBUBBLEMAKER__STATIC: - if (sp->hitag && sp->picnum == WATERBUBBLEMAKER) - { // JBF 20030913: Pisses off move(), eg. in bobsp2 - OSD_Printf("WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup.\n", - i,sp->x,sp->y); - sp->hitag = 0; - } - sp->cstat |= 32768; - changespritestat(i,6); - break; - //case BOLT1: - //case BOLT1+1: - //case BOLT1+2: - //case BOLT1+3: - //case SIDEBOLT1: - //case SIDEBOLT1+1: - //case SIDEBOLT1+2: - //case SIDEBOLT1+3: - // T1 = sp->xrepeat; - // T2 = sp->yrepeat; - case MASTERSWITCH__STATIC: - if (sp->picnum == MASTERSWITCH) + break; + + case PLAYERONWATER__STATIC: + if (j >= 0) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + sp->zvel = 128; + if (sector[sp->sectnum].lotag != 2) sp->cstat |= 32768; - sp->yvel = 0; - changespritestat(i,6); - break; - case TARGET__STATIC: - case DUCK__STATIC: - case LETTER__STATIC: - sp->extra = 1; - sp->cstat |= 257; - changespritestat(i,1); - break; - case OCTABRAINSTAYPUT__STATIC: - case LIZTROOPSTAYPUT__STATIC: - case PIGCOPSTAYPUT__STATIC: - case LIZMANSTAYPUT__STATIC: - case BOSS1STAYPUT__STATIC: - case PIGCOPDIVE__STATIC: - case COMMANDERSTAYPUT__STATIC: - case BOSS4STAYPUT__STATIC: - hittype[i].actorstayput = sp->sectnum; - case BOSS1__STATIC: - case BOSS2__STATIC: - case BOSS3__STATIC: - case BOSS4__STATIC: - case ROTATEGUN__STATIC: - case GREENSLIME__STATIC: - if (sp->picnum == GREENSLIME) - sp->extra = 1; - case DRONE__STATIC: - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - case OCTABRAIN__STATIC: - case COMMANDER__STATIC: - case PIGCOP__STATIC: - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - case ORGANTIC__STATIC: - case RAT__STATIC: - case SHARK__STATIC: + } + changespritestat(i,13); + break; - if (sp->pal == 0) - { - switch (dynamictostatic[sp->picnum]) - { - case LIZTROOPONTOILET__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOPSTAYPUT__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOP__STATIC: - sp->pal = 22; - break; - } - } + case APLAYER__STATIC: + sp->xrepeat = sp->yrepeat = 0; + //j = ud.coop; + //if(j == 2) j = 0; + j=(gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSPAWN) / GAMETYPE_FLAG_COOPSPAWN ; + if (ud.multimode < 2 || (ud.multimode > 1 && j != sp->lotag)) + changespritestat(i,5); + else + changespritestat(i,10); + break; + case WATERBUBBLE__STATIC: + if (j >= 0 && sprite[j].picnum == APLAYER) + sp->z -= (16<<8); + if (sp->picnum == WATERBUBBLE) + { + if (j >= 0) + sp->ang = sprite[j].ang; + sp->xrepeat = sp->yrepeat = 4; + } + else sp->xrepeat = sp->yrepeat = 32; - if (sp->picnum == BOSS4STAYPUT || sp->picnum == BOSS1 || sp->picnum == BOSS2 || sp->picnum == BOSS1STAYPUT || sp->picnum == BOSS3 || sp->picnum == BOSS4) - { - if (j >= 0 && sprite[j].picnum == RESPAWN) - sp->pal = sprite[j].pal; - if (sp->pal) - { - sp->clipdist = 80; - sp->xrepeat = 40; - sp->yrepeat = 40; - } - else - { - sp->xrepeat = 80; - sp->yrepeat = 80; - sp->clipdist = 164; - } - } - else - { - if (sp->picnum != SHARK) - { - sp->xrepeat = 40; - sp->yrepeat = 40; - sp->clipdist = 80; - } - else - { - sp->xrepeat = 60; - sp->yrepeat = 60; - sp->clipdist = 40; - } - } + changespritestat(i,5); + break; - if (j >= 0) sp->lotag = 0; + case CRANE__STATIC: - if ((sp->lotag > ud.player_skill) || ud.monsters_off == 1) + sp->cstat |= 64|257; + + sp->picnum += 2; + sp->z = sector[sect].ceilingz+(48<<8); + T5 = tempwallptr; + + msx[tempwallptr] = sp->x; + msy[tempwallptr] = sp->y; + msx[tempwallptr+2] = sp->z; + + s = headspritestat[0]; + while (s >= 0) + { + if (sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag)) { - sp->xrepeat=sp->yrepeat=0; - changespritestat(i,5); + msy[tempwallptr+2] = s; + + T2 = sprite[s].sectnum; + + sprite[s].xrepeat = 48; + sprite[s].yrepeat = 128; + + msx[tempwallptr+1] = sprite[s].x; + msy[tempwallptr+1] = sprite[s].y; + + sprite[s].x = sp->x; + sprite[s].y = sp->y; + sprite[s].z = sp->z; + sprite[s].shade = sp->shade; + + setsprite(s,sprite[s].x,sprite[s].y,sprite[s].z); break; } - else + s = nextspritestat[s]; + } + + tempwallptr += 3; + sp->owner = -1; + sp->extra = 8; + changespritestat(i,6); + break; + + case WATERDRIP__STATIC: + if ((j >= 0 && sprite[j].statnum == 10) || sprite[j].statnum == 1) + { + sp->shade = 32; + if (sprite[j].pal != 1) { - makeitfall(i); - - if (sp->picnum == RAT) - { - sp->ang = TRAND&2047; - sp->xrepeat = sp->yrepeat = 48; - sp->cstat = 0; - } - else - { - sp->cstat |= 257; - - if (sp->picnum != SHARK) - ps[myconnectindex].max_actors_killed++; - } - - if (sp->picnum == ORGANTIC) sp->cstat |= 128; - - if (j >= 0) - { - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i,1); - } - else changespritestat(i,2); + sp->pal = 2; + sp->z -= (18<<8); } + else sp->z -= (13<<8); + sp->ang = getangle(ps[connecthead].posx-sp->x,ps[connecthead].posy-sp->y); + sp->xvel = 48-(TRAND&31); + ssp(i,CLIPMASK0); + } + else if (j == -1) + { + sp->z += (4<<8); + T1 = sp->z; + T2 = TRAND&127; + } + case TRASH__STATIC: - if (sp->picnum == ROTATEGUN) - sp->zvel = 0; + if (sp->picnum != WATERDRIP) + sp->ang = TRAND&2047; + case WATERDRIPSPLASH__STATIC: + + sp->xrepeat = 24; + sp->yrepeat = 24; + + + changespritestat(i,6); + break; + + case PLUG__STATIC: + sp->lotag = 9999; + changespritestat(i,6); + break; + case TOUCHPLATE__STATIC: + T3 = sector[sect].floorz; + if (sector[sect].lotag != 1 && sector[sect].lotag != 2) + sector[sect].floorz = sp->z; + if (sp->pal && ud.multimode > 1) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); break; - - case LOCATORS__STATIC: + } + case WATERBUBBLEMAKER__STATIC: + if (sp->hitag && sp->picnum == WATERBUBBLEMAKER) + { // JBF 20030913: Pisses off move(), eg. in bobsp2 + OSD_Printf("WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup.\n", + i,sp->x,sp->y); + sp->hitag = 0; + } + sp->cstat |= 32768; + changespritestat(i,6); + break; + //case BOLT1: + //case BOLT1+1: + //case BOLT1+2: + //case BOLT1+3: + //case SIDEBOLT1: + //case SIDEBOLT1+1: + //case SIDEBOLT1+2: + //case SIDEBOLT1+3: + // T1 = sp->xrepeat; + // T2 = sp->yrepeat; + case MASTERSWITCH__STATIC: + if (sp->picnum == MASTERSWITCH) sp->cstat |= 32768; - changespritestat(i,7); - break; + sp->yvel = 0; + changespritestat(i,6); + break; + case TARGET__STATIC: + case DUCK__STATIC: + case LETTER__STATIC: + sp->extra = 1; + sp->cstat |= 257; + changespritestat(i,1); + break; + case OCTABRAINSTAYPUT__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case PIGCOPSTAYPUT__STATIC: + case LIZMANSTAYPUT__STATIC: + case BOSS1STAYPUT__STATIC: + case PIGCOPDIVE__STATIC: + case COMMANDERSTAYPUT__STATIC: + case BOSS4STAYPUT__STATIC: + hittype[i].actorstayput = sp->sectnum; + case BOSS1__STATIC: + case BOSS2__STATIC: + case BOSS3__STATIC: + case BOSS4__STATIC: + case ROTATEGUN__STATIC: + case GREENSLIME__STATIC: + if (sp->picnum == GREENSLIME) + sp->extra = 1; + case DRONE__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case PIGCOP__STATIC: + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + case ORGANTIC__STATIC: + case RAT__STATIC: + case SHARK__STATIC: - case ACTIVATORLOCKED__STATIC: - case ACTIVATOR__STATIC: - sp->cstat = (short) 32768; - if (sp->picnum == ACTIVATORLOCKED) - sector[sp->sectnum].lotag |= 16384; - changespritestat(i,8); - break; - - case DOORSHOCK__STATIC: - sp->cstat |= 1+256; - sp->shade = -12; - changespritestat(i,6); - break; - - case OOZ__STATIC: - case OOZ2__STATIC: - sp->shade = -12; - - if (j >= 0) + if (sp->pal == 0) + { + switch (dynamictostatic[sp->picnum]) { - if (sprite[j].picnum == NUKEBARREL) - sp->pal = 8; - insertspriteq(i); - } - - changespritestat(i,1); - - getglobalz(i); - - j = (hittype[i].floorz-hittype[i].ceilingz)>>9; - - sp->yrepeat = j; - sp->xrepeat = 25-(j>>1); - sp->cstat |= (TRAND&4); - - break; - - case HEAVYHBOMB__STATIC: - if (j >= 0) - sp->owner = j; - else sp->owner = i; - sp->xrepeat = sp->yrepeat = 9; - sp->yvel = 4; - case REACTOR2__STATIC: - case REACTOR__STATIC: - case RECON__STATIC: - - if (sp->picnum == RECON) - { - if (sp->lotag > ud.player_skill) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - return i; - } - ps[myconnectindex].max_actors_killed++; - hittype[i].temp_data[5] = 0; - if (ud.monsters_off == 1) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } - sp->extra = 130; - } - - if (sp->picnum == REACTOR || sp->picnum == REACTOR2) - sp->extra = impact_damage; - - CS |= 257; // Make it hitable - - if (ud.multimode < 2 && sp->pal != 0) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); + case LIZTROOPONTOILET__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOP__STATIC: + sp->pal = 22; break; } - sp->pal = 0; - SS = -17; + } - changespritestat(i,2); - break; - - case ATOMICHEALTH__STATIC: - case STEROIDS__STATIC: - case HEATSENSOR__STATIC: - case SHIELD__STATIC: - case AIRTANK__STATIC: - case TRIPBOMBSPRITE__STATIC: - case JETPACK__STATIC: - case HOLODUKE__STATIC: - - case FIRSTGUNSPRITE__STATIC: - case CHAINGUNSPRITE__STATIC: - case SHOTGUNSPRITE__STATIC: - case RPGSPRITE__STATIC: - case SHRINKERSPRITE__STATIC: - case FREEZESPRITE__STATIC: - case DEVISTATORSPRITE__STATIC: - - case SHOTGUNAMMO__STATIC: - case FREEZEAMMO__STATIC: - case HBOMBAMMO__STATIC: - case CRYSTALAMMO__STATIC: - case GROWAMMO__STATIC: - case BATTERYAMMO__STATIC: - case DEVISTATORAMMO__STATIC: - case RPGAMMO__STATIC: - case BOOTS__STATIC: - case AMMO__STATIC: - case AMMOLOTS__STATIC: - case COLA__STATIC: - case FIRSTAID__STATIC: - case SIXPAK__STATIC: - - if (j >= 0) + if (sp->picnum == BOSS4STAYPUT || sp->picnum == BOSS1 || sp->picnum == BOSS2 || sp->picnum == BOSS1STAYPUT || sp->picnum == BOSS3 || sp->picnum == BOSS4) + { + if (j >= 0 && sprite[j].picnum == RESPAWN) + sp->pal = sprite[j].pal; + if (sp->pal) { - sp->lotag = 0; - sp->z -= (32<<8); - sp->zvel = -1024; - ssp(i,CLIPMASK0); - sp->cstat = TRAND&4; + sp->clipdist = 80; + sp->xrepeat = 40; + sp->yrepeat = 40; } else { - sp->owner = i; + sp->xrepeat = 80; + sp->yrepeat = 80; + sp->clipdist = 164; + } + } + else + { + if (sp->picnum != SHARK) + { + sp->xrepeat = 40; + sp->yrepeat = 40; + sp->clipdist = 80; + } + else + { + sp->xrepeat = 60; + sp->yrepeat = 60; + sp->clipdist = 40; + } + } + + if (j >= 0) sp->lotag = 0; + + if ((sp->lotag > ud.player_skill) || ud.monsters_off == 1) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + else + { + makeitfall(i); + + if (sp->picnum == RAT) + { + sp->ang = TRAND&2047; + sp->xrepeat = sp->yrepeat = 48; sp->cstat = 0; } - - if ((ud.multimode < 2 && sp->pal != 0) || (sp->lotag > ud.player_skill)) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } - - sp->pal = 0; - - case ACCESSCARD__STATIC: - - if (sp->picnum == ATOMICHEALTH) - sp->cstat |= 128; - - if (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_ACCESSCARDSPRITES) && sp->picnum == ACCESSCARD) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } else { - if (sp->picnum == AMMO) - sp->xrepeat = sp->yrepeat = 16; - else sp->xrepeat = sp->yrepeat = 32; + sp->cstat |= 257; + + if (sp->picnum != SHARK) + ps[myconnectindex].max_actors_killed++; } - sp->shade = -17; + if (sp->picnum == ORGANTIC) sp->cstat |= 128; - if (j >= 0) changespritestat(i,1); - else - { - changespritestat(i,2); - makeitfall(i); - } - break; - - case WATERFOUNTAIN__STATIC: - SLT = 1; - - case TREE1__STATIC: - case TREE2__STATIC: - case TIRE__STATIC: - case CONE__STATIC: - case BOX__STATIC: - CS = 257; // Make it hitable - sprite[i].extra = 1; - changespritestat(i,6); - break; - - case FLOORFLAME__STATIC: - sp->shade = -127; - changespritestat(i,6); - break; - - case BOUNCEMINE__STATIC: - sp->owner = i; - sp->cstat |= 1+256; //Make it hitable - sp->xrepeat = sp->yrepeat = 24; - sp->shade = -127; - sp->extra = impact_damage<<2; - changespritestat(i,2); - break; - - - - case STEAM__STATIC: if (j >= 0) { - sp->ang = sprite[j].ang; - sp->cstat = 16+128+2; - sp->xrepeat=sp->yrepeat=1; - sp->xvel = -8; - ssp(i,CLIPMASK0); + hittype[i].timetosleep = 0; + check_fta_sounds(i); + changespritestat(i,1); } - case CEILINGSTEAM__STATIC: - changespritestat(i,6); + else changespritestat(i,2); + } + + if (sp->picnum == ROTATEGUN) + sp->zvel = 0; + + break; + + case LOCATORS__STATIC: + sp->cstat |= 32768; + changespritestat(i,7); + break; + + case ACTIVATORLOCKED__STATIC: + case ACTIVATOR__STATIC: + sp->cstat = (short) 32768; + if (sp->picnum == ACTIVATORLOCKED) + sector[sp->sectnum].lotag |= 16384; + changespritestat(i,8); + break; + + case DOORSHOCK__STATIC: + sp->cstat |= 1+256; + sp->shade = -12; + changespritestat(i,6); + break; + + case OOZ__STATIC: + case OOZ2__STATIC: + sp->shade = -12; + + if (j >= 0) + { + if (sprite[j].picnum == NUKEBARREL) + sp->pal = 8; + insertspriteq(i); + } + + changespritestat(i,1); + + getglobalz(i); + + j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + + sp->yrepeat = j; + sp->xrepeat = 25-(j>>1); + sp->cstat |= (TRAND&4); + + break; + + case HEAVYHBOMB__STATIC: + if (j >= 0) + sp->owner = j; + else sp->owner = i; + sp->xrepeat = sp->yrepeat = 9; + sp->yvel = 4; + case REACTOR2__STATIC: + case REACTOR__STATIC: + case RECON__STATIC: + + if (sp->picnum == RECON) + { + if (sp->lotag > ud.player_skill) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + return i; + } + ps[myconnectindex].max_actors_killed++; + hittype[i].temp_data[5] = 0; + if (ud.monsters_off == 1) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + sp->extra = 130; + } + + if (sp->picnum == REACTOR || sp->picnum == REACTOR2) + sp->extra = impact_damage; + + CS |= 257; // Make it hitable + + if (ud.multimode < 2 && sp->pal != 0) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + sp->pal = 0; + SS = -17; + + changespritestat(i,2); + break; + + case ATOMICHEALTH__STATIC: + case STEROIDS__STATIC: + case HEATSENSOR__STATIC: + case SHIELD__STATIC: + case AIRTANK__STATIC: + case TRIPBOMBSPRITE__STATIC: + case JETPACK__STATIC: + case HOLODUKE__STATIC: + + case FIRSTGUNSPRITE__STATIC: + case CHAINGUNSPRITE__STATIC: + case SHOTGUNSPRITE__STATIC: + case RPGSPRITE__STATIC: + case SHRINKERSPRITE__STATIC: + case FREEZESPRITE__STATIC: + case DEVISTATORSPRITE__STATIC: + + case SHOTGUNAMMO__STATIC: + case FREEZEAMMO__STATIC: + case HBOMBAMMO__STATIC: + case CRYSTALAMMO__STATIC: + case GROWAMMO__STATIC: + case BATTERYAMMO__STATIC: + case DEVISTATORAMMO__STATIC: + case RPGAMMO__STATIC: + case BOOTS__STATIC: + case AMMO__STATIC: + case AMMOLOTS__STATIC: + case COLA__STATIC: + case FIRSTAID__STATIC: + case SIXPAK__STATIC: + + if (j >= 0) + { + sp->lotag = 0; + sp->z -= (32<<8); + sp->zvel = -1024; + ssp(i,CLIPMASK0); + sp->cstat = TRAND&4; + } + else + { + sp->owner = i; + sp->cstat = 0; + } + + if ((ud.multimode < 2 && sp->pal != 0) || (sp->lotag > ud.player_skill)) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + + sp->pal = 0; + + case ACCESSCARD__STATIC: + + if (sp->picnum == ATOMICHEALTH) + sp->cstat |= 128; + + if (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_ACCESSCARDSPRITES) && sp->picnum == ACCESSCARD) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + else + { + if (sp->picnum == AMMO) + sp->xrepeat = sp->yrepeat = 16; + else sp->xrepeat = sp->yrepeat = 32; + } + + sp->shade = -17; + + if (j >= 0) changespritestat(i,1); + else + { + changespritestat(i,2); + makeitfall(i); + } + break; + + case WATERFOUNTAIN__STATIC: + SLT = 1; + + case TREE1__STATIC: + case TREE2__STATIC: + case TIRE__STATIC: + case CONE__STATIC: + case BOX__STATIC: + CS = 257; // Make it hitable + sprite[i].extra = 1; + changespritestat(i,6); + break; + + case FLOORFLAME__STATIC: + sp->shade = -127; + changespritestat(i,6); + break; + + case BOUNCEMINE__STATIC: + sp->owner = i; + sp->cstat |= 1+256; //Make it hitable + sp->xrepeat = sp->yrepeat = 24; + sp->shade = -127; + sp->extra = impact_damage<<2; + changespritestat(i,2); + break; + + + + case STEAM__STATIC: + if (j >= 0) + { + sp->ang = sprite[j].ang; + sp->cstat = 16+128+2; + sp->xrepeat=sp->yrepeat=1; + sp->xvel = -8; + ssp(i,CLIPMASK0); + } + case CEILINGSTEAM__STATIC: + changespritestat(i,6); + break; + + case SECTOREFFECTOR__STATIC: + sp->yvel = sector[sect].extra; + sp->cstat |= 32768; + sp->xrepeat = sp->yrepeat = 0; + + switch (sp->lotag) + { + case 28: + T6 = 65;// Delay for lightning + break; + case 7: // Transporters!!!! + case 23:// XPTR END + if (sp->lotag != 23) + { + for (j=0;jcstat = 0; + changespritestat(i,9); + return i; + case 1: + sp->owner = -1; + T1 = 1; + break; + case 18: + + if (sp->ang == 512) + { + T2 = sector[sect].ceilingz; + if (sp->pal) + sector[sect].ceilingz = sp->z; + } + else + { + T2 = sector[sect].floorz; + if (sp->pal) + sector[sect].floorz = sp->z; + } + + sp->hitag <<= 2; break; - case SECTOREFFECTOR__STATIC: - sp->yvel = sector[sect].extra; - sp->cstat |= 32768; - sp->xrepeat = sp->yrepeat = 0; - - switch (sp->lotag) + case 19: + sp->owner = -1; + break; + case 25: // Pistons + T4 = sector[sect].ceilingz; + T5 = 1; + sector[sect].ceilingz = sp->z; + setinterpolation(§or[sect].ceilingz); + break; + case 35: + sector[sect].ceilingz = sp->z; + break; + case 27: + if (ud.recstat == 1) { - case 28: - T6 = 65;// Delay for lightning - break; - case 7: // Transporters!!!! - case 23:// XPTR END - if (sp->lotag != 23) - { - for (j=0;jxrepeat=sp->yrepeat=64; + sp->cstat &= 32767; + } + break; + case 12: - T5 = sector[sect].floorz == SZ; - sp->cstat = 0; - changespritestat(i,9); - return i; - case 1: - sp->owner = -1; - T1 = 1; - break; - case 18: + T2 = sector[sect].floorshade; + T3 = sector[sect].ceilingshade; + break; - if (sp->ang == 512) - { - T2 = sector[sect].ceilingz; - if (sp->pal) - sector[sect].ceilingz = sp->z; - } - else - { - T2 = sector[sect].floorz; - if (sp->pal) - sector[sect].floorz = sp->z; - } + case 13: - sp->hitag <<= 2; - break; + T1 = sector[sect].ceilingz; + T2 = sector[sect].floorz; - case 19: - sp->owner = -1; - break; - case 25: // Pistons - T4 = sector[sect].ceilingz; - T5 = 1; + if (klabs(T1-sp->z) < klabs(T2-sp->z)) + sp->owner = 1; + else sp->owner = 0; + + if (sp->ang == 512) + { + if (sp->owner) sector[sect].ceilingz = sp->z; - setinterpolation(§or[sect].ceilingz); - break; - case 35: - sector[sect].ceilingz = sp->z; - break; - case 27: - if (ud.recstat == 1) - { - sp->xrepeat=sp->yrepeat=64; - sp->cstat &= 32767; - } - break; - case 12: + else + sector[sect].floorz = sp->z; + } + else + sector[sect].ceilingz = sector[sect].floorz = sp->z; - T2 = sector[sect].floorshade; - T3 = sector[sect].ceilingshade; - break; + if (sector[sect].ceilingstat&1) + { + sector[sect].ceilingstat ^= 1; + T4 = 1; - case 13: - - T1 = sector[sect].ceilingz; - T2 = sector[sect].floorz; - - if (klabs(T1-sp->z) < klabs(T2-sp->z)) - sp->owner = 1; - else sp->owner = 0; - - if (sp->ang == 512) - { - if (sp->owner) - sector[sect].ceilingz = sp->z; - else - sector[sect].floorz = sp->z; - } - else - sector[sect].ceilingz = sector[sect].floorz = sp->z; - - if (sector[sect].ceilingstat&1) - { - sector[sect].ceilingstat ^= 1; - T4 = 1; - - if (!sp->owner && sp->ang==512) - { - sector[sect].ceilingstat ^= 1; - T4 = 0; - } - - sector[sect].ceilingshade = - sector[sect].floorshade; - - if (sp->ang==512) - { - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - for (j=startwall;j= 0) - if (!(sector[x].ceilingstat&1)) - { - sector[sect].ceilingpicnum = - sector[x].ceilingpicnum; - sector[sect].ceilingshade = - sector[x].ceilingshade; - break; //Leave earily - } - } - } - } - - break; - - case 17: - - T3 = sector[sect].floorz; //Stopping loc - - j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1); - T4 = sector[j].ceilingz; - - j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1); - T5 = sector[j].floorz; - - if (numplayers < 2) - { - setinterpolation(§or[sect].floorz); - setinterpolation(§or[sect].ceilingz); - } - - break; - - case 24: - sp->yvel <<= 1; - case 36: - break; - - case 20: + if (!sp->owner && sp->ang==512) { - long q; - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - //find the two most clostest wall x's and y's - q = 0x7fffffff; - - for (s=startwall;sx-x,sp->y-y); - if (d < q) - { - q = d; - clostest = s; - } - } - - T2 = clostest; - - q = 0x7fffffff; - - for (s=startwall;sx-x,sp->y-y); - if (d < q && s != T2) - { - q = d; - clostest = s; - } - } - - T3 = clostest; + sector[sect].ceilingstat ^= 1; + T4 = 0; } - break; - - case 3: - - T4=sector[sect].floorshade; - - sector[sect].floorshade = sp->shade; - sector[sect].ceilingshade = sp->shade; - - sp->owner = sector[sect].ceilingpal<<8; - sp->owner |= sector[sect].floorpal; - - //fix all the walls; + sector[sect].ceilingshade = + sector[sect].floorshade; + if (sp->ang==512) + { startwall = sector[sect].wallptr; endwall = startwall+sector[sect].wallnum; - - for (s=startwall;sshade; - if ((wall[s].cstat&2) && wall[s].nextwall >= 0) - wall[wall[s].nextwall].shade = sp->shade; - } - break; - - case 31: - T2 = sector[sect].floorz; - // T3 = sp->hitag; - if (sp->ang != 1536) sector[sect].floorz = sp->z; - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - for (s=startwall;shitag; - if (sp->ang != 1536) sector[sect].ceilingz = sp->z; - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - for (s=startwall;sowner = sector[sect].ceilingpal<<8; - sp->owner |= sector[sect].floorpal; - - for (s=startwall;s T4) - T4 = wall[s].shade; - - break; - - case 9: - if (sector[sect].lotag && - labs(sector[sect].ceilingz-sp->z) > 1024) - sector[sect].lotag |= 32768; //If its open - case 8: - //First, get the ceiling-floor shade - - T1 = sector[sect].floorshade; - T2 = sector[sect].ceilingshade; - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - for (s=startwall;s T3) - T3 = wall[s].shade; - - T4 = 1; //Take Out; - - break; - - case 11://Pivitor rotater - if (sp->ang>1024) T4 = 2; - else T4 = -2; - case 0: - case 2://Earthquakemakers - case 5://Boss Creature - case 6://Subway - case 14://Caboos - case 15://Subwaytype sliding door - case 16://That rotating blocker reactor thing - case 26://ESCELATOR - case 30://No rotational subways - - if (sp->lotag == 0) - { - if (sector[sect].lotag == 30) - { - if (sp->pal) sprite[i].clipdist = 1; - else sprite[i].clipdist = 0; - T4 = sector[sect].floorz; - sector[sect].hitag = i; - } - - for (j = 0;j < MAXSPRITES;j++) - { - if (sprite[j].statnum < MAXSTATUS) - if (sprite[j].picnum == SECTOREFFECTOR && - sprite[j].lotag == 1 && - sprite[j].hitag == sp->hitag) - { - if (sp->ang == 512) - { - sp->x = sprite[j].x; - sp->y = sprite[j].y; - } - break; - } - } - if (j == MAXSPRITES) - { - Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%ld,%ld)\n",sp->x,sp->y); - gameexit(tempbuf); - } - sp->owner = j; - } - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - T2 = tempwallptr; - for (s=startwall;sx; - msy[tempwallptr] = wall[s].y-sp->y; - tempwallptr++; - if (tempwallptr > 2047) - { - Bsprintf(tempbuf,"Too many moving sectors at (%ld,%ld).\n",wall[s].x,wall[s].y); - gameexit(tempbuf); - } - } - if (sp->lotag == 30 || sp->lotag == 6 || sp->lotag == 14 || sp->lotag == 5) - { - - startwall = sector[sect].wallptr; - endwall = startwall+sector[sect].wallnum; - - if (sector[sect].hitag == -1) - sp->extra = 0; - else sp->extra = 1; - - sector[sect].hitag = i; - - j = 0; - - for (s=startwall;s= 0 && - sector[ wall[ s ].nextsector].hitag == 0 && - sector[ wall[ s ].nextsector].lotag < 3) + x = wall[j].nextsector; + if (x >= 0) + if (!(sector[x].ceilingstat&1)) { - s = wall[s].nextsector; - j = 1; - break; + sector[sect].ceilingpicnum = + sector[x].ceilingpicnum; + sector[sect].ceilingshade = + sector[x].ceilingshade; + break; //Leave earily } - } + } + } + } - if (j == 0) + break; + + case 17: + + T3 = sector[sect].floorz; //Stopping loc + + j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1); + T4 = sector[j].ceilingz; + + j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1); + T5 = sector[j].floorz; + + if (numplayers < 2) + { + setinterpolation(§or[sect].floorz); + setinterpolation(§or[sect].ceilingz); + } + + break; + + case 24: + sp->yvel <<= 1; + case 36: + break; + + case 20: + { + long q; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + //find the two most clostest wall x's and y's + q = 0x7fffffff; + + for (s=startwall;sx-x,sp->y-y); + if (d < q) + { + q = d; + clostest = s; + } + } + + T2 = clostest; + + q = 0x7fffffff; + + for (s=startwall;sx-x,sp->y-y); + if (d < q && s != T2) + { + q = d; + clostest = s; + } + } + + T3 = clostest; + } + + break; + + case 3: + + T4=sector[sect].floorshade; + + sector[sect].floorshade = sp->shade; + sector[sect].ceilingshade = sp->shade; + + sp->owner = sector[sect].ceilingpal<<8; + sp->owner |= sector[sect].floorpal; + + //fix all the walls; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for (s=startwall;sshade; + if ((wall[s].cstat&2) && wall[s].nextwall >= 0) + wall[wall[s].nextwall].shade = sp->shade; + } + break; + + case 31: + T2 = sector[sect].floorz; + // T3 = sp->hitag; + if (sp->ang != 1536) sector[sect].floorz = sp->z; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for (s=startwall;shitag; + if (sp->ang != 1536) sector[sect].ceilingz = sp->z; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for (s=startwall;sowner = sector[sect].ceilingpal<<8; + sp->owner |= sector[sect].floorpal; + + for (s=startwall;s T4) + T4 = wall[s].shade; + + break; + + case 9: + if (sector[sect].lotag && + labs(sector[sect].ceilingz-sp->z) > 1024) + sector[sect].lotag |= 32768; //If its open + case 8: + //First, get the ceiling-floor shade + + T1 = sector[sect].floorshade; + T2 = sector[sect].ceilingshade; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for (s=startwall;s T3) + T3 = wall[s].shade; + + T4 = 1; //Take Out; + + break; + + case 11://Pivitor rotater + if (sp->ang>1024) T4 = 2; + else T4 = -2; + case 0: + case 2://Earthquakemakers + case 5://Boss Creature + case 6://Subway + case 14://Caboos + case 15://Subwaytype sliding door + case 16://That rotating blocker reactor thing + case 26://ESCELATOR + case 30://No rotational subways + + if (sp->lotag == 0) + { + if (sector[sect].lotag == 30) + { + if (sp->pal) sprite[i].clipdist = 1; + else sprite[i].clipdist = 0; + T4 = sector[sect].floorz; + sector[sect].hitag = i; + } + + for (j = 0;j < MAXSPRITES;j++) + { + if (sprite[j].statnum < MAXSTATUS) + if (sprite[j].picnum == SECTOREFFECTOR && + sprite[j].lotag == 1 && + sprite[j].hitag == sp->hitag) { - Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%ld,%ld).\n",sp->x,sp->y); - gameexit(tempbuf); + if (sp->ang == 512) + { + sp->x = sprite[j].x; + sp->y = sprite[j].y; + } + break; } - - sp->owner = -1; - T1 = s; - - if (sp->lotag != 30) - T4 = sp->hitag; - } - - else if (sp->lotag == 16) - T4 = sector[sect].ceilingz; - - else if (sp->lotag == 26) - { - T4 = sp->x; - T5 = sp->y; - if (sp->shade==sector[sect].floorshade) //UP - sp->zvel = -256; - else - sp->zvel = 256; - - sp->shade = 0; - } - else if (sp->lotag == 2) - { - T6 = sector[sp->sectnum].floorheinum; - sector[sp->sectnum].floorheinum = 0; - } - } - - switch (sp->lotag) - { - case 6: - case 14: - j = callsound(sect,i); - if (j == -1) j = SUBWAY; - hittype[i].lastvx = j; - case 30: - if (numplayers > 1) break; - case 0: - case 1: - case 5: - case 11: - case 15: - case 16: - case 26: - setsectinterpolate(i); - break; - } - - switch (sprite[i].lotag) - { - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - changespritestat(i,15); - break; - default: - changespritestat(i,3); - break; - } - - break; - - - case SEENINE__STATIC: - case OOZFILTER__STATIC: - - sp->shade = -16; - if (sp->xrepeat <= 8) - { - sp->cstat = (short)32768; - sp->xrepeat=sp->yrepeat=0; - } - else sp->cstat = 1+256; - sp->extra = impact_damage<<2; - sp->owner = i; - - changespritestat(i,6); - break; - - case CRACK1__STATIC: - case CRACK2__STATIC: - case CRACK3__STATIC: - case CRACK4__STATIC: - case FIREEXT__STATIC: - if (sp->picnum == FIREEXT) - { - sp->cstat = 257; - sp->extra = impact_damage<<2; - } - else - { - sp->cstat |= (sp->cstat & 48) ? 1 : 17; - sp->extra = 1; - } - - if (ud.multimode < 2 && sp->pal != 0) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); - break; - } - - sp->pal = 0; - sp->owner = i; - changespritestat(i,6); - sp->xvel = 8; - ssp(i,CLIPMASK0); - break; - - case TOILET__STATIC: - case STALL__STATIC: - sp->lotag = 1; - sp->cstat |= 257; - sp->clipdist = 8; - sp->owner = i; - break; - case CANWITHSOMETHING__STATIC: - case CANWITHSOMETHING2__STATIC: - case CANWITHSOMETHING3__STATIC: - case CANWITHSOMETHING4__STATIC: - case RUBBERCAN__STATIC: - sp->extra = 0; - case EXPLODINGBARREL__STATIC: - case HORSEONSIDE__STATIC: - case FIREBARREL__STATIC: - case NUKEBARREL__STATIC: - case FIREVASE__STATIC: - case NUKEBARRELDENTED__STATIC: - case NUKEBARRELLEAKED__STATIC: - case WOODENHORSE__STATIC: - - if (j >= 0) - sp->xrepeat = sp->yrepeat = 32; - sp->clipdist = 72; - makeitfall(i); - if (j >= 0) + } + if (j == MAXSPRITES) + { + Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%ld,%ld)\n",sp->x,sp->y); + gameexit(tempbuf); + } sp->owner = j; - else sp->owner = i; - case EGG__STATIC: - if (ud.monsters_off == 1 && sp->picnum == EGG) - { - sp->xrepeat = sp->yrepeat = 0; - changespritestat(i,5); } - else + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + T2 = tempwallptr; + for (s=startwall;spicnum == EGG) - sp->clipdist = 24; - sp->cstat = 257|(TRAND&4); - changespritestat(i,2); + msx[tempwallptr] = wall[s].x-sp->x; + msy[tempwallptr] = wall[s].y-sp->y; + tempwallptr++; + if (tempwallptr > 2047) + { + Bsprintf(tempbuf,"Too many moving sectors at (%ld,%ld).\n",wall[s].x,wall[s].y); + gameexit(tempbuf); + } } + if (sp->lotag == 30 || sp->lotag == 6 || sp->lotag == 14 || sp->lotag == 5) + { + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + if (sector[sect].hitag == -1) + sp->extra = 0; + else sp->extra = 1; + + sector[sect].hitag = i; + + j = 0; + + for (s=startwall;s= 0 && + sector[ wall[ s ].nextsector].hitag == 0 && + sector[ wall[ s ].nextsector].lotag < 3) + { + s = wall[s].nextsector; + j = 1; + break; + } + } + + if (j == 0) + { + Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%ld,%ld).\n",sp->x,sp->y); + gameexit(tempbuf); + } + + sp->owner = -1; + T1 = s; + + if (sp->lotag != 30) + T4 = sp->hitag; + } + + else if (sp->lotag == 16) + T4 = sector[sect].ceilingz; + + else if (sp->lotag == 26) + { + T4 = sp->x; + T5 = sp->y; + if (sp->shade==sector[sect].floorshade) //UP + sp->zvel = -256; + else + sp->zvel = 256; + + sp->shade = 0; + } + else if (sp->lotag == 2) + { + T6 = sector[sp->sectnum].floorheinum; + sector[sp->sectnum].floorheinum = 0; + } + } + + switch (sp->lotag) + { + case 6: + case 14: + j = callsound(sect,i); + if (j == -1) j = SUBWAY; + hittype[i].lastvx = j; + case 30: + if (numplayers > 1) break; + case 0: + case 1: + case 5: + case 11: + case 15: + case 16: + case 26: + setsectinterpolate(i); break; - case TOILETWATER__STATIC: - sp->shade = -16; - changespritestat(i,6); + } + + switch (sprite[i].lotag) + { + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + changespritestat(i,15); break; + default: + changespritestat(i,3); + break; + } + + break; + + + case SEENINE__STATIC: + case OOZFILTER__STATIC: + + sp->shade = -16; + if (sp->xrepeat <= 8) + { + sp->cstat = (short)32768; + sp->xrepeat=sp->yrepeat=0; + } + else sp->cstat = 1+256; + sp->extra = impact_damage<<2; + sp->owner = i; + + changespritestat(i,6); + break; + + case CRACK1__STATIC: + case CRACK2__STATIC: + case CRACK3__STATIC: + case CRACK4__STATIC: + case FIREEXT__STATIC: + if (sp->picnum == FIREEXT) + { + sp->cstat = 257; + sp->extra = impact_damage<<2; + } + else + { + sp->cstat |= (sp->cstat & 48) ? 1 : 17; + sp->extra = 1; + } + + if (ud.multimode < 2 && sp->pal != 0) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + + sp->pal = 0; + sp->owner = i; + changespritestat(i,6); + sp->xvel = 8; + ssp(i,CLIPMASK0); + break; + + case TOILET__STATIC: + case STALL__STATIC: + sp->lotag = 1; + sp->cstat |= 257; + sp->clipdist = 8; + sp->owner = i; + break; + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + case RUBBERCAN__STATIC: + sp->extra = 0; + case EXPLODINGBARREL__STATIC: + case HORSEONSIDE__STATIC: + case FIREBARREL__STATIC: + case NUKEBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case WOODENHORSE__STATIC: + + if (j >= 0) + sp->xrepeat = sp->yrepeat = 32; + sp->clipdist = 72; + makeitfall(i); + if (j >= 0) + sp->owner = j; + else sp->owner = i; + case EGG__STATIC: + if (ud.monsters_off == 1 && sp->picnum == EGG) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + } + else + { + if (sp->picnum == EGG) + sp->clipdist = 24; + sp->cstat = 257|(TRAND&4); + changespritestat(i,2); + } + break; + case TOILETWATER__STATIC: + sp->shade = -16; + changespritestat(i,6); + break; } OnEvent(EVENT_SPAWN,i, findplayer(&sprite[i],&p), p); @@ -6205,73 +6205,73 @@ void animatesprites(long x,long y,short a,long smoothratio) {} else switch (dynamictostatic[t->picnum]) { - case BLOODPOOL__STATIC: - case PUKE__STATIC: - case FOOTPRINTS__STATIC: - case FOOTPRINTS2__STATIC: - case FOOTPRINTS3__STATIC: - case FOOTPRINTS4__STATIC: - if (t->shade == 127) continue; - break; - case RESPAWNMARKERRED__STATIC: - case RESPAWNMARKERYELLOW__STATIC: - case RESPAWNMARKERGREEN__STATIC: - if (ud.marker == 0) - t->xrepeat = t->yrepeat = 0; - continue; - case CHAIR3__STATIC: + case BLOODPOOL__STATIC: + case PUKE__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if (t->shade == 127) continue; + break; + case RESPAWNMARKERRED__STATIC: + case RESPAWNMARKERYELLOW__STATIC: + case RESPAWNMARKERGREEN__STATIC: + if (ud.marker == 0) + t->xrepeat = t->yrepeat = 0; + continue; + case CHAIR3__STATIC: #if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) - { - t->cstat &= ~4; - break; - } -#endif - k = (((t->ang+3072+128-a)&2047)>>8)&7; - if (k>4) - { - k = 8-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - t->picnum = s->picnum+k; + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) + { + t->cstat &= ~4; break; - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - if (ud.lockout) t->xrepeat = t->yrepeat = 0; - else if (t->pal == 6) - { - t->shade = -127; - continue; - } - case BULLETHOLE__STATIC: - case CRACK1__STATIC: - case CRACK2__STATIC: - case CRACK3__STATIC: - case CRACK4__STATIC: - t->shade = 16; + } +#endif + k = (((t->ang+3072+128-a)&2047)>>8)&7; + if (k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = s->picnum+k; + break; + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + if (ud.lockout) t->xrepeat = t->yrepeat = 0; + else if (t->pal == 6) + { + t->shade = -127; continue; - case NEON1__STATIC: - case NEON2__STATIC: - case NEON3__STATIC: - case NEON4__STATIC: - case NEON5__STATIC: - case NEON6__STATIC: + } + case BULLETHOLE__STATIC: + case CRACK1__STATIC: + case CRACK2__STATIC: + case CRACK3__STATIC: + case CRACK4__STATIC: + t->shade = 16; + continue; + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: + continue; + //case GREENSLIME: + //case GREENSLIME+1: + //case GREENSLIME+2: + //case GREENSLIME+3: + //case GREENSLIME+4: + //case GREENSLIME+5: + //case GREENSLIME+6: + //case GREENSLIME+7: + // break; + default: + if (((t->cstat&16)) || (badguy(t) && t->extra > 0) || t->statnum == 10) continue; - //case GREENSLIME: - //case GREENSLIME+1: - //case GREENSLIME+2: - //case GREENSLIME+3: - //case GREENSLIME+4: - //case GREENSLIME+5: - //case GREENSLIME+6: - //case GREENSLIME+7: - // break; - default: - if (((t->cstat&16)) || (badguy(t) && t->extra > 0) || t->statnum == 10) - continue; } if (checkspriteflags(t->owner,SPRITE_FLAG_NOSHADE)) @@ -6297,92 +6297,92 @@ void animatesprites(long x,long y,short a,long smoothratio) switch (dynamictostatic[s->picnum]) { - case SECTOREFFECTOR__STATIC: - if (t->lotag == 27 && ud.recstat == 1) - { - t->picnum = 11+((totalclock>>3)&1); - t->cstat |= 128; - } - else - t->xrepeat = t->yrepeat = 0; - break; - case NATURALLIGHTNING__STATIC: - t->shade = -127; - break; - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case MAN__STATIC: - case MAN2__STATIC: - case WOMAN__STATIC: - case NAKED1__STATIC: - case PODFEM1__STATIC: - case FEMMAG1__STATIC: - case FEMMAG2__STATIC: - case FEMPIC1__STATIC: - case FEMPIC2__STATIC: - case FEMPIC3__STATIC: - case FEMPIC4__STATIC: - case FEMPIC5__STATIC: - case FEMPIC6__STATIC: - case FEMPIC7__STATIC: - case BLOODYPOLE__STATIC: - case FEM6PAD__STATIC: - case STATUE__STATIC: - case STATUEFLASH__STATIC: - case OOZ__STATIC: - case OOZ2__STATIC: - case WALLBLOOD1__STATIC: - case WALLBLOOD2__STATIC: - case WALLBLOOD3__STATIC: - case WALLBLOOD4__STATIC: - case WALLBLOOD5__STATIC: - case WALLBLOOD7__STATIC: - case WALLBLOOD8__STATIC: - case SUSHIPLATE1__STATIC: - case SUSHIPLATE2__STATIC: - case SUSHIPLATE3__STATIC: - case SUSHIPLATE4__STATIC: - case FETUS__STATIC: - case FETUSJIB__STATIC: - case FETUSBROKE__STATIC: - case HOTMEAT__STATIC: - case FOODOBJECT16__STATIC: - case DOLPHIN1__STATIC: - case DOLPHIN2__STATIC: - case TOUGHGAL__STATIC: - case TAMPON__STATIC: - case XXXSTACY__STATIC: - if (ud.lockout) - { - t->xrepeat = t->yrepeat = 0; - continue; - } + case SECTOREFFECTOR__STATIC: + if (t->lotag == 27 && ud.recstat == 1) + { + t->picnum = 11+((totalclock>>3)&1); + t->cstat |= 128; + } + else + t->xrepeat = t->yrepeat = 0; + break; + case NATURALLIGHTNING__STATIC: + t->shade = -127; + break; + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case MAN__STATIC: + case MAN2__STATIC: + case WOMAN__STATIC: + case NAKED1__STATIC: + case PODFEM1__STATIC: + case FEMMAG1__STATIC: + case FEMMAG2__STATIC: + case FEMPIC1__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: + case FEMPIC4__STATIC: + case FEMPIC5__STATIC: + case FEMPIC6__STATIC: + case FEMPIC7__STATIC: + case BLOODYPOLE__STATIC: + case FEM6PAD__STATIC: + case STATUE__STATIC: + case STATUEFLASH__STATIC: + case OOZ__STATIC: + case OOZ2__STATIC: + case WALLBLOOD1__STATIC: + case WALLBLOOD2__STATIC: + case WALLBLOOD3__STATIC: + case WALLBLOOD4__STATIC: + case WALLBLOOD5__STATIC: + case WALLBLOOD7__STATIC: + case WALLBLOOD8__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case FETUS__STATIC: + case FETUSJIB__STATIC: + case FETUSBROKE__STATIC: + case HOTMEAT__STATIC: + case FOODOBJECT16__STATIC: + case DOLPHIN1__STATIC: + case DOLPHIN2__STATIC: + case TOUGHGAL__STATIC: + case TAMPON__STATIC: + case XXXSTACY__STATIC: + if (ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } } switch (s->picnum) { - case 4946: - case 4947: - case 693: - case 2254: - case 4560: - case 4561: - case 4562: - case 4498: - case 4957: - if (ud.lockout) - { - t->xrepeat = t->yrepeat = 0; - continue; - } + case 4946: + case 4947: + case 693: + case 2254: + case 4560: + case 4561: + case 4562: + case 4498: + case 4957: + if (ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } } if (t->statnum == 99) continue; @@ -6413,320 +6413,320 @@ void animatesprites(long x,long y,short a,long smoothratio) switch (dynamictostatic[switchpic]) { - case DUKELYINGDEAD__STATIC: - t->z += (24<<8); - break; - case BLOODPOOL__STATIC: - case FOOTPRINTS__STATIC: - case FOOTPRINTS2__STATIC: - case FOOTPRINTS3__STATIC: - case FOOTPRINTS4__STATIC: - if (t->pal == 6) - t->shade = -127; - case PUKE__STATIC: - case MONEY__STATIC: - //case MONEY+1__STATIC: - case MAIL__STATIC: - //case MAIL+1__STATIC: - case PAPER__STATIC: - //case PAPER+1__STATIC: - if (ud.lockout && s->pal == 2) - { - t->xrepeat = t->yrepeat = 0; - continue; - } - break; - case TRIPBOMB__STATIC: + case DUKELYINGDEAD__STATIC: + t->z += (24<<8); + break; + case BLOODPOOL__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if (t->pal == 6) + t->shade = -127; + case PUKE__STATIC: + case MONEY__STATIC: + //case MONEY+1__STATIC: + case MAIL__STATIC: + //case MAIL+1__STATIC: + case PAPER__STATIC: + //case PAPER+1__STATIC: + if (ud.lockout && s->pal == 2) + { + t->xrepeat = t->yrepeat = 0; continue; - case FORCESPHERE__STATIC: - if (t->statnum == 5) - { - short sqa,sqb; + } + break; + case TRIPBOMB__STATIC: + continue; + case FORCESPHERE__STATIC: + if (t->statnum == 5) + { + short sqa,sqb; - sqa = - getangle( - sprite[s->owner].x-ps[screenpeek].posx, - sprite[s->owner].y-ps[screenpeek].posy); - sqb = - getangle( - sprite[s->owner].x-t->x, - sprite[s->owner].y-t->y); + sqa = + getangle( + sprite[s->owner].x-ps[screenpeek].posx, + sprite[s->owner].y-ps[screenpeek].posy); + sqb = + getangle( + sprite[s->owner].x-t->x, + sprite[s->owner].y-t->y); - if (klabs(getincangle(sqa,sqb)) > 512) - if (ldist(&sprite[s->owner],t) < ldist(&sprite[ps[screenpeek].i],&sprite[s->owner])) - t->xrepeat = t->yrepeat = 0; - } - continue; - case BURNING__STATIC: - case BURNING2__STATIC: - if (sprite[s->owner].statnum == 10) + if (klabs(getincangle(sqa,sqb)) > 512) + if (ldist(&sprite[s->owner],t) < ldist(&sprite[ps[screenpeek].i],&sprite[s->owner])) + t->xrepeat = t->yrepeat = 0; + } + continue; + case BURNING__STATIC: + case BURNING2__STATIC: + if (sprite[s->owner].statnum == 10) + { + if (display_mirror == 0 && sprite[s->owner].yvel == screenpeek && ps[sprite[s->owner].yvel].over_shoulder_on == 0) + t->xrepeat = 0; + else { - if (display_mirror == 0 && sprite[s->owner].yvel == screenpeek && ps[sprite[s->owner].yvel].over_shoulder_on == 0) - t->xrepeat = 0; - else - { - t->ang = getangle(x-t->x,y-t->y); - t->x = sprite[s->owner].x; - t->y = sprite[s->owner].y; - t->x += sintable[(t->ang+512)&2047]>>10; - t->y += sintable[t->ang&2047]>>10; - } + t->ang = getangle(x-t->x,y-t->y); + t->x = sprite[s->owner].x; + t->y = sprite[s->owner].y; + t->x += sintable[(t->ang+512)&2047]>>10; + t->y += sintable[t->ang&2047]>>10; } - break; + } + break; - case ATOMICHEALTH__STATIC: - t->z -= (4<<8); - break; - case CRYSTALAMMO__STATIC: - t->shade = (sintable[(totalclock<<4)&2047]>>10); - continue; - case VIEWSCREEN__STATIC: - case VIEWSCREEN2__STATIC: - if (camsprite >= 0 && hittype[OW].temp_data[0] == 1) - { - t->picnum = STATIC; - t->cstat |= (rand()&12); - t->xrepeat += 8; - t->yrepeat += 8; - } - else if (camsprite >= 0 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) - { - t->picnum = TILE_VIEWSCR; - } - break; + case ATOMICHEALTH__STATIC: + t->z -= (4<<8); + break; + case CRYSTALAMMO__STATIC: + t->shade = (sintable[(totalclock<<4)&2047]>>10); + continue; + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + if (camsprite >= 0 && hittype[OW].temp_data[0] == 1) + { + t->picnum = STATIC; + t->cstat |= (rand()&12); + t->xrepeat += 8; + t->yrepeat += 8; + } + else if (camsprite >= 0 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) + { + t->picnum = TILE_VIEWSCR; + } + break; - case SHRINKSPARK__STATIC: - t->picnum = SHRINKSPARK+((totalclock>>4)&3); - break; - case GROWSPARK__STATIC: - t->picnum = GROWSPARK+((totalclock>>4)&3); - break; - case RPG__STATIC: + case SHRINKSPARK__STATIC: + t->picnum = SHRINKSPARK+((totalclock>>4)&3); + break; + case GROWSPARK__STATIC: + t->picnum = GROWSPARK+((totalclock>>4)&3); + break; + case RPG__STATIC: #if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) - { - t->cstat &= ~4; - break; - } + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) + { + t->cstat &= ~4; + break; + } #endif - k = getangle(s->x-x,s->y-y); + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)/170); + if (k > 6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = RPG+k; + break; + + case RECON__STATIC: +#if defined(POLYMOST) && defined(USE_OPENGL) + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) + { + t->cstat &= ~4; + break; + } +#endif + k = getangle(s->x-x,s->y-y); + if (T1 < 4) k = (((s->ang+3072+128-k)&2047)/170); - if (k > 6) - { - k = 12-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - t->picnum = RPG+k; - break; + else k = (((s->ang+3072+128-k)&2047)/170); - case RECON__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) + if (k>6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + + if (klabs(t3) > 64) k += 7; + t->picnum = RECON+k; + + break; + + case APLAYER__STATIC: + + p = s->yvel; + + if (t->pal == 1) t->z -= (18<<8); + + if (ps[p].over_shoulder_on > 0 && ps[p].newowner < 0) + { + t->cstat |= 2; + if (screenpeek == myconnectindex && numplayers >= 2) { + t->x = omyx+mulscale16((long)(myx-omyx),smoothratio); + t->y = omyy+mulscale16((long)(myy-omyy),smoothratio); + t->z = omyz+mulscale16((long)(myz-omyz),smoothratio)+(40<<8); + t->ang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + t->sectnum = mycursectnum; + } + } + + if ((display_mirror == 1 || screenpeek != p || s->owner == -1) && ud.multimode > 1 && ud.showweapons && sprite[ps[p].i].extra > 0 && ps[p].curr_weapon > 0) + { + memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); + + tsprite[spritesortcnt].statnum = 99; + + tsprite[spritesortcnt].yrepeat = (t->yrepeat>>3); + if (t->yrepeat < 4) t->yrepeat = 4; + + tsprite[spritesortcnt].shade = t->shade; + tsprite[spritesortcnt].cstat = 0; + + tsprite[spritesortcnt].picnum = (ps[p].curr_weapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[ps[p].curr_weapon]); + + if (s->owner >= 0) + tsprite[spritesortcnt].z = ps[p].posz-(12<<8); + else tsprite[spritesortcnt].z = s->z-(51<<8); + if (tsprite[spritesortcnt].picnum == HEAVYHBOMB) + { + tsprite[spritesortcnt].xrepeat = 10; + tsprite[spritesortcnt].yrepeat = 10; + } + else + { + tsprite[spritesortcnt].xrepeat = 16; + tsprite[spritesortcnt].yrepeat = 16; + } + tsprite[spritesortcnt].pal = 0; + spritesortcnt++; + } + + if ((display_mirror == 1 || screenpeek != p || s->owner == -1) && ud.multimode > 1 && sync[p].svel == 0 && sync[p].fvel == 0 && !ud.pause_on) + { + memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); + + tsprite[spritesortcnt].statnum = 99; + + tsprite[spritesortcnt].yrepeat = (t->yrepeat>>3); + if (t->yrepeat < 4) t->yrepeat = 4; + + tsprite[spritesortcnt].cstat = 0; + + tsprite[spritesortcnt].picnum = RESPAWNMARKERGREEN; + + if (s->owner >= 0) + tsprite[spritesortcnt].z = ps[p].posz-(20<<8); + else tsprite[spritesortcnt].z = s->z-(96<<8); + tsprite[spritesortcnt].xrepeat = 32; + tsprite[spritesortcnt].yrepeat = 32; + tsprite[spritesortcnt].pal = 20; + spritesortcnt++; + } + + if (s->owner == -1) + { +#if defined(POLYMOST) && defined(USE_OPENGL) + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) + { + k = 0; t->cstat &= ~4; - break; } + else #endif - k = getangle(s->x-x,s->y-y); - if (T1 < 4) - k = (((s->ang+3072+128-k)&2047)/170); - else k = (((s->ang+3072+128-k)&2047)/170); - - if (k>6) { - k = 12-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - - if (klabs(t3) > 64) k += 7; - t->picnum = RECON+k; - - break; - - case APLAYER__STATIC: - - p = s->yvel; - - if (t->pal == 1) t->z -= (18<<8); - - if (ps[p].over_shoulder_on > 0 && ps[p].newowner < 0) - { - t->cstat |= 2; - if (screenpeek == myconnectindex && numplayers >= 2) + k = (((s->ang+3072+128-a)&2047)>>8)&7; + if (k>4) { - t->x = omyx+mulscale16((long)(myx-omyx),smoothratio); - t->y = omyy+mulscale16((long)(myy-omyy),smoothratio); - t->z = omyz+mulscale16((long)(myz-omyz),smoothratio)+(40<<8); - t->ang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); - t->sectnum = mycursectnum; + k = 8-k; + t->cstat |= 4; } + else t->cstat &= ~4; } - if ((display_mirror == 1 || screenpeek != p || s->owner == -1) && ud.multimode > 1 && ud.showweapons && sprite[ps[p].i].extra > 0 && ps[p].curr_weapon > 0) - { - memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); + if (sector[t->sectnum].lotag == 2) k += 1795-1405; + else if ((hittype[i].floorz-s->z) > (64<<8)) k += 60; - tsprite[spritesortcnt].statnum = 99; + t->picnum += k; + t->pal = ps[p].palookup; - tsprite[spritesortcnt].yrepeat = (t->yrepeat>>3); - if (t->yrepeat < 4) t->yrepeat = 4; + goto PALONLY; + } - tsprite[spritesortcnt].shade = t->shade; - tsprite[spritesortcnt].cstat = 0; + if (ps[p].on_crane == -1 && (sector[s->sectnum].lotag&0x7ff) != 1) + { + l = s->z-hittype[ps[p].i].floorz+(3<<8); + if (l > 1024 && s->yrepeat > 32 && s->extra > 0) + s->yoffset = (signed char)(l/(s->yrepeat<<2)); + else s->yoffset=0; + } - tsprite[spritesortcnt].picnum = (ps[p].curr_weapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[ps[p].curr_weapon]); + if (ps[p].newowner > -1) + { + t4 = *(actorscrptr[APLAYER]+1); + t3 = 0; + t1 = *(actorscrptr[APLAYER]+2); + } - if (s->owner >= 0) - tsprite[spritesortcnt].z = ps[p].posz-(12<<8); - else tsprite[spritesortcnt].z = s->z-(51<<8); - if (tsprite[spritesortcnt].picnum == HEAVYHBOMB) + if (ud.camerasprite == -1 && ps[p].newowner == -1) + if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0) + if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek)) { - tsprite[spritesortcnt].xrepeat = 10; - tsprite[spritesortcnt].yrepeat = 10; + t->owner = -1; + t->xrepeat = t->yrepeat = 0; + continue; } - else - { - tsprite[spritesortcnt].xrepeat = 16; - tsprite[spritesortcnt].yrepeat = 16; - } - tsprite[spritesortcnt].pal = 0; - spritesortcnt++; - } - - if ((display_mirror == 1 || screenpeek != p || s->owner == -1) && ud.multimode > 1 && sync[p].svel == 0 && sync[p].fvel == 0 && !ud.pause_on) - { - memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); - - tsprite[spritesortcnt].statnum = 99; - - tsprite[spritesortcnt].yrepeat = (t->yrepeat>>3); - if (t->yrepeat < 4) t->yrepeat = 4; - - tsprite[spritesortcnt].cstat = 0; - - tsprite[spritesortcnt].picnum = RESPAWNMARKERGREEN; - - if (s->owner >= 0) - tsprite[spritesortcnt].z = ps[p].posz-(20<<8); - else tsprite[spritesortcnt].z = s->z-(96<<8); - tsprite[spritesortcnt].xrepeat = 32; - tsprite[spritesortcnt].yrepeat = 32; - tsprite[spritesortcnt].pal = 20; - spritesortcnt++; - } - - if (s->owner == -1) - { -#if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) - { - k = 0; - t->cstat &= ~4; - } - else -#endif - { - k = (((s->ang+3072+128-a)&2047)>>8)&7; - if (k>4) - { - k = 8-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - } - - if (sector[t->sectnum].lotag == 2) k += 1795-1405; - else if ((hittype[i].floorz-s->z) > (64<<8)) k += 60; - - t->picnum += k; - t->pal = ps[p].palookup; - - goto PALONLY; - } - - if (ps[p].on_crane == -1 && (sector[s->sectnum].lotag&0x7ff) != 1) - { - l = s->z-hittype[ps[p].i].floorz+(3<<8); - if (l > 1024 && s->yrepeat > 32 && s->extra > 0) - s->yoffset = (signed char)(l/(s->yrepeat<<2)); - else s->yoffset=0; - } - - if (ps[p].newowner > -1) - { - t4 = *(actorscrptr[APLAYER]+1); - t3 = 0; - t1 = *(actorscrptr[APLAYER]+2); - } - - if (ud.camerasprite == -1 && ps[p].newowner == -1) - if (s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0) - if (ud.multimode < 2 || (ud.multimode > 1 && p == screenpeek)) - { - t->owner = -1; - t->xrepeat = t->yrepeat = 0; - continue; - } PALONLY: - if (sector[sect].floorpal && sector[sect].floorpal < numl) - t->pal = sector[sect].floorpal; + if (sector[sect].floorpal && sector[sect].floorpal < numl) + t->pal = sector[sect].floorpal; - if (s->owner == -1) continue; + if (s->owner == -1) continue; - if (t->z > hittype[i].floorz && t->xrepeat < 32) - t->z = hittype[i].floorz; + if (t->z > hittype[i].floorz && t->xrepeat < 32) + t->z = hittype[i].floorz; + break; + + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case LEGJIB1__STATIC: + case ARMJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKELEG__STATIC: + case DUKEGUN__STATIC: + case DUKETORSO__STATIC: + if (ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } + if (t->pal == 6) t->shade = -120; + case SCRAP1__STATIC: + case SCRAP2__STATIC: + case SCRAP3__STATIC: + case SCRAP4__STATIC: + case SCRAP5__STATIC: + if (hittype[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0) + t->picnum = s->yvel; + else t->picnum += T1; + t->shade -= 6; + + if (sector[sect].floorpal && sector[sect].floorpal < numl) + t->pal = sector[sect].floorpal; + break; + + case WATERBUBBLE__STATIC: + if (sector[t->sectnum].floorpicnum == FLOORSLIME) + { + t->pal = 7; break; - - case JIBS1__STATIC: - case JIBS2__STATIC: - case JIBS3__STATIC: - case JIBS4__STATIC: - case JIBS5__STATIC: - case JIBS6__STATIC: - case HEADJIB1__STATIC: - case LEGJIB1__STATIC: - case ARMJIB1__STATIC: - case LIZMANHEAD1__STATIC: - case LIZMANARM1__STATIC: - case LIZMANLEG1__STATIC: - case DUKELEG__STATIC: - case DUKEGUN__STATIC: - case DUKETORSO__STATIC: - if (ud.lockout) - { - t->xrepeat = t->yrepeat = 0; - continue; - } - if (t->pal == 6) t->shade = -120; - case SCRAP1__STATIC: - case SCRAP2__STATIC: - case SCRAP3__STATIC: - case SCRAP4__STATIC: - case SCRAP5__STATIC: - if (hittype[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0) - t->picnum = s->yvel; - else t->picnum += T1; - t->shade -= 6; - - if (sector[sect].floorpal && sector[sect].floorpal < numl) - t->pal = sector[sect].floorpal; - break; - - case WATERBUBBLE__STATIC: - if (sector[t->sectnum].floorpicnum == FLOORSLIME) - { - t->pal = 7; - break; - } - default: - if (sector[sect].floorpal && sector[sect].floorpal < numl) - t->pal = sector[sect].floorpal; - break; + } + default: + if (sector[sect].floorpal && sector[sect].floorpal < numl) + t->pal = sector[sect].floorpal; + break; } if (actorscrptr[s->picnum]) @@ -6744,48 +6744,48 @@ PALONLY: #endif switch (l) { - case 2: - k = (((s->ang+3072+128-a)&2047)>>8)&1; - break; + case 2: + k = (((s->ang+3072+128-a)&2047)>>8)&1; + break; - case 3: - case 4: - k = (((s->ang+3072+128-a)&2047)>>7)&7; - if (k > 3) - { - t->cstat |= 4; - k = 7-k; - } - else t->cstat &= ~4; - break; + case 3: + case 4: + k = (((s->ang+3072+128-a)&2047)>>7)&7; + if (k > 3) + { + t->cstat |= 4; + k = 7-k; + } + else t->cstat &= ~4; + break; - case 5: - k = getangle(s->x-x,s->y-y); - k = (((s->ang+3072+128-k)&2047)>>8)&7; - if (k>4) - { - k = 8-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - break; - case 7: - k = getangle(s->x-x,s->y-y); - k = (((s->ang+3072+128-k)&2047)/170); - if (k>6) - { - k = 12-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - break; - case 8: - k = (((s->ang+3072+128-a)&2047)>>8)&7; - t->cstat &= ~4; - break; - default: - k = 0; - break; + case 5: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)>>8)&7; + if (k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 7: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)/170); + if (k>6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 8: + k = (((s->ang+3072+128-a)&2047)>>8)&7; + t->cstat &= ~4; + break; + default: + k = 0; + break; } t->picnum += k + (*(long *)t4) + l * t3; @@ -6871,115 +6871,52 @@ PALONLY: switch (dynamictostatic[s->picnum]) { - case LASERLINE__STATIC: - if (sector[t->sectnum].lotag == 2) t->pal = 8; - t->z = sprite[s->owner].z-(3<<8); - if (lasermode == 2 && ps[screenpeek].heat_on == 0) - t->yrepeat = 0; - case EXPLOSION2__STATIC: - case EXPLOSION2BOT__STATIC: - case FREEZEBLAST__STATIC: - case ATOMICHEALTH__STATIC: - case FIRELASER__STATIC: - case SHRINKSPARK__STATIC: - case GROWSPARK__STATIC: - case CHAINGUN__STATIC: - case SHRINKEREXPLOSION__STATIC: - case RPG__STATIC: - case FLOORFLAME__STATIC: - if (t->picnum == EXPLOSION2) - { - ps[screenpeek].visibility = -127; - lastvisinc = totalclock+32; - //restorepalette = 1; // JBF 20040101: why? - } - t->shade = -127; - break; - case FIRE__STATIC: - case FIRE2__STATIC: - case BURNING__STATIC: - case BURNING2__STATIC: - if (sprite[s->owner].picnum != TREE1 && sprite[s->owner].picnum != TREE2) - t->z = sector[t->sectnum].floorz; - t->shade = -127; - break; - case COOLEXPLOSION1__STATIC: - t->shade = -127; - t->picnum += (s->shade>>1); - break; - case PLAYERONWATER__STATIC: + case LASERLINE__STATIC: + if (sector[t->sectnum].lotag == 2) t->pal = 8; + t->z = sprite[s->owner].z-(3<<8); + if (lasermode == 2 && ps[screenpeek].heat_on == 0) + t->yrepeat = 0; + case EXPLOSION2__STATIC: + case EXPLOSION2BOT__STATIC: + case FREEZEBLAST__STATIC: + case ATOMICHEALTH__STATIC: + case FIRELASER__STATIC: + case SHRINKSPARK__STATIC: + case GROWSPARK__STATIC: + case CHAINGUN__STATIC: + case SHRINKEREXPLOSION__STATIC: + case RPG__STATIC: + case FLOORFLAME__STATIC: + if (t->picnum == EXPLOSION2) + { + ps[screenpeek].visibility = -127; + lastvisinc = totalclock+32; + //restorepalette = 1; // JBF 20040101: why? + } + t->shade = -127; + break; + case FIRE__STATIC: + case FIRE2__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + if (sprite[s->owner].picnum != TREE1 && sprite[s->owner].picnum != TREE2) + t->z = sector[t->sectnum].floorz; + t->shade = -127; + break; + case COOLEXPLOSION1__STATIC: + t->shade = -127; + t->picnum += (s->shade>>1); + break; + case PLAYERONWATER__STATIC: #if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) - { - k = 0; - t->cstat &= ~4; - } - else + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) + { + k = 0; + t->cstat &= ~4; + } + else #endif - { - k = (((t->ang+3072+128-a)&2047)>>8)&7; - if (k>4) - { - k = 8-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - } - - t->picnum = s->picnum+k+((T1<4)*5); - t->shade = sprite[s->owner].shade; - - break; - - case WATERSPLASH2__STATIC: - t->picnum = WATERSPLASH2+t1; - break; - case REACTOR2__STATIC: - t->picnum = s->picnum + T3; - break; - case SHELL__STATIC: - t->picnum = s->picnum+(T1&1); - case SHOTGUNSHELL__STATIC: - t->cstat |= 12; - if (T1 > 1) t->cstat &= ~4; - if (T1 > 2) t->cstat &= ~12; - break; - case FRAMEEFFECT1_13__STATIC: - if (PLUTOPAK) break; - case FRAMEEFFECT1__STATIC: - if (s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) - { - if (sprite[s->owner].picnum == APLAYER) - if (ud.camerasprite == -1) - if (screenpeek == sprite[s->owner].yvel && display_mirror == 0) - { - t->owner = -1; - break; - } - if ((sprite[s->owner].cstat&32768) == 0) - { - if (!hittype[s->owner].dispicnum) - t->picnum = hittype[i].temp_data[1]; - else t->picnum = hittype[s->owner].dispicnum; - t->pal = sprite[s->owner].pal; - t->shade = sprite[s->owner].shade; - t->ang = sprite[s->owner].ang; - t->cstat = 2|sprite[s->owner].cstat; - } - } - break; - - case CAMERA1__STATIC: - case RAT__STATIC: - -#if defined(POLYMOST) && defined(USE_OPENGL) - if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) - { - t->cstat &= ~4; - break; - } -#endif - + { k = (((t->ang+3072+128-a)&2047)>>8)&7; if (k>4) { @@ -6987,8 +6924,71 @@ PALONLY: t->cstat |= 4; } else t->cstat &= ~4; - t->picnum = s->picnum+k; + } + + t->picnum = s->picnum+k+((T1<4)*5); + t->shade = sprite[s->owner].shade; + + break; + + case WATERSPLASH2__STATIC: + t->picnum = WATERSPLASH2+t1; + break; + case REACTOR2__STATIC: + t->picnum = s->picnum + T3; + break; + case SHELL__STATIC: + t->picnum = s->picnum+(T1&1); + case SHOTGUNSHELL__STATIC: + t->cstat |= 12; + if (T1 > 1) t->cstat &= ~4; + if (T1 > 2) t->cstat &= ~12; + break; + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) break; + case FRAMEEFFECT1__STATIC: + if (s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) + { + if (sprite[s->owner].picnum == APLAYER) + if (ud.camerasprite == -1) + if (screenpeek == sprite[s->owner].yvel && display_mirror == 0) + { + t->owner = -1; + break; + } + if ((sprite[s->owner].cstat&32768) == 0) + { + if (!hittype[s->owner].dispicnum) + t->picnum = hittype[i].temp_data[1]; + else t->picnum = hittype[s->owner].dispicnum; + t->pal = sprite[s->owner].pal; + t->shade = sprite[s->owner].shade; + t->ang = sprite[s->owner].ang; + t->cstat = 2|sprite[s->owner].cstat; + } + } + break; + + case CAMERA1__STATIC: + case RAT__STATIC: + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) + { + t->cstat &= ~4; break; + } +#endif + + k = (((t->ang+3072+128-a)&2047)>>8)&7; + if (k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = s->picnum+k; + break; } hittype[i].dispicnum = t->picnum; @@ -7205,407 +7205,407 @@ FOUNDCHEAT: { switch (k) { - case CHEAT_WEAPONS: - if (VOLUMEONE) - { - j = 6; - } - else - { - j = 0; - } + case CHEAT_WEAPONS: + if (VOLUMEONE) + { + j = 6; + } + else + { + j = 0; + } - for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++) - { - addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); - ps[myconnectindex].gotweapon[weapon] = 1; - } + for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++) + { + addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); + ps[myconnectindex].gotweapon[weapon] = 1; + } - KB_FlushKeyBoardQueue(); - ps[myconnectindex].cheat_phase = 0; - FTA(119,&ps[myconnectindex]); - return; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + FTA(119,&ps[myconnectindex]); + return; - case CHEAT_INVENTORY: - KB_FlushKeyBoardQueue(); - ps[myconnectindex].cheat_phase = 0; - CheatGetInventory(); - FTA(120,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - return; + case CHEAT_INVENTORY: + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + CheatGetInventory(); + FTA(120,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + return; - case CHEAT_KEYS: - ps[myconnectindex].got_access = 7; - KB_FlushKeyBoardQueue(); - ps[myconnectindex].cheat_phase = 0; - FTA(121,&ps[myconnectindex]); - return; + case CHEAT_KEYS: + ps[myconnectindex].got_access = 7; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + FTA(121,&ps[myconnectindex]); + return; - case CHEAT_DEBUG: - debug_on = 1-debug_on; - KB_FlushKeyBoardQueue(); - ps[myconnectindex].cheat_phase = 0; + case CHEAT_DEBUG: + debug_on = 1-debug_on; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; - dumpdebugdata(); - Bsprintf(tempbuf,"GAMEVARS DUMPED TO DEBUG.CON"); - adduserquote(tempbuf); - Bsprintf(tempbuf,"MAP DUMPED TO DEBUG.MAP"); - adduserquote(tempbuf); - break; + dumpdebugdata(); + Bsprintf(tempbuf,"GAMEVARS DUMPED TO DEBUG.CON"); + adduserquote(tempbuf); + Bsprintf(tempbuf,"MAP DUMPED TO DEBUG.MAP"); + adduserquote(tempbuf); + break; - case CHEAT_CLIP: - ud.clipping = 1-ud.clipping; - KB_FlushKeyBoardQueue(); - ps[myconnectindex].cheat_phase = 0; - FTA(112+ud.clipping,&ps[myconnectindex]); - return; + case CHEAT_CLIP: + ud.clipping = 1-ud.clipping; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + FTA(112+ud.clipping,&ps[myconnectindex]); + return; - case CHEAT_RESERVED2: - ps[myconnectindex].gm = MODE_EOL; - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; + case CHEAT_RESERVED2: + ps[myconnectindex].gm = MODE_EOL; + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; - case CHEAT_ALLEN: - FTA(79,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_ClearKeyDown(sc_N); - return; + case CHEAT_ALLEN: + FTA(79,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_ClearKeyDown(sc_N); + return; - case CHEAT_CORNHOLIO: - case CHEAT_KROZ: - ud.god = 1-ud.god; + case CHEAT_CORNHOLIO: + case CHEAT_KROZ: + ud.god = 1-ud.god; - if (ud.god) - { - pus = 1; - pub = 1; - sprite[ps[myconnectindex].i].cstat = 257; + if (ud.god) + { + pus = 1; + pub = 1; + sprite[ps[myconnectindex].i].cstat = 257; - hittype[ps[myconnectindex].i].temp_data[0] = 0; - hittype[ps[myconnectindex].i].temp_data[1] = 0; - hittype[ps[myconnectindex].i].temp_data[2] = 0; - hittype[ps[myconnectindex].i].temp_data[3] = 0; - hittype[ps[myconnectindex].i].temp_data[4] = 0; - hittype[ps[myconnectindex].i].temp_data[5] = 0; + hittype[ps[myconnectindex].i].temp_data[0] = 0; + hittype[ps[myconnectindex].i].temp_data[1] = 0; + hittype[ps[myconnectindex].i].temp_data[2] = 0; + hittype[ps[myconnectindex].i].temp_data[3] = 0; + hittype[ps[myconnectindex].i].temp_data[4] = 0; + hittype[ps[myconnectindex].i].temp_data[5] = 0; - sprite[ps[myconnectindex].i].hitag = 0; - sprite[ps[myconnectindex].i].lotag = 0; - sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup; - - FTA(17,&ps[myconnectindex]); - } - else - { - ud.god = 0; - sprite[ps[myconnectindex].i].extra = max_player_health; - hittype[ps[myconnectindex].i].extra = -1; - ps[myconnectindex].last_extra = max_player_health; - FTA(18,&ps[myconnectindex]); - } + sprite[ps[myconnectindex].i].hitag = 0; + sprite[ps[myconnectindex].i].lotag = 0; + sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup; + FTA(17,&ps[myconnectindex]); + } + else + { + ud.god = 0; sprite[ps[myconnectindex].i].extra = max_player_health; - hittype[ps[myconnectindex].i].extra = 0; - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; + hittype[ps[myconnectindex].i].extra = -1; + ps[myconnectindex].last_extra = max_player_health; + FTA(18,&ps[myconnectindex]); + } - case CHEAT_SCREAMFORME: - ud.god = 1-ud.god; + sprite[ps[myconnectindex].i].extra = max_player_health; + hittype[ps[myconnectindex].i].extra = 0; + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; - if (ud.god) - { - pus = 1; - pub = 1; - sprite[ps[myconnectindex].i].cstat = 257; + case CHEAT_SCREAMFORME: + ud.god = 1-ud.god; - hittype[ps[myconnectindex].i].temp_data[0] = 0; - hittype[ps[myconnectindex].i].temp_data[1] = 0; - hittype[ps[myconnectindex].i].temp_data[2] = 0; - hittype[ps[myconnectindex].i].temp_data[3] = 0; - hittype[ps[myconnectindex].i].temp_data[4] = 0; - hittype[ps[myconnectindex].i].temp_data[5] = 0; + if (ud.god) + { + pus = 1; + pub = 1; + sprite[ps[myconnectindex].i].cstat = 257; - sprite[ps[myconnectindex].i].hitag = 0; - sprite[ps[myconnectindex].i].lotag = 0; - sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup; - Bstrcpy(fta_quotes[122],"Scream for me, Long Beach!"); - FTA(122,&ps[myconnectindex]); - } - else - { - ud.god = 0; - sprite[ps[myconnectindex].i].extra = max_player_health; - hittype[ps[myconnectindex].i].extra = -1; - ps[myconnectindex].last_extra = max_player_health; - FTA(18,&ps[myconnectindex]); - } + hittype[ps[myconnectindex].i].temp_data[0] = 0; + hittype[ps[myconnectindex].i].temp_data[1] = 0; + hittype[ps[myconnectindex].i].temp_data[2] = 0; + hittype[ps[myconnectindex].i].temp_data[3] = 0; + hittype[ps[myconnectindex].i].temp_data[4] = 0; + hittype[ps[myconnectindex].i].temp_data[5] = 0; - CheatGetInventory(); - for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS;weapon++) - ps[myconnectindex].gotweapon[weapon] = 1; - - for (weapon = PISTOL_WEAPON; - weapon < (MAX_WEAPONS); - weapon++) - addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); - ps[myconnectindex].got_access = 7; + sprite[ps[myconnectindex].i].hitag = 0; + sprite[ps[myconnectindex].i].lotag = 0; + sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup; + Bstrcpy(fta_quotes[122],"Scream for me, Long Beach!"); + FTA(122,&ps[myconnectindex]); + } + else + { + ud.god = 0; sprite[ps[myconnectindex].i].extra = max_player_health; - hittype[ps[myconnectindex].i].extra = 0; - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; + hittype[ps[myconnectindex].i].extra = -1; + ps[myconnectindex].last_extra = max_player_health; + FTA(18,&ps[myconnectindex]); + } - case CHEAT_STUFF: + CheatGetInventory(); + for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS;weapon++) + ps[myconnectindex].gotweapon[weapon] = 1; - if (VOLUMEONE) - { - j = 6; - } - else - { - j = 0; - } - for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++) - ps[myconnectindex].gotweapon[weapon] = 1; + for (weapon = PISTOL_WEAPON; + weapon < (MAX_WEAPONS); + weapon++) + addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); + ps[myconnectindex].got_access = 7; + sprite[ps[myconnectindex].i].extra = max_player_health; + hittype[ps[myconnectindex].i].extra = 0; + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; - for (weapon = PISTOL_WEAPON; - weapon < (MAX_WEAPONS-j); - weapon++) - addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); - CheatGetInventory(); - ps[myconnectindex].got_access = 7; - FTA(5,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; + case CHEAT_STUFF: + + if (VOLUMEONE) + { + j = 6; + } + else + { + j = 0; + } + for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++) + ps[myconnectindex].gotweapon[weapon] = 1; + + for (weapon = PISTOL_WEAPON; + weapon < (MAX_WEAPONS-j); + weapon++) + addammo(weapon, &ps[myconnectindex], max_ammo_amount[weapon]); + CheatGetInventory(); + ps[myconnectindex].got_access = 7; + FTA(5,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; - // FTA(21,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - ps[myconnectindex].inven_icon = 1; - return; + // FTA(21,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].inven_icon = 1; + return; - case CHEAT_SCOTTY: - case CHEAT_SKILL: - if (k == CHEAT_SCOTTY) - { - i = Bstrlen(cheatquotes[k])-3+VOLUMEONE; - if (!consolecheat) - { // JBF 20030914 - short volnume,levnume; - if (VOLUMEALL) - { - volnume = cheatbuf[i] - '0'; - levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0'); - } - else - { - volnume = cheatbuf[i] - '0'; - levnume = cheatbuf[i+1] - '0'; - } - - volnume--; - levnume--; - - if (VOLUMEONE && volnume > 0) - { - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - } - else if (volnume > num_volumes-1) - { - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - } - else if (volnume == 0) - { - if (levnume > 5) - { - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - } - } - else - { - if (levnume >= 11) - { - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - } - } - - ud.m_volume_number = ud.volume_number = volnume; - ud.m_level_number = ud.level_number = levnume; + case CHEAT_SCOTTY: + case CHEAT_SKILL: + if (k == CHEAT_SCOTTY) + { + i = Bstrlen(cheatquotes[k])-3+VOLUMEONE; + if (!consolecheat) + { // JBF 20030914 + short volnume,levnume; + if (VOLUMEALL) + { + volnume = cheatbuf[i] - '0'; + levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0'); } else - { // JBF 20030914 - ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume; - ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level; - } - - } - else - { - i = Bstrlen(cheatquotes[k])-1; - ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1'; - } - if (numplayers > 1 && myconnectindex == connecthead) - { - tempbuf[0] = 5; - tempbuf[1] = ud.m_level_number; - tempbuf[2] = ud.m_volume_number; - tempbuf[3] = ud.m_player_skill; - tempbuf[4] = ud.m_monsters_off; - tempbuf[5] = ud.m_respawn_monsters; - tempbuf[6] = ud.m_respawn_items; - tempbuf[7] = ud.m_respawn_inventory; - tempbuf[8] = ud.m_coop; - tempbuf[9] = ud.m_marker; - tempbuf[10] = ud.m_ffire; - tempbuf[11] = ud.m_noexits; - - for (i=connecthead;i>=0;i=connectpoint2[i]) - sendpacket(i,tempbuf,12); - } - else ps[myconnectindex].gm |= MODE_RESTART; - - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_COORDS: - ps[myconnectindex].cheat_phase = 0; - ud.coords = 1-ud.coords; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_VIEW: - if (ps[myconnectindex].over_shoulder_on) - ps[myconnectindex].over_shoulder_on = 0; - else - { - ps[myconnectindex].over_shoulder_on = 1; - cameradist = 0; - cameraclock = totalclock; - } - FTA(22,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_TIME: - - FTA(21,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_UNLOCK: - if (VOLUMEONE) return; - - for (i=numsectors-1;i>=0;i--) //Unlock - { - j = sector[i].lotag; - if (j == -1 || j == 32767) continue; - if ((j & 0x7fff) > 2) { - if (j&(0xffff-16384)) - sector[i].lotag &= (0xffff-16384); - operatesectors(i,ps[myconnectindex].i); + volnume = cheatbuf[i] - '0'; + levnume = cheatbuf[i+1] - '0'; } - } - operateforcefields(ps[myconnectindex].i,-1); - FTA(100,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; + volnume--; + levnume--; - case CHEAT_CASHMAN: - ud.cashman = 1-ud.cashman; - KB_ClearKeyDown(sc_N); - ps[myconnectindex].cheat_phase = 0; - return; + if (VOLUMEONE && volnume > 0) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + else if (volnume > num_volumes-1) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + else if (volnume == 0) + { + if (levnume > 5) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + } + else + { + if (levnume >= 11) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + } - case CHEAT_ITEMS: - CheatGetInventory(); - ps[myconnectindex].got_access = 7; - FTA(5,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE; - ud.showallmap = 1-ud.showallmap; - if (ud.showallmap) - { - for (i=0;i<(MAXSECTORS>>3);i++) - show2dsector[i] = 255; - for (i=0;i<(MAXWALLS>>3);i++) - show2dwall[i] = 255; - FTA(111,&ps[myconnectindex]); + ud.m_volume_number = ud.volume_number = volnume; + ud.m_level_number = ud.level_number = levnume; } else - { - for (i=0;i<(MAXSECTORS>>3);i++) - show2dsector[i] = 0; - for (i=0;i<(MAXWALLS>>3);i++) - show2dwall[i] = 0; - FTA(1,&ps[myconnectindex]); + { // JBF 20030914 + ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume; + ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level; } - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - case CHEAT_TODD: - FTA(99,&ps[myconnectindex]); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_RATE: - ud.tickrate = !ud.tickrate; - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_BETA: - FTA(105,&ps[myconnectindex]); - KB_ClearKeyDown(sc_H); - ps[myconnectindex].cheat_phase = 0; - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_HYPER: - ps[myconnectindex].steroids_amount = 399; - ps[myconnectindex].heat_amount = 1200; - ps[myconnectindex].cheat_phase = 0; - FTA(37,&ps[myconnectindex]); - KB_FlushKeyBoardQueue(); - return; - - case CHEAT_MONSTERS: - { - char *s[] = { "ON", "OFF", "ON (BLOCKING)" }; - - actor_tog++; - if (actor_tog == 3) actor_tog = 0; - ps[screenpeek].cheat_phase = 0; - Bsprintf(fta_quotes[122],"MONSTERS: %s",s[actor_tog]); - FTA(122,&ps[myconnectindex]); - KB_FlushKeyBoardQueue(); - return; } - case CHEAT_RESERVED: - case CHEAT_RESERVED3: - ud.eog = 1; - ps[myconnectindex].gm |= MODE_EOL; - KB_FlushKeyBoardQueue(); - return; + else + { + i = Bstrlen(cheatquotes[k])-1; + ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1'; + } + if (numplayers > 1 && myconnectindex == connecthead) + { + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill; + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + tempbuf[11] = ud.m_noexits; + + for (i=connecthead;i>=0;i=connectpoint2[i]) + sendpacket(i,tempbuf,12); + } + else ps[myconnectindex].gm |= MODE_RESTART; + + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_COORDS: + ps[myconnectindex].cheat_phase = 0; + ud.coords = 1-ud.coords; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_VIEW: + if (ps[myconnectindex].over_shoulder_on) + ps[myconnectindex].over_shoulder_on = 0; + else + { + ps[myconnectindex].over_shoulder_on = 1; + cameradist = 0; + cameraclock = totalclock; + } + FTA(22,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_TIME: + + FTA(21,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_UNLOCK: + if (VOLUMEONE) return; + + for (i=numsectors-1;i>=0;i--) //Unlock + { + j = sector[i].lotag; + if (j == -1 || j == 32767) continue; + if ((j & 0x7fff) > 2) + { + if (j&(0xffff-16384)) + sector[i].lotag &= (0xffff-16384); + operatesectors(i,ps[myconnectindex].i); + } + } + operateforcefields(ps[myconnectindex].i,-1); + + FTA(100,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_CASHMAN: + ud.cashman = 1-ud.cashman; + KB_ClearKeyDown(sc_N); + ps[myconnectindex].cheat_phase = 0; + return; + + case CHEAT_ITEMS: + CheatGetInventory(); + ps[myconnectindex].got_access = 7; + FTA(5,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE; + ud.showallmap = 1-ud.showallmap; + if (ud.showallmap) + { + for (i=0;i<(MAXSECTORS>>3);i++) + show2dsector[i] = 255; + for (i=0;i<(MAXWALLS>>3);i++) + show2dwall[i] = 255; + FTA(111,&ps[myconnectindex]); + } + else + { + for (i=0;i<(MAXSECTORS>>3);i++) + show2dsector[i] = 0; + for (i=0;i<(MAXWALLS>>3);i++) + show2dwall[i] = 0; + FTA(1,&ps[myconnectindex]); + } + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_TODD: + FTA(99,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_RATE: + ud.tickrate = !ud.tickrate; + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_BETA: + FTA(105,&ps[myconnectindex]); + KB_ClearKeyDown(sc_H); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_HYPER: + ps[myconnectindex].steroids_amount = 399; + ps[myconnectindex].heat_amount = 1200; + ps[myconnectindex].cheat_phase = 0; + FTA(37,&ps[myconnectindex]); + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_MONSTERS: + { + char *s[] = { "ON", "OFF", "ON (BLOCKING)" }; + + actor_tog++; + if (actor_tog == 3) actor_tog = 0; + ps[screenpeek].cheat_phase = 0; + Bsprintf(fta_quotes[122],"MONSTERS: %s",s[actor_tog]); + FTA(122,&ps[myconnectindex]); + KB_FlushKeyBoardQueue(); + return; + } + case CHEAT_RESERVED: + case CHEAT_RESERVED3: + ud.eog = 1; + ps[myconnectindex].gm |= MODE_EOL; + KB_FlushKeyBoardQueue(); + return; } } } @@ -8229,38 +8229,38 @@ int load_rancid_net(char *fn) cmdtokptr = script->ltextptr; switch (tokn) { - case T_INTERFACE: - { - char *ip; + case T_INTERFACE: + { + char *ip; - if (scriptfile_getstring(script,&ip)) break; - Bstrcpy(rancid_ip_strings[MAXPLAYERS],ip); - Bstrcpy(rancid_ip_strings[rancid_players++],ip); - strtok(ip,":"); - Bsprintf(tempbuf,"%s",strtok(NULL,":")); - if (atoi(tempbuf) > 1024) - Bsprintf(rancid_local_port_string,"-p %s",tempbuf); - } - break; - case T_MODE: - { - char *mode; + if (scriptfile_getstring(script,&ip)) break; + Bstrcpy(rancid_ip_strings[MAXPLAYERS],ip); + Bstrcpy(rancid_ip_strings[rancid_players++],ip); + strtok(ip,":"); + Bsprintf(tempbuf,"%s",strtok(NULL,":")); + if (atoi(tempbuf) > 1024) + Bsprintf(rancid_local_port_string,"-p %s",tempbuf); + } + break; + case T_MODE: + { + char *mode; - if (scriptfile_getstring(script,&mode)) break; - } - break; - case T_ALLOW: - { - char *ip; + if (scriptfile_getstring(script,&mode)) break; + } + break; + case T_ALLOW: + { + char *ip; - if (scriptfile_getstring(script,&ip)) break; - Bstrcpy(rancid_ip_strings[rancid_players++],ip); - } + if (scriptfile_getstring(script,&ip)) break; + Bstrcpy(rancid_ip_strings[rancid_players++],ip); + } + break; + case T_EOF: + return(0); + default: break; - case T_EOF: - return(0); - default: - break; } } @@ -8296,24 +8296,24 @@ int loadgroupfiles(char *fn) cmdtokptr = script->ltextptr; switch (tokn) { - case T_LOADGRP: + case T_LOADGRP: + { + char *fn; + if (!scriptfile_getstring(script,&fn)) { - char *fn; - if (!scriptfile_getstring(script,&fn)) - { - int j = initgroupfile(fn); + int j = initgroupfile(fn); - if (j == -1) - initprintf("Could not find GRP file %s.\n",fn); - else - initprintf("Using GRP file %s.\n",fn); - } + if (j == -1) + initprintf("Could not find GRP file %s.\n",fn); + else + initprintf("Using GRP file %s.\n",fn); } + } + break; + case T_EOF: + return(0); + default: break; - case T_EOF: - return(0); - default: - break; } } @@ -8558,282 +8558,282 @@ void checkcommandline(int argc,char **argv) c++; switch (*c) { - case '?': + case '?': + comlinehelp(argv); + exit(0); + break; + case 'a': + case 'A': + ud.playerai = 1; + initprintf("Other player AI.\n"); + break; + case 'c': + case 'C': + + c++; + //if(*c == '1' || *c == '2' || *c == '3') + // ud.m_coop = *c - '0' - 1; + //else ud.m_coop = 0; + + ud.m_coop = 0; + while ((*c >= '0')&&(*c <= '9')) + { + ud.m_coop *= 10; + ud.m_coop += *c - '0'; + c++; + } + ud.m_coop--; + //switch(ud.m_coop) + //{ + //case 0: + // initprintf("Dukematch (spawn).\n"); + // break; + //case 1: + // initprintf("Cooperative play.\n"); + // break; + //case 2: + // initprintf("Dukematch (no spawn).\n"); + // break; + //} + break; + case 'd': + case 'D': + c++; + if (strchr(c,'.') == 0) + Bstrcat(c,".dmo"); + initprintf("Play demo %s.\n",c); + Bstrcpy(firstdemofile,c); + break; + case 'f': + case 'F': + c++; + if (*c == '1') + movesperpacket = 1; + if (*c == '2') + movesperpacket = 2; + if (*c == '4') + { + movesperpacket = 4; + setpackettimeout(0x3fffffff,0x3fffffff); + } + break; + case 'g': + case 'G': + c++; + if (!*c) break; + strcpy(tempbuf,c); + if (strchr(tempbuf,'.') == 0) + strcat(tempbuf,".grp"); + + { + struct strllist *s; + s = (struct strllist *)calloc(1,sizeof(struct strllist)); + s->str = strdup(tempbuf); + if (CommandGrps) + { + struct strllist *t; + for (t = CommandGrps; t->next; t=t->next) ; + t->next = s; + } + else + { + CommandGrps = s; + } + } + break; + case 'h': + case 'H': + c++; + if (*c) + { + duke3ddef = c; + initprintf("Using DEF file: %s.\n",duke3ddef); + } + break; + case 'i': + case 'I': + c++; + if (*c == '0') networkmode = 0; + if (*c == '1') networkmode = 1; + initprintf("Network Mode %d\n",networkmode); + break; + case 'j': + case 'J': + c++; + if (!*c) break; + { + struct strllist *s; + s = (struct strllist *)calloc(1,sizeof(struct strllist)); + s->str = strdup(c); + if (CommandPaths) + { + struct strllist *t; + for (t = CommandPaths; t->next; t=t->next) ; + t->next = s; + } + else + { + CommandPaths = s; + } + } + break; + case 'l': + case 'L': + ud.warp_on = 1; + c++; + ud.m_level_number = ud.level_number = (atol(c)-1)%11; + break; + case 'm': + case 'M': + if (*(c+1) != 'a' && *(c+1) != 'A') + { + ud.m_monsters_off = 1; + ud.m_player_skill = ud.player_skill = 0; + initprintf("Monsters off.\n"); + } + break; + case 'n': + case 'N': + c++; + if (*c == 's' || *c == 'S') + { + CommandSoundToggleOff = 2; + initprintf("Sound off.\n"); + } + else if (*c == 'm' || *c == 'M') + { + CommandMusicToggleOff = 1; + initprintf("Music off.\n"); + } + else if (*c == 'd' || *c == 'D') + { + FILE * fp=fopen("gamevars.txt","w"); + InitGameVars(); + DumpGameVars(fp); + fclose(fp); + initprintf("Game variables saved to gamevars.txt.\n"); + } + else + { comlinehelp(argv); - exit(0); - break; - case 'a': - case 'A': - ud.playerai = 1; - initprintf("Other player AI.\n"); - break; - case 'c': - case 'C': - - c++; - //if(*c == '1' || *c == '2' || *c == '3') - // ud.m_coop = *c - '0' - 1; - //else ud.m_coop = 0; - - ud.m_coop = 0; - while ((*c >= '0')&&(*c <= '9')) - { - ud.m_coop *= 10; - ud.m_coop += *c - '0'; - c++; - } - ud.m_coop--; - //switch(ud.m_coop) - //{ - //case 0: - // initprintf("Dukematch (spawn).\n"); - // break; - //case 1: - // initprintf("Cooperative play.\n"); - // break; - //case 2: - // initprintf("Dukematch (no spawn).\n"); - // break; - //} - break; - case 'd': - case 'D': - c++; - if (strchr(c,'.') == 0) - Bstrcat(c,".dmo"); - initprintf("Play demo %s.\n",c); - Bstrcpy(firstdemofile,c); - break; - case 'f': - case 'F': - c++; - if (*c == '1') - movesperpacket = 1; - if (*c == '2') - movesperpacket = 2; - if (*c == '4') - { - movesperpacket = 4; - setpackettimeout(0x3fffffff,0x3fffffff); - } - break; - case 'g': - case 'G': - c++; - if (!*c) break; - strcpy(tempbuf,c); - if (strchr(tempbuf,'.') == 0) - strcat(tempbuf,".grp"); - - { - struct strllist *s; - s = (struct strllist *)calloc(1,sizeof(struct strllist)); - s->str = strdup(tempbuf); - if (CommandGrps) - { - struct strllist *t; - for (t = CommandGrps; t->next; t=t->next) ; - t->next = s; - } - else - { - CommandGrps = s; - } - } - break; - case 'h': - case 'H': - c++; - if (*c) - { - duke3ddef = c; - initprintf("Using DEF file: %s.\n",duke3ddef); - } - break; - case 'i': - case 'I': - c++; - if (*c == '0') networkmode = 0; - if (*c == '1') networkmode = 1; - initprintf("Network Mode %d\n",networkmode); - break; - case 'j': - case 'J': - c++; - if (!*c) break; - { - struct strllist *s; - s = (struct strllist *)calloc(1,sizeof(struct strllist)); - s->str = strdup(c); - if (CommandPaths) - { - struct strllist *t; - for (t = CommandPaths; t->next; t=t->next) ; - t->next = s; - } - else - { - CommandPaths = s; - } - } - break; - case 'l': - case 'L': - ud.warp_on = 1; - c++; - ud.m_level_number = ud.level_number = (atol(c)-1)%11; - break; - case 'm': - case 'M': - if (*(c+1) != 'a' && *(c+1) != 'A') - { - ud.m_monsters_off = 1; - ud.m_player_skill = ud.player_skill = 0; - initprintf("Monsters off.\n"); - } - break; - case 'n': - case 'N': - c++; - if (*c == 's' || *c == 'S') - { - CommandSoundToggleOff = 2; - initprintf("Sound off.\n"); - } - else if (*c == 'm' || *c == 'M') - { - CommandMusicToggleOff = 1; - initprintf("Music off.\n"); - } - else if (*c == 'd' || *c == 'D') - { - FILE * fp=fopen("gamevars.txt","w"); - InitGameVars(); - DumpGameVars(fp); - fclose(fp); - initprintf("Game variables saved to gamevars.txt.\n"); - } - else - { - comlinehelp(argv); - exit(-1); - } - break; - case 'q': - case 'Q': - initprintf("Fake multiplayer mode.\n"); - if (*(++c) == 0) ud.multimode = 1; - else ud.multimode = atol(c)%17; - ud.m_coop = ud.coop = 0; - ud.m_marker = ud.marker = 1; + exit(-1); + } + break; + case 'q': + case 'Q': + initprintf("Fake multiplayer mode.\n"); + if (*(++c) == 0) ud.multimode = 1; + else ud.multimode = atol(c)%17; + ud.m_coop = ud.coop = 0; + ud.m_marker = ud.marker = 1; + ud.m_respawn_monsters = ud.respawn_monsters = 1; + ud.m_respawn_items = ud.respawn_items = 1; + ud.m_respawn_inventory = ud.respawn_inventory = 1; + break; + case 'r': + case 'R': + ud.m_recstat = 1; + initprintf("Demo record mode on.\n"); + break; + case 's': + case 'S': + c++; + ud.m_player_skill = ud.player_skill = (atol(c)%5); + if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1; - ud.m_respawn_items = ud.respawn_items = 1; - ud.m_respawn_inventory = ud.respawn_inventory = 1; - break; - case 'r': - case 'R': - ud.m_recstat = 1; - initprintf("Demo record mode on.\n"); - break; - case 's': - case 'S': - c++; - ud.m_player_skill = ud.player_skill = (atol(c)%5); - if (ud.m_player_skill == 4) - ud.m_respawn_monsters = ud.respawn_monsters = 1; - break; - case 't': - case 'T': - c++; - if (*c == '1') ud.m_respawn_monsters = 1; - else if (*c == '2') ud.m_respawn_items = 1; - else if (*c == '3') ud.m_respawn_inventory = 1; - else + break; + case 't': + case 'T': + c++; + if (*c == '1') ud.m_respawn_monsters = 1; + else if (*c == '2') ud.m_respawn_items = 1; + else if (*c == '3') ud.m_respawn_inventory = 1; + else + { + ud.m_respawn_monsters = 1; + ud.m_respawn_items = 1; + ud.m_respawn_inventory = 1; + } + initprintf("Respawn on.\n"); + break; + case 'u': + case 'U': + CommandWeaponChoice = 1; + c++; + j = 0; + if (*c) + { + initprintf("Using favorite weapon order(s).\n"); + while (*c) { - ud.m_respawn_monsters = 1; - ud.m_respawn_items = 1; - ud.m_respawn_inventory = 1; + ud.wchoice[0][j] = *c-'0'; + c++; + j++; } - initprintf("Respawn on.\n"); - break; - case 'u': - case 'U': - CommandWeaponChoice = 1; - c++; - j = 0; - if (*c) + while (j < 10) { - initprintf("Using favorite weapon order(s).\n"); - while (*c) - { - ud.wchoice[0][j] = *c-'0'; - c++; - j++; - } - while (j < 10) - { - if (j == 9) - ud.wchoice[0][9] = 1; - else - ud.wchoice[0][j] = 2; + if (j == 9) + ud.wchoice[0][9] = 1; + else + ud.wchoice[0][j] = 2; - j++; - } + j++; } - else - { - initprintf("Using default weapon orders.\n"); - ud.wchoice[0][0] = 3; - ud.wchoice[0][1] = 4; - ud.wchoice[0][2] = 5; - ud.wchoice[0][3] = 7; - ud.wchoice[0][4] = 8; - ud.wchoice[0][5] = 6; - ud.wchoice[0][6] = 0; - ud.wchoice[0][7] = 2; - ud.wchoice[0][8] = 9; - ud.wchoice[0][9] = 1; - } - break; - case 'v': - case 'V': - c++; - ud.warp_on = 1; - ud.m_volume_number = ud.volume_number = atol(c)-1; - break; - case 'w': - case 'W': - ud.coords = 1; - break; - case 'x': - case 'X': - c++; - if (*c) - { - Bstrcpy(confilename,c); - userconfiles = 1; - initprintf("Using CON file: %s.\n",confilename); - } - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - ud.warp_on = 2 + (*c) - '0'; - break; - case 'z': - case 'Z': - c++; - condebug = atol(c); - if (!condebug) - condebug = 1; - break; + } + else + { + initprintf("Using default weapon orders.\n"); + ud.wchoice[0][0] = 3; + ud.wchoice[0][1] = 4; + ud.wchoice[0][2] = 5; + ud.wchoice[0][3] = 7; + ud.wchoice[0][4] = 8; + ud.wchoice[0][5] = 6; + ud.wchoice[0][6] = 0; + ud.wchoice[0][7] = 2; + ud.wchoice[0][8] = 9; + ud.wchoice[0][9] = 1; + } + break; + case 'v': + case 'V': + c++; + ud.warp_on = 1; + ud.m_volume_number = ud.volume_number = atol(c)-1; + break; + case 'w': + case 'W': + ud.coords = 1; + break; + case 'x': + case 'X': + c++; + if (*c) + { + Bstrcpy(confilename,c); + userconfiles = 1; + initprintf("Using CON file: %s.\n",confilename); + } + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + ud.warp_on = 2 + (*c) - '0'; + break; + case 'z': + case 'Z': + c++; + condebug = atol(c); + if (!condebug) + condebug = 1; + break; } } i++; @@ -9862,12 +9862,12 @@ MAIN_LOOP_RESTART: switch (ud.pteam[myconnectindex]) { - case 0: - k = 3; - break; - case 1: - k = 21; - break; + case 0: + k = 3; + break; + case 1: + k = 21; + break; } ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = k; } @@ -11125,12 +11125,12 @@ char domovethings(void) j = 0; switch (ps[i].team) { - case 0: - j = 3; - break; - case 1: - j = 21; - break; + case 0: + j = 3; + break; + case 1: + j = 21; + break; } ps[i].palookup = ud.pcolor[i] = j; } @@ -11300,272 +11300,272 @@ void dobonus(char bonusonly) if (numplayers < 2 && ud.eog && ud.from_bonus == 0) switch (ud.volume_number) { - case 0: - if (ud.lockout == 0) + case 0: + if (ud.lockout == 0) + { + setgamepalette(&ps[myconnectindex], endingpal, 3); // JBF 20040308 + clearview(0L); + rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + nextpage(); + //ps[myconnectindex].palette = endingpal; + fadepal(0,0,0, 63,0,-1); + + KB_FlushKeyboardQueue(); + totalclock = 0; + tinc = 0; + while (1) { - setgamepalette(&ps[myconnectindex], endingpal, 3); // JBF 20040308 clearview(0L); rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - nextpage(); - //ps[myconnectindex].palette = endingpal; - fadepal(0,0,0, 63,0,-1); - KB_FlushKeyboardQueue(); - totalclock = 0; - tinc = 0; - while (1) - { - clearview(0L); - rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - - // boss - if (totalclock > 390 && totalclock < 780) - for (t=0;t<35;t+=5) if (bossmove[t+2] && (totalclock%390) > bossmove[t] && (totalclock%390) <= bossmove[t+1]) - { - if (t==10 && bonuscnt == 1) - { - sound(SHOTGUN_FIRE); - sound(SQUISHED); - bonuscnt++; - } - rotatesprite(bossmove[t+3]<<16,bossmove[t+4]<<16,65536L,0,bossmove[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - } - - // Breathe - if (totalclock < 450 || totalclock >= 750) - { - if (totalclock >= 750) + // boss + if (totalclock > 390 && totalclock < 780) + for (t=0;t<35;t+=5) if (bossmove[t+2] && (totalclock%390) > bossmove[t] && (totalclock%390) <= bossmove[t+1]) { - rotatesprite(86<<16,59<<16,65536L,0,VICTORY1+8,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - if (totalclock >= 750 && bonuscnt == 2) + if (t==10 && bonuscnt == 1) { - sound(DUKETALKTOBOSS); + sound(SHOTGUN_FIRE); + sound(SQUISHED); bonuscnt++; } - - + rotatesprite(bossmove[t+3]<<16,bossmove[t+4]<<16,65536L,0,bossmove[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); } - for (t=0;t<20;t+=5) - if (breathe[t+2] && (totalclock%120) > breathe[t] && (totalclock%120) <= breathe[t+1]) - { - if (t==5 && bonuscnt == 0) - { - sound(BOSSTALKTODUKE); - bonuscnt++; - } - rotatesprite(breathe[t+3]<<16,breathe[t+4]<<16,65536L,0,breathe[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - } + + // Breathe + if (totalclock < 450 || totalclock >= 750) + { + if (totalclock >= 750) + { + rotatesprite(86<<16,59<<16,65536L,0,VICTORY1+8,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + if (totalclock >= 750 && bonuscnt == 2) + { + sound(DUKETALKTOBOSS); + bonuscnt++; + } + + } - handleevents(); - getpackets(); - nextpage(); - if (KB_KeyWaiting()) break; + for (t=0;t<20;t+=5) + if (breathe[t+2] && (totalclock%120) > breathe[t] && (totalclock%120) <= breathe[t+1]) + { + if (t==5 && bonuscnt == 0) + { + sound(BOSSTALKTODUKE); + bonuscnt++; + } + rotatesprite(breathe[t+3]<<16,breathe[t+4]<<16,65536L,0,breathe[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + } } + handleevents(); + getpackets(); + nextpage(); + if (KB_KeyWaiting()) break; } + } - fadepal(0,0,0, 0,64,1); + fadepal(0,0,0, 0,64,1); + KB_FlushKeyboardQueue(); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + + rotatesprite(0,0,65536L,0,3292,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-1); + else nextpage(); + while (!KB_KeyWaiting()) + { + handleevents(); + getpackets(); + } + fadepal(0,0,0, 0,64,1); + MUSIC_StopSong(); + FX_StopAllSounds(); + clearsoundlocks(); + break; + case 1: + MUSIC_StopSong(); + clearview(0L); + nextpage(); + + if (ud.lockout == 0) + { + playanm("cineov2.anm",1); + KB_FlushKeyBoardQueue(); + clearview(0L); + nextpage(); + } + + sound(PIPEBOMB_EXPLODE); + + fadepal(0,0,0, 0,64,1); + setview(0,0,xdim-1,ydim-1); + KB_FlushKeyboardQueue(); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + rotatesprite(0,0,65536L,0,3293,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-1); + else nextpage(); + while (!KB_KeyWaiting()) + { + handleevents(); + getpackets(); + } + IFISSOFTMODE fadepal(0,0,0, 0,64,1); + + break; + + case 3: + + setview(0,0,xdim-1,ydim-1); + + MUSIC_StopSong(); + clearview(0L); + nextpage(); + + if (ud.lockout == 0) + { KB_FlushKeyboardQueue(); - //ps[myconnectindex].palette = palette; - setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + playanm("vol4e1.anm",8); + clearview(0L); + nextpage(); + playanm("vol4e2.anm",10); + clearview(0L); + nextpage(); + playanm("vol4e3.anm",11); + clearview(0L); + nextpage(); + } - rotatesprite(0,0,65536L,0,3292,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); - IFISSOFTMODE fadepal(0,0,0, 63,0,-1); - else nextpage(); - while (!KB_KeyWaiting()) + FX_StopAllSounds(); + clearsoundlocks(); + sound(ENDSEQVOL3SND4); + KB_FlushKeyBoardQueue(); + + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + IFISSOFTMODE palto(0,0,0,63); + clearview(0L); + menutext(160,60,0,0,"THANKS TO ALL OUR"); + menutext(160,60+16,0,0,"FANS FOR GIVING"); + menutext(160,60+16+16,0,0,"US BIG HEADS."); + menutext(160,70+16+16+16,0,0,"LOOK FOR A DUKE NUKEM 3D"); + menutext(160,70+16+16+16+16,0,0,"SEQUEL SOON."); + nextpage(); + + fadepal(0,0,0, 63,0,-3); + KB_FlushKeyboardQueue(); + while (!KB_KeyWaiting()) + { + handleevents(); + getpackets(); + } + fadepal(0,0,0, 0,64,3); + + clearview(0L); + nextpage(); + + playanm("DUKETEAM.ANM",4); + + KB_FlushKeyBoardQueue(); + while (!KB_KeyWaiting()) + { + handleevents(); + getpackets(); + } + + clearview(0L); + nextpage(); + IFISSOFTMODE palto(0,0,0,63); + + FX_StopAllSounds(); + clearsoundlocks(); + KB_FlushKeyBoardQueue(); + + break; + + case 2: + + MUSIC_StopSong(); + clearview(0L); + nextpage(); + if (ud.lockout == 0) + { + fadepal(0,0,0, 63,0,-1); + playanm("cineov3.anm",2); + KB_FlushKeyBoardQueue(); + ototalclock = totalclock+200; + while (totalclock < ototalclock) { handleevents(); getpackets(); } - fadepal(0,0,0, 0,64,1); - MUSIC_StopSong(); - FX_StopAllSounds(); - clearsoundlocks(); - break; - case 1: - MUSIC_StopSong(); clearview(0L); nextpage(); - if (ud.lockout == 0) - { - playanm("cineov2.anm",1); - KB_FlushKeyBoardQueue(); - clearview(0L); - nextpage(); - } - - sound(PIPEBOMB_EXPLODE); - - fadepal(0,0,0, 0,64,1); - setview(0,0,xdim-1,ydim-1); - KB_FlushKeyboardQueue(); - //ps[myconnectindex].palette = palette; - setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 - rotatesprite(0,0,65536L,0,3293,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); - IFISSOFTMODE fadepal(0,0,0, 63,0,-1); - else nextpage(); - while (!KB_KeyWaiting()) - { - handleevents(); - getpackets(); - } - IFISSOFTMODE fadepal(0,0,0, 0,64,1); - - break; - - case 3: - - setview(0,0,xdim-1,ydim-1); - - MUSIC_StopSong(); - clearview(0L); - nextpage(); - - if (ud.lockout == 0) - { - KB_FlushKeyboardQueue(); - playanm("vol4e1.anm",8); - clearview(0L); - nextpage(); - playanm("vol4e2.anm",10); - clearview(0L); - nextpage(); - playanm("vol4e3.anm",11); - clearview(0L); - nextpage(); - } - FX_StopAllSounds(); clearsoundlocks(); - sound(ENDSEQVOL3SND4); - KB_FlushKeyBoardQueue(); + } - //ps[myconnectindex].palette = palette; - setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 - IFISSOFTMODE palto(0,0,0,63); - clearview(0L); - menutext(160,60,0,0,"THANKS TO ALL OUR"); - menutext(160,60+16,0,0,"FANS FOR GIVING"); - menutext(160,60+16+16,0,0,"US BIG HEADS."); - menutext(160,70+16+16+16,0,0,"LOOK FOR A DUKE NUKEM 3D"); - menutext(160,70+16+16+16+16,0,0,"SEQUEL SOON."); - nextpage(); + playanm("RADLOGO.ANM",3); - fadepal(0,0,0, 63,0,-3); - KB_FlushKeyboardQueue(); - while (!KB_KeyWaiting()) + if (ud.lockout == 0 && !KB_KeyWaiting()) + { + sound(ENDSEQVOL3SND5); + while (issoundplaying(-1,ENDSEQVOL3SND5)) { handleevents(); getpackets(); } - fadepal(0,0,0, 0,64,3); - - clearview(0L); - nextpage(); - - playanm("DUKETEAM.ANM",4); - - KB_FlushKeyBoardQueue(); - while (!KB_KeyWaiting()) + if (KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND6); + while (issoundplaying(-1,ENDSEQVOL3SND6)) + { + handleevents(); + getpackets(); + } + if (KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND7); + while (issoundplaying(-1,ENDSEQVOL3SND7)) + { + handleevents(); + getpackets(); + } + if (KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND8); + while (issoundplaying(-1,ENDSEQVOL3SND8)) + { + handleevents(); + getpackets(); + } + if (KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND9); + while (issoundplaying(-1,ENDSEQVOL3SND9)) { handleevents(); getpackets(); } - clearview(0L); - nextpage(); - IFISSOFTMODE palto(0,0,0,63); - FX_StopAllSounds(); - clearsoundlocks(); - KB_FlushKeyBoardQueue(); + } - break; - - case 2: - - MUSIC_StopSong(); - clearview(0L); - nextpage(); - if (ud.lockout == 0) - { - fadepal(0,0,0, 63,0,-1); - playanm("cineov3.anm",2); - KB_FlushKeyBoardQueue(); - ototalclock = totalclock+200; - while (totalclock < ototalclock) - { - handleevents(); - getpackets(); - } - clearview(0L); - nextpage(); - - FX_StopAllSounds(); - clearsoundlocks(); - } - - playanm("RADLOGO.ANM",3); - - if (ud.lockout == 0 && !KB_KeyWaiting()) - { - sound(ENDSEQVOL3SND5); - while (issoundplaying(-1,ENDSEQVOL3SND5)) - { - handleevents(); - getpackets(); - } - if (KB_KeyWaiting()) goto ENDANM; - sound(ENDSEQVOL3SND6); - while (issoundplaying(-1,ENDSEQVOL3SND6)) - { - handleevents(); - getpackets(); - } - if (KB_KeyWaiting()) goto ENDANM; - sound(ENDSEQVOL3SND7); - while (issoundplaying(-1,ENDSEQVOL3SND7)) - { - handleevents(); - getpackets(); - } - if (KB_KeyWaiting()) goto ENDANM; - sound(ENDSEQVOL3SND8); - while (issoundplaying(-1,ENDSEQVOL3SND8)) - { - handleevents(); - getpackets(); - } - if (KB_KeyWaiting()) goto ENDANM; - sound(ENDSEQVOL3SND9); - while (issoundplaying(-1,ENDSEQVOL3SND9)) - { - handleevents(); - getpackets(); - } - - - } - - KB_FlushKeyBoardQueue(); - totalclock = 0; - while (!KB_KeyWaiting() && totalclock < 120) - { - handleevents(); - getpackets(); - } + KB_FlushKeyBoardQueue(); + totalclock = 0; + while (!KB_KeyWaiting() && totalclock < 120) + { + handleevents(); + getpackets(); + } ENDANM: - FX_StopAllSounds(); - clearsoundlocks(); + FX_StopAllSounds(); + clearsoundlocks(); - KB_FlushKeyBoardQueue(); + KB_FlushKeyBoardQueue(); - clearview(0L); + clearview(0L); - break; + break; } FRAGBONUS: @@ -11681,12 +11681,12 @@ FRAGBONUS: switch (ud.volume_number) { - case 1: - gfx_offset = 5; - break; - default: - gfx_offset = 0; - break; + case 1: + gfx_offset = 5; + break; + default: + gfx_offset = 0; + break; } rotatesprite(0,0,65536L,0,BONUSSCREEN+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); @@ -11750,36 +11750,36 @@ FRAGBONUS: { switch ((totalclock>>4)%15) { - case 0: - if (bonuscnt == 6) + case 0: + if (bonuscnt == 6) + { + bonuscnt++; + sound(SHOTGUN_COCK); + switch (rand()&3) { - bonuscnt++; - sound(SHOTGUN_COCK); - switch (rand()&3) - { - case 0: - sound(BONUS_SPEECH1); - break; - case 1: - sound(BONUS_SPEECH2); - break; - case 2: - sound(BONUS_SPEECH3); - break; - case 3: - sound(BONUS_SPEECH4); - break; - } + case 0: + sound(BONUS_SPEECH1); + break; + case 1: + sound(BONUS_SPEECH2); + break; + case 2: + sound(BONUS_SPEECH3); + break; + case 3: + sound(BONUS_SPEECH4); + break; } - case 1: - case 4: - case 5: - rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+3+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - break; - case 2: - case 3: - rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+4+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - break; + } + case 1: + case 4: + case 5: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+3+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + case 2: + case 3: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+4+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; } } else if (totalclock > (10240+120L)) break; @@ -11787,13 +11787,13 @@ FRAGBONUS: { switch ((totalclock>>5)&3) { - case 1: - case 3: - rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+1+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - break; - case 2: - rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+2+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); - break; + case 1: + case 3: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+1+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + case 2: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+2+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; } } diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index fca7adc67..1028b9387 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -909,120 +909,120 @@ void DefineProjectile(long lVar1, long lLabelID, long lVar2) { switch (lLabelID) { - case PROJ_WORKSLIKE: - projectile[lVar1].workslike=lVar2; - break; + case PROJ_WORKSLIKE: + projectile[lVar1].workslike=lVar2; + break; - case PROJ_SPAWNS: - projectile[lVar1].spawns=lVar2; - break; + case PROJ_SPAWNS: + projectile[lVar1].spawns=lVar2; + break; - case PROJ_SXREPEAT: - projectile[lVar1].sxrepeat=lVar2; - break; + case PROJ_SXREPEAT: + projectile[lVar1].sxrepeat=lVar2; + break; - case PROJ_SYREPEAT: - projectile[lVar1].syrepeat=lVar2; - break; + case PROJ_SYREPEAT: + projectile[lVar1].syrepeat=lVar2; + break; - case PROJ_SOUND: - projectile[lVar1].sound=lVar2; - break; + case PROJ_SOUND: + projectile[lVar1].sound=lVar2; + break; - case PROJ_ISOUND: - projectile[lVar1].isound=lVar2; - break; + case PROJ_ISOUND: + projectile[lVar1].isound=lVar2; + break; - case PROJ_VEL: - projectile[lVar1].vel=lVar2; - break; + case PROJ_VEL: + projectile[lVar1].vel=lVar2; + break; - case PROJ_EXTRA: - projectile[lVar1].extra=lVar2; - break; + case PROJ_EXTRA: + projectile[lVar1].extra=lVar2; + break; - case PROJ_DECAL: - projectile[lVar1].decal=lVar2; - break; + case PROJ_DECAL: + projectile[lVar1].decal=lVar2; + break; - case PROJ_TRAIL: - projectile[lVar1].trail=lVar2; - break; + case PROJ_TRAIL: + projectile[lVar1].trail=lVar2; + break; - case PROJ_TXREPEAT: - projectile[lVar1].txrepeat=lVar2; - break; + case PROJ_TXREPEAT: + projectile[lVar1].txrepeat=lVar2; + break; - case PROJ_TYREPEAT: - projectile[lVar1].tyrepeat=lVar2; - break; + case PROJ_TYREPEAT: + projectile[lVar1].tyrepeat=lVar2; + break; - case PROJ_TOFFSET: - projectile[lVar1].toffset=lVar2; - break; + case PROJ_TOFFSET: + projectile[lVar1].toffset=lVar2; + break; - case PROJ_TNUM: - projectile[lVar1].tnum=lVar2; - break; + case PROJ_TNUM: + projectile[lVar1].tnum=lVar2; + break; - case PROJ_DROP: - projectile[lVar1].drop=lVar2; - break; + case PROJ_DROP: + projectile[lVar1].drop=lVar2; + break; - case PROJ_CSTAT: - projectile[lVar1].cstat=lVar2; - break; + case PROJ_CSTAT: + projectile[lVar1].cstat=lVar2; + break; - case PROJ_CLIPDIST: - projectile[lVar1].clipdist=lVar2; - break; + case PROJ_CLIPDIST: + projectile[lVar1].clipdist=lVar2; + break; - case PROJ_SHADE: - projectile[lVar1].shade=lVar2; - break; + case PROJ_SHADE: + projectile[lVar1].shade=lVar2; + break; - case PROJ_XREPEAT: - projectile[lVar1].xrepeat=lVar2; - break; + case PROJ_XREPEAT: + projectile[lVar1].xrepeat=lVar2; + break; - case PROJ_YREPEAT: - projectile[lVar1].yrepeat=lVar2; - break; + case PROJ_YREPEAT: + projectile[lVar1].yrepeat=lVar2; + break; - case PROJ_PAL: - projectile[lVar1].pal=lVar2; - break; + case PROJ_PAL: + projectile[lVar1].pal=lVar2; + break; - case PROJ_EXTRA_RAND: - projectile[lVar1].extra_rand=lVar2; - break; + case PROJ_EXTRA_RAND: + projectile[lVar1].extra_rand=lVar2; + break; - case PROJ_HITRADIUS: - projectile[lVar1].hitradius=lVar2; - break; + case PROJ_HITRADIUS: + projectile[lVar1].hitradius=lVar2; + break; - case PROJ_VEL_MULT: - projectile[lVar1].velmult=lVar2; - break; + case PROJ_VEL_MULT: + projectile[lVar1].velmult=lVar2; + break; - case PROJ_OFFSET: - projectile[lVar1].offset=lVar2; - break; + case PROJ_OFFSET: + projectile[lVar1].offset=lVar2; + break; - case PROJ_BOUNCES: - projectile[lVar1].bounces=lVar2; - break; + case PROJ_BOUNCES: + projectile[lVar1].bounces=lVar2; + break; - case PROJ_BSOUND: - projectile[lVar1].bsound=lVar2; - break; + case PROJ_BSOUND: + projectile[lVar1].bsound=lVar2; + break; - case PROJ_RANGE: - projectile[lVar1].range=lVar2; - break; + case PROJ_RANGE: + projectile[lVar1].range=lVar2; + break; - default: - break; + default: + break; } // defaultprojectile[lVar1] = projectile[lVar1]; @@ -1037,27 +1037,27 @@ char CheckEventSync(int iEventID) { switch (iEventID) { - case EVENT_CHEATGETSTEROIDS: - case EVENT_CHEATGETHEAT: - case EVENT_CHEATGETBOOT: - case EVENT_CHEATGETSHIELD: - case EVENT_CHEATGETSCUBA: - case EVENT_CHEATGETHOLODUKE: - case EVENT_CHEATGETJETPACK: - case EVENT_CHEATGETFIRSTAID: - case EVENT_DISPLAYWEAPON: - case EVENT_DRAWWEAPON: - case EVENT_DISPLAYCROSSHAIR: - case EVENT_DISPLAYREST: - case EVENT_ENTERLEVEL: - case EVENT_FAKEDOMOVETHINGS: - case EVENT_GETLOADTILE: - case EVENT_GETMENUTILE: - case EVENT_INIT: - case EVENT_LOGO: - return 0; - default: - return 1; + case EVENT_CHEATGETSTEROIDS: + case EVENT_CHEATGETHEAT: + case EVENT_CHEATGETBOOT: + case EVENT_CHEATGETSHIELD: + case EVENT_CHEATGETSCUBA: + case EVENT_CHEATGETHOLODUKE: + case EVENT_CHEATGETJETPACK: + case EVENT_CHEATGETFIRSTAID: + case EVENT_DISPLAYWEAPON: + case EVENT_DRAWWEAPON: + case EVENT_DISPLAYCROSSHAIR: + case EVENT_DISPLAYREST: + case EVENT_ENTERLEVEL: + case EVENT_FAKEDOMOVETHINGS: + case EVENT_GETLOADTILE: + case EVENT_GETMENUTILE: + case EVENT_INIT: + case EVENT_LOGO: + return 0; + default: + return 1; } } return 1; @@ -1997,238 +1997,319 @@ char parsecommand(void) switch (tw) { - default: - case -1: - return 0; //End - case CON_STATE: - if (parsing_actor == 0 && parsing_state == 0) - { - getlabel(); - scriptptr--; - labelcode[labelcnt] = (long) scriptptr; - labeltype[labelcnt] = LABEL_STATE; - - parsing_state = 1; - Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); - labelcnt++; - return 0; - } - - getlabel(); - - for (i=0;i 1) - initprintf("%s:%ld: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); - *scriptptr = labelcode[j]; - break; - } - else - { - char *gl; - gl = translatelabeltype(labeltype[j]); - ReportError(-1); - initprintf("%s:%ld: warning: expected a state, found a %s.\n",compilefile,line_number,gl); - Bfree(gl); - *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions - return 0; // valid label name, but wrong type - } - } - } - if (j==labelcnt) - { - ReportError(-1); - initprintf("%s:%ld: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); - error++; - } - scriptptr++; - return 0; - - case CON_ENDS: - if (parsing_state == 0) - { - ReportError(-1); - initprintf("%s:%ld: error: found `ends' without open `state'.\n",compilefile,line_number); - error++; - } - // else - { - if (num_braces > 0) - { - ReportError(ERROR_OPENBRACKET); - error++; - } - if (num_braces < 0) - { - ReportError(ERROR_CLOSEBRACKET); - error++; - } - if (checking_switch > 0) - { - ReportError(ERROR_NOENDSWITCH); - error++; - - checking_switch = 0; // can't be checking anymore... - } - - parsing_state = 0; - Bsprintf(parsing_item_name,"(none)"); - } - return 0; - - case CON_SETTHISPROJECTILE: - case CON_SETPROJECTILE: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETTHISPROJECTILE: - case CON_GETPROJECTILE: + default: + case -1: + return 0; //End + case CON_STATE: + if (parsing_actor == 0 && parsing_state == 0) { - long lLabelID; - - // syntax getwall[].x - // gets the value of wall[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - if (tw == CON_SETTHISPROJECTILE) - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + scriptptr--; + labelcode[labelcnt] = (long) scriptptr; + labeltype[labelcnt] = LABEL_STATE; - lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - - *scriptptr++=projectilelabels[lLabelID].lId; - - //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); - - // now at target VAR... - - // get the ID of the DEF - switch (tw) - { - case CON_SETPROJECTILE: - case CON_SETTHISPROJECTILE: - transvar(); - break; - default: - transvartype(GAMEVAR_FLAG_READONLY); - break; - } - break; + parsing_state = 1; + Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); + labelcnt++; + return 0; } - case CON_GAMEVAR: - // syntax: gamevar - // defines var1 and sets initial value. - // flags are used to define usage - // (see top of this files for flags) - //printf("Got gamedef. Getting Label. '%.20s'\n",textptr); + getlabel(); - if (isdigit(*textptr) || (*textptr == '-')) + for (i=0;i 1) + initprintf("%s:%ld: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); + *scriptptr = labelcode[j]; + break; + } + else + { + char *gl; + gl = translatelabeltype(labeltype[j]); + ReportError(-1); + initprintf("%s:%ld: warning: expected a state, found a %s.\n",compilefile,line_number,gl); + Bfree(gl); + *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions + return 0; // valid label name, but wrong type + } + } + } + if (j==labelcnt) + { + ReportError(-1); + initprintf("%s:%ld: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); + error++; + } + scriptptr++; + return 0; + + case CON_ENDS: + if (parsing_state == 0) + { + ReportError(-1); + initprintf("%s:%ld: error: found `ends' without open `state'.\n",compilefile,line_number); + error++; + } + // else + { + if (num_braces > 0) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if (num_braces < 0) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + if (checking_switch > 0) + { + ReportError(ERROR_NOENDSWITCH); + error++; + + checking_switch = 0; // can't be checking anymore... + } + + parsing_state = 0; + Bsprintf(parsing_item_name,"(none)"); + } + return 0; + + case CON_SETTHISPROJECTILE: + case CON_SETPROJECTILE: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETTHISPROJECTILE: + case CON_GETPROJECTILE: + { + long lLabelID; + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + if (tw == CON_SETTHISPROJECTILE) + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=projectilelabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); + + // now at target VAR... + + // get the ID of the DEF + switch (tw) + { + case CON_SETPROJECTILE: + case CON_SETTHISPROJECTILE: + transvar(); + break; + default: + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + break; + } + + case CON_GAMEVAR: + // syntax: gamevar + // defines var1 and sets initial value. + // flags are used to define usage + // (see top of this files for flags) + //printf("Got gamedef. Getting Label. '%.20s'\n",textptr); + + if (isdigit(*textptr) || (*textptr == '-')) + { + getlabel(); + error++; + ReportError(ERROR_SYNTAXERROR); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section + return 0; + } + + getlabel(); + //printf("Got Label '%.20s'\n",textptr); + // Check to see it's already defined + + for (i=0;i= defaultlabelcnt) + { + warning++; + ReportError(WARNING_DUPLICATEDEFINITION); + } + break; + } + } + //printf("Translating. '%.20s'\n",textptr); + transnum(LABEL_DEFINE); + //printf("Translated. '%.20s'\n",textptr); + if (i == labelcnt) + { + // printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1)); + labeltype[labelcnt] = LABEL_DEFINE; + labelcode[labelcnt++] = *(scriptptr-1); + if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap) + processnames(label+(i<<6),*(scriptptr-1)); + } + scriptptr -= 2; + return 0; + } + + case CON_PALFROM: + for (j=0;j<4;j++) + { + if (keyword() == -1) + transnum(LABEL_DEFINE); + else break; + } + + while (j<4) + { + *scriptptr = 0; + scriptptr++; + j++; + } + return 0; + + case CON_MOVE: + if (parsing_actor || parsing_state) + { + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + + if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + { + ReportError(-1); + *(scriptptr-1) = 0; + initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + } + + j = 0; + while (keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + *scriptptr = j; + + scriptptr++; + } + else + { + scriptptr--; getlabel(); - //printf("Got label. '%.20s'\n",textptr); // Check to see it's already defined for (i=0;i= defaultlabelcnt) - { - warning++; - ReportError(WARNING_DUPLICATEDEFINITION); - } + warning++; + initprintf("%s:%ld: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); break; } - } - //printf("Translating. '%.20s'\n",textptr); - transnum(LABEL_DEFINE); - //printf("Translated. '%.20s'\n",textptr); if (i == labelcnt) { - // printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1)); - labeltype[labelcnt] = LABEL_DEFINE; - labelcode[labelcnt++] = *(scriptptr-1); - if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap) - processnames(label+(i<<6),*(scriptptr-1)); + labeltype[labelcnt] = LABEL_MOVE; + labelcode[labelcnt++] = (long) scriptptr; } - scriptptr -= 2; - return 0; - } - - case CON_PALFROM: - for (j=0;j<4;j++) + for (j=0;j<2;j++) { - if (keyword() == -1) - transnum(LABEL_DEFINE); - else break; + if (keyword() >= 0) break; + transnum(LABEL_DEFINE); } - - while (j<4) + for (k=j;k<2;k++) { *scriptptr = 0; scriptptr++; - j++; - } - return 0; - - case CON_MOVE: - if (parsing_actor || parsing_state) - { - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) - { - ReportError(-1); - *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); - } - - j = 0; - while (keyword() == -1) - { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; - } - *scriptptr = j; - - scriptptr++; - } - else - { - scriptptr--; - getlabel(); - // Check to see it's already defined - - for (i=0;i= 0) break; - transnum(LABEL_DEFINE); - } - for (k=j;k<2;k++) - { - *scriptptr = 0; - scriptptr++; - } - } - return 0; - - case CON_MUSIC: - { - // NOTE: this doesn't get stored in the PCode... - - // music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid - // thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid - scriptptr--; - transnum(LABEL_DEFINE); // Volume Number (0/4) - scriptptr--; - - k = *scriptptr-1; - - if (k >= 0) // if it's background music - { - i = 0; - // get the file name... - while (keyword() == -1) - { - while (isaltok(*textptr) == 0) - { - if (*textptr == 0x0a) line_number++; - textptr++; - if (*textptr == 0) break; - } - j = 0; - while (isaltok(*(textptr+j))) - { - music_fn[k][i][j] = textptr[j]; - j++; - } - music_fn[k][i][j] = '\0'; - textptr += j; - if (i > 9) break; - i++; - } - } - else - { - i = 0; - while (keyword() == -1) - { - while (isaltok(*textptr) == 0) - { - if (*textptr == 0x0a) line_number++; - textptr++; - if (*textptr == 0) break; - } - j = 0; - while (isaltok(*(textptr+j))) - { - env_music_fn[i][j] = textptr[j]; - j++; - } - env_music_fn[i][j] = '\0'; - - textptr += j; - if (i > 9) break; - i++; - } } } return 0; - case CON_INCLUDE: - scriptptr--; - while (isaltok(*textptr) == 0) - { - if (*textptr == 0x0a) line_number++; - textptr++; - if (*textptr == 0) break; - } - j = 0; - while (isaltok(*textptr)) - { - tempbuf[j] = *(textptr++); - j++; - } - tempbuf[j] = '\0'; + case CON_MUSIC: + { + // NOTE: this doesn't get stored in the PCode... - { - short temp_line_number; - char temp_ifelse_check; - char *origtptr, *mptr; - char parentcompilefile[255]; - int fp; + // music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid + // thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid + scriptptr--; + transnum(LABEL_DEFINE); // Volume Number (0/4) + scriptptr--; - fp = kopen4load(tempbuf,loadfromgrouponly); - if (fp < 0) + k = *scriptptr-1; + + if (k >= 0) // if it's background music + { + i = 0; + // get the file name... + while (keyword() == -1) + { + while (isaltok(*textptr) == 0) { - error++; - initprintf("%s:%ld: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); - return 0; - } - - j = kfilelength(fp); - - mptr = (char *)Bmalloc(j+1); - if (!mptr) - { - kclose(fp); - error++; - initprintf("%s:%ld: error: could not allocate %ld bytes to include `%s'.\n", - line_number,compilefile,j,tempbuf); - return 0; - } - - initprintf("Including: %s (%ld bytes)\n",tempbuf, j); - kread(fp, mptr, j); - kclose(fp); - mptr[j] = 0; - - if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line + if (*textptr == 0x0a) line_number++; textptr++; - origtptr = textptr; - - Bstrcpy(parentcompilefile, compilefile); - Bstrcpy(compilefile, tempbuf); - temp_line_number = line_number; - line_number = 1; - temp_ifelse_check = checking_ifelse; - checking_ifelse = 0; - - textptr = mptr; - do done = parsecommand(); - while (!done); - - Bstrcpy(compilefile, parentcompilefile); - total_lines += line_number; - line_number = temp_line_number; - checking_ifelse = temp_ifelse_check; - - textptr = origtptr; - - Bfree(mptr); - } - return 0; - - case CON_AI: - if (parsing_actor || parsing_state) - { - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - transnum(LABEL_AI); - } - else - { - scriptptr--; - getlabel(); - - for (i=0;i= 0) break; - if (j == 1) - transnum(LABEL_ACTION); - else if (j == 2) - { - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) - { - ReportError(-1); - *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); - } - k = 0; - while (keyword() == -1) - { - transnum(LABEL_DEFINE); - scriptptr--; - k |= *scriptptr; - } - *scriptptr = k; - scriptptr++; - return 0; - } - } - for (k=j;k<3;k++) - { - *scriptptr = 0; - scriptptr++; - } - } - return 0; - - case CON_ACTION: - if (parsing_actor || parsing_state) - { - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - transnum(LABEL_ACTION); - } - else - { - scriptptr--; - getlabel(); - // Check to see it's already defined - - for (i=0;i= 0) break; - transnum(LABEL_DEFINE); - } - for (k=j;k<5;k++) - { - *scriptptr = 0; - scriptptr++; - } - } - return 0; - - case CON_ACTOR: - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; - - skipcomments(); - j = 0; - while (isaltok(*(textptr+j))) - { - parsing_item_name[j] = textptr[j]; - j++; - } - parsing_item_name[j] = 0; - transnum(LABEL_DEFINE); - // Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); - scriptptr--; - actorscrptr[*scriptptr] = parsing_actor; - - for (j=0;j<4;j++) - { - *(parsing_actor+j) = 0; - if (j == 3) - { - j = 0; - while (keyword() == -1) - { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; - } - *scriptptr = j; - scriptptr++; - break; - } - else - { - if (keyword() >= 0) - { - for (i=4-j; i; i--) *(scriptptr++) = 0; - break; - } - switch (j) - { - case 0: - transnum(LABEL_DEFINE); - break; - case 1: - transnum(LABEL_ACTION); - break; - case 2: - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) - { - ReportError(-1); - *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); - } - break; - } - *(parsing_actor+j) = *(scriptptr-1); - } - } - checking_ifelse = 0; - return 0; - - case CON_ONEVENT: - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - num_braces = 0; - scriptptr--; - parsing_event = scriptptr; - parsing_actor = scriptptr; - - skipcomments(); - j = 0; - while (isaltok(*(textptr+j))) - { - parsing_item_name[j] = textptr[j]; - j++; - } - parsing_item_name[j] = 0; - labelsonly = 1; - transnum(LABEL_DEFINE); - labelsonly = 0; - scriptptr--; - j= *scriptptr; // type of event - current_event = j; - //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, parsing_event); - //AddLog(g_szBuf); - if (j > MAXGAMEEVENTS-1 || j < 0) - { - initprintf("%s:%ld: error: invalid event ID.\n",compilefile,line_number); - error++; - return 0; - } - - if (apScriptGameEvent[j]) - { - tempscrptr = parsing_event; - parsing_event = parsing_actor = 0; - ReportError(-1); - parsing_event = parsing_actor = tempscrptr; - initprintf("%s:%ld: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); - } - else apScriptGameEvent[j]=parsing_event; - - checking_ifelse = 0; - - return 0; - - case CON_EVENTLOADACTOR: - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; - - skipcomments(); - j = 0; - while (isaltok(*(textptr+j))) - { - parsing_item_name[j] = textptr[j]; - j++; - } - parsing_item_name[j] = 0; - transnum(LABEL_DEFINE); - scriptptr--; - actorLoadEventScrptr[*scriptptr] = parsing_actor; - - checking_ifelse = 0; - return 0; - - case CON_USERACTOR: - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; - - transnum(LABEL_DEFINE); - scriptptr--; - - skipcomments(); - j = 0; - while (isaltok(*(textptr+j))) - { - parsing_item_name[j] = textptr[j]; - j++; - } - parsing_item_name[j] = 0; - - j = *scriptptr; - - if (j > 2) - { - ReportError(-1); - initprintf("%s:%ld: warning: invalid useractor type.\n",compilefile,line_number); j = 0; + while (isaltok(*(textptr+j))) + { + music_fn[k][i][j] = textptr[j]; + j++; + } + music_fn[k][i][j] = '\0'; + textptr += j; + if (i > 9) break; + i++; } - - transnum(LABEL_DEFINE); - scriptptr--; - actorscrptr[*scriptptr] = parsing_actor; - actortype[*scriptptr] = j; - - for (j=0;j<4;j++) + } + else + { + i = 0; + while (keyword() == -1) { - *(parsing_actor+j) = 0; - if (j == 3) + while (isaltok(*textptr) == 0) { - j = 0; - while (keyword() == -1) - { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; - } - *scriptptr = j; - scriptptr++; - break; + if (*textptr == 0x0a) line_number++; + textptr++; + if (*textptr == 0) break; } - else + j = 0; + while (isaltok(*(textptr+j))) { - if (keyword() >= 0) - { - for (i=4-j; i; i--) *(scriptptr++) = 0; - break; - } - switch (j) - { - case 0: - transnum(LABEL_DEFINE); - break; - case 1: - transnum(LABEL_ACTION); - break; - case 2: - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) - { - ReportError(-1); - *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); - } - break; - } - *(parsing_actor+j) = *(scriptptr-1); + env_music_fn[i][j] = textptr[j]; + j++; } + env_music_fn[i][j] = '\0'; + + textptr += j; + if (i > 9) break; + i++; } + } + } + return 0; + + case CON_INCLUDE: + scriptptr--; + while (isaltok(*textptr) == 0) + { + if (*textptr == 0x0a) line_number++; + textptr++; + if (*textptr == 0) break; + } + j = 0; + while (isaltok(*textptr)) + { + tempbuf[j] = *(textptr++); + j++; + } + tempbuf[j] = '\0'; + + { + short temp_line_number; + char temp_ifelse_check; + char *origtptr, *mptr; + char parentcompilefile[255]; + int fp; + + fp = kopen4load(tempbuf,loadfromgrouponly); + if (fp < 0) + { + error++; + initprintf("%s:%ld: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); + return 0; + } + + j = kfilelength(fp); + + mptr = (char *)Bmalloc(j+1); + if (!mptr) + { + kclose(fp); + error++; + initprintf("%s:%ld: error: could not allocate %ld bytes to include `%s'.\n", + line_number,compilefile,j,tempbuf); + return 0; + } + + initprintf("Including: %s (%ld bytes)\n",tempbuf, j); + kread(fp, mptr, j); + kclose(fp); + mptr[j] = 0; + + if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line + textptr++; + origtptr = textptr; + + Bstrcpy(parentcompilefile, compilefile); + Bstrcpy(compilefile, tempbuf); + temp_line_number = line_number; + line_number = 1; + temp_ifelse_check = checking_ifelse; checking_ifelse = 0; - return 0; - case CON_INSERTSPRITEQ: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - return 0; + textptr = mptr; + do done = parsecommand(); + while (!done); - case CON_QSPRINTF: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - for (j = 0;j < 4;j++) - { - if (keyword() == -1) - transvar(); - else break; - } + Bstrcpy(compilefile, parentcompilefile); + total_lines += line_number; + line_number = temp_line_number; + checking_ifelse = temp_ifelse_check; - while (j < 4) - { - *scriptptr = 0; - scriptptr++; - j++; - } - return 0; + textptr = origtptr; - case CON_ESPAWN: - case CON_ESHOOT: - case CON_QSPAWN: - case CON_EQSPAWN: - case CON_STRENGTH: - case CON_SHOOT: - case CON_ADDPHEALTH: - case CON_SPAWN: - case CON_CSTAT: - case CON_COUNT: - case CON_ENDOFGAME: - case CON_SPRITEPAL: - case CON_CACTOR: - case CON_MONEY: - case CON_ADDKILLS: - case CON_DEBUG: - case CON_ADDSTRENGTH: - case CON_CSTATOR: - case CON_MAIL: - case CON_PAPER: - case CON_SLEEPTIME: - case CON_CLIPDIST: - case CON_LOTSOFGLASS: - case CON_SAVE: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_ANGOFF: - case CON_USERQUOTE: - case CON_QUOTE: - case CON_SOUND: - case CON_GLOBALSOUND: - case CON_SOUNDONCE: - case CON_STOPSOUND: - transnum(LABEL_DEFINE); - if (tw == CON_CSTAT) - { - if (*(scriptptr-1) == 32767) - { - ReportError(-1); - initprintf("%s:%ld: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); - *(scriptptr-1) = 32768; - } - else if ((*(scriptptr-1) & 32) && (*(scriptptr-1) & 16)) - { - i = *(scriptptr-1); - *(scriptptr-1) ^= 48; - ReportError(-1); - initprintf("%s:%ld: warning: tried to set cstat %ld, using %ld instead.\n",compilefile,line_number,i,*(scriptptr-1)); - } - } - return 0; + Bfree(mptr); + } + return 0; - case CON_HITRADIUS: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - case CON_ADDAMMO: - case CON_ADDWEAPON: - case CON_SIZETO: - case CON_SIZEAT: - case CON_DEBRIS: - case CON_ADDINVENTORY: - case CON_GUTS: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - break; - - case CON_ELSE: - if (checking_ifelse) - { - checking_ifelse--; - tempscrptr = scriptptr; - scriptptr++; //Leave a spot for the fail location - parsecommand(); - *tempscrptr = (long) scriptptr; - } - else - { - scriptptr--; - error++; - ReportError(-1); - initprintf("%s:%ld: error: found `else' with no `if'.\n",compilefile,line_number); - } - return 0; - - case CON_SETSECTOR: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETSECTOR: + case CON_AI: + if (parsing_actor || parsing_state) { - long lLabelID; - - // syntax getsector[].x - // gets the value of sector[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_AI); + } + else + { + scriptptr--; getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); - lLabelID=getlabelid(sectorlabels,label+(labelcnt<<6)); - - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - *scriptptr++=lLabelID; - - // now at target VAR... - - // get the ID of the DEF - if (tw==CON_GETSECTOR) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_FINDNEARACTOR: - case CON_FINDNEARACTOR3D: - case CON_FINDNEARSPRITE: - case CON_FINDNEARSPRITE3D: - case CON_FINDNEARACTORZ: - case CON_FINDNEARSPRITEZ: - { - // syntax findnearactor - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - - transnum(LABEL_DEFINE); // get - transnum(LABEL_DEFINE); // get maxdist - - switch (tw) - { - case CON_FINDNEARACTORZ: - case CON_FINDNEARSPRITEZ: - transnum(LABEL_DEFINE); - default: - break; - } - - // target var - // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); - break; - } - - case CON_FINDNEARACTORVAR: - case CON_FINDNEARACTOR3DVAR: - case CON_FINDNEARSPRITEVAR: - case CON_FINDNEARSPRITE3DVAR: - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITEZVAR: - { - transnum(LABEL_DEFINE); // get - - // get the ID of the DEF - transvar(); - switch (tw) - { - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITEZVAR: - transvar(); - default: - break; - } - // target var - // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); - break; - } - - case CON_SQRT: - { - // syntax sqrt - // gets the sqrt of invar into outvar - - // get the ID of the DEF - transvar(); - // target var - // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); - break; - } - - case CON_SETWALL: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETWALL: - { - long lLabelID; - - // syntax getwall[].x - // gets the value of wall[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); - - lLabelID=getlabelid(walllabels,label+(labelcnt<<6)); - - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - *scriptptr++=lLabelID; - - // now at target VAR... - - // get the ID of the DEF - if (tw == CON_GETWALL) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_SETPLAYER: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETPLAYER: - { - long lLabelID; - - // syntax getwall[].x - // gets the value of wall[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); - - lLabelID=getlabeloffset(playerlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - - *scriptptr++=playerlabels[lLabelID].lId; - - //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); - if (playerlabels[lLabelID].flags & LABEL_HASPARM2) - { - //printf("Member has PARM2\n"); - // get parm2 - // get the ID of the DEF - transvar(); - } - else - { - //printf("Member does not have Parm2\n"); - } - - // now at target VAR... - - // get the ID of the DEF - if (tw==CON_GETPLAYER) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_SETINPUT: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETINPUT: - { - long lLabelID; - - // syntax getwall[].x - // gets the value of wall[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); - - lLabelID=getlabeloffset(inputlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - - *scriptptr++=inputlabels[lLabelID].lId; - - // now at target VAR... - - // get the ID of the DEF - if (tw==CON_GETINPUT) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_SETUSERDEF: - case CON_GETUSERDEF: - { - long lLabelID; - - // syntax [gs]etuserdef.x - // gets the value of ud.xxx into - - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); - - lLabelID=getlabelid(userdefslabels,label+(labelcnt<<6)); - - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - *scriptptr++=lLabelID; - - // now at target VAR... - - // get the ID of the DEF - if (tw==CON_GETUSERDEF) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_SETACTORVAR: - case CON_SETPLAYERVAR: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETACTORVAR: - case CON_GETPLAYERVAR: - { - // syntax [gs]etactorvar[]. - // gets the value of the per-actor variable varx into VAR - - // now get name of - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of . - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' - - // get the ID of the DEF - getlabel(); - //printf("found label of '%s'\n", label+(labelcnt<<6)); - - // Check to see if it's a keyword for (i=0;i= 0) break; + if (j == 1) + transnum(LABEL_ACTION); + else if (j == 2) + { + if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + { + ReportError(-1); + *(scriptptr-1) = 0; + initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); } - break; + k = 0; + while (keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + k |= *scriptptr; + } + *scriptptr = k; + scriptptr++; + return 0; } } - - *scriptptr++=i; // the ID of the DEF (offset into array...) - - switch (tw) + for (k=j;k<3;k++) { - case CON_GETACTORVAR: - case CON_GETPLAYERVAR: - transvartype(GAMEVAR_FLAG_READONLY); - break; - default: - transvar(); - break; + *scriptptr = 0; + scriptptr++; } - break; } + return 0; - case CON_SETACTOR: + case CON_ACTION: + if (parsing_actor || parsing_state) + { if (!CheckEventSync(current_event)) ReportError(WARNING_EVENTSYNC); - case CON_GETACTOR: + transnum(LABEL_ACTION); + } + else { - long lLabelID; - - // syntax getwall[].x - // gets the value of wall[].xxx into - - // now get name of .xxx - while ((*textptr != '[')) - { - textptr++; - } - if (*textptr == '[') - textptr++; - - // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; - // now get name of .xxx - while (*textptr != '.') - { - if (*textptr == 0xa) - break; - if (!*textptr) - break; - - textptr++; - } - if (*textptr!='.') - { - error++; - ReportError(ERROR_SYNTAXERROR); - return 0; - } - textptr++; - /// now pointing at 'xxx' + scriptptr--; getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + // Check to see it's already defined - lLabelID=getlabeloffset(actorlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); - if (lLabelID == -1) - { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); - return 0; - } - - *scriptptr++=actorlabels[lLabelID].lId; - - //printf("member's flags are: %02Xh\n",actorlabels[lLabelID].flags); - if (actorlabels[lLabelID].flags & LABEL_HASPARM2) - { - //printf("Member has PARM2\n"); - // get parm2 - // get the ID of the DEF - transvar(); - } - else - { - //printf("Member does not have Parm2\n"); - } - - // now at target VAR... - - // get the ID of the DEF - if (tw == CON_GETACTOR) - transvartype(GAMEVAR_FLAG_READONLY); - else - transvar(); - break; - } - - case CON_GETCURRADDRESS: - transvartype(GAMEVAR_FLAG_READONLY); - return 0; - - case CON_ESHOOTVAR: - case CON_ESPAWNVAR: - case CON_QSPAWNVAR: - case CON_EQSPAWNVAR: - case CON_OPERATERESPAWNS: - case CON_OPERATEMASTERSWITCHES: - case CON_CHECKACTIVATORMOTION: - case CON_TIME: - case CON_INITTIMER: - case CON_LOCKPLAYER: - case CON_SHOOTVAR: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_JUMP: - case CON_SOUNDVAR: - case CON_GLOBALSOUNDVAR: - case CON_STOPSOUNDVAR: - case CON_SOUNDONCEVAR: - case CON_ANGOFFVAR: - case CON_CHECKAVAILWEAPON: - case CON_CHECKAVAILINVEN: - case CON_GUNIQHUDID: - case CON_SAVEGAMEVAR: - case CON_READGAMEVAR: - transvar(); - return 0; - - case CON_ENHANCED: - { - // don't store in pCode... - scriptptr--; - //printf("We are enhanced, baby...\n"); - transnum(LABEL_DEFINE); - scriptptr--; - if (*scriptptr > BYTEVERSION_JF) - { - warning++; - initprintf("%s:%ld: warning: need build %ld, found build %ld\n",compilefile,line_number,k,BYTEVERSION_JF); - } - break; - } - - case CON_DYNAMICREMAP: - { - scriptptr--; - initprintf("Dynamic tile remapping enabled.\n"); - dynamicremap = 1; - break; - } - - case CON_RANDVAR: - case CON_ZSHOOT: - case CON_EZSHOOT: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_SETVAR: - case CON_ADDVAR: - case CON_SUBVAR: - case CON_DISPLAYRANDVAR: - case CON_MULVAR: - case CON_DIVVAR: - case CON_MODVAR: - case CON_ANDVAR: - case CON_ORVAR: - case CON_XORVAR: - case CON_SHIFTVARL: - case CON_SHIFTVARR: - - // syntax: [rand|add|set]var - // sets var1 to const1 - // adds const1 to var1 (const1 can be negative...) - //printf("Found [add|set]var at line= %ld\n",line_number); - - // get the ID of the DEF - if (tw != CON_ZSHOOT && tw != CON_EZSHOOT) - transvartype(GAMEVAR_FLAG_READONLY); - else transvar(); - - transnum(LABEL_DEFINE); // the number to check against... - return 0; - case CON_RANDVARVAR: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_SETVARVAR: - case CON_ADDVARVAR: - case CON_SUBVARVAR: - case CON_MULVARVAR: - case CON_DIVVARVAR: - case CON_MODVARVAR: - case CON_ANDVARVAR: - case CON_ORVARVAR: - case CON_XORVARVAR: - case CON_DISPLAYRANDVARVAR: - case CON_SIN: - case CON_COS: - transvartype(GAMEVAR_FLAG_READONLY); - transvar(); - return 0; - - case CON_SMAXAMMO: - case CON_ADDWEAPONVAR: - case CON_ACTIVATEBYSECTOR: - case CON_OPERATESECTORS: - case CON_OPERATEACTIVATORS: - case CON_SSP: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GMAXAMMO: - case CON_DIST: - case CON_LDIST: - case CON_GETINCANGLE: - case CON_GETANGLE: - case CON_MULSCALE: - case CON_SETASPECT: - // get the ID of the DEF - switch (tw) - { - case CON_DIST: - case CON_LDIST: - case CON_GETANGLE: - case CON_GETINCANGLE: - transvartype(GAMEVAR_FLAG_READONLY); - break; - default: - transvar(); - break; - } - - // get the ID of the DEF - if (tw == CON_GMAXAMMO) - transvartype(GAMEVAR_FLAG_READONLY); - else transvar(); - - switch (tw) - { - case CON_DIST: - case CON_LDIST: - case CON_GETANGLE: - case CON_GETINCANGLE: - transvar(); - break; - case CON_MULSCALE: - transmultvars(2); - break; - } - return 0; - - case CON_FLASH: - return 0; - - case CON_DRAGPOINT: - transmultvars(3); - return 0; - - case CON_GETFLORZOFSLOPE: - case CON_GETCEILZOFSLOPE: - transmultvars(3); - transvartype(GAMEVAR_FLAG_READONLY); - return 0; - - case CON_DEFINEPROJECTILE: - { - short y; - signed long z; - - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - scriptptr--; - - transnum(LABEL_DEFINE); - j = *(scriptptr-1); - - if (j > MAXTILES-1) - { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; - } - - transnum(LABEL_DEFINE); - y = *(scriptptr-1); - transnum(LABEL_DEFINE); - z = *(scriptptr-1); - - DefineProjectile(j,y,z); - spriteflags[j] |= SPRITE_FLAG_PROJECTILE; - return 0; - } - - case CON_SPRITEFLAGS: - { - if (parsing_actor == 0 && parsing_state == 0) - { - scriptptr--; - - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - - if (j > MAXTILES-1) + for (i=0;i= 0) break; transnum(LABEL_DEFINE); - scriptptr--; - spriteflags[j] = *scriptptr; - - return 0; } - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - transvar(); - return 0; + for (k=j;k<5;k++) + { + *scriptptr = 0; + scriptptr++; + } } + return 0; - case CON_SPRITESHADOW: - case CON_SPRITENVG: - case CON_SPRITENOSHADE: - case CON_PRECACHE: + case CON_ACTOR: + if (parsing_state || parsing_actor) { - if (parsing_state || parsing_actor) - { - ReportError(ERROR_FOUNDWITHIN); - error++; - } - - scriptptr--; - - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - - if (j > MAXTILES-1) - { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; - } - - switch (tw) - { - case CON_SPRITESHADOW: - spriteflags[*scriptptr] |= SPRITE_FLAG_SHADOW; - break; - case CON_SPRITENVG: - spriteflags[*scriptptr] |= SPRITE_FLAG_NVG; - break; - case CON_SPRITENOSHADE: - spriteflags[*scriptptr] |= SPRITE_FLAG_NOSHADE; - break; - case CON_PRECACHE: - spritecache[*scriptptr][0] = j; - transnum(LABEL_DEFINE); - scriptptr--; - i = *scriptptr; - if (i > MAXTILES-1) - { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; - } - spritecache[j][1] = i; - transnum(LABEL_DEFINE); - scriptptr--; - i = *scriptptr; - spritecache[j][2] = i; - break; - } - return 0; + ReportError(ERROR_FOUNDWITHIN); + error++; } - case CON_IFVARVARG: - case CON_IFVARVARL: - case CON_IFVARVARE: - case CON_IFVARVARN: - case CON_IFVARVARAND: - case CON_WHILEVARVARN: - transmultvars(2); - tempscrptr = scriptptr; - scriptptr++; // Leave a spot for the fail location + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; - j = keyword(); - parsecommand(); + skipcomments(); + j = 0; + while (isaltok(*(textptr+j))) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + transnum(LABEL_DEFINE); + // Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); + scriptptr--; + actorscrptr[*scriptptr] = parsing_actor; - *tempscrptr = (long) scriptptr; - - if (tw != CON_WHILEVARVARN) checking_ifelse++; - return 0; - - case CON_SPGETLOTAG: - case CON_SPGETHITAG: - case CON_SECTGETLOTAG: - case CON_SECTGETHITAG: - case CON_GETTEXTUREFLOOR: - case CON_GETTEXTURECEILING: - // no paramaters... - return 0; - - case CON_STARTTRACK: - // one parameter (track#) - transnum(LABEL_DEFINE); - return 0; - - case CON_IFVARL: - case CON_IFVARG: - case CON_IFVARE: - case CON_IFVARN: - case CON_IFVARAND: - case CON_WHILEVARN: - - // get the ID of the DEF - transvar(); - transnum(LABEL_DEFINE); // the number to check against... - - tempscrptr = scriptptr; - scriptptr++; //Leave a spot for the fail location - - j = keyword(); - parsecommand(); - - *tempscrptr = (long) scriptptr; - - if (tw != CON_WHILEVARN) checking_ifelse++; - return 0; - - case CON_ADDLOGVAR: - - // syntax: addlogvar - - // prints the line number in the log file. - *scriptptr=line_number; - scriptptr++; - - // get the ID of the DEF - transvar(); - return 0; - - case CON_ROTATESPRITE: - if (parsing_event == 0 && parsing_state == 0) + for (j=0;j<4;j++) + { + *(parsing_actor+j) = 0; + if (j == 3) { - ReportError(ERROR_EVENTONLY); - error++; - } - - // syntax: - // long x, long y, long z, short a, short tilenum, signed char shade, char orientation, x1, y1, x2, y2 - // myospal adds char pal - - // get the ID of the DEFs - - transmultvars(12); - break; - - case CON_GETZRANGE: - transmultvars(4); - transmultvarstype(GAMEVAR_FLAG_READONLY,4); - transmultvars(2); - break; - - case CON_HITSCAN: - case CON_CANSEE: - // get the ID of the DEF - transmultvars(tw==CON_CANSEE?8:7); - transmultvarstype(GAMEVAR_FLAG_READONLY,tw==CON_CANSEE?1:6); - if (tw==CON_HITSCAN) transvar(); - break; - - case CON_CANSEESPR: - transmultvars(2); - transvartype(GAMEVAR_FLAG_READONLY); - break; - - case CON_ROTATEPOINT: - case CON_NEARTAG: - transmultvars(5); - transmultvarstype(GAMEVAR_FLAG_READONLY,2); - if (tw == CON_NEARTAG) - { - transmultvarstype(GAMEVAR_FLAG_READONLY,2); - transmultvars(2); - } - break; - - case CON_MOVESPRITE: - case CON_SETSPRITE: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - transmultvars(4); - if (tw == CON_MOVESPRITE) - { - transvar(); - transvartype(GAMEVAR_FLAG_READONLY); - } - break; - - case CON_MINITEXT: - case CON_GAMETEXT: - case CON_DIGITALNUMBER: - if (parsing_event == 0 && parsing_state == 0) - { - ReportError(ERROR_EVENTONLY); - error++; - } - - switch (tw) - { - case CON_GAMETEXT: - case CON_DIGITALNUMBER: - transmultvars(6); - default: - transmultvars(5); - break; - } - break; - - case CON_UPDATESECTOR: - case CON_UPDATESECTORZ: - transmultvars(2); - if (tw==CON_UPDATESECTORZ) - transvar(); - transvartype(GAMEVAR_FLAG_READONLY); - break; - - case CON_MYOS: - case CON_MYOSPAL: - case CON_MYOSX: - case CON_MYOSPALX: - if (parsing_event == 0 && parsing_state == 0) - { - ReportError(ERROR_EVENTONLY); - error++; - } - - // syntax: - // long x, long y, short tilenum, signed char shade, char orientation - // myospal adds char pal - - transmultvars(5); - if (tw==CON_MYOSPAL || tw==CON_MYOSPALX) - { - // Parse: pal - - // get the ID of the DEF - transvar(); - } - break; - - case CON_FINDPLAYER: - case CON_FINDOTHERPLAYER: - case CON_DISPLAYRAND: - - // syntax: displayrand - // gets rand (not game rand) into - - // Get The ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); - break; - - case CON_SWITCH: - //AddLog("Got Switch statement"); - if (checking_switch) - { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); - // AddLog(g_szBuf); - } - checking_switch++; // allow nesting (if other things work) - // Get The ID of the DEF - transvar(); - - tempscrptr= scriptptr; - *scriptptr++=0; // leave spot for end location (for after processing) - *scriptptr++=0; // count of case statements - casescriptptr=scriptptr; // the first case's pointer. - - *scriptptr++=0; // leave spot for 'default' location (null if none) - - j = keyword(); - temptextptr=textptr; - // probably does not allow nesting... - - //AddLog("Counting Case Statements..."); - - j=CountCaseStatements(); - //Bsprintf(g_szBuf,"Done Counting Case Statements: found %d.", j); - //AddLog(g_szBuf); - if (checking_switch>1) - { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); - // AddLog(g_szBuf); - } - if (j<0) - { - return 1; - } - if (tempscrptr) - { - tempscrptr[1]=(long)j; // save count of cases - } - else - { - //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); - //AddLog(g_szBuf); - } - - while (j--) - { - // leave room for statements - *scriptptr++=0; // value check - *scriptptr++=0; // code offset - } - - //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); - //AddLog(g_szBuf); - - casecount=0; - - while (parsecommand() == 0) - { - //Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); - //AddLog(g_szBuf); - } - //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); - //AddLog(g_szBuf); - // done processing switch. clean up. - if (checking_switch!=1) - { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); - // AddLog(g_szBuf); - } - casecount=0; - if (tempscrptr) - { - tempscrptr[0]= (long)scriptptr - (long)&script[0]; // save 'end' location - } - else - { - //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); - //AddLog(g_szBuf); - } - casescriptptr=NULL; - // decremented in endswitch. Don't decrement here... - // checking_switch--; // allow nesting (maybe if other things work) - tempscrptr=NULL; - if (checking_switch) - { - //Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); - //AddLog(g_szBuf); - } - //AddLog("End of Switch statement"); - break; - - case CON_CASE: - //AddLog("Found Case"); -repeatcase: - scriptptr--; // don't save in code - if (checking_switch<1) - { - error++; - ReportError(-1); - initprintf("%s:%ld: error: found `case' statement when not in switch\n",compilefile,line_number); - return 1; - } - casecount++; - //Bsprintf(g_szBuf,"case1: %.12s",textptr); - //AddLog(g_szBuf); - transnum(LABEL_DEFINE); - if (*textptr == ':') - textptr++; - //Bsprintf(g_szBuf,"case2: %.12s",textptr); - //AddLog(g_szBuf); - - j=*(--scriptptr); // get value - //Bsprintf(g_szBuf,"case: Value of case %ld is %ld",(long)casecount,(long)j); - //AddLog(g_szBuf); - if (casescriptptr) - { - //AddLog("Adding value to script"); - casescriptptr[casecount++]=j; // save value - casescriptptr[casecount]=(long)((long*)scriptptr-&script[0]); // save offset - } - // j = keyword(); - //Bsprintf(g_szBuf,"case3: %.12s",textptr); - //AddLog(g_szBuf); - - j = keyword(); - if (j == CON_CASE) - { - //AddLog("Found Repeat Case"); - transword(); // eat 'case' - goto repeatcase; - } - //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); - //AddLog(g_szBuf); - while (parsecommand() == 0) - { - //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); - //AddLog(g_szBuf); - j = keyword(); - if (j == CON_CASE) + j = 0; + while (keyword() == -1) { - //AddLog("Found Repeat Case"); - transword(); // eat 'case' - goto repeatcase; - } - } - //AddLog("End Case"); - return 0; - // break; - case CON_DEFAULT: - scriptptr--; // don't save - if (checking_switch<1) - { - error++; - ReportError(-1); - initprintf("%s:%ld: error: found `default' statement when not in switch\n",compilefile,line_number); - return 1; - } - if (casescriptptr && casescriptptr[0]!=0) - { - // duplicate default statement - error++; - ReportError(-1); - initprintf("%s:%ld: error: multiple `default' statements found in switch\n",compilefile,line_number); - } - if (casescriptptr) - { - casescriptptr[0]=(long)(scriptptr-&script[0]); // save offset - } - //Bsprintf(g_szBuf,"default: '%.22s'",textptr); - //AddLog(g_szBuf); - while (parsecommand() == 0) - { - //Bsprintf(g_szBuf,"defaultParse: '%.22s'",textptr); - //AddLog(g_szBuf); - ; - } - break; - - case CON_ENDSWITCH: - //AddLog("End Switch"); - checking_switch--; - if (checking_switch < 0) - { - error++; - ReportError(-1); - initprintf("%s:%ld: error: found `endswitch' without matching `switch'\n",compilefile,line_number); - } - if (casescriptptr) - { - int i; - - //Bsprintf(g_szBuf,"Default Offset is %ld\n Total of %ld cases",casescriptptr[0],(long)casecount/2); - //AddLog(g_szBuf); - for (i=1;i<=casecount;i++) - { - if (i & 1) - { - //Bsprintf(g_szBuf,"Case Value %d is %ld",i/2+1,casescriptptr[i]); - //AddLog(g_szBuf); - } - else - { - //Bsprintf(g_szBuf,"Offset %d is %ld",i/2+1,casescriptptr[i]); - //AddLog(g_szBuf); - } + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; } + *scriptptr = j; + scriptptr++; + break; } else { - //AddLog("Not saving case value: just counting"); - } - return 1; // end of block - break; - - case CON_CHANGESPRITESTAT: - case CON_CHANGESPRITESECT: - case CON_ZSHOOTVAR: - case CON_EZSHOOTVAR: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETPNAME: - case CON_STARTLEVEL: - case CON_QSTRCAT: - case CON_QSTRCPY: - case CON_QSTRLEN: - transmultvars(2); - return 0; - case CON_SETACTORANGLE: - case CON_SETPLAYERANGLE: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_GETANGLETOTARGET: - case CON_GETACTORANGLE: - case CON_GETPLAYERANGLE: - // Syntax: - - // get the ID of the DEF - transvar(); - return 0; - - case CON_ADDLOG: - // syntax: addlog - - // prints the line number in the log file. - *scriptptr=line_number; - scriptptr++; - return 0; - - case CON_IFPINVENTORY: - case CON_IFRND: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_IFPDISTL: - case CON_IFPDISTG: - case CON_IFWASWEAPON: - case CON_IFACTIONCOUNT: - case CON_IFCOUNT: - case CON_IFACTOR: - case CON_IFSTRENGTH: - case CON_IFSPAWNEDBY: - case CON_IFGAPZL: - case CON_IFFLOORDISTL: - case CON_IFCEILINGDISTL: - // case 74: - case CON_IFPHEALTHL: - case CON_IFSPRITEPAL: - case CON_IFGOTWEAPONCE: - case CON_IFANGDIFFL: - case CON_IFSOUND: - case CON_IFAI: - case CON_IFACTION: - case CON_IFMOVE: - switch (tw) - { - case CON_IFAI: - transnum(LABEL_AI); + if (keyword() >= 0) + { + for (i=4-j; i; i--) *(scriptptr++) = 0; break; - case CON_IFACTION: + } + switch (j) + { + case 0: + transnum(LABEL_DEFINE); + break; + case 1: transnum(LABEL_ACTION); break; - case CON_IFMOVE: + case 2: if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) { ReportError(-1); @@ -4264,637 +2660,2241 @@ repeatcase: initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); } break; - case CON_IFPINVENTORY: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - break; - default: - transnum(LABEL_DEFINE); - break; + } + *(parsing_actor+j) = *(scriptptr-1); } + } + checking_ifelse = 0; + return 0; - case CON_IFONWATER: - case CON_IFINWATER: - case CON_IFACTORNOTSTAYPUT: - case CON_IFCANSEE: - case CON_IFHITWEAPON: - case CON_IFSQUISHED: - case CON_IFDEAD: - case CON_IFCANSHOOTTARGET: - case CON_IFP: - case CON_IFHITSPACE: - case CON_IFOUTSIDE: - case CON_IFMULTIPLAYER: - case CON_IFINSPACE: - case CON_IFBULLETNEAR: - case CON_IFRESPAWN: - case CON_IFINOUTERSPACE: - case CON_IFNOTMOVING: - case CON_IFAWAYFROMWALL: - case CON_IFCANSEETARGET: - case CON_IFNOSOUNDS: - if (tw == CON_IFP) + case CON_ONEVENT: + if (parsing_state || parsing_actor) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_event = scriptptr; + parsing_actor = scriptptr; + + skipcomments(); + j = 0; + while (isaltok(*(textptr+j))) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + labelsonly = 1; + transnum(LABEL_DEFINE); + labelsonly = 0; + scriptptr--; + j= *scriptptr; // type of event + current_event = j; + //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, parsing_event); + //AddLog(g_szBuf); + if (j > MAXGAMEEVENTS-1 || j < 0) + { + initprintf("%s:%ld: error: invalid event ID.\n",compilefile,line_number); + error++; + return 0; + } + + if (apScriptGameEvent[j]) + { + tempscrptr = parsing_event; + parsing_event = parsing_actor = 0; + ReportError(-1); + parsing_event = parsing_actor = tempscrptr; + initprintf("%s:%ld: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); + } + else apScriptGameEvent[j]=parsing_event; + + checking_ifelse = 0; + + return 0; + + case CON_EVENTLOADACTOR: + if (parsing_state || parsing_actor) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; + + skipcomments(); + j = 0; + while (isaltok(*(textptr+j))) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + transnum(LABEL_DEFINE); + scriptptr--; + actorLoadEventScrptr[*scriptptr] = parsing_actor; + + checking_ifelse = 0; + return 0; + + case CON_USERACTOR: + if (parsing_state || parsing_actor) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; + + transnum(LABEL_DEFINE); + scriptptr--; + + skipcomments(); + j = 0; + while (isaltok(*(textptr+j))) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + + j = *scriptptr; + + if (j > 2) + { + ReportError(-1); + initprintf("%s:%ld: warning: invalid useractor type.\n",compilefile,line_number); + j = 0; + } + + transnum(LABEL_DEFINE); + scriptptr--; + actorscrptr[*scriptptr] = parsing_actor; + actortype[*scriptptr] = j; + + for (j=0;j<4;j++) + { + *(parsing_actor+j) = 0; + if (j == 3) { j = 0; - do + while (keyword() == -1) { transnum(LABEL_DEFINE); scriptptr--; j |= *scriptptr; } - while (keyword() == -1); *scriptptr = j; scriptptr++; - } - - tempscrptr = scriptptr; - scriptptr++; //Leave a spot for the fail location - - j = keyword(); - parsecommand(); - - *tempscrptr = (long) scriptptr; - - checking_ifelse++; - return 0; - - case CON_LEFTBRACE: - if (!(parsing_state || parsing_actor || parsing_event)) - { - error++; - ReportError(ERROR_SYNTAXERROR); - } - num_braces++; - do - done = parsecommand(); - while (done == 0); - return 0; - - case CON_RIGHTBRACE: - num_braces--; - if (num_braces < 0) - { - if (checking_switch) - { - ReportError(ERROR_NOENDSWITCH); - } - - ReportError(-1); - initprintf("%s:%ld: error: found more `}' than `{'.\n",compilefile,line_number); - error++; - } - return 1; - - case CON_BETANAME: - scriptptr--; - j = 0; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - textptr++; - return 0; - - case CON_DEFINEVOLUMENAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - if (j < 0 || j > MAXVOLUMES-1) - { - initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; break; } - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - volume_names[j][i] = toupper(*textptr); - textptr++,i++; - if (i >= (signed)sizeof(volume_names[j])-1) - { - initprintf("%s:%ld: error: volume name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - num_volumes = j+1; - volume_names[j][i] = '\0'; - return 0; - - case CON_DEFINEGAMEFUNCNAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - if (j < 0 || j > NUMGAMEFUNCTIONS-1) - { - initprintf("%s:%ld: error: function number exceeds number of game functions.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; - break; - } - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - gamefunctions[j][i] = *textptr; - keydefaults[j*3][i] = *textptr; - textptr++,i++; - if (i >= MAXGAMEFUNCLEN-1) - { - initprintf("%s:%ld: error: function name exceeds limit of %ld characters.\n",compilefile,line_number,MAXGAMEFUNCLEN); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - gamefunctions[j][i] = '\0'; - keydefaults[j*3][i] = '\0'; - return 0; - - case CON_DEFINESKILLNAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - if (j < 0 || j > 4) - { - initprintf("%s:%ld: error: skill number exceeds maximum skill count.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; - break; - } - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - skill_names[j][i] = toupper(*textptr); - textptr++,i++; - if (i >= (signed)sizeof(skill_names[j])-1) - { - initprintf("%s:%ld: error: skill name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - skill_names[j][i] = '\0'; - return 0; - - case CON_DEFINEGAMETYPE: - scriptptr--; //remove opcode from compiled code - transnum(LABEL_DEFINE); //translate number - scriptptr--; //remove it from compiled code - j = *scriptptr; //put it into j - - transnum(LABEL_DEFINE); //translate number - scriptptr--; //remove it from compiled code - gametype_flags[j] = *scriptptr; //put it into the flags - - while (*textptr == ' ' || *textptr == '\t') textptr++; - - if (j < 0 || j > MAXGAMETYPES-1) - { - initprintf("%s:%ld: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; - break; - } - num_gametypes = j+1; - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - gametype_names[j][i] = toupper(*textptr); - textptr++,i++; - if (i >= (signed)sizeof(gametype_names[j])-1) - { - initprintf("%s:%ld: error: gametype name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - gametype_names[j][i] = '\0'; - return 0; - - case CON_DEFINELEVELNAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - transnum(LABEL_DEFINE); - scriptptr--; - k = *scriptptr; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - if (j < 0 || j > MAXVOLUMES-1) - { - initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; - break; - } - if (k < 0 || k > 10) - { - initprintf("%s:%ld: error: level number exceeds maximum number of levels per episode.\n", - line_number,compilefile); - error++; - while (*textptr != 0x0a && *textptr != 0) textptr++; - break; - } - - i = 0; - while (*textptr != ' ' && *textptr != '\t' && *textptr != 0x0a) - { - level_file_names[j*11+k][i] = *textptr; - textptr++,i++; - if (i >= BMAX_PATH) - { - initprintf("%s:%ld: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); - error++; - while (*textptr != ' ' && *textptr != '\t') textptr++; - break; - } - } - level_names[j*11+k][i] = '\0'; - - while (*textptr == ' ' || *textptr == '\t') textptr++; - - partime[j*11+k] = - (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ - (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); - - textptr += 5; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - designertime[j*11+k] = - (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ - (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); - - textptr += 5; - while (*textptr == ' ' || *textptr == '\t') textptr++; - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - level_names[j*11+k][i] = toupper(*textptr); - textptr++,i++; - if (i >= (signed)sizeof(level_names[j*11+k])-1) - { - initprintf("%s:%ld: error: level name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(level_names[j*11+k])-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - level_names[j*11+k][i] = '\0'; - return 0; - - case CON_DEFINEQUOTE: - case CON_REDEFINEQUOTE: - if (tw == CON_DEFINEQUOTE) - scriptptr--; - - transnum(LABEL_DEFINE); - - k = *(scriptptr-1); - - if (k >= MAXQUOTES) - { - initprintf("%s:%ld: error: quote number exceeds limit of %ld.\n",compilefile,line_number,MAXQUOTES); - error++; - } - - if (fta_quotes[k] == NULL) - fta_quotes[k] = Bcalloc(MAXQUOTELEN,sizeof(char)); - if (!fta_quotes[k]) - { - fta_quotes[k] = NULL; - Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN); - gameexit(tempbuf); - } - - if (tw == CON_DEFINEQUOTE) - scriptptr--; - - i = 0; - - while (*textptr == ' ' || *textptr == '\t') - textptr++; - - if (tw == CON_REDEFINEQUOTE) - { - if (redefined_quotes[redefined_quote_count] == NULL) - redefined_quotes[redefined_quote_count] = Bcalloc(MAXQUOTELEN,sizeof(char)); - if (!redefined_quotes[redefined_quote_count]) - { - redefined_quotes[redefined_quote_count] = NULL; - Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN); - gameexit(tempbuf); - } - } - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - if (*textptr == '%' && *(textptr+1) == 's') - { - initprintf("%s:%ld: error: quote text contains string identifier.\n",compilefile,line_number); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - if (tw == CON_DEFINEQUOTE) - *(fta_quotes[k]+i) = *textptr; - else - *(redefined_quotes[redefined_quote_count]+i) = *textptr; - textptr++,i++; - if (i >= MAXQUOTELEN-1) - { - initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,MAXQUOTELEN-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; - break; - } - } - if (tw == CON_DEFINEQUOTE) - *(fta_quotes[k]+i) = '\0'; else { - *(redefined_quotes[redefined_quote_count]+i) = '\0'; - *scriptptr++=redefined_quote_count; - redefined_quote_count++; + if (keyword() >= 0) + { + for (i=4-j; i; i--) *(scriptptr++) = 0; + break; + } + switch (j) + { + case 0: + transnum(LABEL_DEFINE); + break; + case 1: + transnum(LABEL_ACTION); + break; + case 2: + if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + { + ReportError(-1); + *(scriptptr-1) = 0; + initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + } + break; + } + *(parsing_actor+j) = *(scriptptr-1); } - return 0; + } + checking_ifelse = 0; + return 0; - case CON_CHEATKEYS: - scriptptr--; - transnum(LABEL_DEFINE); - cheatkey[0] = *(scriptptr-1); - transnum(LABEL_DEFINE); - cheatkey[1] = *(scriptptr-1); - return 0; + case CON_INSERTSPRITEQ: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + return 0; - case CON_DEFINECHEAT: - scriptptr--; - transnum(LABEL_DEFINE); - k = *(scriptptr-1); + case CON_QSPRINTF: + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + for (j = 0;j < 4;j++) + { + if (keyword() == -1) + transvar(); + else break; + } - if (k > 25) + while (j < 4) + { + *scriptptr = 0; + scriptptr++; + j++; + } + return 0; + + case CON_ESPAWN: + case CON_ESHOOT: + case CON_QSPAWN: + case CON_EQSPAWN: + case CON_STRENGTH: + case CON_SHOOT: + case CON_ADDPHEALTH: + case CON_SPAWN: + case CON_CSTAT: + case CON_COUNT: + case CON_ENDOFGAME: + case CON_SPRITEPAL: + case CON_CACTOR: + case CON_MONEY: + case CON_ADDKILLS: + case CON_DEBUG: + case CON_ADDSTRENGTH: + case CON_CSTATOR: + case CON_MAIL: + case CON_PAPER: + case CON_SLEEPTIME: + case CON_CLIPDIST: + case CON_LOTSOFGLASS: + case CON_SAVE: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_ANGOFF: + case CON_USERQUOTE: + case CON_QUOTE: + case CON_SOUND: + case CON_GLOBALSOUND: + case CON_SOUNDONCE: + case CON_STOPSOUND: + transnum(LABEL_DEFINE); + if (tw == CON_CSTAT) + { + if (*(scriptptr-1) == 32767) { - initprintf("%s:%ld: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); + ReportError(-1); + initprintf("%s:%ld: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); + *(scriptptr-1) = 32768; + } + else if ((*(scriptptr-1) & 32) && (*(scriptptr-1) & 16)) + { + i = *(scriptptr-1); + *(scriptptr-1) ^= 48; + ReportError(-1); + initprintf("%s:%ld: warning: tried to set cstat %ld, using %ld instead.\n",compilefile,line_number,i,*(scriptptr-1)); + } + } + return 0; + + case CON_HITRADIUS: + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + case CON_ADDAMMO: + case CON_ADDWEAPON: + case CON_SIZETO: + case CON_SIZEAT: + case CON_DEBRIS: + case CON_ADDINVENTORY: + case CON_GUTS: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + break; + + case CON_ELSE: + if (checking_ifelse) + { + checking_ifelse--; + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + parsecommand(); + *tempscrptr = (long) scriptptr; + } + else + { + scriptptr--; + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `else' with no `if'.\n",compilefile,line_number); + } + return 0; + + case CON_SETSECTOR: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETSECTOR: + { + long lLabelID; + + // syntax getsector[].x + // gets the value of sector[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(sectorlabels,label+(labelcnt<<6)); + + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETSECTOR) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_FINDNEARACTOR: + case CON_FINDNEARACTOR3D: + case CON_FINDNEARSPRITE: + case CON_FINDNEARSPRITE3D: + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITEZ: + { + // syntax findnearactor + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + + transnum(LABEL_DEFINE); // get + transnum(LABEL_DEFINE); // get maxdist + + switch (tw) + { + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITEZ: + transnum(LABEL_DEFINE); + default: + break; + } + + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_FINDNEARACTORVAR: + case CON_FINDNEARACTOR3DVAR: + case CON_FINDNEARSPRITEVAR: + case CON_FINDNEARSPRITE3DVAR: + case CON_FINDNEARACTORZVAR: + case CON_FINDNEARSPRITEZVAR: + { + transnum(LABEL_DEFINE); // get + + // get the ID of the DEF + transvar(); + switch (tw) + { + case CON_FINDNEARACTORZVAR: + case CON_FINDNEARSPRITEZVAR: + transvar(); + default: + break; + } + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_SQRT: + { + // syntax sqrt + // gets the sqrt of invar into outvar + + // get the ID of the DEF + transvar(); + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_SETWALL: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETWALL: + { + long lLabelID; + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(walllabels,label+(labelcnt<<6)); + + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw == CON_GETWALL) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETPLAYER: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETPLAYER: + { + long lLabelID; + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(playerlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=playerlabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); + if (playerlabels[lLabelID].flags & LABEL_HASPARM2) + { + //printf("Member has PARM2\n"); + // get parm2 + // get the ID of the DEF + transvar(); + } + else + { + //printf("Member does not have Parm2\n"); + } + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETPLAYER) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETINPUT: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETINPUT: + { + long lLabelID; + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(inputlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=inputlabels[lLabelID].lId; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETINPUT) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETUSERDEF: + case CON_GETUSERDEF: + { + long lLabelID; + + // syntax [gs]etuserdef.x + // gets the value of ud.xxx into + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(userdefslabels,label+(labelcnt<<6)); + + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETUSERDEF) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETACTORVAR: + case CON_SETPLAYERVAR: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETACTORVAR: + case CON_GETPLAYERVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + + // now get name of + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of . + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + + // get the ID of the DEF + getlabel(); + //printf("found label of '%s'\n", label+(labelcnt<<6)); + + // Check to see if it's a keyword + for (i=0;i].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(actorlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if (lLabelID == -1) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=actorlabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",actorlabels[lLabelID].flags); + if (actorlabels[lLabelID].flags & LABEL_HASPARM2) + { + //printf("Member has PARM2\n"); + // get parm2 + // get the ID of the DEF + transvar(); + } + else + { + //printf("Member does not have Parm2\n"); + } + + // now at target VAR... + + // get the ID of the DEF + if (tw == CON_GETACTOR) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_GETCURRADDRESS: + transvartype(GAMEVAR_FLAG_READONLY); + return 0; + + case CON_ESHOOTVAR: + case CON_ESPAWNVAR: + case CON_QSPAWNVAR: + case CON_EQSPAWNVAR: + case CON_OPERATERESPAWNS: + case CON_OPERATEMASTERSWITCHES: + case CON_CHECKACTIVATORMOTION: + case CON_TIME: + case CON_INITTIMER: + case CON_LOCKPLAYER: + case CON_SHOOTVAR: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_JUMP: + case CON_SOUNDVAR: + case CON_GLOBALSOUNDVAR: + case CON_STOPSOUNDVAR: + case CON_SOUNDONCEVAR: + case CON_ANGOFFVAR: + case CON_CHECKAVAILWEAPON: + case CON_CHECKAVAILINVEN: + case CON_GUNIQHUDID: + case CON_SAVEGAMEVAR: + case CON_READGAMEVAR: + transvar(); + return 0; + + case CON_ENHANCED: + { + // don't store in pCode... + scriptptr--; + //printf("We are enhanced, baby...\n"); + transnum(LABEL_DEFINE); + scriptptr--; + if (*scriptptr > BYTEVERSION_JF) + { + warning++; + initprintf("%s:%ld: warning: need build %ld, found build %ld\n",compilefile,line_number,k,BYTEVERSION_JF); + } + break; + } + + case CON_DYNAMICREMAP: + { + scriptptr--; + initprintf("Dynamic tile remapping enabled.\n"); + dynamicremap = 1; + break; + } + + case CON_RANDVAR: + case CON_ZSHOOT: + case CON_EZSHOOT: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_SETVAR: + case CON_ADDVAR: + case CON_SUBVAR: + case CON_DISPLAYRANDVAR: + case CON_MULVAR: + case CON_DIVVAR: + case CON_MODVAR: + case CON_ANDVAR: + case CON_ORVAR: + case CON_XORVAR: + case CON_SHIFTVARL: + case CON_SHIFTVARR: + + // syntax: [rand|add|set]var + // sets var1 to const1 + // adds const1 to var1 (const1 can be negative...) + //printf("Found [add|set]var at line= %ld\n",line_number); + + // get the ID of the DEF + if (tw != CON_ZSHOOT && tw != CON_EZSHOOT) + transvartype(GAMEVAR_FLAG_READONLY); + else transvar(); + + transnum(LABEL_DEFINE); // the number to check against... + return 0; + case CON_RANDVARVAR: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_SETVARVAR: + case CON_ADDVARVAR: + case CON_SUBVARVAR: + case CON_MULVARVAR: + case CON_DIVVARVAR: + case CON_MODVARVAR: + case CON_ANDVARVAR: + case CON_ORVARVAR: + case CON_XORVARVAR: + case CON_DISPLAYRANDVARVAR: + case CON_SIN: + case CON_COS: + transvartype(GAMEVAR_FLAG_READONLY); + transvar(); + return 0; + + case CON_SMAXAMMO: + case CON_ADDWEAPONVAR: + case CON_ACTIVATEBYSECTOR: + case CON_OPERATESECTORS: + case CON_OPERATEACTIVATORS: + case CON_SSP: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GMAXAMMO: + case CON_DIST: + case CON_LDIST: + case CON_GETINCANGLE: + case CON_GETANGLE: + case CON_MULSCALE: + case CON_SETASPECT: + // get the ID of the DEF + switch (tw) + { + case CON_DIST: + case CON_LDIST: + case CON_GETANGLE: + case CON_GETINCANGLE: + transvartype(GAMEVAR_FLAG_READONLY); + break; + default: + transvar(); + break; + } + + // get the ID of the DEF + if (tw == CON_GMAXAMMO) + transvartype(GAMEVAR_FLAG_READONLY); + else transvar(); + + switch (tw) + { + case CON_DIST: + case CON_LDIST: + case CON_GETANGLE: + case CON_GETINCANGLE: + transvar(); + break; + case CON_MULSCALE: + transmultvars(2); + break; + } + return 0; + + case CON_FLASH: + return 0; + + case CON_DRAGPOINT: + transmultvars(3); + return 0; + + case CON_GETFLORZOFSLOPE: + case CON_GETCEILZOFSLOPE: + transmultvars(3); + transvartype(GAMEVAR_FLAG_READONLY); + return 0; + + case CON_DEFINEPROJECTILE: + { + short y; + signed long z; + + if (parsing_state || parsing_actor) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + scriptptr--; + + transnum(LABEL_DEFINE); + j = *(scriptptr-1); + + if (j > MAXTILES-1) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + transnum(LABEL_DEFINE); + y = *(scriptptr-1); + transnum(LABEL_DEFINE); + z = *(scriptptr-1); + + DefineProjectile(j,y,z); + spriteflags[j] |= SPRITE_FLAG_PROJECTILE; + return 0; + } + + case CON_SPRITEFLAGS: + { + if (parsing_actor == 0 && parsing_state == 0) + { + scriptptr--; + + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + + if (j > MAXTILES-1) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + transnum(LABEL_DEFINE); + scriptptr--; + spriteflags[j] = *scriptptr; + + return 0; + } + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transvar(); + return 0; + } + + case CON_SPRITESHADOW: + case CON_SPRITENVG: + case CON_SPRITENOSHADE: + case CON_PRECACHE: + { + if (parsing_state || parsing_actor) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + scriptptr--; + + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + + if (j > MAXTILES-1) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + switch (tw) + { + case CON_SPRITESHADOW: + spriteflags[*scriptptr] |= SPRITE_FLAG_SHADOW; + break; + case CON_SPRITENVG: + spriteflags[*scriptptr] |= SPRITE_FLAG_NVG; + break; + case CON_SPRITENOSHADE: + spriteflags[*scriptptr] |= SPRITE_FLAG_NOSHADE; + break; + case CON_PRECACHE: + spritecache[*scriptptr][0] = j; + transnum(LABEL_DEFINE); + scriptptr--; + i = *scriptptr; + if (i > MAXTILES-1) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + spritecache[j][1] = i; + transnum(LABEL_DEFINE); + scriptptr--; + i = *scriptptr; + spritecache[j][2] = i; + break; + } + return 0; + } + + case CON_IFVARVARG: + case CON_IFVARVARL: + case CON_IFVARVARE: + case CON_IFVARVARN: + case CON_IFVARVARAND: + case CON_WHILEVARVARN: + transmultvars(2); + tempscrptr = scriptptr; + scriptptr++; // Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + if (tw != CON_WHILEVARVARN) checking_ifelse++; + return 0; + + case CON_SPGETLOTAG: + case CON_SPGETHITAG: + case CON_SECTGETLOTAG: + case CON_SECTGETHITAG: + case CON_GETTEXTUREFLOOR: + case CON_GETTEXTURECEILING: + // no paramaters... + return 0; + + case CON_STARTTRACK: + // one parameter (track#) + transnum(LABEL_DEFINE); + return 0; + + case CON_IFVARL: + case CON_IFVARG: + case CON_IFVARE: + case CON_IFVARN: + case CON_IFVARAND: + case CON_WHILEVARN: + + // get the ID of the DEF + transvar(); + transnum(LABEL_DEFINE); // the number to check against... + + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + if (tw != CON_WHILEVARN) checking_ifelse++; + return 0; + + case CON_ADDLOGVAR: + + // syntax: addlogvar + + // prints the line number in the log file. + *scriptptr=line_number; + scriptptr++; + + // get the ID of the DEF + transvar(); + return 0; + + case CON_ROTATESPRITE: + if (parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + // syntax: + // long x, long y, long z, short a, short tilenum, signed char shade, char orientation, x1, y1, x2, y2 + // myospal adds char pal + + // get the ID of the DEFs + + transmultvars(12); + break; + + case CON_GETZRANGE: + transmultvars(4); + transmultvarstype(GAMEVAR_FLAG_READONLY,4); + transmultvars(2); + break; + + case CON_HITSCAN: + case CON_CANSEE: + // get the ID of the DEF + transmultvars(tw==CON_CANSEE?8:7); + transmultvarstype(GAMEVAR_FLAG_READONLY,tw==CON_CANSEE?1:6); + if (tw==CON_HITSCAN) transvar(); + break; + + case CON_CANSEESPR: + transmultvars(2); + transvartype(GAMEVAR_FLAG_READONLY); + break; + + case CON_ROTATEPOINT: + case CON_NEARTAG: + transmultvars(5); + transmultvarstype(GAMEVAR_FLAG_READONLY,2); + if (tw == CON_NEARTAG) + { + transmultvarstype(GAMEVAR_FLAG_READONLY,2); + transmultvars(2); + } + break; + + case CON_MOVESPRITE: + case CON_SETSPRITE: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transmultvars(4); + if (tw == CON_MOVESPRITE) + { + transvar(); + transvartype(GAMEVAR_FLAG_READONLY); + } + break; + + case CON_MINITEXT: + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + if (parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + switch (tw) + { + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + transmultvars(6); + default: + transmultvars(5); + break; + } + break; + + case CON_UPDATESECTOR: + case CON_UPDATESECTORZ: + transmultvars(2); + if (tw==CON_UPDATESECTORZ) + transvar(); + transvartype(GAMEVAR_FLAG_READONLY); + break; + + case CON_MYOS: + case CON_MYOSPAL: + case CON_MYOSX: + case CON_MYOSPALX: + if (parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + // syntax: + // long x, long y, short tilenum, signed char shade, char orientation + // myospal adds char pal + + transmultvars(5); + if (tw==CON_MYOSPAL || tw==CON_MYOSPALX) + { + // Parse: pal + + // get the ID of the DEF + transvar(); + } + break; + + case CON_FINDPLAYER: + case CON_FINDOTHERPLAYER: + case CON_DISPLAYRAND: + + // syntax: displayrand + // gets rand (not game rand) into + + // Get The ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + + case CON_SWITCH: + //AddLog("Got Switch statement"); + if (checking_switch) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + checking_switch++; // allow nesting (if other things work) + // Get The ID of the DEF + transvar(); + + tempscrptr= scriptptr; + *scriptptr++=0; // leave spot for end location (for after processing) + *scriptptr++=0; // count of case statements + casescriptptr=scriptptr; // the first case's pointer. + + *scriptptr++=0; // leave spot for 'default' location (null if none) + + j = keyword(); + temptextptr=textptr; + // probably does not allow nesting... + + //AddLog("Counting Case Statements..."); + + j=CountCaseStatements(); + //Bsprintf(g_szBuf,"Done Counting Case Statements: found %d.", j); + //AddLog(g_szBuf); + if (checking_switch>1) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + if (j<0) + { + return 1; + } + if (tempscrptr) + { + tempscrptr[1]=(long)j; // save count of cases + } + else + { + //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + } + + while (j--) + { + // leave room for statements + *scriptptr++=0; // value check + *scriptptr++=0; // code offset + } + + //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); + //AddLog(g_szBuf); + + casecount=0; + + while (parsecommand() == 0) + { + //Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); + //AddLog(g_szBuf); + } + //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); + //AddLog(g_szBuf); + // done processing switch. clean up. + if (checking_switch!=1) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + casecount=0; + if (tempscrptr) + { + tempscrptr[0]= (long)scriptptr - (long)&script[0]; // save 'end' location + } + else + { + //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + } + casescriptptr=NULL; + // decremented in endswitch. Don't decrement here... + // checking_switch--; // allow nesting (maybe if other things work) + tempscrptr=NULL; + if (checking_switch) + { + //Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + //AddLog(g_szBuf); + } + //AddLog("End of Switch statement"); + break; + + case CON_CASE: + //AddLog("Found Case"); +repeatcase: + scriptptr--; // don't save in code + if (checking_switch<1) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `case' statement when not in switch\n",compilefile,line_number); + return 1; + } + casecount++; + //Bsprintf(g_szBuf,"case1: %.12s",textptr); + //AddLog(g_szBuf); + transnum(LABEL_DEFINE); + if (*textptr == ':') + textptr++; + //Bsprintf(g_szBuf,"case2: %.12s",textptr); + //AddLog(g_szBuf); + + j=*(--scriptptr); // get value + //Bsprintf(g_szBuf,"case: Value of case %ld is %ld",(long)casecount,(long)j); + //AddLog(g_szBuf); + if (casescriptptr) + { + //AddLog("Adding value to script"); + casescriptptr[casecount++]=j; // save value + casescriptptr[casecount]=(long)((long*)scriptptr-&script[0]); // save offset + } + // j = keyword(); + //Bsprintf(g_szBuf,"case3: %.12s",textptr); + //AddLog(g_szBuf); + + j = keyword(); + if (j == CON_CASE) + { + //AddLog("Found Repeat Case"); + transword(); // eat 'case' + goto repeatcase; + } + //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); + //AddLog(g_szBuf); + while (parsecommand() == 0) + { + //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); + //AddLog(g_szBuf); + j = keyword(); + if (j == CON_CASE) + { + //AddLog("Found Repeat Case"); + transword(); // eat 'case' + goto repeatcase; + } + } + //AddLog("End Case"); + return 0; + // break; + case CON_DEFAULT: + scriptptr--; // don't save + if (checking_switch<1) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `default' statement when not in switch\n",compilefile,line_number); + return 1; + } + if (casescriptptr && casescriptptr[0]!=0) + { + // duplicate default statement + error++; + ReportError(-1); + initprintf("%s:%ld: error: multiple `default' statements found in switch\n",compilefile,line_number); + } + if (casescriptptr) + { + casescriptptr[0]=(long)(scriptptr-&script[0]); // save offset + } + //Bsprintf(g_szBuf,"default: '%.22s'",textptr); + //AddLog(g_szBuf); + while (parsecommand() == 0) + { + //Bsprintf(g_szBuf,"defaultParse: '%.22s'",textptr); + //AddLog(g_szBuf); + ; + } + break; + + case CON_ENDSWITCH: + //AddLog("End Switch"); + checking_switch--; + if (checking_switch < 0) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `endswitch' without matching `switch'\n",compilefile,line_number); + } + if (casescriptptr) + { + int i; + + //Bsprintf(g_szBuf,"Default Offset is %ld\n Total of %ld cases",casescriptptr[0],(long)casecount/2); + //AddLog(g_szBuf); + for (i=1;i<=casecount;i++) + { + if (i & 1) + { + //Bsprintf(g_szBuf,"Case Value %d is %ld",i/2+1,casescriptptr[i]); + //AddLog(g_szBuf); + } + else + { + //Bsprintf(g_szBuf,"Offset %d is %ld",i/2+1,casescriptptr[i]); + //AddLog(g_szBuf); + } + } + } + else + { + //AddLog("Not saving case value: just counting"); + } + return 1; // end of block + break; + + case CON_CHANGESPRITESTAT: + case CON_CHANGESPRITESECT: + case CON_ZSHOOTVAR: + case CON_EZSHOOTVAR: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETPNAME: + case CON_STARTLEVEL: + case CON_QSTRCAT: + case CON_QSTRCPY: + case CON_QSTRLEN: + transmultvars(2); + return 0; + case CON_SETACTORANGLE: + case CON_SETPLAYERANGLE: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETANGLETOTARGET: + case CON_GETACTORANGLE: + case CON_GETPLAYERANGLE: + // Syntax: + + // get the ID of the DEF + transvar(); + return 0; + + case CON_ADDLOG: + // syntax: addlog + + // prints the line number in the log file. + *scriptptr=line_number; + scriptptr++; + return 0; + + case CON_IFPINVENTORY: + case CON_IFRND: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_IFPDISTL: + case CON_IFPDISTG: + case CON_IFWASWEAPON: + case CON_IFACTIONCOUNT: + case CON_IFCOUNT: + case CON_IFACTOR: + case CON_IFSTRENGTH: + case CON_IFSPAWNEDBY: + case CON_IFGAPZL: + case CON_IFFLOORDISTL: + case CON_IFCEILINGDISTL: + // case 74: + case CON_IFPHEALTHL: + case CON_IFSPRITEPAL: + case CON_IFGOTWEAPONCE: + case CON_IFANGDIFFL: + case CON_IFSOUND: + case CON_IFAI: + case CON_IFACTION: + case CON_IFMOVE: + switch (tw) + { + case CON_IFAI: + transnum(LABEL_AI); + break; + case CON_IFACTION: + transnum(LABEL_ACTION); + break; + case CON_IFMOVE: + if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + { + ReportError(-1); + *(scriptptr-1) = 0; + initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + } + break; + case CON_IFPINVENTORY: + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + break; + default: + transnum(LABEL_DEFINE); + break; + } + + case CON_IFONWATER: + case CON_IFINWATER: + case CON_IFACTORNOTSTAYPUT: + case CON_IFCANSEE: + case CON_IFHITWEAPON: + case CON_IFSQUISHED: + case CON_IFDEAD: + case CON_IFCANSHOOTTARGET: + case CON_IFP: + case CON_IFHITSPACE: + case CON_IFOUTSIDE: + case CON_IFMULTIPLAYER: + case CON_IFINSPACE: + case CON_IFBULLETNEAR: + case CON_IFRESPAWN: + case CON_IFINOUTERSPACE: + case CON_IFNOTMOVING: + case CON_IFAWAYFROMWALL: + case CON_IFCANSEETARGET: + case CON_IFNOSOUNDS: + if (tw == CON_IFP) + { + j = 0; + do + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + while (keyword() == -1); + *scriptptr = j; + scriptptr++; + } + + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + checking_ifelse++; + return 0; + + case CON_LEFTBRACE: + if (!(parsing_state || parsing_actor || parsing_event)) + { + error++; + ReportError(ERROR_SYNTAXERROR); + } + num_braces++; + do + done = parsecommand(); + while (done == 0); + return 0; + + case CON_RIGHTBRACE: + num_braces--; + if (num_braces < 0) + { + if (checking_switch) + { + ReportError(ERROR_NOENDSWITCH); + } + + ReportError(-1); + initprintf("%s:%ld: error: found more `}' than `{'.\n",compilefile,line_number); + error++; + } + return 1; + + case CON_BETANAME: + scriptptr--; + j = 0; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + textptr++; + return 0; + + case CON_DEFINEVOLUMENAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + while (*textptr == ' ' || *textptr == '\t') textptr++; + + if (j < 0 || j > MAXVOLUMES-1) + { + initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } + + i = 0; + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + volume_names[j][i] = toupper(*textptr); + textptr++,i++; + if (i >= (signed)sizeof(volume_names[j])-1) + { + initprintf("%s:%ld: error: volume name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } - scriptptr--; - i = 0; - while (*textptr == ' ' || *textptr == '\t') - textptr++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') - { - cheatquotes[k][i] = *textptr; - textptr++,i++; - if (i >= (signed)sizeof(cheatquotes[k])-1) - { - initprintf("%s:%ld: error: cheat exceeds limit of %ld characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatquotes[k])-1); - error++; - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') textptr++; - break; - } - } - cheatquotes[k][i] = '\0'; - return 0; + } + num_volumes = j+1; + volume_names[j][i] = '\0'; + return 0; - case CON_DEFINESOUND: - scriptptr--; - transnum(LABEL_DEFINE); - k = *(scriptptr-1); - if (k >= NUM_SOUNDS) - { - initprintf("%s:%ld: error: exceeded sound limit of %ld.\n",compilefile,line_number,NUM_SOUNDS); - error++; - } - scriptptr--; - i = 0; - skipcomments(); + case CON_DEFINEGAMEFUNCNAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + while (*textptr == ' ' || *textptr == '\t') textptr++; - while (*textptr != ' ' || *textptr == '\t') - { - sounds[k][i] = *textptr; - textptr++,i++; - if (i >= BMAX_PATH) - { - initprintf("%s:%ld: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); - error++; - skipcomments(); - break; - } - } - sounds[k][i] = '\0'; - - transnum(LABEL_DEFINE); - soundps[k] = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - soundpe[k] = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - soundpr[k] = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - soundm[k] = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - soundvo[k] = *(scriptptr-1); - scriptptr--; - return 0; - - case CON_ENDEVENT: - - if (parsing_event == 0) - { - ReportError(-1); - initprintf("%s:%ld: error: found `endevent' without open `onevent'.\n",compilefile,line_number); - error++; - } - if (num_braces > 0) - { - ReportError(ERROR_OPENBRACKET); - error++; - } - if (num_braces < 0) - { - ReportError(ERROR_CLOSEBRACKET); - error++; - } - parsing_event = 0; - parsing_actor = 0; - current_event = -1; - Bsprintf(parsing_item_name,"(none)"); - return 0; - - case CON_ENDA: - if (parsing_actor == 0) - { - ReportError(-1); - initprintf("%s:%ld: error: found `enda' without open `actor'.\n",compilefile,line_number); - error++; - } - if (num_braces > 0) - { - ReportError(ERROR_OPENBRACKET); - error++; - } - if (num_braces < 0) - { - ReportError(ERROR_CLOSEBRACKET); - error++; - } - parsing_actor = 0; - Bsprintf(parsing_item_name,"(none)"); - return 0; - - case CON_BREAK: - if (checking_switch) - { - //Bsprintf(g_szBuf," * (L%ld) case Break statement.\n",line_number); - //AddLog(g_szBuf); - return 1; - } - return 0; - - case CON_FALL: - case CON_TIP: - // case 21: - case CON_KILLIT: - case CON_RESETACTIONCOUNT: - case CON_PSTOMP: - case CON_RESETPLAYER: - case CON_RESETCOUNT: - case CON_WACKPLAYER: - case CON_OPERATE: - case CON_RESPAWNHITAG: - case CON_GETLASTPAL: - case CON_PKICK: - case CON_MIKESND: - case CON_TOSSWEAPON: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); - case CON_NULLOP: - case CON_STOPALLSOUNDS: - return 0; - case CON_GAMESTARTUP: + if (j < 0 || j > NUMGAMEFUNCTIONS-1) { - long params[30]; + initprintf("%s:%ld: error: function number exceeds number of game functions.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } - scriptptr--; - for (j = 0; j < 30; j++) + i = 0; + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + gamefunctions[j][i] = *textptr; + keydefaults[j*3][i] = *textptr; + textptr++,i++; + if (i >= MAXGAMEFUNCLEN-1) { - transnum(LABEL_DEFINE); - scriptptr--; - params[j] = *scriptptr; - - if (j != 25) continue; - - if (keyword() != -1) - { - initprintf("Duke Nukem 3D v1.3D style CON files detected.\n"); - break; - } - else - { - conversion = 14; - initprintf("Duke Nukem 3D v1.4+ style CON files detected.\n"); - } - - } - - /* - v1.3d v1.5 - DEFAULTVISIBILITY DEFAULTVISIBILITY - GENERICIMPACTDAMAGE GENERICIMPACTDAMAGE - MAXPLAYERHEALTH MAXPLAYERHEALTH - STARTARMORHEALTH STARTARMORHEALTH - RESPAWNACTORTIME RESPAWNACTORTIME - RESPAWNITEMTIME RESPAWNITEMTIME - RUNNINGSPEED RUNNINGSPEED - RPGBLASTRADIUS GRAVITATIONALCONSTANT - PIPEBOMBRADIUS RPGBLASTRADIUS - SHRINKERBLASTRADIUS PIPEBOMBRADIUS - TRIPBOMBBLASTRADIUS SHRINKERBLASTRADIUS - MORTERBLASTRADIUS TRIPBOMBBLASTRADIUS - BOUNCEMINEBLASTRADIUS MORTERBLASTRADIUS - SEENINEBLASTRADIUS BOUNCEMINEBLASTRADIUS - MAXPISTOLAMMO SEENINEBLASTRADIUS - MAXSHOTGUNAMMO MAXPISTOLAMMO - MAXCHAINGUNAMMO MAXSHOTGUNAMMO - MAXRPGAMMO MAXCHAINGUNAMMO - MAXHANDBOMBAMMO MAXRPGAMMO - MAXSHRINKERAMMO MAXHANDBOMBAMMO - MAXDEVISTATORAMMO MAXSHRINKERAMMO - MAXTRIPBOMBAMMO MAXDEVISTATORAMMO - MAXFREEZEAMMO MAXTRIPBOMBAMMO - CAMERASDESTRUCTABLE MAXFREEZEAMMO - NUMFREEZEBOUNCES MAXGROWAMMO - FREEZERHURTOWNER CAMERASDESTRUCTABLE - NUMFREEZEBOUNCES - FREEZERHURTOWNER - QSIZE - TRIPBOMBLASERMODE - */ - - j = 0; - ud.const_visibility = params[j++]; - impact_damage = params[j++]; - max_player_health = params[j++]; - max_armour_amount = params[j++]; - respawnactortime = params[j++]; - respawnitemtime = params[j++]; - dukefriction = params[j++]; - if (conversion == 14) gc = params[j++]; - rpgblastradius = params[j++]; - pipebombblastradius = params[j++]; - shrinkerblastradius = params[j++]; - tripbombblastradius = params[j++]; - morterblastradius = params[j++]; - bouncemineblastradius = params[j++]; - seenineblastradius = params[j++]; - max_ammo_amount[PISTOL_WEAPON] = params[j++]; - max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; - max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; - max_ammo_amount[RPG_WEAPON] = params[j++]; - max_ammo_amount[HANDBOMB_WEAPON] = params[j++]; - max_ammo_amount[SHRINKER_WEAPON] = params[j++]; - max_ammo_amount[DEVISTATOR_WEAPON] = params[j++]; - max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; - max_ammo_amount[FREEZE_WEAPON] = params[j++]; - if (conversion == 14) max_ammo_amount[GROW_WEAPON] = params[j++]; - camerashitable = params[j++]; - numfreezebounces = params[j++]; - freezerhurtowner = params[j++]; - if (conversion == 14) - { - spriteqamount = params[j++]; - if (spriteqamount > 1024) spriteqamount = 1024; - else if (spriteqamount < 0) spriteqamount = 0; - - lasermode = params[j++]; + initprintf("%s:%ld: error: function name exceeds limit of %ld characters.\n",compilefile,line_number,MAXGAMEFUNCLEN); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; } } + gamefunctions[j][i] = '\0'; + keydefaults[j*3][i] = '\0'; return 0; + + case CON_DEFINESKILLNAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + while (*textptr == ' ' || *textptr == '\t') textptr++; + + if (j < 0 || j > 4) + { + initprintf("%s:%ld: error: skill number exceeds maximum skill count.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } + + i = 0; + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + skill_names[j][i] = toupper(*textptr); + textptr++,i++; + if (i >= (signed)sizeof(skill_names[j])-1) + { + initprintf("%s:%ld: error: skill name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + } + skill_names[j][i] = '\0'; + return 0; + + case CON_DEFINEGAMETYPE: + scriptptr--; //remove opcode from compiled code + transnum(LABEL_DEFINE); //translate number + scriptptr--; //remove it from compiled code + j = *scriptptr; //put it into j + + transnum(LABEL_DEFINE); //translate number + scriptptr--; //remove it from compiled code + gametype_flags[j] = *scriptptr; //put it into the flags + + while (*textptr == ' ' || *textptr == '\t') textptr++; + + if (j < 0 || j > MAXGAMETYPES-1) + { + initprintf("%s:%ld: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } + num_gametypes = j+1; + + i = 0; + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + gametype_names[j][i] = toupper(*textptr); + textptr++,i++; + if (i >= (signed)sizeof(gametype_names[j])-1) + { + initprintf("%s:%ld: error: gametype name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + } + gametype_names[j][i] = '\0'; + return 0; + + case CON_DEFINELEVELNAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + transnum(LABEL_DEFINE); + scriptptr--; + k = *scriptptr; + while (*textptr == ' ' || *textptr == '\t') textptr++; + + if (j < 0 || j > MAXVOLUMES-1) + { + initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } + if (k < 0 || k > 10) + { + initprintf("%s:%ld: error: level number exceeds maximum number of levels per episode.\n", + line_number,compilefile); + error++; + while (*textptr != 0x0a && *textptr != 0) textptr++; + break; + } + + i = 0; + while (*textptr != ' ' && *textptr != '\t' && *textptr != 0x0a) + { + level_file_names[j*11+k][i] = *textptr; + textptr++,i++; + if (i >= BMAX_PATH) + { + initprintf("%s:%ld: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + error++; + while (*textptr != ' ' && *textptr != '\t') textptr++; + break; + } + } + level_names[j*11+k][i] = '\0'; + + while (*textptr == ' ' || *textptr == '\t') textptr++; + + partime[j*11+k] = + (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ + (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); + + textptr += 5; + while (*textptr == ' ' || *textptr == '\t') textptr++; + + designertime[j*11+k] = + (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ + (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); + + textptr += 5; + while (*textptr == ' ' || *textptr == '\t') textptr++; + + i = 0; + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + level_names[j*11+k][i] = toupper(*textptr); + textptr++,i++; + if (i >= (signed)sizeof(level_names[j*11+k])-1) + { + initprintf("%s:%ld: error: level name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(level_names[j*11+k])-1); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + } + level_names[j*11+k][i] = '\0'; + return 0; + + case CON_DEFINEQUOTE: + case CON_REDEFINEQUOTE: + if (tw == CON_DEFINEQUOTE) + scriptptr--; + + transnum(LABEL_DEFINE); + + k = *(scriptptr-1); + + if (k >= MAXQUOTES) + { + initprintf("%s:%ld: error: quote number exceeds limit of %ld.\n",compilefile,line_number,MAXQUOTES); + error++; + } + + if (fta_quotes[k] == NULL) + fta_quotes[k] = Bcalloc(MAXQUOTELEN,sizeof(char)); + if (!fta_quotes[k]) + { + fta_quotes[k] = NULL; + Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN); + gameexit(tempbuf); + } + + if (tw == CON_DEFINEQUOTE) + scriptptr--; + + i = 0; + + while (*textptr == ' ' || *textptr == '\t') + textptr++; + + if (tw == CON_REDEFINEQUOTE) + { + if (redefined_quotes[redefined_quote_count] == NULL) + redefined_quotes[redefined_quote_count] = Bcalloc(MAXQUOTELEN,sizeof(char)); + if (!redefined_quotes[redefined_quote_count]) + { + redefined_quotes[redefined_quote_count] = NULL; + Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN); + gameexit(tempbuf); + } + } + + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + { + if (*textptr == '%' && *(textptr+1) == 's') + { + initprintf("%s:%ld: error: quote text contains string identifier.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + if (tw == CON_DEFINEQUOTE) + *(fta_quotes[k]+i) = *textptr; + else + *(redefined_quotes[redefined_quote_count]+i) = *textptr; + textptr++,i++; + if (i >= MAXQUOTELEN-1) + { + initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,MAXQUOTELEN-1); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + } + if (tw == CON_DEFINEQUOTE) + *(fta_quotes[k]+i) = '\0'; + else + { + *(redefined_quotes[redefined_quote_count]+i) = '\0'; + *scriptptr++=redefined_quote_count; + redefined_quote_count++; + } + return 0; + + case CON_CHEATKEYS: + scriptptr--; + transnum(LABEL_DEFINE); + cheatkey[0] = *(scriptptr-1); + transnum(LABEL_DEFINE); + cheatkey[1] = *(scriptptr-1); + return 0; + + case CON_DEFINECHEAT: + scriptptr--; + transnum(LABEL_DEFINE); + k = *(scriptptr-1); + + if (k > 25) + { + initprintf("%s:%ld: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; + break; + } + scriptptr--; + i = 0; + while (*textptr == ' ' || *textptr == '\t') + textptr++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') + { + cheatquotes[k][i] = *textptr; + textptr++,i++; + if (i >= (signed)sizeof(cheatquotes[k])-1) + { + initprintf("%s:%ld: error: cheat exceeds limit of %ld characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatquotes[k])-1); + error++; + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') textptr++; + break; + } + } + cheatquotes[k][i] = '\0'; + return 0; + + case CON_DEFINESOUND: + scriptptr--; + transnum(LABEL_DEFINE); + k = *(scriptptr-1); + if (k >= NUM_SOUNDS) + { + initprintf("%s:%ld: error: exceeded sound limit of %ld.\n",compilefile,line_number,NUM_SOUNDS); + error++; + } + scriptptr--; + i = 0; + skipcomments(); + + while (*textptr != ' ' || *textptr == '\t') + { + sounds[k][i] = *textptr; + textptr++,i++; + if (i >= BMAX_PATH) + { + initprintf("%s:%ld: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + error++; + skipcomments(); + break; + } + } + sounds[k][i] = '\0'; + + transnum(LABEL_DEFINE); + soundps[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundpe[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundpr[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundm[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundvo[k] = *(scriptptr-1); + scriptptr--; + return 0; + + case CON_ENDEVENT: + + if (parsing_event == 0) + { + ReportError(-1); + initprintf("%s:%ld: error: found `endevent' without open `onevent'.\n",compilefile,line_number); + error++; + } + if (num_braces > 0) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if (num_braces < 0) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + parsing_event = 0; + parsing_actor = 0; + current_event = -1; + Bsprintf(parsing_item_name,"(none)"); + return 0; + + case CON_ENDA: + if (parsing_actor == 0) + { + ReportError(-1); + initprintf("%s:%ld: error: found `enda' without open `actor'.\n",compilefile,line_number); + error++; + } + if (num_braces > 0) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if (num_braces < 0) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + parsing_actor = 0; + Bsprintf(parsing_item_name,"(none)"); + return 0; + + case CON_BREAK: + if (checking_switch) + { + //Bsprintf(g_szBuf," * (L%ld) case Break statement.\n",line_number); + //AddLog(g_szBuf); + return 1; + } + return 0; + + case CON_FALL: + case CON_TIP: + // case 21: + case CON_KILLIT: + case CON_RESETACTIONCOUNT: + case CON_PSTOMP: + case CON_RESETPLAYER: + case CON_RESETCOUNT: + case CON_WACKPLAYER: + case CON_OPERATE: + case CON_RESPAWNHITAG: + case CON_GETLASTPAL: + case CON_PKICK: + case CON_MIKESND: + case CON_TOSSWEAPON: + if (!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_NULLOP: + case CON_STOPALLSOUNDS: + return 0; + case CON_GAMESTARTUP: + { + long params[30]; + + scriptptr--; + for (j = 0; j < 30; j++) + { + transnum(LABEL_DEFINE); + scriptptr--; + params[j] = *scriptptr; + + if (j != 25) continue; + + if (keyword() != -1) + { + initprintf("Duke Nukem 3D v1.3D style CON files detected.\n"); + break; + } + else + { + conversion = 14; + initprintf("Duke Nukem 3D v1.4+ style CON files detected.\n"); + } + + } + + /* + v1.3d v1.5 + DEFAULTVISIBILITY DEFAULTVISIBILITY + GENERICIMPACTDAMAGE GENERICIMPACTDAMAGE + MAXPLAYERHEALTH MAXPLAYERHEALTH + STARTARMORHEALTH STARTARMORHEALTH + RESPAWNACTORTIME RESPAWNACTORTIME + RESPAWNITEMTIME RESPAWNITEMTIME + RUNNINGSPEED RUNNINGSPEED + RPGBLASTRADIUS GRAVITATIONALCONSTANT + PIPEBOMBRADIUS RPGBLASTRADIUS + SHRINKERBLASTRADIUS PIPEBOMBRADIUS + TRIPBOMBBLASTRADIUS SHRINKERBLASTRADIUS + MORTERBLASTRADIUS TRIPBOMBBLASTRADIUS + BOUNCEMINEBLASTRADIUS MORTERBLASTRADIUS + SEENINEBLASTRADIUS BOUNCEMINEBLASTRADIUS + MAXPISTOLAMMO SEENINEBLASTRADIUS + MAXSHOTGUNAMMO MAXPISTOLAMMO + MAXCHAINGUNAMMO MAXSHOTGUNAMMO + MAXRPGAMMO MAXCHAINGUNAMMO + MAXHANDBOMBAMMO MAXRPGAMMO + MAXSHRINKERAMMO MAXHANDBOMBAMMO + MAXDEVISTATORAMMO MAXSHRINKERAMMO + MAXTRIPBOMBAMMO MAXDEVISTATORAMMO + MAXFREEZEAMMO MAXTRIPBOMBAMMO + CAMERASDESTRUCTABLE MAXFREEZEAMMO + NUMFREEZEBOUNCES MAXGROWAMMO + FREEZERHURTOWNER CAMERASDESTRUCTABLE + NUMFREEZEBOUNCES + FREEZERHURTOWNER + QSIZE + TRIPBOMBLASERMODE + */ + + j = 0; + ud.const_visibility = params[j++]; + impact_damage = params[j++]; + max_player_health = params[j++]; + max_armour_amount = params[j++]; + respawnactortime = params[j++]; + respawnitemtime = params[j++]; + dukefriction = params[j++]; + if (conversion == 14) gc = params[j++]; + rpgblastradius = params[j++]; + pipebombblastradius = params[j++]; + shrinkerblastradius = params[j++]; + tripbombblastradius = params[j++]; + morterblastradius = params[j++]; + bouncemineblastradius = params[j++]; + seenineblastradius = params[j++]; + max_ammo_amount[PISTOL_WEAPON] = params[j++]; + max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; + max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; + max_ammo_amount[RPG_WEAPON] = params[j++]; + max_ammo_amount[HANDBOMB_WEAPON] = params[j++]; + max_ammo_amount[SHRINKER_WEAPON] = params[j++]; + max_ammo_amount[DEVISTATOR_WEAPON] = params[j++]; + max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; + max_ammo_amount[FREEZE_WEAPON] = params[j++]; + if (conversion == 14) max_ammo_amount[GROW_WEAPON] = params[j++]; + camerashitable = params[j++]; + numfreezebounces = params[j++]; + freezerhurtowner = params[j++]; + if (conversion == 14) + { + spriteqamount = params[j++]; + if (spriteqamount > 1024) spriteqamount = 1024; + else if (spriteqamount < 0) spriteqamount = 0; + + lasermode = params[j++]; + } + } + return 0; } return 0; } @@ -6017,59 +6017,59 @@ void ReportError(int iError) } switch (iError) { - case ERROR_CLOSEBRACKET: - initprintf("%s:%ld: error: found more `}' than `{' before `%s'.\n",compilefile,line_number,tempbuf); - break; - case ERROR_EVENTONLY: - initprintf("%s:%ld: error: command `%s' only valid during events.\n",compilefile,line_number,tempbuf); - break; - case ERROR_EXCEEDSMAXTILES: - initprintf("%s:%ld: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",compilefile,line_number,tempbuf,MAXTILES-1); - break; - case ERROR_EXPECTEDKEYWORD: - initprintf("%s:%ld: error: expected a keyword but found `%s'.\n",compilefile,line_number,tempbuf); - break; - case ERROR_FOUNDWITHIN: - initprintf("%s:%ld: error: found `%s' within %s.\n",compilefile,line_number,tempbuf,parsing_event?"an event":parsing_actor?"an actor":"a state"); - break; - case ERROR_ISAKEYWORD: - initprintf("%s:%ld: error: symbol `%s' is a keyword.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_NOENDSWITCH: - initprintf("%s:%ld: error: did not find `endswitch' before `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_NOTAGAMEDEF: - initprintf("%s:%ld: error: symbol `%s' is not a game definition.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_NOTAGAMEVAR: - initprintf("%s:%ld: error: symbol `%s' is not a game variable.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_OPENBRACKET: - initprintf("%s:%ld: error: found more `{' than `}' before `%s'.\n",compilefile,line_number,tempbuf); - break; - case ERROR_PARAMUNDEFINED: - initprintf("%s:%ld: error: parameter `%s' is undefined.\n",compilefile,line_number,tempbuf); - break; - case ERROR_SYMBOLNOTRECOGNIZED: - initprintf("%s:%ld: error: symbol `%s' is not recognized.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_SYNTAXERROR: - initprintf("%s:%ld: error: syntax error.\n",compilefile,line_number); - break; - case ERROR_VARREADONLY: - initprintf("%s:%ld: error: variable `%s' is read-only.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case ERROR_VARTYPEMISMATCH: - initprintf("%s:%ld: error: variable `%s' is of the wrong type.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case WARNING_DUPLICATEDEFINITION: - initprintf("%s:%ld: warning: duplicate game definition `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); - break; - case WARNING_EVENTSYNC: - initprintf("%s:%ld: warning: found `%s' within a local event.\n",compilefile,line_number,tempbuf); - break; - case WARNING_LABELSONLY: - initprintf("%s:%ld: warning: expected a label, found a constant.\n",compilefile,line_number); - break; + case ERROR_CLOSEBRACKET: + initprintf("%s:%ld: error: found more `}' than `{' before `%s'.\n",compilefile,line_number,tempbuf); + break; + case ERROR_EVENTONLY: + initprintf("%s:%ld: error: command `%s' only valid during events.\n",compilefile,line_number,tempbuf); + break; + case ERROR_EXCEEDSMAXTILES: + initprintf("%s:%ld: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",compilefile,line_number,tempbuf,MAXTILES-1); + break; + case ERROR_EXPECTEDKEYWORD: + initprintf("%s:%ld: error: expected a keyword but found `%s'.\n",compilefile,line_number,tempbuf); + break; + case ERROR_FOUNDWITHIN: + initprintf("%s:%ld: error: found `%s' within %s.\n",compilefile,line_number,tempbuf,parsing_event?"an event":parsing_actor?"an actor":"a state"); + break; + case ERROR_ISAKEYWORD: + initprintf("%s:%ld: error: symbol `%s' is a keyword.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_NOENDSWITCH: + initprintf("%s:%ld: error: did not find `endswitch' before `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_NOTAGAMEDEF: + initprintf("%s:%ld: error: symbol `%s' is not a game definition.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_NOTAGAMEVAR: + initprintf("%s:%ld: error: symbol `%s' is not a game variable.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_OPENBRACKET: + initprintf("%s:%ld: error: found more `{' than `}' before `%s'.\n",compilefile,line_number,tempbuf); + break; + case ERROR_PARAMUNDEFINED: + initprintf("%s:%ld: error: parameter `%s' is undefined.\n",compilefile,line_number,tempbuf); + break; + case ERROR_SYMBOLNOTRECOGNIZED: + initprintf("%s:%ld: error: symbol `%s' is not recognized.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_SYNTAXERROR: + initprintf("%s:%ld: error: syntax error.\n",compilefile,line_number); + break; + case ERROR_VARREADONLY: + initprintf("%s:%ld: error: variable `%s' is read-only.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case ERROR_VARTYPEMISMATCH: + initprintf("%s:%ld: error: variable `%s' is of the wrong type.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case WARNING_DUPLICATEDEFINITION: + initprintf("%s:%ld: warning: duplicate game definition `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + break; + case WARNING_EVENTSYNC: + initprintf("%s:%ld: warning: found `%s' within a local event.\n",compilefile,line_number,tempbuf); + break; + case WARNING_LABELSONLY: + initprintf("%s:%ld: warning: expected a label, found a constant.\n",compilefile,line_number); + break; } } diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 968c742cd..751086d83 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -44,767 +44,767 @@ void DoUserDef(char bSet, long lLabelID, long lVar2, short sActor, short sPlayer switch (lLabelID) { - case USERDEFS_GOD: - if (bSet) - ud.god = lValue; - else - SetGameVarID((int)lVar2, ud.god, sActor, sPlayer); - break; - - case USERDEFS_WARP_ON: - if (bSet) - ud.warp_on = lValue; - else - SetGameVarID((int)lVar2, ud.warp_on, sActor, sPlayer); - break; - - case USERDEFS_CASHMAN: - if (bSet) - ud.cashman = lValue; - else - SetGameVarID((int)lVar2, ud.cashman, sActor, sPlayer); - break; - - case USERDEFS_EOG: - if (bSet) - ud.eog = lValue; - else - SetGameVarID((int)lVar2, ud.eog, sActor, sPlayer); - break; - - case USERDEFS_SHOWALLMAP: - if (bSet) - ud.showallmap = lValue; - else - SetGameVarID((int)lVar2, ud.showallmap, sActor, sPlayer); - break; - - case USERDEFS_SHOW_HELP: - if (bSet) - ud.show_help = lValue; - else - SetGameVarID((int)lVar2, ud.show_help, sActor, sPlayer); - break; - - case USERDEFS_SCROLLMODE: - if (bSet) - ud.scrollmode = lValue; - else - SetGameVarID((int)lVar2, ud.scrollmode, sActor, sPlayer); - break; - - case USERDEFS_CLIPPING: - if (bSet) - ud.clipping = lValue; - else - SetGameVarID((int)lVar2, ud.clipping, sActor, sPlayer); - break; - - // case USERDEFS_USER_NAME: - // if(bSet) - // { - // ud.user_name[MAXPLAYERS][32] = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.user_name[MAXPLAYERS][32], sActor, sPlayer); - // } - // break; - - // case USERDEFS_RIDECULE: - // if(bSet) - // { - // ud.ridecule = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.ridecule, sActor, sPlayer); - // } - // break; - - // case USERDEFS_SAVEGAME: - // if(bSet) - // { - // ud.savegame = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.savegame, sActor, sPlayer); - // } - // break; - - // case USERDEFS_PWLOCKOUT: - // if(bSet) - // { - // ud.pwlockout = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.pwlockout, sActor, sPlayer); - // } - // break; - - // case USERDEFS_RTSNAME: - // if(bSet) - // { - // ud.rtsname = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.rtsname, sActor, sPlayer); - // } - // break; - - case USERDEFS_OVERHEAD_ON: - if (bSet) - ud.overhead_on = lValue; - else - SetGameVarID((int)lVar2, ud.overhead_on, sActor, sPlayer); - break; - - case USERDEFS_LAST_OVERHEAD: - if (bSet) - ud.last_overhead = lValue; - else - SetGameVarID((int)lVar2, ud.last_overhead, sActor, sPlayer); - break; - - case USERDEFS_SHOWWEAPONS: - if (bSet) - ud.showweapons = lValue; - else - SetGameVarID((int)lVar2, ud.showweapons, sActor, sPlayer); - break; - - case USERDEFS_PAUSE_ON: - if (bSet) - ud.pause_on = lValue; - else - SetGameVarID((int)lVar2, ud.pause_on, sActor, sPlayer); - break; - - case USERDEFS_FROM_BONUS: - if (bSet) - ud.from_bonus = lValue; - else - SetGameVarID((int)lVar2, ud.from_bonus, sActor, sPlayer); - break; - - case USERDEFS_CAMERASPRITE: - if (bSet) - ud.camerasprite = lValue; - else - SetGameVarID((int)lVar2, ud.camerasprite, sActor, sPlayer); - break; - - case USERDEFS_LAST_CAMSPRITE: - if (bSet) - ud.last_camsprite = lValue; - else - SetGameVarID((int)lVar2, ud.last_camsprite, sActor, sPlayer); - break; - - case USERDEFS_LAST_LEVEL: - if (bSet) - ud.last_level = lValue; - else - SetGameVarID((int)lVar2, ud.last_level, sActor, sPlayer); - break; - - case USERDEFS_SECRETLEVEL: - if (bSet) - ud.secretlevel = lValue; - else - SetGameVarID((int)lVar2, ud.secretlevel, sActor, sPlayer); - break; - - case USERDEFS_CONST_VISIBILITY: - if (bSet) - ud.const_visibility = lValue; - else - SetGameVarID((int)lVar2, ud.const_visibility, sActor, sPlayer); - break; - - case USERDEFS_UW_FRAMERATE: - if (bSet) - ud.uw_framerate = lValue; - else - SetGameVarID((int)lVar2, ud.uw_framerate, sActor, sPlayer); - break; - - case USERDEFS_CAMERA_TIME: - if (bSet) - ud.camera_time = lValue; - else - SetGameVarID((int)lVar2, ud.camera_time, sActor, sPlayer); - break; - - case USERDEFS_FOLFVEL: - if (bSet) - ud.folfvel = lValue; - else - SetGameVarID((int)lVar2, ud.folfvel, sActor, sPlayer); - break; - - case USERDEFS_FOLAVEL: - if (bSet) - ud.folavel = lValue; - else - SetGameVarID((int)lVar2, ud.folavel, sActor, sPlayer); - break; - - case USERDEFS_FOLX: - if (bSet) - ud.folx = lValue; - else - SetGameVarID((int)lVar2, ud.folx, sActor, sPlayer); - break; - - case USERDEFS_FOLY: - if (bSet) - ud.foly = lValue; - else - SetGameVarID((int)lVar2, ud.foly, sActor, sPlayer); - break; - - case USERDEFS_FOLA: - if (bSet) - ud.fola = lValue; - else - SetGameVarID((int)lVar2, ud.fola, sActor, sPlayer); - break; - - case USERDEFS_RECCNT: - if (bSet) - ud.reccnt = lValue; - else - SetGameVarID((int)lVar2, ud.reccnt, sActor, sPlayer); - break; - - case USERDEFS_ENTERED_NAME: - if (bSet) - ud.entered_name = lValue; - else - SetGameVarID((int)lVar2, ud.entered_name, sActor, sPlayer); - break; - - case USERDEFS_SCREEN_TILTING: - if (bSet) - ud.screen_tilting = lValue; - else - SetGameVarID((int)lVar2, ud.screen_tilting, sActor, sPlayer); - break; - - case USERDEFS_SHADOWS: - if (bSet) - ud.shadows = lValue; - else - SetGameVarID((int)lVar2, ud.shadows, sActor, sPlayer); - break; - - case USERDEFS_FTA_ON: - if (bSet) - ud.fta_on = lValue; - else - SetGameVarID((int)lVar2, ud.fta_on, sActor, sPlayer); - break; - - case USERDEFS_EXECUTIONS: - if (bSet) - ud.executions = lValue; - else - SetGameVarID((int)lVar2, ud.executions, sActor, sPlayer); - break; - - case USERDEFS_AUTO_RUN: - if (bSet) - ud.auto_run = lValue; - else - SetGameVarID((int)lVar2, ud.auto_run, sActor, sPlayer); - break; - - case USERDEFS_COORDS: - if (bSet) - ud.coords = lValue; - else - SetGameVarID((int)lVar2, ud.coords, sActor, sPlayer); - break; - - case USERDEFS_TICKRATE: - if (bSet) - ud.tickrate = lValue; - else - SetGameVarID((int)lVar2, ud.tickrate, sActor, sPlayer); - break; - - case USERDEFS_M_COOP: - if (bSet) - ud.m_coop = lValue; - else - SetGameVarID((int)lVar2, ud.m_coop, sActor, sPlayer); - break; - - case USERDEFS_COOP: - if (bSet) - ud.coop = lValue; - else - SetGameVarID((int)lVar2, ud.coop, sActor, sPlayer); - break; - - case USERDEFS_SCREEN_SIZE: - if (bSet) - ud.screen_size = lValue; - else - SetGameVarID((int)lVar2, ud.screen_size, sActor, sPlayer); - break; - - case USERDEFS_LOCKOUT: - if (bSet) - ud.lockout = lValue; - else - SetGameVarID((int)lVar2, ud.lockout, sActor, sPlayer); - break; - - case USERDEFS_CROSSHAIR: - if (bSet) - ud.crosshair = lValue; - else - SetGameVarID((int)lVar2, ud.crosshair, sActor, sPlayer); - break; - - // case USERDEFS_WCHOICE: - // if(bSet) - // { - // ud.wchoice = lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ud.wchoice, sActor, sPlayer); - // } - // break; - - case USERDEFS_PLAYERAI: - if (bSet) - ud.playerai = lValue; - else - SetGameVarID((int)lVar2, ud.playerai, sActor, sPlayer); - break; - - case USERDEFS_RESPAWN_MONSTERS: - if (bSet) - ud.respawn_monsters = lValue; - else - SetGameVarID((int)lVar2, ud.respawn_monsters, sActor, sPlayer); - break; - - case USERDEFS_RESPAWN_ITEMS: - if (bSet) - ud.respawn_items = lValue; - else - SetGameVarID((int)lVar2, ud.respawn_items, sActor, sPlayer); - break; - - case USERDEFS_RESPAWN_INVENTORY: - if (bSet) - ud.respawn_inventory = lValue; - else - SetGameVarID((int)lVar2, ud.respawn_inventory, sActor, sPlayer); - break; - - case USERDEFS_RECSTAT: - if (bSet) - ud.recstat = lValue; - else - SetGameVarID((int)lVar2, ud.recstat, sActor, sPlayer); - break; - - case USERDEFS_MONSTERS_OFF: - if (bSet) - ud.monsters_off = lValue; - else - SetGameVarID((int)lVar2, ud.monsters_off, sActor, sPlayer); - break; - - case USERDEFS_BRIGHTNESS: - if (bSet) - ud.brightness = lValue; - else - SetGameVarID((int)lVar2, ud.brightness, sActor, sPlayer); - break; - - case USERDEFS_M_RESPAWN_ITEMS: - if (bSet) - ud.m_respawn_items = lValue; - else - SetGameVarID((int)lVar2, ud.m_respawn_items, sActor, sPlayer); - break; - - case USERDEFS_M_RESPAWN_MONSTERS: - if (bSet) - ud.m_respawn_monsters = lValue; - else - SetGameVarID((int)lVar2, ud.m_respawn_monsters, sActor, sPlayer); - break; - - case USERDEFS_M_RESPAWN_INVENTORY: - if (bSet) - ud.m_respawn_inventory = lValue; - else - SetGameVarID((int)lVar2, ud.m_respawn_inventory, sActor, sPlayer); - break; - - case USERDEFS_M_RECSTAT: - if (bSet) - ud.m_recstat = lValue; - else - SetGameVarID((int)lVar2, ud.m_recstat, sActor, sPlayer); - break; - - case USERDEFS_M_MONSTERS_OFF: - if (bSet) - ud.m_monsters_off = lValue; - else - SetGameVarID((int)lVar2, ud.m_monsters_off, sActor, sPlayer); - break; - - case USERDEFS_DETAIL: - if (bSet) - ud.detail = lValue; - else - SetGameVarID((int)lVar2, ud.detail, sActor, sPlayer); - break; - - case USERDEFS_M_FFIRE: - if (bSet) - ud.m_ffire = lValue; - else - SetGameVarID((int)lVar2, ud.m_ffire, sActor, sPlayer); - break; - - case USERDEFS_FFIRE: - if (bSet) - ud.ffire = lValue; - else - SetGameVarID((int)lVar2, ud.ffire, sActor, sPlayer); - break; - - case USERDEFS_M_PLAYER_SKILL: - if (bSet) - ud.m_player_skill = lValue; - else - SetGameVarID((int)lVar2, ud.m_player_skill, sActor, sPlayer); - break; - - case USERDEFS_M_LEVEL_NUMBER: - if (bSet) - ud.m_level_number = lValue; - else - SetGameVarID((int)lVar2, ud.m_level_number, sActor, sPlayer); - break; - - case USERDEFS_M_VOLUME_NUMBER: - if (bSet) - ud.m_volume_number = lValue; - else - SetGameVarID((int)lVar2, ud.m_volume_number, sActor, sPlayer); - break; - - case USERDEFS_MULTIMODE: - if (bSet) - ud.multimode = lValue; - else - SetGameVarID((int)lVar2, ud.multimode, sActor, sPlayer); - break; - - case USERDEFS_PLAYER_SKILL: - if (bSet) - ud.player_skill = lValue; - else - SetGameVarID((int)lVar2, ud.player_skill, sActor, sPlayer); - break; - - case USERDEFS_LEVEL_NUMBER: - if (bSet) - ud.level_number = lValue; - else - SetGameVarID((int)lVar2, ud.level_number, sActor, sPlayer); - break; - - case USERDEFS_VOLUME_NUMBER: - if (bSet) - ud.volume_number = lValue; - else - SetGameVarID((int)lVar2, ud.volume_number, sActor, sPlayer); - break; - - case USERDEFS_M_MARKER: - if (bSet) - ud.m_marker = lValue; - else - SetGameVarID((int)lVar2, ud.m_marker, sActor, sPlayer); - break; - - case USERDEFS_MARKER: - if (bSet) - ud.marker = lValue; - else - SetGameVarID((int)lVar2, ud.marker, sActor, sPlayer); - break; - - case USERDEFS_MOUSEFLIP: - if (bSet) - ud.mouseflip = lValue; - else - SetGameVarID((int)lVar2, ud.mouseflip, sActor, sPlayer); - break; - - case USERDEFS_STATUSBARSCALE: - if (bSet) - ud.statusbarscale = lValue; - else - SetGameVarID((int)lVar2, ud.statusbarscale, sActor, sPlayer); - break; - - case USERDEFS_DRAWWEAPON: - if (bSet) - ud.drawweapon = lValue; - else - SetGameVarID((int)lVar2, ud.drawweapon, sActor, sPlayer); - break; - - case USERDEFS_MOUSEAIMING: - if (bSet) - ud.mouseaiming = lValue; - else - SetGameVarID((int)lVar2, ud.mouseaiming, sActor, sPlayer); - break; - - case USERDEFS_WEAPONSWITCH: - if (bSet) - ud.weaponswitch = lValue; - else - SetGameVarID((int)lVar2, ud.weaponswitch, sActor, sPlayer); - break; - - case USERDEFS_DEMOCAMS: - if (bSet) - ud.democams = lValue; - else - SetGameVarID((int)lVar2, ud.democams, sActor, sPlayer); - break; - - case USERDEFS_COLOR: - if (bSet) - ud.color = lValue; - else - SetGameVarID((int)lVar2, ud.color, sActor, sPlayer); - break; - - case USERDEFS_MSGDISPTIME: - if (bSet) - ud.msgdisptime = lValue; - else - SetGameVarID((int)lVar2, ud.msgdisptime, sActor, sPlayer); - break; - - case USERDEFS_STATUSBARMODE: - if (bSet) - ud.statusbarmode = lValue; - else - SetGameVarID((int)lVar2, ud.statusbarmode, sActor, sPlayer); - break; - - case USERDEFS_M_NOEXITS: - if (bSet) - ud.m_noexits = lValue; - else - SetGameVarID((int)lVar2, ud.m_noexits, sActor, sPlayer); - break; - - case USERDEFS_NOEXITS: - if (bSet) - ud.noexits = lValue; - else - SetGameVarID((int)lVar2, ud.noexits, sActor, sPlayer); - break; - - case USERDEFS_AUTOVOTE: - if (bSet) - ud.autovote = lValue; - else - SetGameVarID((int)lVar2, ud.autovote, sActor, sPlayer); - break; - - case USERDEFS_AUTOMSG: - if (bSet) - ud.automsg = lValue; - else - SetGameVarID((int)lVar2, ud.automsg, sActor, sPlayer); - break; - - case USERDEFS_IDPLAYERS: - if (bSet) - ud.idplayers = lValue; - else - SetGameVarID((int)lVar2, ud.idplayers, sActor, sPlayer); - break; - - case USERDEFS_TEAM: - if (bSet) - ud.team = lValue; - else - SetGameVarID((int)lVar2, ud.team, sActor, sPlayer); - break; - - case USERDEFS_MYX: - if (bSet) - myx = lValue; - else - SetGameVarID((int)lVar2, myx, sActor, sPlayer); - break; - - case USERDEFS_OMYX: - if (bSet) - omyx = lValue; - else - SetGameVarID((int)lVar2, omyx, sActor, sPlayer); - break; - - case USERDEFS_MYXVEL: - if (bSet) - myxvel = lValue; - else - SetGameVarID((int)lVar2, myxvel, sActor, sPlayer); - break; - - case USERDEFS_MYY: - if (bSet) - myy = lValue; - else - SetGameVarID((int)lVar2, myy, sActor, sPlayer); - break; - - case USERDEFS_OMYY: - if (bSet) - omyy = lValue; - else - SetGameVarID((int)lVar2, omyy, sActor, sPlayer); - break; - - case USERDEFS_MYYVEL: - if (bSet) - myyvel = lValue; - else - SetGameVarID((int)lVar2, myyvel, sActor, sPlayer); - break; - - case USERDEFS_MYZ: - if (bSet) - myx = lValue; - else - SetGameVarID((int)lVar2, myx, sActor, sPlayer); - break; - - case USERDEFS_OMYZ: - if (bSet) - omyz = lValue; - else - SetGameVarID((int)lVar2, omyz, sActor, sPlayer); - break; - - case USERDEFS_MYZVEL: - if (bSet) - myzvel = lValue; - else - SetGameVarID((int)lVar2, myzvel, sActor, sPlayer); - break; - - case USERDEFS_MYHORIZ: - if (bSet) - myhoriz = lValue; - else - SetGameVarID((int)lVar2, myhoriz, sActor, sPlayer); - break; - - case USERDEFS_OMYHORIZ: - if (bSet) - omyhoriz = lValue; - else - SetGameVarID((int)lVar2, omyhoriz, sActor, sPlayer); - break; - - case USERDEFS_MYHORIZOFF: - if (bSet) - myhorizoff = lValue; - else - SetGameVarID((int)lVar2, myhorizoff, sActor, sPlayer); - break; - - case USERDEFS_OMYHORIZOFF: - if (bSet) - omyhorizoff = lValue; - else - SetGameVarID((int)lVar2, omyhorizoff, sActor, sPlayer); - break; - - case USERDEFS_MYANG: - if (bSet) - myang = lValue; - else - SetGameVarID((int)lVar2, myang, sActor, sPlayer); - break; - - case USERDEFS_OMYANG: - if (bSet) - omyang = lValue; - else - SetGameVarID((int)lVar2, omyang, sActor, sPlayer); - break; - - case USERDEFS_MYCURSECTNUM: - if (bSet) - mycursectnum = lValue; - else - SetGameVarID((int)lVar2, mycursectnum, sActor, sPlayer); - break; - - case USERDEFS_MYJUMPINGCOUNTER: - if (bSet) - myjumpingcounter = lValue; - else - SetGameVarID((int)lVar2, myjumpingcounter, sActor, sPlayer); - break; - - case USERDEFS_MYJUMPINGTOGGLE: - if (bSet) - myjumpingtoggle = lValue; - else - SetGameVarID((int)lVar2, myjumpingtoggle, sActor, sPlayer); - break; - - case USERDEFS_MYONGROUND: - if (bSet) - myonground = lValue; - else - SetGameVarID((int)lVar2, myonground, sActor, sPlayer); - break; - - case USERDEFS_MYHARDLANDING: - if (bSet) - myhardlanding = lValue; - else - SetGameVarID((int)lVar2, myhardlanding, sActor, sPlayer); - break; - - case USERDEFS_MYRETURNTOCENTER: - if (bSet) - myreturntocenter = lValue; - else - SetGameVarID((int)lVar2, myreturntocenter, sActor, sPlayer); - break; - - default: - break; + case USERDEFS_GOD: + if (bSet) + ud.god = lValue; + else + SetGameVarID((int)lVar2, ud.god, sActor, sPlayer); + break; + + case USERDEFS_WARP_ON: + if (bSet) + ud.warp_on = lValue; + else + SetGameVarID((int)lVar2, ud.warp_on, sActor, sPlayer); + break; + + case USERDEFS_CASHMAN: + if (bSet) + ud.cashman = lValue; + else + SetGameVarID((int)lVar2, ud.cashman, sActor, sPlayer); + break; + + case USERDEFS_EOG: + if (bSet) + ud.eog = lValue; + else + SetGameVarID((int)lVar2, ud.eog, sActor, sPlayer); + break; + + case USERDEFS_SHOWALLMAP: + if (bSet) + ud.showallmap = lValue; + else + SetGameVarID((int)lVar2, ud.showallmap, sActor, sPlayer); + break; + + case USERDEFS_SHOW_HELP: + if (bSet) + ud.show_help = lValue; + else + SetGameVarID((int)lVar2, ud.show_help, sActor, sPlayer); + break; + + case USERDEFS_SCROLLMODE: + if (bSet) + ud.scrollmode = lValue; + else + SetGameVarID((int)lVar2, ud.scrollmode, sActor, sPlayer); + break; + + case USERDEFS_CLIPPING: + if (bSet) + ud.clipping = lValue; + else + SetGameVarID((int)lVar2, ud.clipping, sActor, sPlayer); + break; + + // case USERDEFS_USER_NAME: + // if(bSet) + // { + // ud.user_name[MAXPLAYERS][32] = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.user_name[MAXPLAYERS][32], sActor, sPlayer); + // } + // break; + + // case USERDEFS_RIDECULE: + // if(bSet) + // { + // ud.ridecule = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.ridecule, sActor, sPlayer); + // } + // break; + + // case USERDEFS_SAVEGAME: + // if(bSet) + // { + // ud.savegame = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.savegame, sActor, sPlayer); + // } + // break; + + // case USERDEFS_PWLOCKOUT: + // if(bSet) + // { + // ud.pwlockout = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.pwlockout, sActor, sPlayer); + // } + // break; + + // case USERDEFS_RTSNAME: + // if(bSet) + // { + // ud.rtsname = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.rtsname, sActor, sPlayer); + // } + // break; + + case USERDEFS_OVERHEAD_ON: + if (bSet) + ud.overhead_on = lValue; + else + SetGameVarID((int)lVar2, ud.overhead_on, sActor, sPlayer); + break; + + case USERDEFS_LAST_OVERHEAD: + if (bSet) + ud.last_overhead = lValue; + else + SetGameVarID((int)lVar2, ud.last_overhead, sActor, sPlayer); + break; + + case USERDEFS_SHOWWEAPONS: + if (bSet) + ud.showweapons = lValue; + else + SetGameVarID((int)lVar2, ud.showweapons, sActor, sPlayer); + break; + + case USERDEFS_PAUSE_ON: + if (bSet) + ud.pause_on = lValue; + else + SetGameVarID((int)lVar2, ud.pause_on, sActor, sPlayer); + break; + + case USERDEFS_FROM_BONUS: + if (bSet) + ud.from_bonus = lValue; + else + SetGameVarID((int)lVar2, ud.from_bonus, sActor, sPlayer); + break; + + case USERDEFS_CAMERASPRITE: + if (bSet) + ud.camerasprite = lValue; + else + SetGameVarID((int)lVar2, ud.camerasprite, sActor, sPlayer); + break; + + case USERDEFS_LAST_CAMSPRITE: + if (bSet) + ud.last_camsprite = lValue; + else + SetGameVarID((int)lVar2, ud.last_camsprite, sActor, sPlayer); + break; + + case USERDEFS_LAST_LEVEL: + if (bSet) + ud.last_level = lValue; + else + SetGameVarID((int)lVar2, ud.last_level, sActor, sPlayer); + break; + + case USERDEFS_SECRETLEVEL: + if (bSet) + ud.secretlevel = lValue; + else + SetGameVarID((int)lVar2, ud.secretlevel, sActor, sPlayer); + break; + + case USERDEFS_CONST_VISIBILITY: + if (bSet) + ud.const_visibility = lValue; + else + SetGameVarID((int)lVar2, ud.const_visibility, sActor, sPlayer); + break; + + case USERDEFS_UW_FRAMERATE: + if (bSet) + ud.uw_framerate = lValue; + else + SetGameVarID((int)lVar2, ud.uw_framerate, sActor, sPlayer); + break; + + case USERDEFS_CAMERA_TIME: + if (bSet) + ud.camera_time = lValue; + else + SetGameVarID((int)lVar2, ud.camera_time, sActor, sPlayer); + break; + + case USERDEFS_FOLFVEL: + if (bSet) + ud.folfvel = lValue; + else + SetGameVarID((int)lVar2, ud.folfvel, sActor, sPlayer); + break; + + case USERDEFS_FOLAVEL: + if (bSet) + ud.folavel = lValue; + else + SetGameVarID((int)lVar2, ud.folavel, sActor, sPlayer); + break; + + case USERDEFS_FOLX: + if (bSet) + ud.folx = lValue; + else + SetGameVarID((int)lVar2, ud.folx, sActor, sPlayer); + break; + + case USERDEFS_FOLY: + if (bSet) + ud.foly = lValue; + else + SetGameVarID((int)lVar2, ud.foly, sActor, sPlayer); + break; + + case USERDEFS_FOLA: + if (bSet) + ud.fola = lValue; + else + SetGameVarID((int)lVar2, ud.fola, sActor, sPlayer); + break; + + case USERDEFS_RECCNT: + if (bSet) + ud.reccnt = lValue; + else + SetGameVarID((int)lVar2, ud.reccnt, sActor, sPlayer); + break; + + case USERDEFS_ENTERED_NAME: + if (bSet) + ud.entered_name = lValue; + else + SetGameVarID((int)lVar2, ud.entered_name, sActor, sPlayer); + break; + + case USERDEFS_SCREEN_TILTING: + if (bSet) + ud.screen_tilting = lValue; + else + SetGameVarID((int)lVar2, ud.screen_tilting, sActor, sPlayer); + break; + + case USERDEFS_SHADOWS: + if (bSet) + ud.shadows = lValue; + else + SetGameVarID((int)lVar2, ud.shadows, sActor, sPlayer); + break; + + case USERDEFS_FTA_ON: + if (bSet) + ud.fta_on = lValue; + else + SetGameVarID((int)lVar2, ud.fta_on, sActor, sPlayer); + break; + + case USERDEFS_EXECUTIONS: + if (bSet) + ud.executions = lValue; + else + SetGameVarID((int)lVar2, ud.executions, sActor, sPlayer); + break; + + case USERDEFS_AUTO_RUN: + if (bSet) + ud.auto_run = lValue; + else + SetGameVarID((int)lVar2, ud.auto_run, sActor, sPlayer); + break; + + case USERDEFS_COORDS: + if (bSet) + ud.coords = lValue; + else + SetGameVarID((int)lVar2, ud.coords, sActor, sPlayer); + break; + + case USERDEFS_TICKRATE: + if (bSet) + ud.tickrate = lValue; + else + SetGameVarID((int)lVar2, ud.tickrate, sActor, sPlayer); + break; + + case USERDEFS_M_COOP: + if (bSet) + ud.m_coop = lValue; + else + SetGameVarID((int)lVar2, ud.m_coop, sActor, sPlayer); + break; + + case USERDEFS_COOP: + if (bSet) + ud.coop = lValue; + else + SetGameVarID((int)lVar2, ud.coop, sActor, sPlayer); + break; + + case USERDEFS_SCREEN_SIZE: + if (bSet) + ud.screen_size = lValue; + else + SetGameVarID((int)lVar2, ud.screen_size, sActor, sPlayer); + break; + + case USERDEFS_LOCKOUT: + if (bSet) + ud.lockout = lValue; + else + SetGameVarID((int)lVar2, ud.lockout, sActor, sPlayer); + break; + + case USERDEFS_CROSSHAIR: + if (bSet) + ud.crosshair = lValue; + else + SetGameVarID((int)lVar2, ud.crosshair, sActor, sPlayer); + break; + + // case USERDEFS_WCHOICE: + // if(bSet) + // { + // ud.wchoice = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.wchoice, sActor, sPlayer); + // } + // break; + + case USERDEFS_PLAYERAI: + if (bSet) + ud.playerai = lValue; + else + SetGameVarID((int)lVar2, ud.playerai, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_MONSTERS: + if (bSet) + ud.respawn_monsters = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_ITEMS: + if (bSet) + ud.respawn_items = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_items, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_INVENTORY: + if (bSet) + ud.respawn_inventory = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_RECSTAT: + if (bSet) + ud.recstat = lValue; + else + SetGameVarID((int)lVar2, ud.recstat, sActor, sPlayer); + break; + + case USERDEFS_MONSTERS_OFF: + if (bSet) + ud.monsters_off = lValue; + else + SetGameVarID((int)lVar2, ud.monsters_off, sActor, sPlayer); + break; + + case USERDEFS_BRIGHTNESS: + if (bSet) + ud.brightness = lValue; + else + SetGameVarID((int)lVar2, ud.brightness, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_ITEMS: + if (bSet) + ud.m_respawn_items = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_items, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_MONSTERS: + if (bSet) + ud.m_respawn_monsters = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_INVENTORY: + if (bSet) + ud.m_respawn_inventory = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_M_RECSTAT: + if (bSet) + ud.m_recstat = lValue; + else + SetGameVarID((int)lVar2, ud.m_recstat, sActor, sPlayer); + break; + + case USERDEFS_M_MONSTERS_OFF: + if (bSet) + ud.m_monsters_off = lValue; + else + SetGameVarID((int)lVar2, ud.m_monsters_off, sActor, sPlayer); + break; + + case USERDEFS_DETAIL: + if (bSet) + ud.detail = lValue; + else + SetGameVarID((int)lVar2, ud.detail, sActor, sPlayer); + break; + + case USERDEFS_M_FFIRE: + if (bSet) + ud.m_ffire = lValue; + else + SetGameVarID((int)lVar2, ud.m_ffire, sActor, sPlayer); + break; + + case USERDEFS_FFIRE: + if (bSet) + ud.ffire = lValue; + else + SetGameVarID((int)lVar2, ud.ffire, sActor, sPlayer); + break; + + case USERDEFS_M_PLAYER_SKILL: + if (bSet) + ud.m_player_skill = lValue; + else + SetGameVarID((int)lVar2, ud.m_player_skill, sActor, sPlayer); + break; + + case USERDEFS_M_LEVEL_NUMBER: + if (bSet) + ud.m_level_number = lValue; + else + SetGameVarID((int)lVar2, ud.m_level_number, sActor, sPlayer); + break; + + case USERDEFS_M_VOLUME_NUMBER: + if (bSet) + ud.m_volume_number = lValue; + else + SetGameVarID((int)lVar2, ud.m_volume_number, sActor, sPlayer); + break; + + case USERDEFS_MULTIMODE: + if (bSet) + ud.multimode = lValue; + else + SetGameVarID((int)lVar2, ud.multimode, sActor, sPlayer); + break; + + case USERDEFS_PLAYER_SKILL: + if (bSet) + ud.player_skill = lValue; + else + SetGameVarID((int)lVar2, ud.player_skill, sActor, sPlayer); + break; + + case USERDEFS_LEVEL_NUMBER: + if (bSet) + ud.level_number = lValue; + else + SetGameVarID((int)lVar2, ud.level_number, sActor, sPlayer); + break; + + case USERDEFS_VOLUME_NUMBER: + if (bSet) + ud.volume_number = lValue; + else + SetGameVarID((int)lVar2, ud.volume_number, sActor, sPlayer); + break; + + case USERDEFS_M_MARKER: + if (bSet) + ud.m_marker = lValue; + else + SetGameVarID((int)lVar2, ud.m_marker, sActor, sPlayer); + break; + + case USERDEFS_MARKER: + if (bSet) + ud.marker = lValue; + else + SetGameVarID((int)lVar2, ud.marker, sActor, sPlayer); + break; + + case USERDEFS_MOUSEFLIP: + if (bSet) + ud.mouseflip = lValue; + else + SetGameVarID((int)lVar2, ud.mouseflip, sActor, sPlayer); + break; + + case USERDEFS_STATUSBARSCALE: + if (bSet) + ud.statusbarscale = lValue; + else + SetGameVarID((int)lVar2, ud.statusbarscale, sActor, sPlayer); + break; + + case USERDEFS_DRAWWEAPON: + if (bSet) + ud.drawweapon = lValue; + else + SetGameVarID((int)lVar2, ud.drawweapon, sActor, sPlayer); + break; + + case USERDEFS_MOUSEAIMING: + if (bSet) + ud.mouseaiming = lValue; + else + SetGameVarID((int)lVar2, ud.mouseaiming, sActor, sPlayer); + break; + + case USERDEFS_WEAPONSWITCH: + if (bSet) + ud.weaponswitch = lValue; + else + SetGameVarID((int)lVar2, ud.weaponswitch, sActor, sPlayer); + break; + + case USERDEFS_DEMOCAMS: + if (bSet) + ud.democams = lValue; + else + SetGameVarID((int)lVar2, ud.democams, sActor, sPlayer); + break; + + case USERDEFS_COLOR: + if (bSet) + ud.color = lValue; + else + SetGameVarID((int)lVar2, ud.color, sActor, sPlayer); + break; + + case USERDEFS_MSGDISPTIME: + if (bSet) + ud.msgdisptime = lValue; + else + SetGameVarID((int)lVar2, ud.msgdisptime, sActor, sPlayer); + break; + + case USERDEFS_STATUSBARMODE: + if (bSet) + ud.statusbarmode = lValue; + else + SetGameVarID((int)lVar2, ud.statusbarmode, sActor, sPlayer); + break; + + case USERDEFS_M_NOEXITS: + if (bSet) + ud.m_noexits = lValue; + else + SetGameVarID((int)lVar2, ud.m_noexits, sActor, sPlayer); + break; + + case USERDEFS_NOEXITS: + if (bSet) + ud.noexits = lValue; + else + SetGameVarID((int)lVar2, ud.noexits, sActor, sPlayer); + break; + + case USERDEFS_AUTOVOTE: + if (bSet) + ud.autovote = lValue; + else + SetGameVarID((int)lVar2, ud.autovote, sActor, sPlayer); + break; + + case USERDEFS_AUTOMSG: + if (bSet) + ud.automsg = lValue; + else + SetGameVarID((int)lVar2, ud.automsg, sActor, sPlayer); + break; + + case USERDEFS_IDPLAYERS: + if (bSet) + ud.idplayers = lValue; + else + SetGameVarID((int)lVar2, ud.idplayers, sActor, sPlayer); + break; + + case USERDEFS_TEAM: + if (bSet) + ud.team = lValue; + else + SetGameVarID((int)lVar2, ud.team, sActor, sPlayer); + break; + + case USERDEFS_MYX: + if (bSet) + myx = lValue; + else + SetGameVarID((int)lVar2, myx, sActor, sPlayer); + break; + + case USERDEFS_OMYX: + if (bSet) + omyx = lValue; + else + SetGameVarID((int)lVar2, omyx, sActor, sPlayer); + break; + + case USERDEFS_MYXVEL: + if (bSet) + myxvel = lValue; + else + SetGameVarID((int)lVar2, myxvel, sActor, sPlayer); + break; + + case USERDEFS_MYY: + if (bSet) + myy = lValue; + else + SetGameVarID((int)lVar2, myy, sActor, sPlayer); + break; + + case USERDEFS_OMYY: + if (bSet) + omyy = lValue; + else + SetGameVarID((int)lVar2, omyy, sActor, sPlayer); + break; + + case USERDEFS_MYYVEL: + if (bSet) + myyvel = lValue; + else + SetGameVarID((int)lVar2, myyvel, sActor, sPlayer); + break; + + case USERDEFS_MYZ: + if (bSet) + myx = lValue; + else + SetGameVarID((int)lVar2, myx, sActor, sPlayer); + break; + + case USERDEFS_OMYZ: + if (bSet) + omyz = lValue; + else + SetGameVarID((int)lVar2, omyz, sActor, sPlayer); + break; + + case USERDEFS_MYZVEL: + if (bSet) + myzvel = lValue; + else + SetGameVarID((int)lVar2, myzvel, sActor, sPlayer); + break; + + case USERDEFS_MYHORIZ: + if (bSet) + myhoriz = lValue; + else + SetGameVarID((int)lVar2, myhoriz, sActor, sPlayer); + break; + + case USERDEFS_OMYHORIZ: + if (bSet) + omyhoriz = lValue; + else + SetGameVarID((int)lVar2, omyhoriz, sActor, sPlayer); + break; + + case USERDEFS_MYHORIZOFF: + if (bSet) + myhorizoff = lValue; + else + SetGameVarID((int)lVar2, myhorizoff, sActor, sPlayer); + break; + + case USERDEFS_OMYHORIZOFF: + if (bSet) + omyhorizoff = lValue; + else + SetGameVarID((int)lVar2, omyhorizoff, sActor, sPlayer); + break; + + case USERDEFS_MYANG: + if (bSet) + myang = lValue; + else + SetGameVarID((int)lVar2, myang, sActor, sPlayer); + break; + + case USERDEFS_OMYANG: + if (bSet) + omyang = lValue; + else + SetGameVarID((int)lVar2, omyang, sActor, sPlayer); + break; + + case USERDEFS_MYCURSECTNUM: + if (bSet) + mycursectnum = lValue; + else + SetGameVarID((int)lVar2, mycursectnum, sActor, sPlayer); + break; + + case USERDEFS_MYJUMPINGCOUNTER: + if (bSet) + myjumpingcounter = lValue; + else + SetGameVarID((int)lVar2, myjumpingcounter, sActor, sPlayer); + break; + + case USERDEFS_MYJUMPINGTOGGLE: + if (bSet) + myjumpingtoggle = lValue; + else + SetGameVarID((int)lVar2, myjumpingtoggle, sActor, sPlayer); + break; + + case USERDEFS_MYONGROUND: + if (bSet) + myonground = lValue; + else + SetGameVarID((int)lVar2, myonground, sActor, sPlayer); + break; + + case USERDEFS_MYHARDLANDING: + if (bSet) + myhardlanding = lValue; + else + SetGameVarID((int)lVar2, myhardlanding, sActor, sPlayer); + break; + + case USERDEFS_MYRETURNTOCENTER: + if (bSet) + myreturntocenter = lValue; + else + SetGameVarID((int)lVar2, myreturntocenter, sActor, sPlayer); + break; + + default: + break; } return; } @@ -826,204 +826,204 @@ void DoThisProjectile(char bSet, long lVar1, long lLabelID, long lVar2, short sA switch (lLabelID) { - case PROJ_WORKSLIKE: - if (bSet) - thisprojectile[proj].workslike=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].workslike, sActor, sPlayer); - break; + case PROJ_WORKSLIKE: + if (bSet) + thisprojectile[proj].workslike=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].workslike, sActor, sPlayer); + break; - case PROJ_SPAWNS: - if (bSet) - thisprojectile[proj].spawns=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].spawns, sActor, sPlayer); - break; + case PROJ_SPAWNS: + if (bSet) + thisprojectile[proj].spawns=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].spawns, sActor, sPlayer); + break; - case PROJ_SXREPEAT: - if (bSet) - thisprojectile[proj].sxrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].sxrepeat, sActor, sPlayer); - break; + case PROJ_SXREPEAT: + if (bSet) + thisprojectile[proj].sxrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].sxrepeat, sActor, sPlayer); + break; - case PROJ_SYREPEAT: - if (bSet) - thisprojectile[proj].syrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].syrepeat, sActor, sPlayer); - break; + case PROJ_SYREPEAT: + if (bSet) + thisprojectile[proj].syrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].syrepeat, sActor, sPlayer); + break; - case PROJ_SOUND: - if (bSet) - thisprojectile[proj].sound=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].sound, sActor, sPlayer); - break; + case PROJ_SOUND: + if (bSet) + thisprojectile[proj].sound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].sound, sActor, sPlayer); + break; - case PROJ_ISOUND: - if (bSet) - thisprojectile[proj].isound=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].isound, sActor, sPlayer); - break; + case PROJ_ISOUND: + if (bSet) + thisprojectile[proj].isound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].isound, sActor, sPlayer); + break; - case PROJ_VEL: - if (bSet) - thisprojectile[proj].vel=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].vel, sActor, sPlayer); - break; + case PROJ_VEL: + if (bSet) + thisprojectile[proj].vel=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].vel, sActor, sPlayer); + break; - case PROJ_EXTRA: - if (bSet) - thisprojectile[proj].extra=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].extra, sActor, sPlayer); - break; + case PROJ_EXTRA: + if (bSet) + thisprojectile[proj].extra=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].extra, sActor, sPlayer); + break; - case PROJ_DECAL: - if (bSet) - thisprojectile[proj].decal=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].decal, sActor, sPlayer); - break; + case PROJ_DECAL: + if (bSet) + thisprojectile[proj].decal=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].decal, sActor, sPlayer); + break; - case PROJ_TRAIL: - if (bSet) - thisprojectile[proj].trail=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].trail, sActor, sPlayer); - break; + case PROJ_TRAIL: + if (bSet) + thisprojectile[proj].trail=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].trail, sActor, sPlayer); + break; - case PROJ_TXREPEAT: - if (bSet) - thisprojectile[proj].txrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].txrepeat, sActor, sPlayer); - break; + case PROJ_TXREPEAT: + if (bSet) + thisprojectile[proj].txrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].txrepeat, sActor, sPlayer); + break; - case PROJ_TYREPEAT: - if (bSet) - thisprojectile[proj].tyrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].tyrepeat, sActor, sPlayer); - break; + case PROJ_TYREPEAT: + if (bSet) + thisprojectile[proj].tyrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].tyrepeat, sActor, sPlayer); + break; - case PROJ_TOFFSET: - if (bSet) - thisprojectile[proj].toffset=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].toffset, sActor, sPlayer); - break; + case PROJ_TOFFSET: + if (bSet) + thisprojectile[proj].toffset=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].toffset, sActor, sPlayer); + break; - case PROJ_TNUM: - if (bSet) - thisprojectile[proj].tnum=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].tnum, sActor, sPlayer); - break; + case PROJ_TNUM: + if (bSet) + thisprojectile[proj].tnum=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].tnum, sActor, sPlayer); + break; - case PROJ_DROP: - if (bSet) - thisprojectile[proj].drop=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].drop, sActor, sPlayer); - break; + case PROJ_DROP: + if (bSet) + thisprojectile[proj].drop=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].drop, sActor, sPlayer); + break; - case PROJ_CSTAT: - if (bSet) - thisprojectile[proj].cstat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].cstat, sActor, sPlayer); - break; + case PROJ_CSTAT: + if (bSet) + thisprojectile[proj].cstat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].cstat, sActor, sPlayer); + break; - case PROJ_CLIPDIST: - if (bSet) - thisprojectile[proj].clipdist=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].clipdist, sActor, sPlayer); - break; + case PROJ_CLIPDIST: + if (bSet) + thisprojectile[proj].clipdist=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].clipdist, sActor, sPlayer); + break; - case PROJ_SHADE: - if (bSet) - thisprojectile[proj].shade=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].shade, sActor, sPlayer); - break; + case PROJ_SHADE: + if (bSet) + thisprojectile[proj].shade=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].shade, sActor, sPlayer); + break; - case PROJ_XREPEAT: - if (bSet) - thisprojectile[proj].xrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].xrepeat, sActor, sPlayer); - break; + case PROJ_XREPEAT: + if (bSet) + thisprojectile[proj].xrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].xrepeat, sActor, sPlayer); + break; - case PROJ_YREPEAT: - if (bSet) - thisprojectile[proj].yrepeat=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].yrepeat, sActor, sPlayer); - break; + case PROJ_YREPEAT: + if (bSet) + thisprojectile[proj].yrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].yrepeat, sActor, sPlayer); + break; - case PROJ_PAL: - if (bSet) - thisprojectile[proj].pal=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].pal, sActor, sPlayer); - break; + case PROJ_PAL: + if (bSet) + thisprojectile[proj].pal=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].pal, sActor, sPlayer); + break; - case PROJ_EXTRA_RAND: - if (bSet) - thisprojectile[proj].extra_rand=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].extra_rand, sActor, sPlayer); - break; + case PROJ_EXTRA_RAND: + if (bSet) + thisprojectile[proj].extra_rand=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].extra_rand, sActor, sPlayer); + break; - case PROJ_HITRADIUS: - if (bSet) - thisprojectile[proj].hitradius=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].hitradius, sActor, sPlayer); - break; + case PROJ_HITRADIUS: + if (bSet) + thisprojectile[proj].hitradius=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].hitradius, sActor, sPlayer); + break; - case PROJ_VEL_MULT: - if (bSet) - thisprojectile[proj].velmult=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].velmult, sActor, sPlayer); - break; + case PROJ_VEL_MULT: + if (bSet) + thisprojectile[proj].velmult=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].velmult, sActor, sPlayer); + break; - case PROJ_OFFSET: - if (bSet) - thisprojectile[proj].offset=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].offset, sActor, sPlayer); - break; + case PROJ_OFFSET: + if (bSet) + thisprojectile[proj].offset=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].offset, sActor, sPlayer); + break; - case PROJ_BOUNCES: - if (bSet) - thisprojectile[proj].bounces=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].bounces, sActor, sPlayer); - break; + case PROJ_BOUNCES: + if (bSet) + thisprojectile[proj].bounces=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].bounces, sActor, sPlayer); + break; - case PROJ_BSOUND: - if (bSet) - thisprojectile[proj].bsound=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].bsound, sActor, sPlayer); - break; + case PROJ_BSOUND: + if (bSet) + thisprojectile[proj].bsound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].bsound, sActor, sPlayer); + break; - case PROJ_RANGE: - if (bSet) - thisprojectile[proj].range=lValue; - else - SetGameVarID((int)lVar2, thisprojectile[proj].range, sActor, sPlayer); - break; + case PROJ_RANGE: + if (bSet) + thisprojectile[proj].range=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].range, sActor, sPlayer); + break; - default: - break; + default: + break; } return; } @@ -1047,1011 +1047,1011 @@ void DoPlayer(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, sh switch (lLabelID) { - case PLAYER_ZOOM: - if (bSet) - ps[iPlayer].zoom=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].zoom, sActor, sPlayer); - break; - - case PLAYER_EXITX: - if (bSet) - ps[iPlayer].exitx=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].exitx, sActor, sPlayer); - break; - - case PLAYER_EXITY: - if (bSet) - ps[iPlayer].exity=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].exity, sActor, sPlayer); - break; - - case PLAYER_LOOGIEX: - lTemp=lParm2; - if (bSet) - ps[iPlayer].loogiex[lTemp]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].loogiex[lTemp], sActor, sPlayer); - break; - - case PLAYER_LOOGIEY: - lTemp=lParm2; - if (bSet) - ps[iPlayer].loogiey[lTemp]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].loogiey[lTemp], sActor, sPlayer); - break; - - case PLAYER_NUMLOOGS: - if (bSet) - ps[iPlayer].numloogs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].numloogs, sActor, sPlayer); - break; - - case PLAYER_LOOGCNT: - if (bSet) - ps[iPlayer].loogcnt=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); - break; - - case PLAYER_POSX: - if (bSet) - ps[iPlayer].posx=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].posx, sActor, sPlayer); - break; - - case PLAYER_POSY: - if (bSet) - ps[iPlayer].posy=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].posy, sActor, sPlayer); - break; - - case PLAYER_POSZ: - if (bSet) - ps[iPlayer].posz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].posz, sActor, sPlayer); - break; - - case PLAYER_HORIZ: - if (bSet) - ps[iPlayer].horiz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].horiz, sActor, sPlayer); - break; - - case PLAYER_OHORIZ: - if (bSet) - ps[iPlayer].ohoriz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].ohoriz, sActor, sPlayer); - break; - - case PLAYER_OHORIZOFF: - if (bSet) - ps[iPlayer].ohorizoff=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].ohorizoff, sActor, sPlayer); - break; - - case PLAYER_INVDISPTIME: - if (bSet) - ps[iPlayer].invdisptime=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); - break; - - case PLAYER_BOBPOSX: - if (bSet) - ps[iPlayer].bobposx=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].bobposx, sActor, sPlayer); - break; - - case PLAYER_BOBPOSY: - if (bSet) - ps[iPlayer].bobposy=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].bobposy, sActor, sPlayer); - break; - - case PLAYER_OPOSX: - if (bSet) - ps[iPlayer].oposx=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].oposx, sActor, sPlayer); - break; - - case PLAYER_OPOSY: - if (bSet) - ps[iPlayer].oposy=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].oposy, sActor, sPlayer); - break; - - case PLAYER_OPOSZ: - if (bSet) - ps[iPlayer].oposz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].oposz, sActor, sPlayer); - break; - - case PLAYER_PYOFF: - if (bSet) - ps[iPlayer].pyoff=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].pyoff, sActor, sPlayer); - break; - - case PLAYER_OPYOFF: - if (bSet) - ps[iPlayer].opyoff=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].opyoff, sActor, sPlayer); - break; - - case PLAYER_POSXV: - if (bSet) - ps[iPlayer].posxv=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].posxv, sActor, sPlayer); - break; - - case PLAYER_POSYV: - if (bSet) - ps[iPlayer].posyv=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].posyv, sActor, sPlayer); - break; - - case PLAYER_POSZV: - if (bSet) - ps[iPlayer].poszv=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].poszv, sActor, sPlayer); - break; - - case PLAYER_LAST_PISSED_TIME: - if (bSet) - ps[iPlayer].last_pissed_time=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); - break; - - case PLAYER_TRUEFZ: - if (bSet) - ps[iPlayer].truefz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].truefz, sActor, sPlayer); - break; - - case PLAYER_TRUECZ: - if (bSet) - ps[iPlayer].truecz=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].truecz, sActor, sPlayer); - break; - - case PLAYER_PLAYER_PAR: - if (bSet) - ps[iPlayer].player_par=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].player_par, sActor, sPlayer); - break; - - case PLAYER_VISIBILITY: - if (bSet) - ps[iPlayer].visibility=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].visibility, sActor, sPlayer); - break; - - case PLAYER_BOBCOUNTER: - if (bSet) - ps[iPlayer].bobcounter=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); - break; - - case PLAYER_WEAPON_SWAY: - if (bSet) - ps[iPlayer].weapon_sway=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); - break; - - case PLAYER_PALS_TIME: - if (bSet) - ps[iPlayer].pals_time=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].pals_time, sActor, sPlayer); - break; - - case PLAYER_RANDOMFLAMEX: - if (bSet) - ps[iPlayer].randomflamex=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); - break; - - case PLAYER_CRACK_TIME: - if (bSet) - ps[iPlayer].crack_time=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].crack_time, sActor, sPlayer); - break; - - case PLAYER_AIM_MODE: - if (bSet) - ps[iPlayer].aim_mode=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); - break; - - case PLAYER_ANG: - if (bSet) - ps[iPlayer].ang=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].ang, sActor, sPlayer); - break; - - case PLAYER_OANG: - if (bSet) - ps[iPlayer].oang=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].oang, sActor, sPlayer); - break; - - case PLAYER_ANGVEL: - if (bSet) - ps[iPlayer].angvel=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].angvel, sActor, sPlayer); - break; - - case PLAYER_CURSECTNUM: - if (bSet) - ps[iPlayer].cursectnum=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); - break; - - case PLAYER_LOOK_ANG: - if (bSet) - ps[iPlayer].look_ang=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].look_ang, sActor, sPlayer); - break; - - case PLAYER_LAST_EXTRA: - if (bSet) - ps[iPlayer].last_extra=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].last_extra, sActor, sPlayer); - break; - - case PLAYER_SUBWEAPON: - if (bSet) - ps[iPlayer].subweapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].subweapon, sActor, sPlayer); - break; - - case PLAYER_AMMO_AMOUNT: - lTemp=lParm2; - if (bSet) - ps[iPlayer].ammo_amount[lTemp]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); - break; - - case PLAYER_WACKEDBYACTOR: - if (bSet) - ps[iPlayer].wackedbyactor=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].wackedbyactor, sActor, sPlayer); - break; - - case PLAYER_FRAG: - if (bSet) - ps[iPlayer].frag=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].frag, sActor, sPlayer); - break; - - case PLAYER_FRAGGEDSELF: - if (bSet) - ps[iPlayer].fraggedself=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); - break; - - case PLAYER_CURR_WEAPON: - if (bSet) - ps[iPlayer].curr_weapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); - break; - - case PLAYER_LAST_WEAPON: - if (bSet) - ps[iPlayer].last_weapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); - break; - - case PLAYER_TIPINCS: - if (bSet) - ps[iPlayer].tipincs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); - break; - - case PLAYER_HORIZOFF: - if (bSet) - ps[iPlayer].horizoff=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].horizoff, sActor, sPlayer); - break; - - case PLAYER_WANTWEAPONFIRE: - if (bSet) - ps[iPlayer].wantweaponfire=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); - break; - - case PLAYER_HOLODUKE_AMOUNT: - if (bSet) - ps[iPlayer].holoduke_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); - break; - - case PLAYER_NEWOWNER: - if (bSet) - ps[iPlayer].newowner=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].newowner, sActor, sPlayer); - break; - - case PLAYER_HURT_DELAY: - if (bSet) - ps[iPlayer].hurt_delay=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); - break; - - case PLAYER_HBOMB_HOLD_DELAY: - if (bSet) - ps[iPlayer].hbomb_hold_delay=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); - break; - - case PLAYER_JUMPING_COUNTER: - if (bSet) - ps[iPlayer].jumping_counter=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); - break; - - case PLAYER_AIRLEFT: - if (bSet) - ps[iPlayer].airleft=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].airleft, sActor, sPlayer); - break; - - case PLAYER_KNEE_INCS: - if (bSet) - ps[iPlayer].knee_incs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); - break; - - case PLAYER_ACCESS_INCS: - if (bSet) - ps[iPlayer].access_incs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].access_incs, sActor, sPlayer); - break; - - case PLAYER_FTA: - if (bSet) - ps[iPlayer].fta=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].fta, sActor, sPlayer); - break; - - case PLAYER_FTQ: - if (bSet) - ps[iPlayer].ftq=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].ftq, sActor, sPlayer); - break; - - case PLAYER_ACCESS_WALLNUM: - if (bSet) - ps[iPlayer].access_wallnum=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); - break; - - case PLAYER_ACCESS_SPRITENUM: - if (bSet) - ps[iPlayer].access_spritenum=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].access_spritenum, sActor, sPlayer); - break; - - case PLAYER_KICKBACK_PIC: - if (bSet) - ps[iPlayer].kickback_pic=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); - break; - - case PLAYER_GOT_ACCESS: - if (bSet) - ps[iPlayer].got_access=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].got_access, sActor, sPlayer); - break; - - case PLAYER_WEAPON_ANG: - if (bSet) - ps[iPlayer].weapon_ang=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); - break; - - case PLAYER_FIRSTAID_AMOUNT: - if (bSet) - ps[iPlayer].firstaid_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); - break; - - case PLAYER_SOMETHINGONPLAYER: - if (bSet) - ps[iPlayer].somethingonplayer=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].somethingonplayer, sActor, sPlayer); - break; - - case PLAYER_ON_CRANE: - if (bSet) - ps[iPlayer].on_crane=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].on_crane, sActor, sPlayer); - break; - - case PLAYER_I: - if (bSet) - ps[iPlayer].i=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].i, sActor, sPlayer); - break; - - case PLAYER_ONE_PARALLAX_SECTNUM: - if (bSet) - ps[iPlayer].one_parallax_sectnum=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); - break; - - case PLAYER_OVER_SHOULDER_ON: - if (bSet) - ps[iPlayer].over_shoulder_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); - break; - - case PLAYER_RANDOM_CLUB_FRAME: - if (bSet) - ps[iPlayer].random_club_frame=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); - break; - - case PLAYER_FIST_INCS: - if (bSet) - ps[iPlayer].fist_incs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); - break; - - case PLAYER_ONE_EIGHTY_COUNT: - if (bSet) - ps[iPlayer].one_eighty_count=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].one_eighty_count, sActor, sPlayer); - break; - - case PLAYER_CHEAT_PHASE: - if (bSet) - ps[iPlayer].cheat_phase=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); - break; - - case PLAYER_DUMMYPLAYERSPRITE: - if (bSet) - ps[iPlayer].dummyplayersprite=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].dummyplayersprite, sActor, sPlayer); - break; - - case PLAYER_EXTRA_EXTRA8: - if (bSet) - ps[iPlayer].extra_extra8=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); - break; - - case PLAYER_QUICK_KICK: - if (bSet) - ps[iPlayer].quick_kick=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); - break; - - case PLAYER_HEAT_AMOUNT: - if (bSet) - ps[iPlayer].heat_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); - break; - - case PLAYER_ACTORSQU: - if (bSet) - ps[iPlayer].actorsqu=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].actorsqu, sActor, sPlayer); - break; - - case PLAYER_TIMEBEFOREEXIT: - if (bSet) - ps[iPlayer].timebeforeexit=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); - break; - - case PLAYER_CUSTOMEXITSOUND: - if (bSet) - ps[iPlayer].customexitsound=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); - break; - - case PLAYER_WEAPRECS: - if (bSet) - ps[iPlayer].weaprecs[16]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weaprecs[16], sActor, sPlayer); - break; - - case PLAYER_WEAPRECCNT: - if (bSet) - ps[iPlayer].weapreccnt=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); - break; - - case PLAYER_INTERFACE_TOGGLE_FLAG: - if (bSet) - ps[iPlayer].interface_toggle_flag=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); - break; - - case PLAYER_ROTSCRNANG: - if (bSet) - ps[iPlayer].rotscrnang=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].rotscrnang, sActor, sPlayer); - break; - - case PLAYER_DEAD_FLAG: - if (bSet) - ps[iPlayer].dead_flag=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); - break; - - case PLAYER_SHOW_EMPTY_WEAPON: - if (bSet) - ps[iPlayer].show_empty_weapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); - break; - - case PLAYER_SCUBA_AMOUNT: - if (bSet) - ps[iPlayer].scuba_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); - break; - - case PLAYER_JETPACK_AMOUNT: - if (bSet) - ps[iPlayer].jetpack_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); - break; - - case PLAYER_STEROIDS_AMOUNT: - if (bSet) - ps[iPlayer].steroids_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); - break; - - case PLAYER_SHIELD_AMOUNT: - if (bSet) - ps[iPlayer].shield_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); - break; - - case PLAYER_HOLODUKE_ON: - if (bSet) - ps[iPlayer].holoduke_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].holoduke_on, sActor, sPlayer); - break; - - case PLAYER_PYCOUNT: - if (bSet) - ps[iPlayer].pycount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].pycount, sActor, sPlayer); - break; - - case PLAYER_WEAPON_POS: - if (bSet) - ps[iPlayer].weapon_pos=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); - break; - - case PLAYER_FRAG_PS: - if (bSet) - ps[iPlayer].frag_ps=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); - break; - - case PLAYER_TRANSPORTER_HOLD: - if (bSet) - ps[iPlayer].transporter_hold=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); - break; - - case PLAYER_LAST_FULL_WEAPON: - if (bSet) - ps[iPlayer].last_full_weapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); - break; - - case PLAYER_FOOTPRINTSHADE: - if (bSet) - ps[iPlayer].footprintshade=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); - break; - - case PLAYER_BOOT_AMOUNT: - if (bSet) - ps[iPlayer].boot_amount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); - break; - - case PLAYER_SCREAM_VOICE: - if (bSet) - ps[iPlayer].scream_voice=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].scream_voice, sActor, sPlayer); - break; - - case PLAYER_GM: - if (bSet) - ps[iPlayer].gm=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].gm, sActor, sPlayer); - break; - - case PLAYER_ON_WARPING_SECTOR: - if (bSet) - ps[iPlayer].on_warping_sector=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); - break; - - case PLAYER_FOOTPRINTCOUNT: - if (bSet) - ps[iPlayer].footprintcount=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); - break; - - case PLAYER_HBOMB_ON: - if (bSet) - ps[iPlayer].hbomb_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); - break; - - case PLAYER_JUMPING_TOGGLE: - if (bSet) - ps[iPlayer].jumping_toggle=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); - break; - - case PLAYER_RAPID_FIRE_HOLD: - if (bSet) - ps[iPlayer].rapid_fire_hold=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); - break; - - case PLAYER_ON_GROUND: - if (bSet) - ps[iPlayer].on_ground=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].on_ground, sActor, sPlayer); - break; - - case PLAYER_NAME: - if (bSet) - ps[iPlayer].name[32]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].name[32], sActor, sPlayer); - break; - - case PLAYER_INVEN_ICON: - if (bSet) - ps[iPlayer].inven_icon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); - break; - - case PLAYER_BUTTONPALETTE: - if (bSet) - ps[iPlayer].buttonpalette=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); - break; - - case PLAYER_JETPACK_ON: - if (bSet) - ps[iPlayer].jetpack_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); - break; - - case PLAYER_SPRITEBRIDGE: - if (bSet) - ps[iPlayer].spritebridge=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); - break; - - case PLAYER_LASTRANDOMSPOT: - if (bSet) - ps[iPlayer].lastrandomspot=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); - break; - - case PLAYER_SCUBA_ON: - if (bSet) - ps[iPlayer].scuba_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); - break; - - case PLAYER_FOOTPRINTPAL: - if (bSet) - ps[iPlayer].footprintpal=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); - break; - - case PLAYER_HEAT_ON: - if (bSet) - ps[iPlayer].heat_on=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].heat_on, sActor, sPlayer); - break; - - case PLAYER_HOLSTER_WEAPON: - if (bSet) - ps[iPlayer].holster_weapon=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); - break; - - case PLAYER_FALLING_COUNTER: - if (bSet) - ps[iPlayer].falling_counter=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); - break; - - case PLAYER_GOTWEAPON: - lTemp=lParm2; - if (bSet) - ps[iPlayer].gotweapon[lTemp]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].gotweapon[lTemp], sActor, sPlayer); - break; - - case PLAYER_REFRESH_INVENTORY: - if (bSet) - ps[iPlayer].refresh_inventory=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); - break; - - // case PLAYER_PALETTE: - // if(bSet) - // { - // ps[iPlayer].palette=lValue; - // } - // else - // { - // SetGameVarID((int)lVar2, ps[iPlayer].palette, sActor, sPlayer); - // } - // break; - - case PLAYER_TOGGLE_KEY_FLAG: - if (bSet) - ps[iPlayer].toggle_key_flag=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); - break; - - case PLAYER_KNUCKLE_INCS: - if (bSet) - ps[iPlayer].knuckle_incs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); - break; - - case PLAYER_WALKING_SND_TOGGLE: - if (bSet) - ps[iPlayer].walking_snd_toggle=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); - break; - - case PLAYER_PALOOKUP: - if (bSet) - ps[iPlayer].palookup=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].palookup, sActor, sPlayer); - break; - - case PLAYER_HARD_LANDING: - if (bSet) - ps[iPlayer].hard_landing=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); - break; - - case PLAYER_MAX_SECRET_ROOMS: - if (bSet) - ps[iPlayer].max_secret_rooms=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); - break; - - case PLAYER_SECRET_ROOMS: - if (bSet) - ps[iPlayer].secret_rooms=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); - break; - - case PLAYER_PALS: - lTemp=lParm2; - if (bSet) - ps[iPlayer].pals[lTemp]=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].pals[lTemp], sActor, sPlayer); - break; - - case PLAYER_MAX_ACTORS_KILLED: - if (bSet) - ps[iPlayer].max_actors_killed=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); - break; - - case PLAYER_ACTORS_KILLED: - if (bSet) - ps[iPlayer].actors_killed=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); - break; - - case PLAYER_RETURN_TO_CENTER: - if (bSet) - ps[iPlayer].return_to_center=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].return_to_center, sActor, sPlayer); - break; - - case PLAYER_RUNSPEED: - if (bSet) - ps[iPlayer].runspeed=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].runspeed, sActor, sPlayer); - break; - - case PLAYER_SBS: - if (bSet) - ps[iPlayer].sbs=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].sbs, sActor, sPlayer); - break; - - case PLAYER_RELOADING: - if (bSet) - ps[iPlayer].reloading=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].reloading, sActor, sPlayer); - break; - - case PLAYER_AUTO_AIM: - if (bSet) - ps[iPlayer].auto_aim=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].auto_aim, sActor, sPlayer); - break; - - case PLAYER_MOVEMENT_LOCK: - if (bSet) - ps[iPlayer].movement_lock=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].movement_lock, sActor, sPlayer); - break; - - case PLAYER_SOUND_PITCH: - if (bSet) - ps[iPlayer].sound_pitch=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].sound_pitch, sActor, sPlayer); - break; - - case PLAYER_WEAPONSWITCH: - if (bSet) - ps[iPlayer].weaponswitch=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].weaponswitch, sActor, sPlayer); - break; - - case PLAYER_TEAM: - if (bSet) - ps[iPlayer].team=lValue; - else - SetGameVarID((int)lVar2, ps[iPlayer].team, sActor, sPlayer); - break; - - default: - break; + case PLAYER_ZOOM: + if (bSet) + ps[iPlayer].zoom=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].zoom, sActor, sPlayer); + break; + + case PLAYER_EXITX: + if (bSet) + ps[iPlayer].exitx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].exitx, sActor, sPlayer); + break; + + case PLAYER_EXITY: + if (bSet) + ps[iPlayer].exity=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].exity, sActor, sPlayer); + break; + + case PLAYER_LOOGIEX: + lTemp=lParm2; + if (bSet) + ps[iPlayer].loogiex[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogiex[lTemp], sActor, sPlayer); + break; + + case PLAYER_LOOGIEY: + lTemp=lParm2; + if (bSet) + ps[iPlayer].loogiey[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogiey[lTemp], sActor, sPlayer); + break; + + case PLAYER_NUMLOOGS: + if (bSet) + ps[iPlayer].numloogs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].numloogs, sActor, sPlayer); + break; + + case PLAYER_LOOGCNT: + if (bSet) + ps[iPlayer].loogcnt=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); + break; + + case PLAYER_POSX: + if (bSet) + ps[iPlayer].posx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posx, sActor, sPlayer); + break; + + case PLAYER_POSY: + if (bSet) + ps[iPlayer].posy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posy, sActor, sPlayer); + break; + + case PLAYER_POSZ: + if (bSet) + ps[iPlayer].posz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posz, sActor, sPlayer); + break; + + case PLAYER_HORIZ: + if (bSet) + ps[iPlayer].horiz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].horiz, sActor, sPlayer); + break; + + case PLAYER_OHORIZ: + if (bSet) + ps[iPlayer].ohoriz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ohoriz, sActor, sPlayer); + break; + + case PLAYER_OHORIZOFF: + if (bSet) + ps[iPlayer].ohorizoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ohorizoff, sActor, sPlayer); + break; + + case PLAYER_INVDISPTIME: + if (bSet) + ps[iPlayer].invdisptime=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); + break; + + case PLAYER_BOBPOSX: + if (bSet) + ps[iPlayer].bobposx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobposx, sActor, sPlayer); + break; + + case PLAYER_BOBPOSY: + if (bSet) + ps[iPlayer].bobposy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobposy, sActor, sPlayer); + break; + + case PLAYER_OPOSX: + if (bSet) + ps[iPlayer].oposx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposx, sActor, sPlayer); + break; + + case PLAYER_OPOSY: + if (bSet) + ps[iPlayer].oposy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposy, sActor, sPlayer); + break; + + case PLAYER_OPOSZ: + if (bSet) + ps[iPlayer].oposz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposz, sActor, sPlayer); + break; + + case PLAYER_PYOFF: + if (bSet) + ps[iPlayer].pyoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pyoff, sActor, sPlayer); + break; + + case PLAYER_OPYOFF: + if (bSet) + ps[iPlayer].opyoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].opyoff, sActor, sPlayer); + break; + + case PLAYER_POSXV: + if (bSet) + ps[iPlayer].posxv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posxv, sActor, sPlayer); + break; + + case PLAYER_POSYV: + if (bSet) + ps[iPlayer].posyv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posyv, sActor, sPlayer); + break; + + case PLAYER_POSZV: + if (bSet) + ps[iPlayer].poszv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].poszv, sActor, sPlayer); + break; + + case PLAYER_LAST_PISSED_TIME: + if (bSet) + ps[iPlayer].last_pissed_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); + break; + + case PLAYER_TRUEFZ: + if (bSet) + ps[iPlayer].truefz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].truefz, sActor, sPlayer); + break; + + case PLAYER_TRUECZ: + if (bSet) + ps[iPlayer].truecz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].truecz, sActor, sPlayer); + break; + + case PLAYER_PLAYER_PAR: + if (bSet) + ps[iPlayer].player_par=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].player_par, sActor, sPlayer); + break; + + case PLAYER_VISIBILITY: + if (bSet) + ps[iPlayer].visibility=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].visibility, sActor, sPlayer); + break; + + case PLAYER_BOBCOUNTER: + if (bSet) + ps[iPlayer].bobcounter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); + break; + + case PLAYER_WEAPON_SWAY: + if (bSet) + ps[iPlayer].weapon_sway=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); + break; + + case PLAYER_PALS_TIME: + if (bSet) + ps[iPlayer].pals_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pals_time, sActor, sPlayer); + break; + + case PLAYER_RANDOMFLAMEX: + if (bSet) + ps[iPlayer].randomflamex=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); + break; + + case PLAYER_CRACK_TIME: + if (bSet) + ps[iPlayer].crack_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].crack_time, sActor, sPlayer); + break; + + case PLAYER_AIM_MODE: + if (bSet) + ps[iPlayer].aim_mode=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); + break; + + case PLAYER_ANG: + if (bSet) + ps[iPlayer].ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ang, sActor, sPlayer); + break; + + case PLAYER_OANG: + if (bSet) + ps[iPlayer].oang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oang, sActor, sPlayer); + break; + + case PLAYER_ANGVEL: + if (bSet) + ps[iPlayer].angvel=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].angvel, sActor, sPlayer); + break; + + case PLAYER_CURSECTNUM: + if (bSet) + ps[iPlayer].cursectnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); + break; + + case PLAYER_LOOK_ANG: + if (bSet) + ps[iPlayer].look_ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].look_ang, sActor, sPlayer); + break; + + case PLAYER_LAST_EXTRA: + if (bSet) + ps[iPlayer].last_extra=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_extra, sActor, sPlayer); + break; + + case PLAYER_SUBWEAPON: + if (bSet) + ps[iPlayer].subweapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].subweapon, sActor, sPlayer); + break; + + case PLAYER_AMMO_AMOUNT: + lTemp=lParm2; + if (bSet) + ps[iPlayer].ammo_amount[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); + break; + + case PLAYER_WACKEDBYACTOR: + if (bSet) + ps[iPlayer].wackedbyactor=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].wackedbyactor, sActor, sPlayer); + break; + + case PLAYER_FRAG: + if (bSet) + ps[iPlayer].frag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].frag, sActor, sPlayer); + break; + + case PLAYER_FRAGGEDSELF: + if (bSet) + ps[iPlayer].fraggedself=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); + break; + + case PLAYER_CURR_WEAPON: + if (bSet) + ps[iPlayer].curr_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); + break; + + case PLAYER_LAST_WEAPON: + if (bSet) + ps[iPlayer].last_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); + break; + + case PLAYER_TIPINCS: + if (bSet) + ps[iPlayer].tipincs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); + break; + + case PLAYER_HORIZOFF: + if (bSet) + ps[iPlayer].horizoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].horizoff, sActor, sPlayer); + break; + + case PLAYER_WANTWEAPONFIRE: + if (bSet) + ps[iPlayer].wantweaponfire=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_AMOUNT: + if (bSet) + ps[iPlayer].holoduke_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); + break; + + case PLAYER_NEWOWNER: + if (bSet) + ps[iPlayer].newowner=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].newowner, sActor, sPlayer); + break; + + case PLAYER_HURT_DELAY: + if (bSet) + ps[iPlayer].hurt_delay=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); + break; + + case PLAYER_HBOMB_HOLD_DELAY: + if (bSet) + ps[iPlayer].hbomb_hold_delay=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); + break; + + case PLAYER_JUMPING_COUNTER: + if (bSet) + ps[iPlayer].jumping_counter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); + break; + + case PLAYER_AIRLEFT: + if (bSet) + ps[iPlayer].airleft=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].airleft, sActor, sPlayer); + break; + + case PLAYER_KNEE_INCS: + if (bSet) + ps[iPlayer].knee_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); + break; + + case PLAYER_ACCESS_INCS: + if (bSet) + ps[iPlayer].access_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_incs, sActor, sPlayer); + break; + + case PLAYER_FTA: + if (bSet) + ps[iPlayer].fta=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fta, sActor, sPlayer); + break; + + case PLAYER_FTQ: + if (bSet) + ps[iPlayer].ftq=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ftq, sActor, sPlayer); + break; + + case PLAYER_ACCESS_WALLNUM: + if (bSet) + ps[iPlayer].access_wallnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); + break; + + case PLAYER_ACCESS_SPRITENUM: + if (bSet) + ps[iPlayer].access_spritenum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_spritenum, sActor, sPlayer); + break; + + case PLAYER_KICKBACK_PIC: + if (bSet) + ps[iPlayer].kickback_pic=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); + break; + + case PLAYER_GOT_ACCESS: + if (bSet) + ps[iPlayer].got_access=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].got_access, sActor, sPlayer); + break; + + case PLAYER_WEAPON_ANG: + if (bSet) + ps[iPlayer].weapon_ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); + break; + + case PLAYER_FIRSTAID_AMOUNT: + if (bSet) + ps[iPlayer].firstaid_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); + break; + + case PLAYER_SOMETHINGONPLAYER: + if (bSet) + ps[iPlayer].somethingonplayer=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].somethingonplayer, sActor, sPlayer); + break; + + case PLAYER_ON_CRANE: + if (bSet) + ps[iPlayer].on_crane=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_crane, sActor, sPlayer); + break; + + case PLAYER_I: + if (bSet) + ps[iPlayer].i=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].i, sActor, sPlayer); + break; + + case PLAYER_ONE_PARALLAX_SECTNUM: + if (bSet) + ps[iPlayer].one_parallax_sectnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); + break; + + case PLAYER_OVER_SHOULDER_ON: + if (bSet) + ps[iPlayer].over_shoulder_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); + break; + + case PLAYER_RANDOM_CLUB_FRAME: + if (bSet) + ps[iPlayer].random_club_frame=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); + break; + + case PLAYER_FIST_INCS: + if (bSet) + ps[iPlayer].fist_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); + break; + + case PLAYER_ONE_EIGHTY_COUNT: + if (bSet) + ps[iPlayer].one_eighty_count=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].one_eighty_count, sActor, sPlayer); + break; + + case PLAYER_CHEAT_PHASE: + if (bSet) + ps[iPlayer].cheat_phase=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); + break; + + case PLAYER_DUMMYPLAYERSPRITE: + if (bSet) + ps[iPlayer].dummyplayersprite=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].dummyplayersprite, sActor, sPlayer); + break; + + case PLAYER_EXTRA_EXTRA8: + if (bSet) + ps[iPlayer].extra_extra8=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); + break; + + case PLAYER_QUICK_KICK: + if (bSet) + ps[iPlayer].quick_kick=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); + break; + + case PLAYER_HEAT_AMOUNT: + if (bSet) + ps[iPlayer].heat_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); + break; + + case PLAYER_ACTORSQU: + if (bSet) + ps[iPlayer].actorsqu=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].actorsqu, sActor, sPlayer); + break; + + case PLAYER_TIMEBEFOREEXIT: + if (bSet) + ps[iPlayer].timebeforeexit=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); + break; + + case PLAYER_CUSTOMEXITSOUND: + if (bSet) + ps[iPlayer].customexitsound=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); + break; + + case PLAYER_WEAPRECS: + if (bSet) + ps[iPlayer].weaprecs[16]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weaprecs[16], sActor, sPlayer); + break; + + case PLAYER_WEAPRECCNT: + if (bSet) + ps[iPlayer].weapreccnt=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); + break; + + case PLAYER_INTERFACE_TOGGLE_FLAG: + if (bSet) + ps[iPlayer].interface_toggle_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); + break; + + case PLAYER_ROTSCRNANG: + if (bSet) + ps[iPlayer].rotscrnang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].rotscrnang, sActor, sPlayer); + break; + + case PLAYER_DEAD_FLAG: + if (bSet) + ps[iPlayer].dead_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); + break; + + case PLAYER_SHOW_EMPTY_WEAPON: + if (bSet) + ps[iPlayer].show_empty_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); + break; + + case PLAYER_SCUBA_AMOUNT: + if (bSet) + ps[iPlayer].scuba_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); + break; + + case PLAYER_JETPACK_AMOUNT: + if (bSet) + ps[iPlayer].jetpack_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); + break; + + case PLAYER_STEROIDS_AMOUNT: + if (bSet) + ps[iPlayer].steroids_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); + break; + + case PLAYER_SHIELD_AMOUNT: + if (bSet) + ps[iPlayer].shield_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_ON: + if (bSet) + ps[iPlayer].holoduke_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holoduke_on, sActor, sPlayer); + break; + + case PLAYER_PYCOUNT: + if (bSet) + ps[iPlayer].pycount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pycount, sActor, sPlayer); + break; + + case PLAYER_WEAPON_POS: + if (bSet) + ps[iPlayer].weapon_pos=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); + break; + + case PLAYER_FRAG_PS: + if (bSet) + ps[iPlayer].frag_ps=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); + break; + + case PLAYER_TRANSPORTER_HOLD: + if (bSet) + ps[iPlayer].transporter_hold=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); + break; + + case PLAYER_LAST_FULL_WEAPON: + if (bSet) + ps[iPlayer].last_full_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTSHADE: + if (bSet) + ps[iPlayer].footprintshade=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); + break; + + case PLAYER_BOOT_AMOUNT: + if (bSet) + ps[iPlayer].boot_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); + break; + + case PLAYER_SCREAM_VOICE: + if (bSet) + ps[iPlayer].scream_voice=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scream_voice, sActor, sPlayer); + break; + + case PLAYER_GM: + if (bSet) + ps[iPlayer].gm=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].gm, sActor, sPlayer); + break; + + case PLAYER_ON_WARPING_SECTOR: + if (bSet) + ps[iPlayer].on_warping_sector=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTCOUNT: + if (bSet) + ps[iPlayer].footprintcount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); + break; + + case PLAYER_HBOMB_ON: + if (bSet) + ps[iPlayer].hbomb_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); + break; + + case PLAYER_JUMPING_TOGGLE: + if (bSet) + ps[iPlayer].jumping_toggle=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); + break; + + case PLAYER_RAPID_FIRE_HOLD: + if (bSet) + ps[iPlayer].rapid_fire_hold=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); + break; + + case PLAYER_ON_GROUND: + if (bSet) + ps[iPlayer].on_ground=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_ground, sActor, sPlayer); + break; + + case PLAYER_NAME: + if (bSet) + ps[iPlayer].name[32]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].name[32], sActor, sPlayer); + break; + + case PLAYER_INVEN_ICON: + if (bSet) + ps[iPlayer].inven_icon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); + break; + + case PLAYER_BUTTONPALETTE: + if (bSet) + ps[iPlayer].buttonpalette=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); + break; + + case PLAYER_JETPACK_ON: + if (bSet) + ps[iPlayer].jetpack_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); + break; + + case PLAYER_SPRITEBRIDGE: + if (bSet) + ps[iPlayer].spritebridge=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); + break; + + case PLAYER_LASTRANDOMSPOT: + if (bSet) + ps[iPlayer].lastrandomspot=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); + break; + + case PLAYER_SCUBA_ON: + if (bSet) + ps[iPlayer].scuba_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTPAL: + if (bSet) + ps[iPlayer].footprintpal=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); + break; + + case PLAYER_HEAT_ON: + if (bSet) + ps[iPlayer].heat_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].heat_on, sActor, sPlayer); + break; + + case PLAYER_HOLSTER_WEAPON: + if (bSet) + ps[iPlayer].holster_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); + break; + + case PLAYER_FALLING_COUNTER: + if (bSet) + ps[iPlayer].falling_counter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); + break; + + case PLAYER_GOTWEAPON: + lTemp=lParm2; + if (bSet) + ps[iPlayer].gotweapon[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].gotweapon[lTemp], sActor, sPlayer); + break; + + case PLAYER_REFRESH_INVENTORY: + if (bSet) + ps[iPlayer].refresh_inventory=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); + break; + + // case PLAYER_PALETTE: + // if(bSet) + // { + // ps[iPlayer].palette=lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ps[iPlayer].palette, sActor, sPlayer); + // } + // break; + + case PLAYER_TOGGLE_KEY_FLAG: + if (bSet) + ps[iPlayer].toggle_key_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); + break; + + case PLAYER_KNUCKLE_INCS: + if (bSet) + ps[iPlayer].knuckle_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); + break; + + case PLAYER_WALKING_SND_TOGGLE: + if (bSet) + ps[iPlayer].walking_snd_toggle=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); + break; + + case PLAYER_PALOOKUP: + if (bSet) + ps[iPlayer].palookup=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].palookup, sActor, sPlayer); + break; + + case PLAYER_HARD_LANDING: + if (bSet) + ps[iPlayer].hard_landing=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); + break; + + case PLAYER_MAX_SECRET_ROOMS: + if (bSet) + ps[iPlayer].max_secret_rooms=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); + break; + + case PLAYER_SECRET_ROOMS: + if (bSet) + ps[iPlayer].secret_rooms=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); + break; + + case PLAYER_PALS: + lTemp=lParm2; + if (bSet) + ps[iPlayer].pals[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pals[lTemp], sActor, sPlayer); + break; + + case PLAYER_MAX_ACTORS_KILLED: + if (bSet) + ps[iPlayer].max_actors_killed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); + break; + + case PLAYER_ACTORS_KILLED: + if (bSet) + ps[iPlayer].actors_killed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); + break; + + case PLAYER_RETURN_TO_CENTER: + if (bSet) + ps[iPlayer].return_to_center=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].return_to_center, sActor, sPlayer); + break; + + case PLAYER_RUNSPEED: + if (bSet) + ps[iPlayer].runspeed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].runspeed, sActor, sPlayer); + break; + + case PLAYER_SBS: + if (bSet) + ps[iPlayer].sbs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].sbs, sActor, sPlayer); + break; + + case PLAYER_RELOADING: + if (bSet) + ps[iPlayer].reloading=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].reloading, sActor, sPlayer); + break; + + case PLAYER_AUTO_AIM: + if (bSet) + ps[iPlayer].auto_aim=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].auto_aim, sActor, sPlayer); + break; + + case PLAYER_MOVEMENT_LOCK: + if (bSet) + ps[iPlayer].movement_lock=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].movement_lock, sActor, sPlayer); + break; + + case PLAYER_SOUND_PITCH: + if (bSet) + ps[iPlayer].sound_pitch=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].sound_pitch, sActor, sPlayer); + break; + + case PLAYER_WEAPONSWITCH: + if (bSet) + ps[iPlayer].weaponswitch=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weaponswitch, sActor, sPlayer); + break; + + case PLAYER_TEAM: + if (bSet) + ps[iPlayer].team=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].team, sActor, sPlayer); + break; + + default: + break; } return; } @@ -2076,49 +2076,49 @@ void DoInput(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, sho switch (lLabelID) { - case INPUT_AVEL: - if (bSet) - sync[iPlayer].avel=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].avel, sActor, sPlayer); - break; + case INPUT_AVEL: + if (bSet) + sync[iPlayer].avel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].avel, sActor, sPlayer); + break; - case INPUT_HORZ: - if (bSet) - sync[iPlayer].horz=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].horz, sActor, sPlayer); - break; + case INPUT_HORZ: + if (bSet) + sync[iPlayer].horz=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].horz, sActor, sPlayer); + break; - case INPUT_FVEL: - if (bSet) - sync[iPlayer].fvel=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].fvel, sActor, sPlayer); - break; + case INPUT_FVEL: + if (bSet) + sync[iPlayer].fvel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].fvel, sActor, sPlayer); + break; - case INPUT_SVEL: - if (bSet) - sync[iPlayer].svel=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].svel, sActor, sPlayer); - break; + case INPUT_SVEL: + if (bSet) + sync[iPlayer].svel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].svel, sActor, sPlayer); + break; - case INPUT_BITS: - if (bSet) - sync[iPlayer].bits=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].bits, sActor, sPlayer); - break; + case INPUT_BITS: + if (bSet) + sync[iPlayer].bits=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].bits, sActor, sPlayer); + break; - case INPUT_EXTBITS: - if (bSet) - sync[iPlayer].extbits=lValue; - else - SetGameVarID((int)lVar2, sync[iPlayer].extbits, sActor, sPlayer); - break; - default: - break; + case INPUT_EXTBITS: + if (bSet) + sync[iPlayer].extbits=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].extbits, sActor, sPlayer); + break; + default: + break; } return; } @@ -2137,126 +2137,126 @@ void DoWall(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, shor switch (lLabelID) { - case WALL_X: - if (bSet) - wall[iWall].x=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); - break; + case WALL_X: + if (bSet) + wall[iWall].x=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + break; - case WALL_Y: - if (bSet) - wall[iWall].y=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].y, sActor, sPlayer); - break; + case WALL_Y: + if (bSet) + wall[iWall].y=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].y, sActor, sPlayer); + break; - case WALL_POINT2: - if (bSet) - wall[iWall].point2=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].point2, sActor, sPlayer); - break; + case WALL_POINT2: + if (bSet) + wall[iWall].point2=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].point2, sActor, sPlayer); + break; - case WALL_NEXTWALL: - if (bSet) - wall[iWall].nextwall=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].nextwall, sActor, sPlayer); - break; + case WALL_NEXTWALL: + if (bSet) + wall[iWall].nextwall=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].nextwall, sActor, sPlayer); + break; - case WALL_NEXTSECTOR: - if (bSet) - wall[iWall].nextsector=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].nextsector, sActor, sPlayer); - break; + case WALL_NEXTSECTOR: + if (bSet) + wall[iWall].nextsector=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].nextsector, sActor, sPlayer); + break; - case WALL_CSTAT: - if (bSet) - wall[iWall].cstat=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].cstat, sActor, sPlayer); - break; + case WALL_CSTAT: + if (bSet) + wall[iWall].cstat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].cstat, sActor, sPlayer); + break; - case WALL_PICNUM: - if (bSet) - wall[iWall].picnum=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].picnum, sActor, sPlayer); - break; + case WALL_PICNUM: + if (bSet) + wall[iWall].picnum=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].picnum, sActor, sPlayer); + break; - case WALL_OVERPICNUM: - if (bSet) - wall[iWall].overpicnum=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].overpicnum, sActor, sPlayer); - break; + case WALL_OVERPICNUM: + if (bSet) + wall[iWall].overpicnum=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].overpicnum, sActor, sPlayer); + break; - case WALL_SHADE: - if (bSet) - wall[iWall].shade=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].shade, sActor, sPlayer); - break; + case WALL_SHADE: + if (bSet) + wall[iWall].shade=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].shade, sActor, sPlayer); + break; - case WALL_PAL: - if (bSet) - wall[iWall].pal=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].pal, sActor, sPlayer); - break; + case WALL_PAL: + if (bSet) + wall[iWall].pal=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].pal, sActor, sPlayer); + break; - case WALL_XREPEAT: - if (bSet) - wall[iWall].xrepeat=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].xrepeat, sActor, sPlayer); - break; + case WALL_XREPEAT: + if (bSet) + wall[iWall].xrepeat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].xrepeat, sActor, sPlayer); + break; - case WALL_YREPEAT: - if (bSet) - wall[iWall].yrepeat=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer); - break; + case WALL_YREPEAT: + if (bSet) + wall[iWall].yrepeat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer); + break; - case WALL_XPANNING: - if (bSet) - wall[iWall].xpanning=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].xpanning, sActor, sPlayer); - break; + case WALL_XPANNING: + if (bSet) + wall[iWall].xpanning=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].xpanning, sActor, sPlayer); + break; - case WALL_YPANNING: - if (bSet) - wall[iWall].ypanning=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].ypanning, sActor, sPlayer); - break; + case WALL_YPANNING: + if (bSet) + wall[iWall].ypanning=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].ypanning, sActor, sPlayer); + break; - case WALL_LOTAG: - if (bSet) - wall[iWall].lotag=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].lotag, sActor, sPlayer); - break; + case WALL_LOTAG: + if (bSet) + wall[iWall].lotag=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].lotag, sActor, sPlayer); + break; - case WALL_HITAG: - if (bSet) - wall[iWall].hitag=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].hitag, sActor, sPlayer); - break; + case WALL_HITAG: + if (bSet) + wall[iWall].hitag=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].hitag, sActor, sPlayer); + break; - case WALL_EXTRA: - if (bSet) - wall[iWall].extra=lValue; - else - SetGameVarID((int)lVar2, wall[iWall].extra, sActor, sPlayer); - break; - default: - break; + case WALL_EXTRA: + if (bSet) + wall[iWall].extra=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].extra, sActor, sPlayer); + break; + default: + break; } return; } @@ -2279,162 +2279,162 @@ void DoSector(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, sh switch (lLabelID) { - case SECTOR_WALLPTR: - if (bSet) - sector[iSector].wallptr=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].wallptr,sActor,sPlayer); - break; + case SECTOR_WALLPTR: + if (bSet) + sector[iSector].wallptr=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].wallptr,sActor,sPlayer); + break; - case SECTOR_WALLNUM: - if (bSet) - sector[iSector].wallnum=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].wallnum,sActor,sPlayer); - break; + case SECTOR_WALLNUM: + if (bSet) + sector[iSector].wallnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].wallnum,sActor,sPlayer); + break; - case SECTOR_CEILINGZ: - if (bSet) - sector[iSector].ceilingz=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingz,sActor,sPlayer); - break; + case SECTOR_CEILINGZ: + if (bSet) + sector[iSector].ceilingz=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingz,sActor,sPlayer); + break; - case SECTOR_FLOORZ: - if (bSet) - sector[iSector].floorz=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorz,sActor,sPlayer); - break; + case SECTOR_FLOORZ: + if (bSet) + sector[iSector].floorz=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorz,sActor,sPlayer); + break; - case SECTOR_CEILINGSTAT: - if (bSet) - sector[iSector].ceilingstat=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingstat,sActor,sPlayer); - break; + case SECTOR_CEILINGSTAT: + if (bSet) + sector[iSector].ceilingstat=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingstat,sActor,sPlayer); + break; - case SECTOR_FLOORSTAT: - if (bSet) - sector[iSector].floorstat=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorstat,sActor,sPlayer); - break; + case SECTOR_FLOORSTAT: + if (bSet) + sector[iSector].floorstat=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorstat,sActor,sPlayer); + break; - case SECTOR_CEILINGPICNUM: - if (bSet) - sector[iSector].ceilingpicnum=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingpicnum,sActor,sPlayer); - break; + case SECTOR_CEILINGPICNUM: + if (bSet) + sector[iSector].ceilingpicnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingpicnum,sActor,sPlayer); + break; - case SECTOR_CEILINGSLOPE: - if (bSet) - sector[iSector].ceilingheinum=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingheinum,sActor,sPlayer); - break; + case SECTOR_CEILINGSLOPE: + if (bSet) + sector[iSector].ceilingheinum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingheinum,sActor,sPlayer); + break; - case SECTOR_CEILINGSHADE: - if (bSet) - sector[iSector].ceilingshade=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingshade,sActor,sPlayer); - break; + case SECTOR_CEILINGSHADE: + if (bSet) + sector[iSector].ceilingshade=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingshade,sActor,sPlayer); + break; - case SECTOR_CEILINGPAL: - if (bSet) - sector[iSector].ceilingpal=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingpal,sActor,sPlayer); - break; + case SECTOR_CEILINGPAL: + if (bSet) + sector[iSector].ceilingpal=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingpal,sActor,sPlayer); + break; - case SECTOR_CEILINGXPANNING: - if (bSet) - sector[iSector].ceilingxpanning=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].ceilingypanning,sActor,sPlayer); - break; + case SECTOR_CEILINGXPANNING: + if (bSet) + sector[iSector].ceilingxpanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingypanning,sActor,sPlayer); + break; - case SECTOR_FLOORPICNUM: - if (bSet) - sector[iSector].floorpicnum=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorpicnum,sActor,sPlayer); - break; + case SECTOR_FLOORPICNUM: + if (bSet) + sector[iSector].floorpicnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorpicnum,sActor,sPlayer); + break; - case SECTOR_FLOORSLOPE: - if (bSet) - sector[iSector].floorheinum=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorheinum,sActor,sPlayer); - break; + case SECTOR_FLOORSLOPE: + if (bSet) + sector[iSector].floorheinum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorheinum,sActor,sPlayer); + break; - case SECTOR_FLOORSHADE: - if (bSet) - sector[iSector].floorshade=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorshade,sActor,sPlayer); - break; + case SECTOR_FLOORSHADE: + if (bSet) + sector[iSector].floorshade=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorshade,sActor,sPlayer); + break; - case SECTOR_FLOORPAL: - if (bSet) - sector[iSector].floorpal=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorpal,sActor,sPlayer); - break; + case SECTOR_FLOORPAL: + if (bSet) + sector[iSector].floorpal=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorpal,sActor,sPlayer); + break; - case SECTOR_FLOORXPANNING: - if (bSet) - sector[iSector].floorxpanning=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorxpanning,sActor,sPlayer); - break; + case SECTOR_FLOORXPANNING: + if (bSet) + sector[iSector].floorxpanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorxpanning,sActor,sPlayer); + break; - case SECTOR_FLOORYPANNING: - if (bSet) - sector[iSector].floorypanning=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].floorypanning,sActor,sPlayer); - break; + case SECTOR_FLOORYPANNING: + if (bSet) + sector[iSector].floorypanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorypanning,sActor,sPlayer); + break; - case SECTOR_VISIBILITY: - if (bSet) - sector[iSector].visibility=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].visibility,sActor,sPlayer); - break; + case SECTOR_VISIBILITY: + if (bSet) + sector[iSector].visibility=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].visibility,sActor,sPlayer); + break; - case SECTOR_ALIGNTO: - if (bSet) - sector[iSector].filler=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].filler,sActor,sPlayer); - break; + case SECTOR_ALIGNTO: + if (bSet) + sector[iSector].filler=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].filler,sActor,sPlayer); + break; - case SECTOR_LOTAG: - if (bSet) - sector[iSector].lotag=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].lotag,sActor,sPlayer); - break; + case SECTOR_LOTAG: + if (bSet) + sector[iSector].lotag=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].lotag,sActor,sPlayer); + break; - case SECTOR_HITAG: - if (bSet) - sector[iSector].hitag=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].hitag,sActor,sPlayer); - break; + case SECTOR_HITAG: + if (bSet) + sector[iSector].hitag=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].hitag,sActor,sPlayer); + break; - case SECTOR_EXTRA: - if (bSet) - sector[iSector].extra=lValue; - else - SetGameVarID((int)lVar2, sector[iSector].extra,sActor,sPlayer); - break; + case SECTOR_EXTRA: + if (bSet) + sector[iSector].extra=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].extra,sActor,sPlayer); + break; - default: - break; + default: + break; } return; } @@ -2458,338 +2458,338 @@ void DoActor(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, sho switch (lLabelID) { - case ACTOR_X: - if (bSet) - sprite[iActor].x=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].x,sActor,sPlayer); - break; + case ACTOR_X: + if (bSet) + sprite[iActor].x=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].x,sActor,sPlayer); + break; - case ACTOR_Y: - if (bSet) - sprite[iActor].y=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].y,sActor,sPlayer); - break; + case ACTOR_Y: + if (bSet) + sprite[iActor].y=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].y,sActor,sPlayer); + break; - case ACTOR_Z: - if (bSet) - sprite[iActor].z=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].z,sActor,sPlayer); - break; + case ACTOR_Z: + if (bSet) + sprite[iActor].z=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].z,sActor,sPlayer); + break; - case ACTOR_CSTAT: - if (bSet) - sprite[iActor].cstat=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].cstat,sActor,sPlayer); - break; + case ACTOR_CSTAT: + if (bSet) + sprite[iActor].cstat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].cstat,sActor,sPlayer); + break; - case ACTOR_PICNUM: - if (bSet) - sprite[iActor].picnum=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].picnum,sActor,sPlayer); - break; + case ACTOR_PICNUM: + if (bSet) + sprite[iActor].picnum=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].picnum,sActor,sPlayer); + break; - case ACTOR_SHADE: - if (bSet) - sprite[iActor].shade=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].shade,sActor,sPlayer); - break; + case ACTOR_SHADE: + if (bSet) + sprite[iActor].shade=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].shade,sActor,sPlayer); + break; - case ACTOR_PAL: - if (bSet) - sprite[iActor].pal=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].pal,sActor,sPlayer); - break; + case ACTOR_PAL: + if (bSet) + sprite[iActor].pal=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].pal,sActor,sPlayer); + break; - case ACTOR_CLIPDIST: - if (bSet) - sprite[iActor].clipdist=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].clipdist,sActor,sPlayer); - break; + case ACTOR_CLIPDIST: + if (bSet) + sprite[iActor].clipdist=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].clipdist,sActor,sPlayer); + break; - case ACTOR_DETAIL: - if (bSet) - sprite[iActor].filler=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].filler,sActor,sPlayer); - break; + case ACTOR_DETAIL: + if (bSet) + sprite[iActor].filler=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].filler,sActor,sPlayer); + break; - case ACTOR_XREPEAT: - if (bSet) - sprite[iActor].xrepeat=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].xrepeat,sActor,sPlayer); - break; + case ACTOR_XREPEAT: + if (bSet) + sprite[iActor].xrepeat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xrepeat,sActor,sPlayer); + break; - case ACTOR_YREPEAT: - if (bSet) - sprite[iActor].yrepeat=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].yrepeat,sActor,sPlayer); - break; + case ACTOR_YREPEAT: + if (bSet) + sprite[iActor].yrepeat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yrepeat,sActor,sPlayer); + break; - case ACTOR_XOFFSET: - if (bSet) - sprite[iActor].xoffset=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].xoffset,sActor,sPlayer); - break; + case ACTOR_XOFFSET: + if (bSet) + sprite[iActor].xoffset=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xoffset,sActor,sPlayer); + break; - case ACTOR_YOFFSET: - if (bSet) - sprite[iActor].yoffset=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].yoffset,sActor,sPlayer); - break; + case ACTOR_YOFFSET: + if (bSet) + sprite[iActor].yoffset=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yoffset,sActor,sPlayer); + break; - case ACTOR_SECTNUM: - if (bSet) - changespritesect(iActor,lValue); - else - SetGameVarID((int)lVar2, sprite[iActor].sectnum,sActor,sPlayer); - break; + case ACTOR_SECTNUM: + if (bSet) + changespritesect(iActor,lValue); + else + SetGameVarID((int)lVar2, sprite[iActor].sectnum,sActor,sPlayer); + break; - case ACTOR_STATNUM: - if (bSet) - changespritestat(iActor,lValue); - else - SetGameVarID((int)lVar2, sprite[iActor].statnum,sActor,sPlayer); - break; + case ACTOR_STATNUM: + if (bSet) + changespritestat(iActor,lValue); + else + SetGameVarID((int)lVar2, sprite[iActor].statnum,sActor,sPlayer); + break; - case ACTOR_ANG: - if (bSet) - sprite[iActor].ang=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].ang,sActor,sPlayer); - break; + case ACTOR_ANG: + if (bSet) + sprite[iActor].ang=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].ang,sActor,sPlayer); + break; - case ACTOR_OWNER: - if (bSet) - sprite[iActor].owner=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].owner,sActor,sPlayer); - break; + case ACTOR_OWNER: + if (bSet) + sprite[iActor].owner=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].owner,sActor,sPlayer); + break; - case ACTOR_XVEL: - if (bSet) - sprite[iActor].xvel=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].xvel,sActor,sPlayer); - break; + case ACTOR_XVEL: + if (bSet) + sprite[iActor].xvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xvel,sActor,sPlayer); + break; - case ACTOR_YVEL: - if (bSet) - sprite[iActor].yvel=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].yvel,sActor,sPlayer); - break; + case ACTOR_YVEL: + if (bSet) + sprite[iActor].yvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yvel,sActor,sPlayer); + break; - case ACTOR_ZVEL: - if (bSet) - sprite[iActor].zvel=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].zvel,sActor,sPlayer); - break; + case ACTOR_ZVEL: + if (bSet) + sprite[iActor].zvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].zvel,sActor,sPlayer); + break; - case ACTOR_LOTAG: - if (bSet) - sprite[iActor].lotag=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].lotag,sActor,sPlayer); - break; + case ACTOR_LOTAG: + if (bSet) + sprite[iActor].lotag=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].lotag,sActor,sPlayer); + break; - case ACTOR_HITAG: - if (bSet) - sprite[iActor].hitag=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].hitag,sActor,sPlayer); - break; + case ACTOR_HITAG: + if (bSet) + sprite[iActor].hitag=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].hitag,sActor,sPlayer); + break; - case ACTOR_EXTRA: - if (bSet) - sprite[iActor].extra=lValue; - else - SetGameVarID((int)lVar2, sprite[iActor].extra,sActor,sPlayer); - break; + case ACTOR_EXTRA: + if (bSet) + sprite[iActor].extra=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].extra,sActor,sPlayer); + break; - case ACTOR_HTCGG: - if (bSet) - hittype[iActor].cgg=lValue; - else - SetGameVarID((int)lVar2, hittype[iActor].cgg, sActor, sPlayer); - break; + case ACTOR_HTCGG: + if (bSet) + hittype[iActor].cgg=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].cgg, sActor, sPlayer); + break; - case ACTOR_HTPICNUM : - if (bSet) - hittype[iActor].picnum=lValue; - else - SetGameVarID((int)lVar2, hittype[iActor].picnum, sActor, sPlayer); - break; + case ACTOR_HTPICNUM : + if (bSet) + hittype[iActor].picnum=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].picnum, sActor, sPlayer); + break; - case ACTOR_HTANG: - if (bSet) - hittype[iActor].ang=lValue; - else - SetGameVarID((int)lVar2, hittype[iActor].ang, sActor, sPlayer); - break; + case ACTOR_HTANG: + if (bSet) + hittype[iActor].ang=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].ang, sActor, sPlayer); + break; - case ACTOR_HTEXTRA: - if (bSet) - hittype[iActor].extra=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].extra, sActor, sPlayer); - break; + case ACTOR_HTEXTRA: + if (bSet) + hittype[iActor].extra=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].extra, sActor, sPlayer); + break; - case ACTOR_HTOWNER: - if (bSet) - hittype[iActor].owner=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].owner, sActor, sPlayer); - break; + case ACTOR_HTOWNER: + if (bSet) + hittype[iActor].owner=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].owner, sActor, sPlayer); + break; - case ACTOR_HTMOVFLAG: - if (bSet) - hittype[iActor].movflag=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].movflag, sActor, sPlayer); - break; + case ACTOR_HTMOVFLAG: + if (bSet) + hittype[iActor].movflag=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].movflag, sActor, sPlayer); + break; - case ACTOR_HTTEMPANG: - if (bSet) - hittype[iActor].tempang=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].tempang, sActor, sPlayer); - break; + case ACTOR_HTTEMPANG: + if (bSet) + hittype[iActor].tempang=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].tempang, sActor, sPlayer); + break; - case ACTOR_HTACTORSTAYPUT: - if (bSet) - hittype[iActor].actorstayput=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].actorstayput, sActor, sPlayer); - break; + case ACTOR_HTACTORSTAYPUT: + if (bSet) + hittype[iActor].actorstayput=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].actorstayput, sActor, sPlayer); + break; - case ACTOR_HTDISPICNUM: - if (bSet) - hittype[iActor].dispicnum=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].dispicnum, sActor, sPlayer); - break; + case ACTOR_HTDISPICNUM: + if (bSet) + hittype[iActor].dispicnum=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].dispicnum, sActor, sPlayer); + break; - case ACTOR_HTTIMETOSLEEP: - if (bSet) - hittype[iActor].timetosleep=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].timetosleep, sActor, sPlayer); - break; + case ACTOR_HTTIMETOSLEEP: + if (bSet) + hittype[iActor].timetosleep=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].timetosleep, sActor, sPlayer); + break; - case ACTOR_HTFLOORZ: - if (bSet) - hittype[iActor].floorz=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].floorz, sActor, sPlayer); - break; + case ACTOR_HTFLOORZ: + if (bSet) + hittype[iActor].floorz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].floorz, sActor, sPlayer); + break; - case ACTOR_HTCEILINGZ: - if (bSet) - hittype[iActor].ceilingz=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].ceilingz, sActor, sPlayer); - break; + case ACTOR_HTCEILINGZ: + if (bSet) + hittype[iActor].ceilingz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].ceilingz, sActor, sPlayer); + break; - case ACTOR_HTLASTVX: - if (bSet) - hittype[iActor].lastvx=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].lastvx, sActor, sPlayer); - break; + case ACTOR_HTLASTVX: + if (bSet) + hittype[iActor].lastvx=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].lastvx, sActor, sPlayer); + break; - case ACTOR_HTLASTVY: - if (bSet) - hittype[iActor].lastvy=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].lastvy, sActor, sPlayer); - break; + case ACTOR_HTLASTVY: + if (bSet) + hittype[iActor].lastvy=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].lastvy, sActor, sPlayer); + break; - case ACTOR_HTBPOSX: - if (bSet) - hittype[iActor].bposx=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].bposx, sActor, sPlayer); - break; + case ACTOR_HTBPOSX: + if (bSet) + hittype[iActor].bposx=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposx, sActor, sPlayer); + break; - case ACTOR_HTBPOSY: - if (bSet) - hittype[iActor].bposy=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].bposy, sActor, sPlayer); - break; + case ACTOR_HTBPOSY: + if (bSet) + hittype[iActor].bposy=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposy, sActor, sPlayer); + break; - case ACTOR_HTBPOSZ: - if (bSet) - hittype[iActor].bposz=lValue; - else - SetGameVarID((int)lVar2,hittype[iActor].bposz, sActor, sPlayer); - break; + case ACTOR_HTBPOSZ: + if (bSet) + hittype[iActor].bposz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposz, sActor, sPlayer); + break; - case ACTOR_HTG_T: - lTemp=lParm2; - if (bSet) - hittype[iActor].temp_data[lTemp]=lValue; - else - SetGameVarID((int)lVar2, hittype[iActor].temp_data[lTemp], sActor, sPlayer); - break; + case ACTOR_HTG_T: + lTemp=lParm2; + if (bSet) + hittype[iActor].temp_data[lTemp]=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].temp_data[lTemp], sActor, sPlayer); + break; - case ACTOR_ANGOFF: - if (bSet) - spriteext[iActor].angoff=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].angoff, sActor, sPlayer); - break; + case ACTOR_ANGOFF: + if (bSet) + spriteext[iActor].angoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].angoff, sActor, sPlayer); + break; - case ACTOR_PITCH: - if (bSet) - spriteext[iActor].pitch=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].pitch, sActor, sPlayer); - break; + case ACTOR_PITCH: + if (bSet) + spriteext[iActor].pitch=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].pitch, sActor, sPlayer); + break; - case ACTOR_ROLL: - if (bSet) - spriteext[iActor].roll=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].roll, sActor, sPlayer); - break; + case ACTOR_ROLL: + if (bSet) + spriteext[iActor].roll=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].roll, sActor, sPlayer); + break; - case ACTOR_MDXOFF: - if (bSet) - spriteext[iActor].xoff=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].xoff, sActor, sPlayer); - break; + case ACTOR_MDXOFF: + if (bSet) + spriteext[iActor].xoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].xoff, sActor, sPlayer); + break; - case ACTOR_MDYOFF: - if (bSet) - spriteext[iActor].yoff=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].yoff, sActor, sPlayer); - break; + case ACTOR_MDYOFF: + if (bSet) + spriteext[iActor].yoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].yoff, sActor, sPlayer); + break; - case ACTOR_MDZOFF: - if (bSet) - spriteext[iActor].zoff=lValue; - else - SetGameVarID((int)lVar2,spriteext[iActor].zoff, sActor, sPlayer); - break; + case ACTOR_MDZOFF: + if (bSet) + spriteext[iActor].zoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].zoff, sActor, sPlayer); + break; - default: - break; + default: + break; } return; } @@ -2808,204 +2808,204 @@ void DoProjectile(char bSet, long lVar1, long lLabelID, long lVar2, short sActor switch (lLabelID) { - case PROJ_WORKSLIKE: - if (bSet) - projectile[proj].workslike=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].workslike, sActor, sPlayer); - break; + case PROJ_WORKSLIKE: + if (bSet) + projectile[proj].workslike=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].workslike, sActor, sPlayer); + break; - case PROJ_SPAWNS: - if (bSet) - projectile[proj].spawns=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].spawns, sActor, sPlayer); - break; + case PROJ_SPAWNS: + if (bSet) + projectile[proj].spawns=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].spawns, sActor, sPlayer); + break; - case PROJ_SXREPEAT: - if (bSet) - projectile[proj].sxrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].sxrepeat, sActor, sPlayer); - break; + case PROJ_SXREPEAT: + if (bSet) + projectile[proj].sxrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].sxrepeat, sActor, sPlayer); + break; - case PROJ_SYREPEAT: - if (bSet) - projectile[proj].syrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].syrepeat, sActor, sPlayer); - break; + case PROJ_SYREPEAT: + if (bSet) + projectile[proj].syrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].syrepeat, sActor, sPlayer); + break; - case PROJ_SOUND: - if (bSet) - projectile[proj].sound=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].sound, sActor, sPlayer); - break; + case PROJ_SOUND: + if (bSet) + projectile[proj].sound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].sound, sActor, sPlayer); + break; - case PROJ_ISOUND: - if (bSet) - projectile[proj].isound=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].isound, sActor, sPlayer); - break; + case PROJ_ISOUND: + if (bSet) + projectile[proj].isound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].isound, sActor, sPlayer); + break; - case PROJ_VEL: - if (bSet) - projectile[proj].vel=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].vel, sActor, sPlayer); - break; + case PROJ_VEL: + if (bSet) + projectile[proj].vel=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].vel, sActor, sPlayer); + break; - case PROJ_EXTRA: - if (bSet) - projectile[proj].extra=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].extra, sActor, sPlayer); - break; + case PROJ_EXTRA: + if (bSet) + projectile[proj].extra=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].extra, sActor, sPlayer); + break; - case PROJ_DECAL: - if (bSet) - projectile[proj].decal=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].decal, sActor, sPlayer); - break; + case PROJ_DECAL: + if (bSet) + projectile[proj].decal=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].decal, sActor, sPlayer); + break; - case PROJ_TRAIL: - if (bSet) - projectile[proj].trail=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].trail, sActor, sPlayer); - break; + case PROJ_TRAIL: + if (bSet) + projectile[proj].trail=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].trail, sActor, sPlayer); + break; - case PROJ_TXREPEAT: - if (bSet) - projectile[proj].txrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].txrepeat, sActor, sPlayer); - break; + case PROJ_TXREPEAT: + if (bSet) + projectile[proj].txrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].txrepeat, sActor, sPlayer); + break; - case PROJ_TYREPEAT: - if (bSet) - projectile[proj].tyrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].tyrepeat, sActor, sPlayer); - break; + case PROJ_TYREPEAT: + if (bSet) + projectile[proj].tyrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].tyrepeat, sActor, sPlayer); + break; - case PROJ_TOFFSET: - if (bSet) - projectile[proj].toffset=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].toffset, sActor, sPlayer); - break; + case PROJ_TOFFSET: + if (bSet) + projectile[proj].toffset=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].toffset, sActor, sPlayer); + break; - case PROJ_TNUM: - if (bSet) - projectile[proj].tnum=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].tnum, sActor, sPlayer); - break; + case PROJ_TNUM: + if (bSet) + projectile[proj].tnum=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].tnum, sActor, sPlayer); + break; - case PROJ_DROP: - if (bSet) - projectile[proj].drop=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].drop, sActor, sPlayer); - break; + case PROJ_DROP: + if (bSet) + projectile[proj].drop=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].drop, sActor, sPlayer); + break; - case PROJ_CSTAT: - if (bSet) - projectile[proj].cstat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].cstat, sActor, sPlayer); - break; + case PROJ_CSTAT: + if (bSet) + projectile[proj].cstat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].cstat, sActor, sPlayer); + break; - case PROJ_CLIPDIST: - if (bSet) - projectile[proj].clipdist=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].clipdist, sActor, sPlayer); - break; + case PROJ_CLIPDIST: + if (bSet) + projectile[proj].clipdist=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].clipdist, sActor, sPlayer); + break; - case PROJ_SHADE: - if (bSet) - projectile[proj].shade=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].shade, sActor, sPlayer); - break; + case PROJ_SHADE: + if (bSet) + projectile[proj].shade=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].shade, sActor, sPlayer); + break; - case PROJ_XREPEAT: - if (bSet) - projectile[proj].xrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].xrepeat, sActor, sPlayer); - break; + case PROJ_XREPEAT: + if (bSet) + projectile[proj].xrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].xrepeat, sActor, sPlayer); + break; - case PROJ_YREPEAT: - if (bSet) - projectile[proj].yrepeat=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].yrepeat, sActor, sPlayer); - break; + case PROJ_YREPEAT: + if (bSet) + projectile[proj].yrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].yrepeat, sActor, sPlayer); + break; - case PROJ_PAL: - if (bSet) - projectile[proj].pal=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].pal, sActor, sPlayer); - break; + case PROJ_PAL: + if (bSet) + projectile[proj].pal=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].pal, sActor, sPlayer); + break; - case PROJ_EXTRA_RAND: - if (bSet) - projectile[proj].extra_rand=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].extra_rand, sActor, sPlayer); - break; + case PROJ_EXTRA_RAND: + if (bSet) + projectile[proj].extra_rand=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].extra_rand, sActor, sPlayer); + break; - case PROJ_HITRADIUS: - if (bSet) - projectile[proj].hitradius=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].hitradius, sActor, sPlayer); - break; + case PROJ_HITRADIUS: + if (bSet) + projectile[proj].hitradius=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].hitradius, sActor, sPlayer); + break; - case PROJ_VEL_MULT: - if (bSet) - projectile[proj].velmult=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].velmult, sActor, sPlayer); - break; + case PROJ_VEL_MULT: + if (bSet) + projectile[proj].velmult=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].velmult, sActor, sPlayer); + break; - case PROJ_OFFSET: - if (bSet) - projectile[proj].offset=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].offset, sActor, sPlayer); - break; + case PROJ_OFFSET: + if (bSet) + projectile[proj].offset=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].offset, sActor, sPlayer); + break; - case PROJ_BOUNCES: - if (bSet) - projectile[proj].bounces=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].bounces, sActor, sPlayer); - break; + case PROJ_BOUNCES: + if (bSet) + projectile[proj].bounces=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].bounces, sActor, sPlayer); + break; - case PROJ_BSOUND: - if (bSet) - projectile[proj].bsound=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].bsound, sActor, sPlayer); - break; + case PROJ_BSOUND: + if (bSet) + projectile[proj].bsound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].bsound, sActor, sPlayer); + break; - case PROJ_RANGE: - if (bSet) - projectile[proj].range=lValue; - else - SetGameVarID((int)lVar2, projectile[proj].range, sActor, sPlayer); - break; + case PROJ_RANGE: + if (bSet) + projectile[proj].range=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].range, sActor, sPlayer); + break; - default: - break; + default: + break; } return; } @@ -3592,3320 +3592,3320 @@ char parse(void) switch (tw) { - case CON_REDEFINEQUOTE: + case CON_REDEFINEQUOTE: + { + int q, i; + insptr++; + q = *insptr++; + i = *insptr++; + if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL) + OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i); + else Bstrcpy(fta_quotes[q],redefined_quotes[i]); + break; + } + + case CON_GETTHISPROJECTILE: + case CON_SETTHISPROJECTILE: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + DoThisProjectile(tw==CON_SETTHISPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); + break; + } + + case CON_IFRND: + insptr++; + parseifelse(rnd(*insptr)); + break; + + case CON_IFCANSHOOTTARGET: + + if (g_x > 1024) { - int q, i; - insptr++; - q = *insptr++; - i = *insptr++; - if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL) - OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i); - else Bstrcpy(fta_quotes[q],redefined_quotes[i]); - break; - } + short temphit, sclip, angdif; - case CON_GETTHISPROJECTILE: - case CON_SETTHISPROJECTILE: - { - // syntax [gs]etplayer[].x - // - long lLabelID; - long lVar1, lVar2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - lVar2=*insptr++; - DoThisProjectile(tw==CON_SETTHISPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); - break; - } - - case CON_IFRND: - insptr++; - parseifelse(rnd(*insptr)); - break; - - case CON_IFCANSHOOTTARGET: - - if (g_x > 1024) + if (badguy(g_sp) && g_sp->xrepeat > 56) { - short temphit, sclip, angdif; - - if (badguy(g_sp) && g_sp->xrepeat > 56) - { - sclip = 3084; - angdif = 48; - } - else - { - sclip = 768; - angdif = 16; - } - - j = hitasprite(g_i,&temphit); - if (j == (1<<30)) - { - parseifelse(1); - break; - } - if (j > sclip) - { - if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) - j = 0; - else - { - g_sp->ang += angdif; - j = hitasprite(g_i,&temphit); - g_sp->ang -= angdif; - if (j > sclip) - { - if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) - j = 0; - else - { - g_sp->ang -= angdif; - j = hitasprite(g_i,&temphit); - g_sp->ang += angdif; - if (j > 768) - { - if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) - j = 0; - else j = 1; - } - else j = 0; - } - } - else j = 0; - } - } - else j = 0; - } - else j = 1; - - parseifelse(j); - break; - - case CON_IFCANSEETARGET: - j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz/*-((TRAND&41)<<8)*/,sprite[ps[g_p].i].sectnum); - parseifelse(j); - if (j) hittype[g_i].timetosleep = SLEEPTIME; - break; - - case CON_IFACTORNOTSTAYPUT: - parseifelse(hittype[g_i].actorstayput == -1); - break; - - case CON_IFCANSEE: - { - spritetype *s; - - // select sprite for monster to target - // if holoduke is on, let them target holoduke first. - // - if (ps[g_p].holoduke_on >= 0) - { - s = &sprite[ps[g_p].holoduke_on]; - j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((32<<8)-1)),g_sp->sectnum, - s->x,s->y,s->z,s->sectnum); - - if (j == 0) - { - // they can't see player's holoduke - // check for player... - s = &sprite[ps[g_p].i]; - } - } - else s = &sprite[ps[g_p].i]; // holoduke not on. look for player - - // can they see player, (or player's holoduke) - j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum, - s->x,s->y,s->z-(24<<8),s->sectnum); - - if (j == 0) - { - // they can't see it. - - // Huh?. This does nothing.... - // (the result is always j==0....) - if ((klabs(hittype[g_i].lastvx-g_sp->x)+klabs(hittype[g_i].lastvy-g_sp->y)) < - (klabs(hittype[g_i].lastvx-s->x)+klabs(hittype[g_i].lastvy-s->y))) - j = 0; - - // um yeah, this if() will always fire.... - if (j == 0) - { - // search around for target player - - // also modifies 'target' x&y if found.. - - j = furthestcanseepoint(g_i,s,&hittype[g_i].lastvx,&hittype[g_i].lastvy); - - if (j == -1) j = 0; - else j = 1; - } + sclip = 3084; + angdif = 48; } else { - // else, they did see it. - // save where we were looking... - hittype[g_i].lastvx = s->x; - hittype[g_i].lastvy = s->y; + sclip = 768; + angdif = 16; } - if (j == 1 && (g_sp->statnum == 1 || g_sp->statnum == 6)) - hittype[g_i].timetosleep = SLEEPTIME; - - parseifelse(j == 1); - break; + j = hitasprite(g_i,&temphit); + if (j == (1<<30)) + { + parseifelse(1); + break; + } + if (j > sclip) + { + if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else + { + g_sp->ang += angdif; + j = hitasprite(g_i,&temphit); + g_sp->ang -= angdif; + if (j > sclip) + { + if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else + { + g_sp->ang -= angdif; + j = hitasprite(g_i,&temphit); + g_sp->ang += angdif; + if (j > 768) + { + if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else j = 1; + } + else j = 0; + } + } + else j = 0; + } + } + else j = 0; } + else j = 1; - case CON_IFHITWEAPON: - parseifelse(ifhitbyweapon(g_i) >= 0); - break; - - case CON_IFSQUISHED: - parseifelse(ifsquished(g_i, g_p) == 1); - break; - - case CON_IFDEAD: - { - j = g_sp->extra; - if (g_sp->picnum == APLAYER) - j--; - parseifelse(j < 0); - } + parseifelse(j); break; - case CON_AI: - insptr++; - g_t[5] = *insptr++; // Ai - g_t[4] = *(long *)(g_t[5]); // Action - g_t[1] = *(long *)(g_t[5]+4); // move - g_sp->hitag = *(long *)(g_t[5]+8); // move flags - g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ??? - if (g_sp->hitag&random_angle) - g_sp->ang = TRAND&2047; - break; + case CON_IFCANSEETARGET: + j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz/*-((TRAND&41)<<8)*/,sprite[ps[g_p].i].sectnum); + parseifelse(j); + if (j) hittype[g_i].timetosleep = SLEEPTIME; + break; - case CON_ACTION: - insptr++; - g_t[2] = 0; - g_t[3] = 0; - g_t[4] = *insptr++; - break; + case CON_IFACTORNOTSTAYPUT: + parseifelse(hittype[g_i].actorstayput == -1); + break; - case CON_IFPDISTL: - insptr++; - parseifelse(g_x < *insptr); - if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) - hittype[g_i].timetosleep = SLEEPTIME; - break; + case CON_IFCANSEE: + { + spritetype *s; - case CON_IFPDISTG: - insptr++; - parseifelse(g_x > *insptr); - if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) - hittype[g_i].timetosleep = SLEEPTIME; - break; + // select sprite for monster to target + // if holoduke is on, let them target holoduke first. + // + if (ps[g_p].holoduke_on >= 0) + { + s = &sprite[ps[g_p].holoduke_on]; + j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((32<<8)-1)),g_sp->sectnum, + s->x,s->y,s->z,s->sectnum); - case CON_ELSE: - insptr = (long *) *(insptr+1); - break; - - case CON_ADDSTRENGTH: - insptr++; - g_sp->extra += *insptr++; - break; - - case CON_STRENGTH: - insptr++; - g_sp->extra = *insptr++; - break; - - case CON_IFGOTWEAPONCE: - insptr++; - - if ((gametype_flags[ud.coop]&GAMETYPE_FLAG_WEAPSTAY) && ud.multimode > 1) + if (j == 0) { - if (*insptr == 0) - { - for (j=0;j < ps[g_p].weapreccnt;j++) - if (ps[g_p].weaprecs[j] == g_sp->picnum) - break; - - parseifelse(j < ps[g_p].weapreccnt && g_sp->owner == g_i); - } - else if (ps[g_p].weapreccnt < 16) - { - ps[g_p].weaprecs[ps[g_p].weapreccnt++] = g_sp->picnum; - parseifelse(g_sp->owner == g_i); - } + // they can't see player's holoduke + // check for player... + s = &sprite[ps[g_p].i]; } - else parseifelse(0); - break; + } + else s = &sprite[ps[g_p].i]; // holoduke not on. look for player - case CON_GETLASTPAL: - insptr++; - if (g_sp->picnum == APLAYER) - g_sp->pal = ps[g_sp->yvel].palookup; - else g_sp->pal = hittype[g_i].tempang; - hittype[g_i].tempang = 0; - break; + // can they see player, (or player's holoduke) + j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum, + s->x,s->y,s->z-(24<<8),s->sectnum); - case CON_TOSSWEAPON: - insptr++; - checkweapons(&ps[g_sp->yvel]); - break; + if (j == 0) + { + // they can't see it. - case CON_NULLOP: - insptr++; - break; + // Huh?. This does nothing.... + // (the result is always j==0....) + if ((klabs(hittype[g_i].lastvx-g_sp->x)+klabs(hittype[g_i].lastvy-g_sp->y)) < + (klabs(hittype[g_i].lastvx-s->x)+klabs(hittype[g_i].lastvy-s->y))) + j = 0; - case CON_MIKESND: - insptr++; - if (!isspritemakingsound(g_i,g_sp->yvel)) - spritesound(g_sp->yvel,g_i); - break; - - case CON_PKICK: - insptr++; - - if (ud.multimode > 1 && g_sp->picnum == APLAYER) + // um yeah, this if() will always fire.... + if (j == 0) { - if (ps[otherp].quick_kick == 0) - ps[otherp].quick_kick = 14; + // search around for target player + + // also modifies 'target' x&y if found.. + + j = furthestcanseepoint(g_i,s,&hittype[g_i].lastvx,&hittype[g_i].lastvy); + + if (j == -1) j = 0; + else j = 1; } - else if (g_sp->picnum != APLAYER && ps[g_p].quick_kick == 0) - ps[g_p].quick_kick = 14; - break; + } + else + { + // else, they did see it. + // save where we were looking... + hittype[g_i].lastvx = s->x; + hittype[g_i].lastvy = s->y; + } - case CON_SIZETO: - insptr++; + if (j == 1 && (g_sp->statnum == 1 || g_sp->statnum == 6)) + hittype[g_i].timetosleep = SLEEPTIME; - j = (*insptr++-g_sp->xrepeat)<<1; - g_sp->xrepeat += ksgn(j); + parseifelse(j == 1); + break; + } - if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (hittype[g_i].floorz - hittype[g_i].ceilingz)) + case CON_IFHITWEAPON: + parseifelse(ifhitbyweapon(g_i) >= 0); + break; + + case CON_IFSQUISHED: + parseifelse(ifsquished(g_i, g_p) == 1); + break; + + case CON_IFDEAD: + { + j = g_sp->extra; + if (g_sp->picnum == APLAYER) + j--; + parseifelse(j < 0); + } + break; + + case CON_AI: + insptr++; + g_t[5] = *insptr++; // Ai + g_t[4] = *(long *)(g_t[5]); // Action + g_t[1] = *(long *)(g_t[5]+4); // move + g_sp->hitag = *(long *)(g_t[5]+8); // move flags + g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ??? + if (g_sp->hitag&random_angle) + g_sp->ang = TRAND&2047; + break; + + case CON_ACTION: + insptr++; + g_t[2] = 0; + g_t[3] = 0; + g_t[4] = *insptr++; + break; + + case CON_IFPDISTL: + insptr++; + parseifelse(g_x < *insptr); + if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) + hittype[g_i].timetosleep = SLEEPTIME; + break; + + case CON_IFPDISTG: + insptr++; + parseifelse(g_x > *insptr); + if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) + hittype[g_i].timetosleep = SLEEPTIME; + break; + + case CON_ELSE: + insptr = (long *) *(insptr+1); + break; + + case CON_ADDSTRENGTH: + insptr++; + g_sp->extra += *insptr++; + break; + + case CON_STRENGTH: + insptr++; + g_sp->extra = *insptr++; + break; + + case CON_IFGOTWEAPONCE: + insptr++; + + if ((gametype_flags[ud.coop]&GAMETYPE_FLAG_WEAPSTAY) && ud.multimode > 1) + { + if (*insptr == 0) { - j = ((*insptr)-g_sp->yrepeat)<<1; - if (klabs(j)) g_sp->yrepeat += ksgn(j); + for (j=0;j < ps[g_p].weapreccnt;j++) + if (ps[g_p].weaprecs[j] == g_sp->picnum) + break; + + parseifelse(j < ps[g_p].weapreccnt && g_sp->owner == g_i); } - insptr++; - - break; - - case CON_SIZEAT: - insptr++; - g_sp->xrepeat = (char) *insptr++; - g_sp->yrepeat = (char) *insptr++; - break; - - case CON_SHOOT: - insptr++; - shoot(g_i,(short)*insptr++); - break; - - case CON_SOUNDONCE: - insptr++; - if (!isspritemakingsound(g_i,*insptr)) - spritesound((short) *insptr,g_i); - insptr++; - break; - - case CON_IFSOUND: - insptr++; - parseifelse(isspritemakingsound(g_i,*insptr)); - // parseifelse(SoundOwner[*insptr][0].i == g_i); - break; - - case CON_STOPSOUND: - insptr++; - if (isspritemakingsound(g_i,*insptr)) - stopspritesound((short)*insptr,g_i); - insptr++; - break; - - case CON_GLOBALSOUND: - insptr++; - if (g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) - spritesound((short) *insptr,ps[screenpeek].i); - insptr++; - break; - - case CON_SOUND: - insptr++; - spritesound((short) *insptr++,g_i); - break; - - case CON_TIP: - insptr++; - ps[g_p].tipincs = 26; - break; - - case CON_FALL: - insptr++; - g_sp->xoffset = 0; - g_sp->yoffset = 0; - // if(!gotz) + else if (ps[g_p].weapreccnt < 16) { - long c; + ps[g_p].weaprecs[ps[g_p].weapreccnt++] = g_sp->picnum; + parseifelse(g_sp->owner == g_i); + } + } + else parseifelse(0); + break; - if (floorspace(g_sp->sectnum)) - c = 0; - else + case CON_GETLASTPAL: + insptr++; + if (g_sp->picnum == APLAYER) + g_sp->pal = ps[g_sp->yvel].palookup; + else g_sp->pal = hittype[g_i].tempang; + hittype[g_i].tempang = 0; + break; + + case CON_TOSSWEAPON: + insptr++; + checkweapons(&ps[g_sp->yvel]); + break; + + case CON_NULLOP: + insptr++; + break; + + case CON_MIKESND: + insptr++; + if (!isspritemakingsound(g_i,g_sp->yvel)) + spritesound(g_sp->yvel,g_i); + break; + + case CON_PKICK: + insptr++; + + if (ud.multimode > 1 && g_sp->picnum == APLAYER) + { + if (ps[otherp].quick_kick == 0) + ps[otherp].quick_kick = 14; + } + else if (g_sp->picnum != APLAYER && ps[g_p].quick_kick == 0) + ps[g_p].quick_kick = 14; + break; + + case CON_SIZETO: + insptr++; + + j = (*insptr++-g_sp->xrepeat)<<1; + g_sp->xrepeat += ksgn(j); + + if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (hittype[g_i].floorz - hittype[g_i].ceilingz)) + { + j = ((*insptr)-g_sp->yrepeat)<<1; + if (klabs(j)) g_sp->yrepeat += ksgn(j); + } + insptr++; + + break; + + case CON_SIZEAT: + insptr++; + g_sp->xrepeat = (char) *insptr++; + g_sp->yrepeat = (char) *insptr++; + break; + + case CON_SHOOT: + insptr++; + shoot(g_i,(short)*insptr++); + break; + + case CON_SOUNDONCE: + insptr++; + if (!isspritemakingsound(g_i,*insptr)) + spritesound((short) *insptr,g_i); + insptr++; + break; + + case CON_IFSOUND: + insptr++; + parseifelse(isspritemakingsound(g_i,*insptr)); + // parseifelse(SoundOwner[*insptr][0].i == g_i); + break; + + case CON_STOPSOUND: + insptr++; + if (isspritemakingsound(g_i,*insptr)) + stopspritesound((short)*insptr,g_i); + insptr++; + break; + + case CON_GLOBALSOUND: + insptr++; + if (g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) + spritesound((short) *insptr,ps[screenpeek].i); + insptr++; + break; + + case CON_SOUND: + insptr++; + spritesound((short) *insptr++,g_i); + break; + + case CON_TIP: + insptr++; + ps[g_p].tipincs = 26; + break; + + case CON_FALL: + insptr++; + g_sp->xoffset = 0; + g_sp->yoffset = 0; + // if(!gotz) + { + long c; + + if (floorspace(g_sp->sectnum)) + c = 0; + else + { + if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) + c = gc/6; + else c = gc; + } + + if (hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat&2)) + { + getglobalz(g_i); + hittype[g_i].cgg = 6; + } + else hittype[g_i].cgg --; + + if (g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT)) + { + g_sp->zvel += c; + g_sp->z+=g_sp->zvel; + + if (g_sp->zvel > 6144) g_sp->zvel = 6144; + } + else + { + g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; + + if (badguy(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0)) { - if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) - c = gc/6; - else c = gc; - } - if (hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat&2)) - { - getglobalz(g_i); - hittype[g_i].cgg = 6; - } - else hittype[g_i].cgg --; - - if (g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT)) - { - g_sp->zvel += c; - g_sp->z+=g_sp->zvel; - - if (g_sp->zvel > 6144) g_sp->zvel = 6144; - } - else - { - g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; - - if (badguy(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0)) + if (g_sp->zvel > 3084 && g_sp->extra <= 1) { - - if (g_sp->zvel > 3084 && g_sp->extra <= 1) + if (g_sp->pal != 1 && g_sp->picnum != DRONE) { - if (g_sp->pal != 1 && g_sp->picnum != DRONE) - { - if (g_sp->picnum == APLAYER && g_sp->extra > 0) - goto SKIPJIBS; - guts(g_sp,JIBS6,15,g_p); - spritesound(SQUISHED,g_i); - spawn(g_i,BLOODPOOL); - } + if (g_sp->picnum == APLAYER && g_sp->extra > 0) + goto SKIPJIBS; + guts(g_sp,JIBS6,15,g_p); + spritesound(SQUISHED,g_i); + spawn(g_i,BLOODPOOL); + } SKIPJIBS: - hittype[g_i].picnum = SHOTSPARK1; - hittype[g_i].extra = 1; - g_sp->zvel = 0; - } - else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1) - { - - j = g_sp->sectnum; - pushmove(&g_sp->x,&g_sp->y,&g_sp->z,(short*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); - if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS) - changespritesect(g_i,j); - - spritesound(THUD,g_i); - } + hittype[g_i].picnum = SHOTSPARK1; + hittype[g_i].extra = 1; + g_sp->zvel = 0; + } + else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1) + { + + j = g_sp->sectnum; + pushmove(&g_sp->x,&g_sp->y,&g_sp->z,(short*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS) + changespritesect(g_i,j); + + spritesound(THUD,g_i); } - if (sector[g_sp->sectnum].lotag == 1) - switch (dynamictostatic[g_sp->picnum]) - { - case OCTABRAIN__STATIC: - case COMMANDER__STATIC: - case DRONE__STATIC: - break; - default: - g_sp->z += (24<<8); - break; - } - else g_sp->zvel = 0; } + if (sector[g_sp->sectnum].lotag == 1) + switch (dynamictostatic[g_sp->picnum]) + { + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case DRONE__STATIC: + break; + default: + g_sp->z += (24<<8); + break; + } + else g_sp->zvel = 0; } + } + break; + + case CON_ENDA: + case CON_BREAK: + case CON_ENDS: + return 1; + case CON_RIGHTBRACE: + insptr++; + return 1; + case CON_ADDAMMO: + insptr++; + if (ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr]) + { + killit_flag = 2; break; - - case CON_ENDA: - case CON_BREAK: - case CON_ENDS: - return 1; - case CON_RIGHTBRACE: - insptr++; - return 1; - case CON_ADDAMMO: - insptr++; - if (ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr]) - { - killit_flag = 2; - break; - } - addammo(*insptr, &ps[g_p], *(insptr+1)); - if (ps[g_p].curr_weapon == KNEE_WEAPON) - if (ps[g_p].gotweapon[*insptr]) - { - if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); - else addweapon(&ps[g_p], *insptr); - } - insptr += 2; - break; - - case CON_MONEY: - insptr++; - lotsofmoney(g_sp,*insptr++); - break; - - case CON_MAIL: - insptr++; - lotsofmail(g_sp,*insptr++); - break; - - case CON_SLEEPTIME: - insptr++; - hittype[g_i].timetosleep = (short)*insptr++; - break; - - case CON_PAPER: - insptr++; - lotsofpaper(g_sp,*insptr++); - break; - - case CON_ADDKILLS: - insptr++; - ps[g_p].actors_killed += *insptr++; - hittype[g_i].actorstayput = -1; - break; - - case CON_LOTSOFGLASS: - insptr++; - spriteglass(g_i,*insptr++); - break; - - case CON_KILLIT: - insptr++; - killit_flag = 1; - break; - - case CON_ADDWEAPON: - insptr++; - if (ps[g_p].gotweapon[*insptr] == 0) + } + addammo(*insptr, &ps[g_p], *(insptr+1)); + if (ps[g_p].curr_weapon == KNEE_WEAPON) + if (ps[g_p].gotweapon[*insptr]) { if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); else addweapon(&ps[g_p], *insptr); } - else if (ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr]) + insptr += 2; + break; + + case CON_MONEY: + insptr++; + lotsofmoney(g_sp,*insptr++); + break; + + case CON_MAIL: + insptr++; + lotsofmail(g_sp,*insptr++); + break; + + case CON_SLEEPTIME: + insptr++; + hittype[g_i].timetosleep = (short)*insptr++; + break; + + case CON_PAPER: + insptr++; + lotsofpaper(g_sp,*insptr++); + break; + + case CON_ADDKILLS: + insptr++; + ps[g_p].actors_killed += *insptr++; + hittype[g_i].actorstayput = -1; + break; + + case CON_LOTSOFGLASS: + insptr++; + spriteglass(g_i,*insptr++); + break; + + case CON_KILLIT: + insptr++; + killit_flag = 1; + break; + + case CON_ADDWEAPON: + insptr++; + if (ps[g_p].gotweapon[*insptr] == 0) + { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); + else addweapon(&ps[g_p], *insptr); + } + else if (ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr]) + { + killit_flag = 2; + break; + } + addammo(*insptr, &ps[g_p], *(insptr+1)); + if (ps[g_p].curr_weapon == KNEE_WEAPON) + if (ps[g_p].gotweapon[*insptr]) { - killit_flag = 2; + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); + else addweapon(&ps[g_p], *insptr); + } + insptr+=2; + break; + + case CON_DEBUG: + insptr++; + initprintf("%ld\n",*insptr++); + break; + + case CON_ENDOFGAME: + insptr++; + ps[g_p].timebeforeexit = *insptr++; + ps[g_p].customexitsound = -1; + ud.eog = 1; + break; + + case CON_ADDPHEALTH: + insptr++; + + if (ps[g_p].newowner >= 0) + { + ps[g_p].newowner = -1; + ps[g_p].posx = ps[g_p].oposx; + ps[g_p].posy = ps[g_p].oposy; + ps[g_p].posz = ps[g_p].oposz; + ps[g_p].ang = ps[g_p].oang; + updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); + setpal(&ps[g_p]); + + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum==CAMERA1) + sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + j = sprite[ps[g_p].i].extra; + + if (g_sp->picnum != ATOMICHEALTH) + { + if (j > max_player_health && *insptr > 0) + { + insptr++; break; } - addammo(*insptr, &ps[g_p], *(insptr+1)); - if (ps[g_p].curr_weapon == KNEE_WEAPON) - if (ps[g_p].gotweapon[*insptr]) - { - if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); - else addweapon(&ps[g_p], *insptr); - } - insptr+=2; - break; - - case CON_DEBUG: - insptr++; - initprintf("%ld\n",*insptr++); - break; - - case CON_ENDOFGAME: - insptr++; - ps[g_p].timebeforeexit = *insptr++; - ps[g_p].customexitsound = -1; - ud.eog = 1; - break; - - case CON_ADDPHEALTH: - insptr++; - - if (ps[g_p].newowner >= 0) - { - ps[g_p].newowner = -1; - ps[g_p].posx = ps[g_p].oposx; - ps[g_p].posy = ps[g_p].oposy; - ps[g_p].posz = ps[g_p].oposz; - ps[g_p].ang = ps[g_p].oang; - updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); - setpal(&ps[g_p]); - - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].picnum==CAMERA1) - sprite[j].yvel = 0; - j = nextspritestat[j]; - } - } - - j = sprite[ps[g_p].i].extra; - - if (g_sp->picnum != ATOMICHEALTH) - { - if (j > max_player_health && *insptr > 0) - { - insptr++; - break; - } - else - { - if (j > 0) - j += *insptr; - if (j > max_player_health && *insptr > 0) - j = max_player_health; - } - } else { if (j > 0) j += *insptr; - if (j > (max_player_health<<1)) - j = (max_player_health<<1); + if (j > max_player_health && *insptr > 0) + j = max_player_health; } - - if (j < 0) j = 0; - - if (ud.god == 0) - { - if (*insptr > 0) - { - if ((j - *insptr) < (max_player_health>>2) && - j >= (max_player_health>>2)) - spritesound(DUKE_GOTHEALTHATLOW,ps[g_p].i); - - ps[g_p].last_extra = j; - } - - sprite[ps[g_p].i].extra = j; - } - - insptr++; - break; - - case CON_STATE: - { - long *tempscrptr; - - tempscrptr = insptr+2; - - insptr = (long *) *(insptr+1); - while (1) if (parse()) break; - insptr = tempscrptr; } + else + { + if (j > 0) + j += *insptr; + if (j > (max_player_health<<1)) + j = (max_player_health<<1); + } + + if (j < 0) j = 0; + + if (ud.god == 0) + { + if (*insptr > 0) + { + if ((j - *insptr) < (max_player_health>>2) && + j >= (max_player_health>>2)) + spritesound(DUKE_GOTHEALTHATLOW,ps[g_p].i); + + ps[g_p].last_extra = j; + } + + sprite[ps[g_p].i].extra = j; + } + + insptr++; break; - case CON_LEFTBRACE: - insptr++; - while (1) if (parse()) break; - break; + case CON_STATE: + { + long *tempscrptr; - case CON_MOVE: - insptr++; - g_t[0]=0; - g_t[1] = *insptr++; - g_sp->hitag = *insptr++; - if (g_sp->hitag&random_angle) - g_sp->ang = TRAND&2047; - break; + tempscrptr = insptr+2; - case CON_ADDWEAPONVAR: - insptr++; - if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0) + insptr = (long *) *(insptr+1); + while (1) if (parse()) break; + insptr = tempscrptr; + } + break; + + case CON_LEFTBRACE: + insptr++; + while (1) if (parse()) break; + break; + + case CON_MOVE: + insptr++; + g_t[0]=0; + g_t[1] = *insptr++; + g_sp->hitag = *insptr++; + if (g_sp->hitag&random_angle) + g_sp->ang = TRAND&2047; + break; + + case CON_ADDWEAPONVAR: + insptr++; + if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0) + { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); + else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); + } + else if (ps[g_p].ammo_amount[GetGameVarID(*(insptr),g_i,g_p)] >= max_ammo_amount[GetGameVarID(*(insptr),g_i,g_p)]) + { + killit_flag = 2; + break; + } + addammo(GetGameVarID(*(insptr),g_i,g_p), &ps[g_p], GetGameVarID(*(insptr+1),g_i,g_p)); + if (ps[g_p].curr_weapon == KNEE_WEAPON) + if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)]) { if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); } - else if (ps[g_p].ammo_amount[GetGameVarID(*(insptr),g_i,g_p)] >= max_ammo_amount[GetGameVarID(*(insptr),g_i,g_p)]) - { - killit_flag = 2; - break; - } - addammo(GetGameVarID(*(insptr),g_i,g_p), &ps[g_p], GetGameVarID(*(insptr+1),g_i,g_p)); - if (ps[g_p].curr_weapon == KNEE_WEAPON) - if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)]) - { - if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); - else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); - } - insptr+=2; - break; + insptr+=2; + break; + case CON_ACTIVATEBYSECTOR: + case CON_OPERATESECTORS: + case CON_OPERATEACTIVATORS: + case CON_SETASPECT: + case CON_SSP: + { + long var1, var2; + + insptr++; + + var1 = GetGameVarID(*insptr++,g_i,g_p); + if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) + { + var2 = g_p; + insptr++; + } + else var2 = GetGameVarID(*insptr++,g_i,g_p); + + switch (tw) + { case CON_ACTIVATEBYSECTOR: + activatebysector(var1, var2); + break; case CON_OPERATESECTORS: + operatesectors(var1, var2); + break; case CON_OPERATEACTIVATORS: + operateactivators(var1, var2); + break; case CON_SETASPECT: + setaspect(var1, var2); + break; case CON_SSP: - { - long var1, var2; - - insptr++; - - var1 = GetGameVarID(*insptr++,g_i,g_p); - if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) - { - var2 = g_p; - insptr++; - } - else var2 = GetGameVarID(*insptr++,g_i,g_p); - - switch (tw) - { - case CON_ACTIVATEBYSECTOR: - activatebysector(var1, var2); - break; - case CON_OPERATESECTORS: - operatesectors(var1, var2); - break; - case CON_OPERATEACTIVATORS: - operateactivators(var1, var2); - break; - case CON_SETASPECT: - setaspect(var1, var2); - break; - case CON_SSP: - ssp(var1, var2); - break; - } + ssp(var1, var2); break; } + break; + } - case CON_CANSEESPR: + case CON_CANSEESPR: + { + long lVar1, lVar2, lVar3; + + insptr++; + + lVar1 = GetGameVarID(*insptr++,g_i,g_p); + lVar2 = GetGameVarID(*insptr++,g_i,g_p); + lVar3 = *insptr++; + + SetGameVarID(lVar3, cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum, + sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum), g_i, g_p); + break; + } + + case CON_OPERATERESPAWNS: + case CON_OPERATEMASTERSWITCHES: + case CON_CHECKACTIVATORMOTION: + { + long var1; + + insptr++; + var1 = GetGameVarID(*insptr++,g_i,g_p); + + switch (tw) { - long lVar1, lVar2, lVar3; - - insptr++; - - lVar1 = GetGameVarID(*insptr++,g_i,g_p); - lVar2 = GetGameVarID(*insptr++,g_i,g_p); - lVar3 = *insptr++; - - SetGameVarID(lVar3, cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum, - sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum), g_i, g_p); - break; - } - case CON_OPERATERESPAWNS: + operaterespawns(var1); + break; case CON_OPERATEMASTERSWITCHES: + operatemasterswitches(var1); + break; case CON_CHECKACTIVATORMOTION: - { - long var1; - - insptr++; - var1 = GetGameVarID(*insptr++,g_i,g_p); - - switch (tw) - { - case CON_OPERATERESPAWNS: - operaterespawns(var1); - break; - case CON_OPERATEMASTERSWITCHES: - operatemasterswitches(var1); - break; - case CON_CHECKACTIVATORMOTION: - SetGameVarID(g_iReturnVarID, check_activator_motion(var1), g_i, g_p); - break; - } + SetGameVarID(g_iReturnVarID, check_activator_motion(var1), g_i, g_p); break; } + break; + } - case CON_INSERTSPRITEQ: - insptr++; - insertspriteq(g_i); - break; + case CON_INSERTSPRITEQ: + insptr++; + insertspriteq(g_i); + break; - case CON_QSTRLEN: + case CON_QSTRLEN: + { + int i,j; + insptr++; + i=*insptr++; + j=GetGameVarID(*insptr++, g_i, g_p); + if (fta_quotes[j] != NULL) + SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); + else SetGameVarID(i,-1,g_i,g_p); + break; + } + + case CON_GETPNAME: + case CON_QSTRCAT: + case CON_QSTRCPY: + case CON_CHANGESPRITESTAT: + case CON_CHANGESPRITESECT: + { + int i,j; + insptr++; + + i = GetGameVarID(*insptr++, g_i, g_p); + if (tw == CON_GETPNAME && *insptr == g_iThisActorID) { - int i,j; + j = g_p; insptr++; - i=*insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); - if (fta_quotes[j] != NULL) - SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); - else SetGameVarID(i,-1,g_i,g_p); - break; } + else j = GetGameVarID(*insptr++, g_i, g_p); + switch (tw) + { case CON_GETPNAME: + if (fta_quotes[i] != NULL) + { + if (ud.user_name[j][0]) + Bstrcpy(fta_quotes[i],ud.user_name[j]); + else Bsprintf(fta_quotes[i],"%d",j); + } + else OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,i); + break; case CON_QSTRCAT: + if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) + Bstrncat(fta_quotes[i],fta_quotes[j],(MAXQUOTELEN-1)-Bstrlen(fta_quotes[i])); + else OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); + break; case CON_QSTRCPY: + if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) + Bstrcpy(fta_quotes[i],fta_quotes[j]); + else OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); + break; case CON_CHANGESPRITESTAT: + changespritestat(i,j); + break; case CON_CHANGESPRITESECT: + changespritesect(i,j); + break; + } + break; + } + + case CON_STARTLEVEL: + { + // from 'level' cheat in game.c (about line 6250) + long volnume; + long levnume; + int i; + + insptr++; // skip command + volnume=GetGameVarID(*insptr++,g_i,g_p); + levnume=GetGameVarID(*insptr++,g_i,g_p); + + if (volnume > num_volumes || volnume < 0) { - int i,j; - insptr++; - - i = GetGameVarID(*insptr++, g_i, g_p); - if (tw == CON_GETPNAME && *insptr == g_iThisActorID) + /* + if(g_cmddebug&CMDDEBUG_COMPILE) { - j = g_p; - insptr++; - } - else j = GetGameVarID(*insptr++, g_i, g_p); - - switch (tw) - { - case CON_GETPNAME: - if (fta_quotes[i] != NULL) - { - if (ud.user_name[j][0]) - Bstrcpy(fta_quotes[i],ud.user_name[j]); - else Bsprintf(fta_quotes[i],"%d",j); - } - else OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,i); - break; - case CON_QSTRCAT: - if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) - Bstrncat(fta_quotes[i],fta_quotes[j],(MAXQUOTELEN-1)-Bstrlen(fta_quotes[i])); - else OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); - break; - case CON_QSTRCPY: - if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) - Bstrcpy(fta_quotes[i],fta_quotes[j]); - else OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); - break; - case CON_CHANGESPRITESTAT: - changespritestat(i,j); - break; - case CON_CHANGESPRITESECT: - changespritesect(i,j); - break; + Bsprintf(g_szBuf,"startlevel: Invalid Volume number: %ld. Command ignored.",volnume); + AddLog(g_szBuf); } + */ break; } - case CON_STARTLEVEL: + if (levnume >= 11 || levnume <0) { - // from 'level' cheat in game.c (about line 6250) - long volnume; - long levnume; - int i; - - insptr++; // skip command - volnume=GetGameVarID(*insptr++,g_i,g_p); - levnume=GetGameVarID(*insptr++,g_i,g_p); - - if (volnume > num_volumes || volnume < 0) + /* + if(g_cmddebug&CMDDEBUG_COMPILE) { - /* - if(g_cmddebug&CMDDEBUG_COMPILE) - { - Bsprintf(g_szBuf,"startlevel: Invalid Volume number: %ld. Command ignored.",volnume); - AddLog(g_szBuf); - } - */ - break; + Bsprintf(g_szBuf,"startlevel: Invalid Level number: %ld. Command ignored.",levnume); + AddLog(g_szBuf); } + */ + break; + } - if (levnume >= 11 || levnume <0) + ud.m_volume_number = ud.volume_number = volnume; + ud.m_level_number = ud.level_number = levnume; + if (numplayers > 1 && myconnectindex == connecthead) + { + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill; + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + tempbuf[11] = ud.m_noexits; + + for (i=connecthead;i>=0;i=connectpoint2[i]) { - /* - if(g_cmddebug&CMDDEBUG_COMPILE) - { - Bsprintf(g_szBuf,"startlevel: Invalid Level number: %ld. Command ignored.",levnume); - AddLog(g_szBuf); - } - */ - break; + if (i != myconnectindex) sendpacket(i,tempbuf,12); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } + } + else + { + ps[myconnectindex].gm |= MODE_EOL; + display_bonus_screen = 0; + } // MODE_RESTART; - ud.m_volume_number = ud.volume_number = volnume; - ud.m_level_number = ud.level_number = levnume; - if (numplayers > 1 && myconnectindex == connecthead) + break; + } + + case CON_MYOSX: + case CON_MYOSPALX: + case CON_MYOS: + case CON_MYOSPAL: + { + long x,y; + short tilenum; + signed char shade; + char orientation; + char pal; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + tilenum=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + orientation=GetGameVarID(*insptr++,g_i,g_p); + + switch (tw) + { + case CON_MYOS: + myos(x,y,tilenum,shade,orientation); + break; + case CON_MYOSPAL: + pal=GetGameVarID(*insptr++,g_i,g_p); + myospal(x,y,tilenum,shade,orientation,pal); + break; + case CON_MYOSX: + myosx(x,y,tilenum,shade,orientation); + break; + case CON_MYOSPALX: + pal=GetGameVarID(*insptr++,g_i,g_p); + myospalx(x,y,tilenum,shade,orientation,pal); + break; + } + break; + } + + case CON_SWITCH: + { + long lVarID; + long lValue; + long *lpDefault; + long *lpCases; + long lCases; + long lEnd; + long lCheckCase; + char bMatched; + long *lTempInsPtr; + + // command format: + // variable ID to check + // script offset to 'end' + // count of case statements + // script offset to default case (null if none) + // For each case: value, ptr to code + //AddLog("Processing Switch..."); + insptr++; // p-code + lVarID=*insptr++; + lValue=GetGameVarID(lVarID, g_i, g_p); + lEnd=*insptr++; + lCases=*insptr++; + lpDefault=insptr++; + lpCases=insptr; + insptr+=lCases*2; + bMatched=0; + lTempInsPtr=insptr; + //Bsprintf(g_szBuf,"lEnd= %ld *lpDefault=%ld",lEnd,*lpDefault); + //AddLog(g_szBuf); + + //Bsprintf(g_szBuf,"Checking %ld cases for %ld",lCases, lValue); + //AddLog(g_szBuf); + for (lCheckCase=0; lCheckCase=0;i=connectpoint2[i]) + //AddLog("Found Case Match"); + //Bsprintf(g_szBuf,"insptr=%ld. lCheckCase=%ld, offset=%ld, &script[0]=%ld", + // (long)insptr,(long)lCheckCase,lpCases[lCheckCase*2+1],(long)&script[0]); + //AddLog(g_szBuf); + // fake a 2-d Array + insptr=(long*)(lpCases[lCheckCase*2+1] + &script[0]); + //Bsprintf(g_szBuf,"insptr=%ld. ", (long)insptr); + //AddLog(g_szBuf); + while (1) { - if (i != myconnectindex) sendpacket(i,tempbuf,12); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (parse()) + break; } + //AddLog("Done Executing Case"); + bMatched=1; + } + } + if (!bMatched) + { + if (*lpDefault) + { + //AddLog("No Matching Case: Using Default"); + insptr=(long*)(*lpDefault + &script[0]); + while (1) if (parse()) break; } else { - ps[myconnectindex].gm |= MODE_EOL; - display_bonus_screen = 0; - } // MODE_RESTART; - - break; - } - - case CON_MYOSX: - case CON_MYOSPALX: - case CON_MYOS: - case CON_MYOSPAL: - { - long x,y; - short tilenum; - signed char shade; - char orientation; - char pal; - - insptr++; - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - tilenum=GetGameVarID(*insptr++,g_i,g_p); - shade=GetGameVarID(*insptr++,g_i,g_p); - orientation=GetGameVarID(*insptr++,g_i,g_p); - - switch (tw) - { - case CON_MYOS: - myos(x,y,tilenum,shade,orientation); - break; - case CON_MYOSPAL: - pal=GetGameVarID(*insptr++,g_i,g_p); - myospal(x,y,tilenum,shade,orientation,pal); - break; - case CON_MYOSX: - myosx(x,y,tilenum,shade,orientation); - break; - case CON_MYOSPALX: - pal=GetGameVarID(*insptr++,g_i,g_p); - myospalx(x,y,tilenum,shade,orientation,pal); - break; + //AddLog("No Matching Case: No Default to use"); } - break; } + insptr=(long*)(lEnd + (long)&script[0]); + //Bsprintf(g_szBuf,"insptr=%ld. ", (long)insptr); + //AddLog(g_szBuf); + //AddLog("Done Processing Switch"); - case CON_SWITCH: + break; + } + + case CON_ENDSWITCH: + case CON_ENDEVENT: + insptr++; + return 1; + break; + + case CON_DISPLAYRAND: + { + int i; + insptr++; + + i=*insptr++; // ID of def + SetGameVarID(i, rand(), g_i, g_p); + break; + } + + case CON_DRAGPOINT: + { + short wallnum; + long newx, newy; + + insptr++; + wallnum = GetGameVarID(*insptr++, g_i, g_p); + newx = GetGameVarID(*insptr++, g_i, g_p); + newy = GetGameVarID(*insptr++, g_i, g_p); + + dragpoint(wallnum,newx,newy); + break; + } + + case CON_DIST: + case CON_LDIST: + { + long distvar, xvar, yvar, distx=0; + + insptr++; + distvar = *insptr++; + xvar = *insptr++; + yvar = *insptr++; + + switch (tw) { - long lVarID; - long lValue; - long *lpDefault; - long *lpCases; - long lCases; - long lEnd; - long lCheckCase; - char bMatched; - long *lTempInsPtr; - - // command format: - // variable ID to check - // script offset to 'end' - // count of case statements - // script offset to default case (null if none) - // For each case: value, ptr to code - //AddLog("Processing Switch..."); - insptr++; // p-code - lVarID=*insptr++; - lValue=GetGameVarID(lVarID, g_i, g_p); - lEnd=*insptr++; - lCases=*insptr++; - lpDefault=insptr++; - lpCases=insptr; - insptr+=lCases*2; - bMatched=0; - lTempInsPtr=insptr; - //Bsprintf(g_szBuf,"lEnd= %ld *lpDefault=%ld",lEnd,*lpDefault); - //AddLog(g_szBuf); - - //Bsprintf(g_szBuf,"Checking %ld cases for %ld",lCases, lValue); - //AddLog(g_szBuf); - for (lCheckCase=0; lCheckCasesectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i, lIn); + switch (tw) + { + case CON_EQSPAWNVAR: + insertspriteq(lReturn); + case CON_ESPAWNVAR: + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + case CON_QSPAWNVAR: + insertspriteq(lReturn); + break; + } + break; + } + + case CON_ESPAWN: + case CON_EQSPAWN: + case CON_QSPAWN: + { + long lReturn=-1; + + insptr++; + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i,*insptr++); + switch (tw) + { + case CON_EQSPAWN: + insertspriteq(lReturn); + case CON_ESPAWN: + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + case CON_QSPAWN: + insertspriteq(lReturn); + break; + } + break; + } + + case CON_ESHOOT: + case CON_EZSHOOT: + case CON_ZSHOOT: + { + long lReturn=-1; + + insptr++; + if (tw == CON_ZSHOOT || tw == CON_EZSHOOT) + { + hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); + if (hittype[g_i].temp_data[9] == 0) + hittype[g_i].temp_data[9] = 1; + } + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + { + lReturn = shoot(g_i,*insptr++); + if (tw == CON_EZSHOOT || tw == CON_ESHOOT) + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + } + hittype[g_i].temp_data[9]=0; + break; + } + + case CON_SHOOTVAR: + case CON_ESHOOTVAR: + case CON_EZSHOOTVAR: + case CON_ZSHOOTVAR: + { + long lIn, lReturn=-1; + + insptr++; + + if (tw == CON_ZSHOOTVAR || tw == CON_EZSHOOTVAR) + { + hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); + if (hittype[g_i].temp_data[9] == 0) + hittype[g_i].temp_data[9] = 1; + } + lIn=GetGameVarID(*insptr++, g_i, g_p); + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + { + lReturn = shoot(g_i, lIn); + if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR) + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + } + hittype[g_i].temp_data[9]=0; + break; + } + + case CON_SOUNDVAR: + case CON_STOPSOUNDVAR: + case CON_SOUNDONCEVAR: + case CON_GLOBALSOUNDVAR: + { + int sound; + + insptr++; + sound=GetGameVarID(*insptr++, g_i, g_p); + + switch (tw) + { + case CON_SOUNDONCEVAR: + if (!isspritemakingsound(g_i,sound)) + spritesound((short)sound,g_i); + break; + case CON_GLOBALSOUNDVAR: + spritesound((short)sound,ps[screenpeek].i); + break; + case CON_STOPSOUNDVAR: + if (isspritemakingsound(g_i,sound)) + stopspritesound((short)sound,g_i); + break; + case CON_SOUNDVAR: + spritesound((short)sound,g_i); + break; + } + break; + } + + case CON_GUNIQHUDID: + { + int i; + insptr++; + i=GetGameVarID(*insptr++, g_i, g_p); + if (i < MAXUNIQHUDID-1) + guniqhudid = i; + break; + } + + case CON_SAVEGAMEVAR: + case CON_READGAMEVAR: + { + int32 i=0; + insptr++; + if (scripthandle < 0) break; + switch (tw) + { + case CON_SAVEGAMEVAR: + i=GetGameVarID(*insptr, g_i, g_p); + SCRIPT_PutNumber(scripthandle, "Gamevars",aGameVars[*insptr++].szLabel,i,false,false); + break; + case CON_READGAMEVAR: + SCRIPT_GetNumber(scripthandle, "Gamevars",aGameVars[*insptr].szLabel,&i); + SetGameVarID(*insptr++, i, g_i, g_p); + break; + } + break; + } + + case CON_ROTATESPRITE: + { + long x,y,z; + short tilenum; + short a; + signed char shade; + char orientation; + char pal; + long x1, y1, x2, y2; + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + a=GetGameVarID(*insptr++,g_i,g_p); + tilenum=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + pal=GetGameVarID(*insptr++,g_i,g_p); + orientation=GetGameVarID(*insptr++,g_i,g_p); + x1=GetGameVarID(*insptr++,g_i,g_p); + y1=GetGameVarID(*insptr++,g_i,g_p); + x2=GetGameVarID(*insptr++,g_i,g_p); + y2=GetGameVarID(*insptr++,g_i,g_p); + + rotatesprite(x<<16,y<<16,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2); + break; + } + + case CON_MINITEXT: + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + { + long x,y; + short tilenum=0; + signed char shade; + char orientation=0; + char pal; + long x1=0, y1=0, x2=0, y2=0; + long q; + insptr++; + + if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) + tilenum=GetGameVarID(*insptr++,g_i,g_p); + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + q=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + pal=GetGameVarID(*insptr++,g_i,g_p); + if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) + { + orientation=GetGameVarID(*insptr++,g_i,g_p); + x1=GetGameVarID(*insptr++,g_i,g_p); + y1=GetGameVarID(*insptr++,g_i,g_p); + x2=GetGameVarID(*insptr++,g_i,g_p); + y2=GetGameVarID(*insptr++,g_i,g_p); + } + if (tw == CON_MINITEXT && fta_quotes[q] != NULL) minitextshade(x,y,fta_quotes[q],shade,pal,26); + else if (tw == CON_GAMETEXT && fta_quotes[q] != NULL) gametext_(0,tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2); + else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2); + if ((tw == CON_MINITEXT || tw == CON_GAMETEXT) && fta_quotes[q] == NULL) + OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,q); + break; + } + + case CON_ANGOFF: + insptr++; + spriteext[g_i].angoff=*insptr++; + break; + + case CON_GETZRANGE: + { + long x, y, z, ceilz, ceilhit, florz, florhit, walldist, clipmask; + long ceilzvar, ceilhitvar, florzvar, florhitvar; + short sectnum; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + ceilzvar=*insptr++; + ceilhitvar=*insptr++; + florzvar=*insptr++; + florhitvar=*insptr++; + walldist=GetGameVarID(*insptr++,g_i,g_p); + clipmask=GetGameVarID(*insptr++,g_i,g_p); + + getzrange(x, y, z, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); + SetGameVarID(ceilzvar, ceilz, g_i, g_p); + SetGameVarID(ceilhitvar, ceilhit, g_i, g_p); + SetGameVarID(florzvar, florz, g_i, g_p); + SetGameVarID(florhitvar, florhit, g_i, g_p); + break; + } + + case CON_HITSCAN: + { + long xs, ys, zs, vx, vy, vz, hitx, hity, hitz; + short sectnum, hitsect, hitwall, hitsprite; + unsigned long cliptype; + + long hitxvar, hityvar, hitzvar; + short hitsectvar, hitwallvar, hitspritevar; + + insptr++; + xs=GetGameVarID(*insptr++,g_i,g_p); + ys=GetGameVarID(*insptr++,g_i,g_p); + zs=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + vx=GetGameVarID(*insptr++,g_i,g_p); + vy=GetGameVarID(*insptr++,g_i,g_p); + vz=GetGameVarID(*insptr++,g_i,g_p); + hitsectvar=*insptr++; + hitwallvar=*insptr++; + hitspritevar=*insptr++; + hitxvar=*insptr++; + hityvar=*insptr++; + hitzvar=*insptr++; + cliptype=GetGameVarID(*insptr++,g_i,g_p); + hitscan(xs, ys, zs, sectnum, vx, vy, vz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, cliptype); + SetGameVarID(hitsectvar, hitsect, g_i, g_p); + SetGameVarID(hitwallvar, hitwall, g_i, g_p); + SetGameVarID(hitspritevar, hitsprite, g_i, g_p); + SetGameVarID(hitxvar, hitx, g_i, g_p); + SetGameVarID(hityvar, hity, g_i, g_p); + SetGameVarID(hitzvar, hitz, g_i, g_p); + break; + } + + case CON_CANSEE: + { + long x1, y1, z1, sect1, x2, y2, z2, sect2, r, rvar; + + insptr++; + x1=GetGameVarID(*insptr++,g_i,g_p); + y1=GetGameVarID(*insptr++,g_i,g_p); + z1=GetGameVarID(*insptr++,g_i,g_p); + sect1=GetGameVarID(*insptr++,g_i,g_p); + x2=GetGameVarID(*insptr++,g_i,g_p); + y2=GetGameVarID(*insptr++,g_i,g_p); + z2=GetGameVarID(*insptr++,g_i,g_p); + sect2=GetGameVarID(*insptr++,g_i,g_p); + rvar=*insptr++; + r = cansee(x1,y1,z1,sect1,x2,y2,z2,sect2); + SetGameVarID(rvar, r, g_i, g_p); + break; + } + + case CON_ROTATEPOINT: + { + long xpivot, ypivot, x, y, x2, y2, x2var, y2var; + short daang; + + insptr++; + xpivot=GetGameVarID(*insptr++,g_i,g_p); + ypivot=GetGameVarID(*insptr++,g_i,g_p); + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + daang=GetGameVarID(*insptr++,g_i,g_p); + x2var=*insptr++; + y2var=*insptr++; + rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2); + SetGameVarID(x2var, x2, g_i, g_p); + SetGameVarID(y2var, y2, g_i, g_p); + break; + } + + case CON_NEARTAG: + { + // neartag(long x, long y, long z, short sectnum, short ang, //Starting position & angle + // short *neartagsector, //Returns near sector if sector[].tag != 0 + // short *neartagwall, //Returns near wall if wall[].tag != 0 + // short *neartagsprite, //Returns near sprite if sprite[].tag != 0 + // long *neartaghitdist, //Returns actual distance to object (scale: 1024=largest grid size) + // long neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size) + // char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag + + long x, y, z, neartaghitdist, neartagrange; + short sectnum, ang, neartagsector, neartagwall, neartagsprite; + long neartagsectorvar, neartagwallvar, neartagspritevar, neartaghitdistvar; + char tagsearch; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + ang=GetGameVarID(*insptr++,g_i,g_p); + neartagsectorvar=*insptr++; + neartagwallvar=*insptr++; + neartagspritevar=*insptr++; + neartaghitdistvar=*insptr++; + neartagrange=GetGameVarID(*insptr++,g_i,g_p); + tagsearch=GetGameVarID(*insptr++,g_i,g_p); + neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); + SetGameVarID(neartagsectorvar, neartagsector, g_i, g_p); + SetGameVarID(neartagwallvar, neartagwall, g_i, g_p); + SetGameVarID(neartagspritevar, neartagsprite, g_i, g_p); + SetGameVarID(neartaghitdistvar, neartaghitdist, g_i, g_p); + break; + } + + case CON_MOVESPRITE: + case CON_SETSPRITE: + { + short spritenum; + long x, y, z; + unsigned long cliptype, returnvar; + insptr++; + spritenum = GetGameVarID(*insptr++,g_i,g_p); + x = GetGameVarID(*insptr++,g_i,g_p); + y = GetGameVarID(*insptr++,g_i,g_p); + z = GetGameVarID(*insptr++,g_i,g_p); + switch (tw) + { + case CON_MOVESPRITE: + cliptype = GetGameVarID(*insptr++,g_i,g_p); + returnvar = *insptr++; + SetGameVarID(returnvar, movesprite(spritenum, x, y, z, cliptype), g_i, g_p); + break; + case CON_SETSPRITE: + setsprite(spritenum, x, y, z); + break; + } + break; + } + + case CON_GETFLORZOFSLOPE: + case CON_GETCEILZOFSLOPE: + { + short sectnum; + long x, y; + unsigned long returnvar; + insptr++; + sectnum = GetGameVarID(*insptr++,g_i,g_p); + x = GetGameVarID(*insptr++,g_i,g_p); + y = GetGameVarID(*insptr++,g_i,g_p); + returnvar = *insptr++; + switch (tw) + { + case CON_GETFLORZOFSLOPE: + SetGameVarID(returnvar, getflorzofslope(sectnum,x,y), g_i, g_p); + break; + case CON_GETCEILZOFSLOPE: + SetGameVarID(returnvar, getceilzofslope(sectnum,x,y), g_i, g_p); + break; + } + break; + } + + case CON_UPDATESECTOR: + case CON_UPDATESECTORZ: + { + long x,y,z=0; + int var; + short w; + + w=sprite[g_i].sectnum; + + insptr++; + + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + if (tw==CON_UPDATESECTORZ) z=GetGameVarID(*insptr++,g_i,g_p); + var=*insptr++; + + if (tw==CON_UPDATESECTOR) updatesector(x,y,&w); + else if (tw==CON_UPDATESECTORZ) updatesectorz(x,y,z,&w); + + SetGameVarID(var, w, g_i, g_p); + break; + } + + case CON_SPAWN: + insptr++; + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + spawn(g_i,*insptr); + insptr++; + break; + + case CON_IFWASWEAPON: + insptr++; + parseifelse(hittype[g_i].picnum == *insptr); + break; + + case CON_IFAI: + insptr++; + parseifelse(g_t[5] == *insptr); + break; + + case CON_IFACTION: + insptr++; + parseifelse(g_t[4] == *insptr); + break; + + case CON_IFACTIONCOUNT: + insptr++; + parseifelse(g_t[2] >= *insptr); + break; + + case CON_RESETACTIONCOUNT: + insptr++; + g_t[2] = 0; + break; + + case CON_DEBRIS: + { + short dnum; + + insptr++; + dnum = *insptr++; + + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + for (j=(*insptr)-1;j>=0;j--) { - case CON_DIST: - distx = dist(&sprite[GetGameVarID(xvar, g_i, g_p)],&sprite[GetGameVarID(yvar, g_i, g_p)]); - break; - case CON_LDIST: - distx = ldist(&sprite[GetGameVarID(xvar, g_i, g_p)],&sprite[GetGameVarID(yvar, g_i, g_p)]); - break; + if (g_sp->picnum == BLIMP && dnum == SCRAP1) + s = 0; + else s = (TRAND%3); + + l = EGS(g_sp->sectnum, + g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191), + dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15), + TRAND&2047,(TRAND&127)+32, + -(TRAND&2047),g_i,5); + if (g_sp->picnum == BLIMP && dnum == SCRAP1) + sprite[l].yvel = weaponsandammosprites[j%14]; + else sprite[l].yvel = -1; + sprite[l].pal = g_sp->pal; } + insptr++; + } + break; - SetGameVarID(distvar, distx, g_i, g_p); + case CON_COUNT: + insptr++; + g_t[0] = (short) *insptr++; + break; + + case CON_CSTATOR: + insptr++; + g_sp->cstat |= (short) *insptr++; + break; + + case CON_CLIPDIST: + insptr++; + g_sp->clipdist = (short) *insptr++; + break; + + case CON_CSTAT: + insptr++; + g_sp->cstat = (short) *insptr++; + break; + + case CON_SAVE: + { + int i; + time_t curtime; + + insptr++; + i = *insptr++; + if (movesperpacket == 4 && connecthead != myconnectindex) + break; + + lastsavedpos = i; + curtime = time(NULL); + Bstrcpy(tempbuf,asctime(localtime(&curtime))); + clearbuf(ud.savegame[lastsavedpos],sizeof(ud.savegame[lastsavedpos]),0); + Bsprintf(ud.savegame[lastsavedpos],"Auto"); + for (i=0;i<13;i++) + Bmemcpy(&ud.savegame[lastsavedpos][i+4],&tempbuf[i+3],sizeof(tempbuf[i+3])); + ud.savegame[lastsavedpos][i+4] = '\0'; + OSD_Printf("Saving to slot %d\n",lastsavedpos); + + KB_FlushKeyboardQueue(); + + screencapt = 1; + displayrooms(myconnectindex,65536); + screencapt = 0; + if (ud.multimode > 1) + saveplayer(-1-(lastsavedpos)); + else saveplayer(lastsavedpos); + + break; + } + + case CON_IFMOVE: + insptr++; + parseifelse(g_t[1] == *insptr); + break; + + case CON_RESETPLAYER: + { + insptr++; + + //AddLog("resetplayer"); + if (ud.multimode < 2) + { + if (lastsavedpos >= 0 && ud.recstat != 2) + { + ps[g_p].gm = MODE_MENU; + KB_ClearKeyDown(sc_Space); + cmenu(15000); + } + else ps[g_p].gm = MODE_RESTART; + killit_flag = 2; + } + else + { + pickrandomspot(g_p); + g_sp->x = hittype[g_i].bposx = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx; + g_sp->y = hittype[g_i].bposy = ps[g_p].bobposy = ps[g_p].oposy =ps[g_p].posy; + g_sp->z = hittype[g_i].bposy = ps[g_p].oposz =ps[g_p].posz; + updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); + setsprite(ps[g_p].i,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+PHEIGHT); + g_sp->cstat = 257; + + g_sp->shade = -12; + g_sp->clipdist = 64; + g_sp->xrepeat = 42; + g_sp->yrepeat = 36; + g_sp->owner = g_i; + g_sp->xoffset = 0; + g_sp->pal = ps[g_p].palookup; + + ps[g_p].last_extra = g_sp->extra = max_player_health; + ps[g_p].wantweaponfire = -1; + ps[g_p].horiz = 100; + ps[g_p].on_crane = -1; + ps[g_p].frag_ps = g_p; + ps[g_p].horizoff = 0; + ps[g_p].opyoff = 0; + ps[g_p].wackedbyactor = -1; + ps[g_p].shield_amount = max_armour_amount; + ps[g_p].dead_flag = 0; + ps[g_p].pals_time = 0; + ps[g_p].footprintcount = 0; + ps[g_p].weapreccnt = 0; + ps[g_p].fta = 0; + ps[g_p].ftq = 0; + ps[g_p].posxv = ps[g_p].posyv = 0; + ps[g_p].rotscrnang = 0; + ps[g_p].runspeed = dukefriction; + ps[g_p].falling_counter = 0; + + hittype[g_i].extra = -1; + hittype[g_i].owner = g_i; + + hittype[g_i].cgg = 0; + hittype[g_i].movflag = 0; + hittype[g_i].tempang = 0; + hittype[g_i].actorstayput = -1; + hittype[g_i].dispicnum = 0; + hittype[g_i].owner = ps[g_p].i; + + resetinventory(g_p); + resetweapons(g_p); + + ps[g_p].reloading = 0; + + ps[g_p].movement_lock = 0; + + OnEvent(EVENT_RESETPLAYER, ps[g_p].i, g_p, -1); + cameradist = 0; + cameraclock = totalclock; + } + setpal(&ps[g_p]); + //AddLog("EOF: resetplayer"); + } + break; + + case CON_IFONWATER: + parseifelse(klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); + break; + + case CON_IFINWATER: + parseifelse(sector[g_sp->sectnum].lotag == 2); + break; + + case CON_IFCOUNT: + insptr++; + parseifelse(g_t[0] >= *insptr); + break; + + case CON_IFACTOR: + insptr++; + parseifelse(g_sp->picnum == *insptr); + break; + + case CON_RESETCOUNT: + insptr++; + g_t[0] = 0; + break; + + case CON_ADDINVENTORY: + insptr+=2; + switch (*(insptr-1)) + { + case GET_STEROIDS: + ps[g_p].steroids_amount = *insptr; + ps[g_p].inven_icon = 2; + break; + + case GET_SHIELD: + ps[g_p].shield_amount += *insptr;// 100; + if (ps[g_p].shield_amount > max_player_health) + ps[g_p].shield_amount = max_player_health; + break; + + case GET_SCUBA: + ps[g_p].scuba_amount = *insptr;// 1600; + ps[g_p].inven_icon = 6; + break; + + case GET_HOLODUKE: + ps[g_p].holoduke_amount = *insptr;// 1600; + ps[g_p].inven_icon = 3; + break; + + case GET_JETPACK: + ps[g_p].jetpack_amount = *insptr;// 1600; + ps[g_p].inven_icon = 4; + break; + + case GET_ACCESS: + switch (g_sp->pal) + { + case 0: + ps[g_p].got_access |= 1; + break; + case 21: + ps[g_p].got_access |= 2; + break; + case 23: + ps[g_p].got_access |= 4; + break; + } + break; + + case GET_HEATS: + ps[g_p].heat_amount = *insptr; + ps[g_p].inven_icon = 5; + break; + + case GET_FIRSTAID: + ps[g_p].inven_icon = 1; + ps[g_p].firstaid_amount = *insptr; + break; + + case GET_BOOTS: + ps[g_p].inven_icon = 7; + ps[g_p].boot_amount = *insptr; break; } + insptr++; + break; - case CON_GETINCANGLE: - case CON_GETANGLE: + case CON_HITRADIUS: + hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); + insptr+=6; + break; + + case CON_IFP: + { + insptr++; + + l = *insptr; + j = 0; + + s = sprite[ps[g_p].i].xvel; + + if ((l&8) && ps[g_p].on_ground && (sync[g_p].bits&2)) + j = 1; + else if ((l&16) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && + ps[g_p].poszv > 2048) + j = 1; + else if ((l&32) && ps[g_p].jumping_counter > 348) + j = 1; + else if ((l&1) && s >= 0 && s < 8) + j = 1; + else if ((l&2) && s >= 8 && !(sync[g_p].bits&(1<<5))) + j = 1; + else if ((l&4) && s >= 8 && sync[g_p].bits&(1<<5)) + j = 1; + else if ((l&64) && ps[g_p].posz < (g_sp->z-(48<<8))) + j = 1; + else if ((l&128) && s <= -8 && !(sync[g_p].bits&(1<<5))) + j = 1; + else if ((l&256) && s <= -8 && (sync[g_p].bits&(1<<5))) + j = 1; + else if ((l&512) && (ps[g_p].quick_kick > 0 || (ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0))) + j = 1; + else if ((l&1024) && sprite[ps[g_p].i].xrepeat < 32) + j = 1; + else if ((l&2048) && ps[g_p].jetpack_on) + j = 1; + else if ((l&4096) && ps[g_p].steroids_amount > 0 && ps[g_p].steroids_amount < 400) + j = 1; + else if ((l&8192) && ps[g_p].on_ground) + j = 1; + else if ((l&16384) && sprite[ps[g_p].i].xrepeat > 32 && sprite[ps[g_p].i].extra > 0 && ps[g_p].timebeforeexit == 0) + j = 1; + else if ((l&32768) && sprite[ps[g_p].i].extra <= 0) + j = 1; + else if ((l&65536L)) { - long angvar, xvar, yvar; - short ang; + if (g_sp->picnum == APLAYER && ud.multimode > 1) + j = getincangle(ps[otherp].ang,getangle(ps[g_p].posx-ps[otherp].posx,ps[g_p].posy-ps[otherp].posy)); + else + j = getincangle(ps[g_p].ang,getangle(g_sp->x-ps[g_p].posx,g_sp->y-ps[g_p].posy)); - insptr++; - angvar = *insptr++; - xvar = *insptr++; - yvar = *insptr++; - if (tw==CON_GETANGLE) - ang = getangle(GetGameVarID(xvar, g_i, g_p),GetGameVarID(yvar, g_i, g_p)); - else ang = getincangle(GetGameVarID(xvar, g_i, g_p),GetGameVarID(yvar, g_i, g_p)); - - SetGameVarID(angvar, ang, g_i, g_p); - break; + if (j > -128 && j < 128) + j = 1; + else + j = 0; } + parseifelse((long) j); + } + break; - case CON_MULSCALE: + case CON_IFSTRENGTH: + insptr++; + parseifelse(g_sp->extra <= *insptr); + break; + + case CON_GUTS: + insptr += 2; + guts(g_sp,*(insptr-1),*insptr,g_p); + insptr++; + break; + + case CON_IFSPAWNEDBY: + insptr++; + parseifelse(hittype[g_i].picnum == *insptr); + break; + + case CON_WACKPLAYER: + insptr++; + forceplayerangle(&ps[g_p]); + return 0; + + case CON_FLASH: + insptr++; + sprite[g_i].shade = -127; + ps[g_p].visibility = -127; + lastvisinc = totalclock+32; + return 0; + + case CON_STOPALLSOUNDS: + insptr++; + if (screenpeek == g_p) + FX_StopAllSounds(); + return 0; + + case CON_IFGAPZL: + insptr++; + parseifelse(((hittype[g_i].floorz - hittype[g_i].ceilingz) >> 8) < *insptr); + break; + + case CON_IFHITSPACE: + parseifelse(sync[g_p].bits&(1<<29)); + break; + + case CON_IFOUTSIDE: + parseifelse(sector[g_sp->sectnum].ceilingstat&1); + break; + + case CON_IFMULTIPLAYER: + parseifelse(ud.multimode > 1); + break; + + case CON_OPERATE: + insptr++; + if (sector[g_sp->sectnum].lotag == 0) { - long var1, var2, var3, var4; - long what; + neartag(g_sp->x,g_sp->y,g_sp->z-(32<<8),g_sp->sectnum,g_sp->ang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,1); + if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag)) + if ((sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz) + if ((sector[neartagsector].lotag&16384) == 0) + if ((sector[neartagsector].lotag&32768) == 0) + { + j = headspritesect[neartagsector]; + while (j >= 0) + { + if (sprite[j].picnum == ACTIVATOR) + break; + j = nextspritesect[j]; + } + if (j == -1) + operatesectors(neartagsector,g_i); + } + } + break; - insptr++; - var1 = *insptr++; + case CON_IFINSPACE: + parseifelse(ceilingspace(g_sp->sectnum)); + break; + + case CON_SPRITEPAL: + insptr++; + if (g_sp->picnum != APLAYER) + hittype[g_i].tempang = g_sp->pal; + g_sp->pal = *insptr++; + break; + + case CON_CACTOR: + insptr++; + g_sp->picnum = *insptr++; + break; + + case CON_IFBULLETNEAR: + parseifelse(dodge(g_sp) == 1); + break; + + case CON_IFRESPAWN: + if (badguy(g_sp)) + parseifelse(ud.respawn_monsters); + else if (inventory(g_sp)) + parseifelse(ud.respawn_inventory); + else + parseifelse(ud.respawn_items); + break; + + case CON_IFFLOORDISTL: + insptr++; + parseifelse((hittype[g_i].floorz - g_sp->z) <= ((*insptr)<<8)); + break; + + case CON_IFCEILINGDISTL: + insptr++; + parseifelse((g_sp->z - hittype[g_i].ceilingz) <= ((*insptr)<<8)); + break; + + case CON_PALFROM: + insptr++; + ps[g_p].pals_time = *insptr++; + for (j=0;j<3;j++) + ps[g_p].pals[j] = *insptr++; + break; + + case CON_QSPRINTF: + { + long var1, var2, var3, var4, sq, dq; + insptr++; + dq = *insptr++; + sq = *insptr++; + if (fta_quotes[sq] != NULL && fta_quotes[dq] != NULL) + { + Bstrcpy(tempbuf,fta_quotes[sq]); + var1 = GetGameVarID(*insptr++, g_i, g_p); var2 = GetGameVarID(*insptr++, g_i, g_p); var3 = GetGameVarID(*insptr++, g_i, g_p); var4 = GetGameVarID(*insptr++, g_i, g_p); - - what = mulscale(var2, var3, var4); - - SetGameVarID(var1, what, g_i, g_p); - break; + Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4); } - - case CON_INITTIMER: + else { - short i; - insptr++; - i = GetGameVarID(*insptr++, g_i, g_p); - if (timer != i) - { - uninittimer(); - inittimer(i); - timer = i; - } - break; - } - - case CON_TIME: - { - insptr += 2; - break; - } - - case CON_ESPAWNVAR: - case CON_EQSPAWNVAR: - case CON_QSPAWNVAR: - { - long lIn, lReturn=-1; - - insptr++; - - lIn=*insptr++; - lIn=GetGameVarID(lIn, g_i, g_p); - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - lReturn = spawn(g_i, lIn); - switch (tw) - { - case CON_EQSPAWNVAR: - insertspriteq(lReturn); - case CON_ESPAWNVAR: - SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); - break; - case CON_QSPAWNVAR: - insertspriteq(lReturn); - break; - } - break; - } - - case CON_ESPAWN: - case CON_EQSPAWN: - case CON_QSPAWN: - { - long lReturn=-1; - - insptr++; - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - lReturn = spawn(g_i,*insptr++); - switch (tw) - { - case CON_EQSPAWN: - insertspriteq(lReturn); - case CON_ESPAWN: - SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); - break; - case CON_QSPAWN: - insertspriteq(lReturn); - break; - } - break; - } - - case CON_ESHOOT: - case CON_EZSHOOT: - case CON_ZSHOOT: - { - long lReturn=-1; - - insptr++; - if (tw == CON_ZSHOOT || tw == CON_EZSHOOT) - { - hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); - if (hittype[g_i].temp_data[9] == 0) - hittype[g_i].temp_data[9] = 1; - } - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - { - lReturn = shoot(g_i,*insptr++); - if (tw == CON_EZSHOOT || tw == CON_ESHOOT) - SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); - } - hittype[g_i].temp_data[9]=0; - break; - } - - case CON_SHOOTVAR: - case CON_ESHOOTVAR: - case CON_EZSHOOTVAR: - case CON_ZSHOOTVAR: - { - long lIn, lReturn=-1; - - insptr++; - - if (tw == CON_ZSHOOTVAR || tw == CON_EZSHOOTVAR) - { - hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); - if (hittype[g_i].temp_data[9] == 0) - hittype[g_i].temp_data[9] = 1; - } - lIn=GetGameVarID(*insptr++, g_i, g_p); - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - { - lReturn = shoot(g_i, lIn); - if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR) - SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); - } - hittype[g_i].temp_data[9]=0; - break; - } - - case CON_SOUNDVAR: - case CON_STOPSOUNDVAR: - case CON_SOUNDONCEVAR: - case CON_GLOBALSOUNDVAR: - { - int sound; - - insptr++; - sound=GetGameVarID(*insptr++, g_i, g_p); - - switch (tw) - { - case CON_SOUNDONCEVAR: - if (!isspritemakingsound(g_i,sound)) - spritesound((short)sound,g_i); - break; - case CON_GLOBALSOUNDVAR: - spritesound((short)sound,ps[screenpeek].i); - break; - case CON_STOPSOUNDVAR: - if (isspritemakingsound(g_i,sound)) - stopspritesound((short)sound,g_i); - break; - case CON_SOUNDVAR: - spritesound((short)sound,g_i); - break; - } - break; - } - - case CON_GUNIQHUDID: - { - int i; - insptr++; - i=GetGameVarID(*insptr++, g_i, g_p); - if (i < MAXUNIQHUDID-1) - guniqhudid = i; - break; - } - - case CON_SAVEGAMEVAR: - case CON_READGAMEVAR: - { - int32 i=0; - insptr++; - if (scripthandle < 0) break; - switch (tw) - { - case CON_SAVEGAMEVAR: - i=GetGameVarID(*insptr, g_i, g_p); - SCRIPT_PutNumber(scripthandle, "Gamevars",aGameVars[*insptr++].szLabel,i,false,false); - break; - case CON_READGAMEVAR: - SCRIPT_GetNumber(scripthandle, "Gamevars",aGameVars[*insptr].szLabel,&i); - SetGameVarID(*insptr++, i, g_i, g_p); - break; - } - break; - } - - case CON_ROTATESPRITE: - { - long x,y,z; - short tilenum; - short a; - signed char shade; - char orientation; - char pal; - long x1, y1, x2, y2; - insptr++; - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - z=GetGameVarID(*insptr++,g_i,g_p); - a=GetGameVarID(*insptr++,g_i,g_p); - tilenum=GetGameVarID(*insptr++,g_i,g_p); - shade=GetGameVarID(*insptr++,g_i,g_p); - pal=GetGameVarID(*insptr++,g_i,g_p); - orientation=GetGameVarID(*insptr++,g_i,g_p); - x1=GetGameVarID(*insptr++,g_i,g_p); - y1=GetGameVarID(*insptr++,g_i,g_p); - x2=GetGameVarID(*insptr++,g_i,g_p); - y2=GetGameVarID(*insptr++,g_i,g_p); - - rotatesprite(x<<16,y<<16,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2); - break; - } - - case CON_MINITEXT: - case CON_GAMETEXT: - case CON_DIGITALNUMBER: - { - long x,y; - short tilenum=0; - signed char shade; - char orientation=0; - char pal; - long x1=0, y1=0, x2=0, y2=0; - long q; - insptr++; - - if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) - tilenum=GetGameVarID(*insptr++,g_i,g_p); - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - q=GetGameVarID(*insptr++,g_i,g_p); - shade=GetGameVarID(*insptr++,g_i,g_p); - pal=GetGameVarID(*insptr++,g_i,g_p); - if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) - { - orientation=GetGameVarID(*insptr++,g_i,g_p); - x1=GetGameVarID(*insptr++,g_i,g_p); - y1=GetGameVarID(*insptr++,g_i,g_p); - x2=GetGameVarID(*insptr++,g_i,g_p); - y2=GetGameVarID(*insptr++,g_i,g_p); - } - if (tw == CON_MINITEXT && fta_quotes[q] != NULL) minitextshade(x,y,fta_quotes[q],shade,pal,26); - else if (tw == CON_GAMETEXT && fta_quotes[q] != NULL) gametext_(0,tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2); - else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2); - if ((tw == CON_MINITEXT || tw == CON_GAMETEXT) && fta_quotes[q] == NULL) - OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,q); - break; - } - - case CON_ANGOFF: - insptr++; - spriteext[g_i].angoff=*insptr++; - break; - - case CON_GETZRANGE: - { - long x, y, z, ceilz, ceilhit, florz, florhit, walldist, clipmask; - long ceilzvar, ceilhitvar, florzvar, florhitvar; - short sectnum; - - insptr++; - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - z=GetGameVarID(*insptr++,g_i,g_p); - sectnum=GetGameVarID(*insptr++,g_i,g_p); - ceilzvar=*insptr++; - ceilhitvar=*insptr++; - florzvar=*insptr++; - florhitvar=*insptr++; - walldist=GetGameVarID(*insptr++,g_i,g_p); - clipmask=GetGameVarID(*insptr++,g_i,g_p); - - getzrange(x, y, z, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); - SetGameVarID(ceilzvar, ceilz, g_i, g_p); - SetGameVarID(ceilhitvar, ceilhit, g_i, g_p); - SetGameVarID(florzvar, florz, g_i, g_p); - SetGameVarID(florhitvar, florhit, g_i, g_p); - break; - } - - case CON_HITSCAN: - { - long xs, ys, zs, vx, vy, vz, hitx, hity, hitz; - short sectnum, hitsect, hitwall, hitsprite; - unsigned long cliptype; - - long hitxvar, hityvar, hitzvar; - short hitsectvar, hitwallvar, hitspritevar; - - insptr++; - xs=GetGameVarID(*insptr++,g_i,g_p); - ys=GetGameVarID(*insptr++,g_i,g_p); - zs=GetGameVarID(*insptr++,g_i,g_p); - sectnum=GetGameVarID(*insptr++,g_i,g_p); - vx=GetGameVarID(*insptr++,g_i,g_p); - vy=GetGameVarID(*insptr++,g_i,g_p); - vz=GetGameVarID(*insptr++,g_i,g_p); - hitsectvar=*insptr++; - hitwallvar=*insptr++; - hitspritevar=*insptr++; - hitxvar=*insptr++; - hityvar=*insptr++; - hitzvar=*insptr++; - cliptype=GetGameVarID(*insptr++,g_i,g_p); - hitscan(xs, ys, zs, sectnum, vx, vy, vz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, cliptype); - SetGameVarID(hitsectvar, hitsect, g_i, g_p); - SetGameVarID(hitwallvar, hitwall, g_i, g_p); - SetGameVarID(hitspritevar, hitsprite, g_i, g_p); - SetGameVarID(hitxvar, hitx, g_i, g_p); - SetGameVarID(hityvar, hity, g_i, g_p); - SetGameVarID(hitzvar, hitz, g_i, g_p); - break; - } - - case CON_CANSEE: - { - long x1, y1, z1, sect1, x2, y2, z2, sect2, r, rvar; - - insptr++; - x1=GetGameVarID(*insptr++,g_i,g_p); - y1=GetGameVarID(*insptr++,g_i,g_p); - z1=GetGameVarID(*insptr++,g_i,g_p); - sect1=GetGameVarID(*insptr++,g_i,g_p); - x2=GetGameVarID(*insptr++,g_i,g_p); - y2=GetGameVarID(*insptr++,g_i,g_p); - z2=GetGameVarID(*insptr++,g_i,g_p); - sect2=GetGameVarID(*insptr++,g_i,g_p); - rvar=*insptr++; - r = cansee(x1,y1,z1,sect1,x2,y2,z2,sect2); - SetGameVarID(rvar, r, g_i, g_p); - break; - } - - case CON_ROTATEPOINT: - { - long xpivot, ypivot, x, y, x2, y2, x2var, y2var; - short daang; - - insptr++; - xpivot=GetGameVarID(*insptr++,g_i,g_p); - ypivot=GetGameVarID(*insptr++,g_i,g_p); - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - daang=GetGameVarID(*insptr++,g_i,g_p); - x2var=*insptr++; - y2var=*insptr++; - rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2); - SetGameVarID(x2var, x2, g_i, g_p); - SetGameVarID(y2var, y2, g_i, g_p); - break; - } - - case CON_NEARTAG: - { - // neartag(long x, long y, long z, short sectnum, short ang, //Starting position & angle - // short *neartagsector, //Returns near sector if sector[].tag != 0 - // short *neartagwall, //Returns near wall if wall[].tag != 0 - // short *neartagsprite, //Returns near sprite if sprite[].tag != 0 - // long *neartaghitdist, //Returns actual distance to object (scale: 1024=largest grid size) - // long neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size) - // char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag - - long x, y, z, neartaghitdist, neartagrange; - short sectnum, ang, neartagsector, neartagwall, neartagsprite; - long neartagsectorvar, neartagwallvar, neartagspritevar, neartaghitdistvar; - char tagsearch; - - insptr++; - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - z=GetGameVarID(*insptr++,g_i,g_p); - sectnum=GetGameVarID(*insptr++,g_i,g_p); - ang=GetGameVarID(*insptr++,g_i,g_p); - neartagsectorvar=*insptr++; - neartagwallvar=*insptr++; - neartagspritevar=*insptr++; - neartaghitdistvar=*insptr++; - neartagrange=GetGameVarID(*insptr++,g_i,g_p); - tagsearch=GetGameVarID(*insptr++,g_i,g_p); - neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); - SetGameVarID(neartagsectorvar, neartagsector, g_i, g_p); - SetGameVarID(neartagwallvar, neartagwall, g_i, g_p); - SetGameVarID(neartagspritevar, neartagsprite, g_i, g_p); - SetGameVarID(neartaghitdistvar, neartaghitdist, g_i, g_p); - break; - } - - case CON_MOVESPRITE: - case CON_SETSPRITE: - { - short spritenum; - long x, y, z; - unsigned long cliptype, returnvar; - insptr++; - spritenum = GetGameVarID(*insptr++,g_i,g_p); - x = GetGameVarID(*insptr++,g_i,g_p); - y = GetGameVarID(*insptr++,g_i,g_p); - z = GetGameVarID(*insptr++,g_i,g_p); - switch (tw) - { - case CON_MOVESPRITE: - cliptype = GetGameVarID(*insptr++,g_i,g_p); - returnvar = *insptr++; - SetGameVarID(returnvar, movesprite(spritenum, x, y, z, cliptype), g_i, g_p); - break; - case CON_SETSPRITE: - setsprite(spritenum, x, y, z); - break; - } - break; - } - - case CON_GETFLORZOFSLOPE: - case CON_GETCEILZOFSLOPE: - { - short sectnum; - long x, y; - unsigned long returnvar; - insptr++; - sectnum = GetGameVarID(*insptr++,g_i,g_p); - x = GetGameVarID(*insptr++,g_i,g_p); - y = GetGameVarID(*insptr++,g_i,g_p); - returnvar = *insptr++; - switch (tw) - { - case CON_GETFLORZOFSLOPE: - SetGameVarID(returnvar, getflorzofslope(sectnum,x,y), g_i, g_p); - break; - case CON_GETCEILZOFSLOPE: - SetGameVarID(returnvar, getceilzofslope(sectnum,x,y), g_i, g_p); - break; - } - break; - } - - case CON_UPDATESECTOR: - case CON_UPDATESECTORZ: - { - long x,y,z=0; - int var; - short w; - - w=sprite[g_i].sectnum; - - insptr++; - - x=GetGameVarID(*insptr++,g_i,g_p); - y=GetGameVarID(*insptr++,g_i,g_p); - if (tw==CON_UPDATESECTORZ) z=GetGameVarID(*insptr++,g_i,g_p); - var=*insptr++; - - if (tw==CON_UPDATESECTOR) updatesector(x,y,&w); - else if (tw==CON_UPDATESECTORZ) updatesectorz(x,y,z,&w); - - SetGameVarID(var, w, g_i, g_p); - break; - } - - case CON_SPAWN: - insptr++; - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - spawn(g_i,*insptr); - insptr++; - break; - - case CON_IFWASWEAPON: - insptr++; - parseifelse(hittype[g_i].picnum == *insptr); - break; - - case CON_IFAI: - insptr++; - parseifelse(g_t[5] == *insptr); - break; - - case CON_IFACTION: - insptr++; - parseifelse(g_t[4] == *insptr); - break; - - case CON_IFACTIONCOUNT: - insptr++; - parseifelse(g_t[2] >= *insptr); - break; - - case CON_RESETACTIONCOUNT: - insptr++; - g_t[2] = 0; - break; - - case CON_DEBRIS: - { - short dnum; - - insptr++; - dnum = *insptr++; - - if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - for (j=(*insptr)-1;j>=0;j--) - { - if (g_sp->picnum == BLIMP && dnum == SCRAP1) - s = 0; - else s = (TRAND%3); - - l = EGS(g_sp->sectnum, - g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191), - dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15), - TRAND&2047,(TRAND&127)+32, - -(TRAND&2047),g_i,5); - if (g_sp->picnum == BLIMP && dnum == SCRAP1) - sprite[l].yvel = weaponsandammosprites[j%14]; - else sprite[l].yvel = -1; - sprite[l].pal = g_sp->pal; - } - insptr++; + if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq); + if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq); + insptr += 5; } break; + } - case CON_COUNT: - insptr++; - g_t[0] = (short) *insptr++; - break; - - case CON_CSTATOR: - insptr++; - g_sp->cstat |= (short) *insptr++; - break; - - case CON_CLIPDIST: - insptr++; - g_sp->clipdist = (short) *insptr++; - break; - - case CON_CSTAT: - insptr++; - g_sp->cstat = (short) *insptr++; - break; - - case CON_SAVE: - { - int i; - time_t curtime; - - insptr++; - i = *insptr++; - if (movesperpacket == 4 && connecthead != myconnectindex) - break; - - lastsavedpos = i; - curtime = time(NULL); - Bstrcpy(tempbuf,asctime(localtime(&curtime))); - clearbuf(ud.savegame[lastsavedpos],sizeof(ud.savegame[lastsavedpos]),0); - Bsprintf(ud.savegame[lastsavedpos],"Auto"); - for (i=0;i<13;i++) - Bmemcpy(&ud.savegame[lastsavedpos][i+4],&tempbuf[i+3],sizeof(tempbuf[i+3])); - ud.savegame[lastsavedpos][i+4] = '\0'; - OSD_Printf("Saving to slot %d\n",lastsavedpos); - - KB_FlushKeyboardQueue(); - - screencapt = 1; - displayrooms(myconnectindex,65536); - screencapt = 0; - if (ud.multimode > 1) - saveplayer(-1-(lastsavedpos)); - else saveplayer(lastsavedpos); - - break; - } - - case CON_IFMOVE: - insptr++; - parseifelse(g_t[1] == *insptr); - break; - - case CON_RESETPLAYER: - { - insptr++; - - //AddLog("resetplayer"); - if (ud.multimode < 2) - { - if (lastsavedpos >= 0 && ud.recstat != 2) - { - ps[g_p].gm = MODE_MENU; - KB_ClearKeyDown(sc_Space); - cmenu(15000); - } - else ps[g_p].gm = MODE_RESTART; - killit_flag = 2; - } - else - { - pickrandomspot(g_p); - g_sp->x = hittype[g_i].bposx = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx; - g_sp->y = hittype[g_i].bposy = ps[g_p].bobposy = ps[g_p].oposy =ps[g_p].posy; - g_sp->z = hittype[g_i].bposy = ps[g_p].oposz =ps[g_p].posz; - updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); - setsprite(ps[g_p].i,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+PHEIGHT); - g_sp->cstat = 257; - - g_sp->shade = -12; - g_sp->clipdist = 64; - g_sp->xrepeat = 42; - g_sp->yrepeat = 36; - g_sp->owner = g_i; - g_sp->xoffset = 0; - g_sp->pal = ps[g_p].palookup; - - ps[g_p].last_extra = g_sp->extra = max_player_health; - ps[g_p].wantweaponfire = -1; - ps[g_p].horiz = 100; - ps[g_p].on_crane = -1; - ps[g_p].frag_ps = g_p; - ps[g_p].horizoff = 0; - ps[g_p].opyoff = 0; - ps[g_p].wackedbyactor = -1; - ps[g_p].shield_amount = max_armour_amount; - ps[g_p].dead_flag = 0; - ps[g_p].pals_time = 0; - ps[g_p].footprintcount = 0; - ps[g_p].weapreccnt = 0; - ps[g_p].fta = 0; - ps[g_p].ftq = 0; - ps[g_p].posxv = ps[g_p].posyv = 0; - ps[g_p].rotscrnang = 0; - ps[g_p].runspeed = dukefriction; - ps[g_p].falling_counter = 0; - - hittype[g_i].extra = -1; - hittype[g_i].owner = g_i; - - hittype[g_i].cgg = 0; - hittype[g_i].movflag = 0; - hittype[g_i].tempang = 0; - hittype[g_i].actorstayput = -1; - hittype[g_i].dispicnum = 0; - hittype[g_i].owner = ps[g_p].i; - - resetinventory(g_p); - resetweapons(g_p); - - ps[g_p].reloading = 0; - - ps[g_p].movement_lock = 0; - - OnEvent(EVENT_RESETPLAYER, ps[g_p].i, g_p, -1); - cameradist = 0; - cameraclock = totalclock; - } - setpal(&ps[g_p]); - //AddLog("EOF: resetplayer"); - } + case CON_ADDLOG: + { + long l; + insptr++; + l=*insptr++; // var + Bsprintf(g_szBuf,"CONLOG: L=%ld",l); + AddLog(g_szBuf); break; + } - case CON_IFONWATER: - parseifelse(klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); - break; + case CON_ADDLOGVAR: + { + long l,m=1,lVarID; + char szBuf[256]; + insptr++; + l=*insptr++; // l=Line number, *instpr=varID - case CON_IFINWATER: - parseifelse(sector[g_sp->sectnum].lotag == 2); - break; - - case CON_IFCOUNT: - insptr++; - parseifelse(g_t[0] >= *insptr); - break; - - case CON_IFACTOR: - insptr++; - parseifelse(g_sp->picnum == *insptr); - break; - - case CON_RESETCOUNT: - insptr++; - g_t[0] = 0; - break; - - case CON_ADDINVENTORY: - insptr+=2; - switch (*(insptr-1)) - { - case GET_STEROIDS: - ps[g_p].steroids_amount = *insptr; - ps[g_p].inven_icon = 2; - break; - - case GET_SHIELD: - ps[g_p].shield_amount += *insptr;// 100; - if (ps[g_p].shield_amount > max_player_health) - ps[g_p].shield_amount = max_player_health; - break; - - case GET_SCUBA: - ps[g_p].scuba_amount = *insptr;// 1600; - ps[g_p].inven_icon = 6; - break; - - case GET_HOLODUKE: - ps[g_p].holoduke_amount = *insptr;// 1600; - ps[g_p].inven_icon = 3; - break; - - case GET_JETPACK: - ps[g_p].jetpack_amount = *insptr;// 1600; - ps[g_p].inven_icon = 4; - break; - - case GET_ACCESS: - switch (g_sp->pal) - { - case 0: - ps[g_p].got_access |= 1; - break; - case 21: - ps[g_p].got_access |= 2; - break; - case 23: - ps[g_p].got_access |= 4; - break; - } - break; - - case GET_HEATS: - ps[g_p].heat_amount = *insptr; - ps[g_p].inven_icon = 5; - break; - - case GET_FIRSTAID: - ps[g_p].inven_icon = 1; - ps[g_p].firstaid_amount = *insptr; - break; - - case GET_BOOTS: - ps[g_p].inven_icon = 7; - ps[g_p].boot_amount = *insptr; - break; - } - insptr++; - break; - - case CON_HITRADIUS: - hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); - insptr+=6; - break; - - case CON_IFP: + lVarID = *insptr; + if ((lVarID >= iGameVarCount) || lVarID < 0) { - insptr++; - - l = *insptr; - j = 0; - - s = sprite[ps[g_p].i].xvel; - - if ((l&8) && ps[g_p].on_ground && (sync[g_p].bits&2)) - j = 1; - else if ((l&16) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && - ps[g_p].poszv > 2048) - j = 1; - else if ((l&32) && ps[g_p].jumping_counter > 348) - j = 1; - else if ((l&1) && s >= 0 && s < 8) - j = 1; - else if ((l&2) && s >= 8 && !(sync[g_p].bits&(1<<5))) - j = 1; - else if ((l&4) && s >= 8 && sync[g_p].bits&(1<<5)) - j = 1; - else if ((l&64) && ps[g_p].posz < (g_sp->z-(48<<8))) - j = 1; - else if ((l&128) && s <= -8 && !(sync[g_p].bits&(1<<5))) - j = 1; - else if ((l&256) && s <= -8 && (sync[g_p].bits&(1<<5))) - j = 1; - else if ((l&512) && (ps[g_p].quick_kick > 0 || (ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0))) - j = 1; - else if ((l&1024) && sprite[ps[g_p].i].xrepeat < 32) - j = 1; - else if ((l&2048) && ps[g_p].jetpack_on) - j = 1; - else if ((l&4096) && ps[g_p].steroids_amount > 0 && ps[g_p].steroids_amount < 400) - j = 1; - else if ((l&8192) && ps[g_p].on_ground) - j = 1; - else if ((l&16384) && sprite[ps[g_p].i].xrepeat > 32 && sprite[ps[g_p].i].extra > 0 && ps[g_p].timebeforeexit == 0) - j = 1; - else if ((l&32768) && sprite[ps[g_p].i].extra <= 0) - j = 1; - else if ((l&65536L)) - { - if (g_sp->picnum == APLAYER && ud.multimode > 1) - j = getincangle(ps[otherp].ang,getangle(ps[g_p].posx-ps[otherp].posx,ps[g_p].posy-ps[otherp].posy)); - else - j = getincangle(ps[g_p].ang,getangle(g_sp->x-ps[g_p].posx,g_sp->y-ps[g_p].posy)); - - if (j > -128 && j < 128) - j = 1; - else - j = 0; - } - parseifelse((long) j); - } - break; - - case CON_IFSTRENGTH: - insptr++; - parseifelse(g_sp->extra <= *insptr); - break; - - case CON_GUTS: - insptr += 2; - guts(g_sp,*(insptr-1),*insptr,g_p); - insptr++; - break; - - case CON_IFSPAWNEDBY: - insptr++; - parseifelse(hittype[g_i].picnum == *insptr); - break; - - case CON_WACKPLAYER: - insptr++; - forceplayerangle(&ps[g_p]); - return 0; - - case CON_FLASH: - insptr++; - sprite[g_i].shade = -127; - ps[g_p].visibility = -127; - lastvisinc = totalclock+32; - return 0; - - case CON_STOPALLSOUNDS: - insptr++; - if (screenpeek == g_p) - FX_StopAllSounds(); - return 0; - - case CON_IFGAPZL: - insptr++; - parseifelse(((hittype[g_i].floorz - hittype[g_i].ceilingz) >> 8) < *insptr); - break; - - case CON_IFHITSPACE: - parseifelse(sync[g_p].bits&(1<<29)); - break; - - case CON_IFOUTSIDE: - parseifelse(sector[g_sp->sectnum].ceilingstat&1); - break; - - case CON_IFMULTIPLAYER: - parseifelse(ud.multimode > 1); - break; - - case CON_OPERATE: - insptr++; - if (sector[g_sp->sectnum].lotag == 0) - { - neartag(g_sp->x,g_sp->y,g_sp->z-(32<<8),g_sp->sectnum,g_sp->ang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,1); - if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag)) - if ((sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz) - if ((sector[neartagsector].lotag&16384) == 0) - if ((sector[neartagsector].lotag&32768) == 0) - { - j = headspritesect[neartagsector]; - while (j >= 0) - { - if (sprite[j].picnum == ACTIVATOR) - break; - j = nextspritesect[j]; - } - if (j == -1) - operatesectors(neartagsector,g_i); - } - } - break; - - case CON_IFINSPACE: - parseifelse(ceilingspace(g_sp->sectnum)); - break; - - case CON_SPRITEPAL: - insptr++; - if (g_sp->picnum != APLAYER) - hittype[g_i].tempang = g_sp->pal; - g_sp->pal = *insptr++; - break; - - case CON_CACTOR: - insptr++; - g_sp->picnum = *insptr++; - break; - - case CON_IFBULLETNEAR: - parseifelse(dodge(g_sp) == 1); - break; - - case CON_IFRESPAWN: - if (badguy(g_sp)) - parseifelse(ud.respawn_monsters); - else if (inventory(g_sp)) - parseifelse(ud.respawn_inventory); - else - parseifelse(ud.respawn_items); - break; - - case CON_IFFLOORDISTL: - insptr++; - parseifelse((hittype[g_i].floorz - g_sp->z) <= ((*insptr)<<8)); - break; - - case CON_IFCEILINGDISTL: - insptr++; - parseifelse((g_sp->z - hittype[g_i].ceilingz) <= ((*insptr)<<8)); - break; - - case CON_PALFROM: - insptr++; - ps[g_p].pals_time = *insptr++; - for (j=0;j<3;j++) - ps[g_p].pals[j] = *insptr++; - break; - - case CON_QSPRINTF: - { - long var1, var2, var3, var4, sq, dq; - insptr++; - dq = *insptr++; - sq = *insptr++; - if (fta_quotes[sq] != NULL && fta_quotes[dq] != NULL) - { - Bstrcpy(tempbuf,fta_quotes[sq]); - var1 = GetGameVarID(*insptr++, g_i, g_p); - var2 = GetGameVarID(*insptr++, g_i, g_p); - var3 = GetGameVarID(*insptr++, g_i, g_p); - var4 = GetGameVarID(*insptr++, g_i, g_p); - Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4); - } - else - { - if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq); - if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq); - insptr += 5; - } - break; - } - - case CON_ADDLOG: - { - long l; - insptr++; - l=*insptr++; // var - Bsprintf(g_szBuf,"CONLOG: L=%ld",l); - AddLog(g_szBuf); - break; - } - - case CON_ADDLOGVAR: - { - long l,m=1,lVarID; - char szBuf[256]; - insptr++; - l=*insptr++; // l=Line number, *instpr=varID - - lVarID = *insptr; - if ((lVarID >= iGameVarCount) || lVarID < 0) - { - if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. - insptr++; - else if (*insptr&(MAXGAMEVARS<<1)) - { - m = -1; - lVarID ^= (MAXGAMEVARS<<1); - goto good; - } - // invalid varID + if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. insptr++; - Bsprintf(g_szBuf,"CONLOGVAR: L=%ld INVALID VARIABLE",l); - AddLog(g_szBuf); - break; // out of switch + else if (*insptr&(MAXGAMEVARS<<1)) + { + m = -1; + lVarID ^= (MAXGAMEVARS<<1); + goto good; } + // invalid varID + insptr++; + Bsprintf(g_szBuf,"CONLOGVAR: L=%ld INVALID VARIABLE",l); + AddLog(g_szBuf); + break; // out of switch + } good: - Bsprintf(szBuf,"CONLOGVAR: L=%ld %s ",l, aGameVars[lVarID].szLabel); - strcpy(g_szBuf,szBuf); + Bsprintf(szBuf,"CONLOGVAR: L=%ld %s ",l, aGameVars[lVarID].szLabel); + strcpy(g_szBuf,szBuf); - if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_READONLY) - { - Bsprintf(szBuf," (read-only)"); - strcat(g_szBuf,szBuf); - } - if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERPLAYER) - { - Bsprintf(szBuf," (Per Player. Player=%d)",g_p); - } - else if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERACTOR) - { - Bsprintf(szBuf," (Per Actor. Actor=%d)",g_i); - } - else - { - Bsprintf(szBuf," (Global)"); - } + if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_READONLY) + { + Bsprintf(szBuf," (read-only)"); strcat(g_szBuf,szBuf); - Bsprintf(szBuf," =%ld", GetGameVarID(lVarID, g_i, g_p)*m); - strcat(g_szBuf,szBuf); - AddLog(g_szBuf); - insptr++; - break; } - - case CON_SETSECTOR: - case CON_GETSECTOR: + if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERPLAYER) { - // syntax [gs]etsector[].x - // - long lLabelID; - long lVar1, lVar2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - lVar2=*insptr++; - DoSector(tw==CON_SETSECTOR, lVar1, lLabelID, lVar2, g_i, g_p); - break; + Bsprintf(szBuf," (Per Player. Player=%d)",g_p); } - - case CON_SQRT: + else if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERACTOR) { - // syntax sqrt - - long lInVarID; - long lOutVarID; - long lIn; - - insptr++; - lInVarID=*insptr++; - lOutVarID=*insptr++; - lIn=GetGameVarID(lInVarID, g_i, g_p); - SetGameVarID(lOutVarID, ksqrt(lIn), g_i, g_p); - break; + Bsprintf(szBuf," (Per Actor. Actor=%d)",g_i); } - - case CON_FINDNEARACTOR: - case CON_FINDNEARSPRITE: - case CON_FINDNEARACTOR3D: - case CON_FINDNEARSPRITE3D: + else { - // syntax findnearactorvar - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - // - long lType, lMaxDist, lVarID, lTemp, lFound; - short j, k; + Bsprintf(szBuf," (Global)"); + } + strcat(g_szBuf,szBuf); + Bsprintf(szBuf," =%ld", GetGameVarID(lVarID, g_i, g_p)*m); + strcat(g_szBuf,szBuf); + AddLog(g_szBuf); + insptr++; + break; + } - insptr++; + case CON_SETSECTOR: + case CON_GETSECTOR: + { + // syntax [gs]etsector[].x + // + long lLabelID; + long lVar1, lVar2; - lType=*insptr++; - lMaxDist=*insptr++; - lVarID=*insptr++; + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + DoSector(tw==CON_SETSECTOR, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } - lFound=-1; + case CON_SQRT: + { + // syntax sqrt - for (k=0;k + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType, lMaxDist, lVarID, lTemp, lFound; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=*insptr++; + lVarID=*insptr++; + + lFound=-1; + + for (k=0;k=0) { - j=headspritestat[(tw==CON_FINDNEARACTOR||tw==CON_FINDNEARACTOR3D)?1:k]; // all sprites - while (j>=0) + if (sprite[j].picnum == lType && j != g_i) { - if (sprite[j].picnum == lType && j != g_i) + if (tw==CON_FINDNEARACTOR3D || tw==CON_FINDNEARSPRITE3D) + lTemp=dist(&sprite[g_i], &sprite[j]); + else lTemp=ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) { - if (tw==CON_FINDNEARACTOR3D || tw==CON_FINDNEARSPRITE3D) - lTemp=dist(&sprite[g_i], &sprite[j]); - else lTemp=ldist(&sprite[g_i], &sprite[j]); - if (lTemp < lMaxDist) + lFound=j; + j = MAXSPRITES; + break; + } + } + j = nextspritestat[j]; + } + if ((tw==CON_FINDNEARACTOR||tw==CON_FINDNEARACTOR3D) || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } + + case CON_FINDNEARACTORVAR: + case CON_FINDNEARSPRITEVAR: + case CON_FINDNEARACTOR3DVAR: + case CON_FINDNEARSPRITE3DVAR: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType, lMaxDist; + long lVarID, lTemp, lFound; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=GetGameVarID(*insptr++, g_i, g_p); + lVarID=*insptr++; + lFound=-1; + + for (k=0;k=0) + { + if (sprite[j].picnum == lType && j != g_i) + { + if (tw==CON_FINDNEARACTOR3DVAR || tw==CON_FINDNEARSPRITE3DVAR) + lTemp=dist(&sprite[g_i], &sprite[j]); + else lTemp=ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) + { + lFound=j; + j = MAXSPRITES; + break; + } + } + j = nextspritestat[j]; + } + if ((tw==CON_FINDNEARACTORVAR||tw==CON_FINDNEARACTOR3DVAR) || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } + + case CON_FINDNEARACTORZVAR: + case CON_FINDNEARSPRITEZVAR: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType, lMaxDist, lMaxZDist; + long lVarID, lTemp, lTemp2, lFound; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=GetGameVarID(*insptr++, g_i, g_p); + lMaxZDist=GetGameVarID(*insptr++, g_i, g_p); + lVarID=*insptr++; + lFound=-1; + + for (k=0;k=0) + { + if (sprite[j].picnum == lType && j != g_i) + { + lTemp=ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) + { + lTemp2=klabs(sprite[g_i].z-sprite[j].z); + if (lTemp2 < lMaxZDist) { lFound=j; j = MAXSPRITES; break; } } - j = nextspritestat[j]; } - if ((tw==CON_FINDNEARACTOR||tw==CON_FINDNEARACTOR3D) || j == MAXSPRITES) - break; + j = nextspritestat[j]; } - SetGameVarID(lVarID, lFound, g_i, g_p); - break; + if (tw==CON_FINDNEARACTORZVAR || j == MAXSPRITES) + break; } + SetGameVarID(lVarID, lFound, g_i, g_p); - case CON_FINDNEARACTORVAR: - case CON_FINDNEARSPRITEVAR: - case CON_FINDNEARACTOR3DVAR: - case CON_FINDNEARSPRITE3DVAR: + break; + } + + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITEZ: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType, lMaxDist, lMaxZDist, lVarID; + long lTemp, lTemp2, lFound; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=*insptr++; + lMaxZDist=*insptr++; + lVarID=*insptr++; + + lFound=-1; + + for (k=0;k - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - // - long lType, lMaxDist; - long lVarID, lTemp, lFound; - short j, k; - - insptr++; - - lType=*insptr++; - lMaxDist=GetGameVarID(*insptr++, g_i, g_p); - lVarID=*insptr++; - lFound=-1; - - for (k=0;k=0) { - j=headspritestat[(tw==CON_FINDNEARACTORVAR||tw==CON_FINDNEARACTOR3DVAR)?1:k]; // all sprites - while (j>=0) + if (sprite[j].picnum == lType && j != g_i) { - if (sprite[j].picnum == lType && j != g_i) + lTemp=ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) { - if (tw==CON_FINDNEARACTOR3DVAR || tw==CON_FINDNEARSPRITE3DVAR) - lTemp=dist(&sprite[g_i], &sprite[j]); - else lTemp=ldist(&sprite[g_i], &sprite[j]); - if (lTemp < lMaxDist) + lTemp2=klabs(sprite[g_i].z-sprite[j].z); + if (lTemp2 < lMaxZDist) { lFound=j; j = MAXSPRITES; break; } } - j = nextspritestat[j]; } - if ((tw==CON_FINDNEARACTORVAR||tw==CON_FINDNEARACTOR3DVAR) || j == MAXSPRITES) - break; + j = nextspritestat[j]; } - SetGameVarID(lVarID, lFound, g_i, g_p); - break; + if (tw==CON_FINDNEARACTORZ || j == MAXSPRITES) + break; } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITEZVAR: + case CON_FINDPLAYER: + case CON_FINDOTHERPLAYER: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + short j=0; + long var1, d; + + insptr++; + var1 = *insptr++; + + if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); + else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); + + SetGameVarID(g_iReturnVarID, j, g_i, g_p); + SetGameVarID(var1, d, g_i, g_p); + + break; + } + + case CON_SETPLAYER: + case CON_GETPLAYER: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + // HACK: need to have access to labels structure at run-time... + + switch (lLabelID) { - // syntax findnearactorvar - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - // - long lType, lMaxDist, lMaxZDist; - long lVarID, lTemp, lTemp2, lFound; - short j, k; - - insptr++; - - lType=*insptr++; - lMaxDist=GetGameVarID(*insptr++, g_i, g_p); - lMaxZDist=GetGameVarID(*insptr++, g_i, g_p); - lVarID=*insptr++; - lFound=-1; - - for (k=0;k=0) - { - if (sprite[j].picnum == lType && j != g_i) - { - lTemp=ldist(&sprite[g_i], &sprite[j]); - if (lTemp < lMaxDist) - { - lTemp2=klabs(sprite[g_i].z-sprite[j].z); - if (lTemp2 < lMaxZDist) - { - lFound=j; - j = MAXSPRITES; - break; - } - } - } - j = nextspritestat[j]; - } - if (tw==CON_FINDNEARACTORZVAR || j == MAXSPRITES) - break; - } - SetGameVarID(lVarID, lFound, g_i, g_p); - + case PLAYER_AMMO_AMOUNT: + case PLAYER_GOTWEAPON: + case PLAYER_PALS: + case PLAYER_LOOGIEX: + case PLAYER_LOOGIEY: + lParm2=GetGameVarID(*insptr++, g_i, g_p); + break; + default: + lParm2=0; break; } + lVar2=*insptr++; - case CON_FINDNEARACTORZ: - case CON_FINDNEARSPRITEZ: + DoPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + + case CON_SETINPUT: + case CON_GETINPUT: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + + lVar2=*insptr++; + + DoInput(tw==CON_SETINPUT, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } + + case CON_GETUSERDEF: + case CON_SETUSERDEF: + { + // syntax [gs]etuserdef.xxx + // + long lLabelID; + long lVar2; + + insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + + DoUserDef(tw==CON_SETUSERDEF, lLabelID, lVar2, g_i, g_p); + break; + } + + case CON_GETPROJECTILE: + case CON_SETPROJECTILE: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=GetGameVarID(*insptr++, g_i, g_p); + lLabelID=*insptr++; + lVar2=*insptr++; + DoProjectile(tw==CON_SETPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); + + break; + } + + case CON_SETWALL: + case CON_GETWALL: + { + // syntax [gs]etwall[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + + DoWall(tw==CON_SETWALL, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } + + case CON_SETACTORVAR: + case CON_GETACTORVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + long lVar1, lVar2, lVar3; + long lTemp,lSprite; + + insptr++; + + lVar1=*insptr++; + lVar2=*insptr++; + lVar3=*insptr++; + + lSprite=GetGameVarID(lVar1, g_i, g_p); + switch (tw) { - // syntax findnearactorvar - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - // - long lType, lMaxDist, lMaxZDist, lVarID; - long lTemp, lTemp2, lFound; - short j, k; - - insptr++; - - lType=*insptr++; - lMaxDist=*insptr++; - lMaxZDist=*insptr++; - lVarID=*insptr++; - - lFound=-1; - - for (k=0;k=0) - { - if (sprite[j].picnum == lType && j != g_i) - { - lTemp=ldist(&sprite[g_i], &sprite[j]); - if (lTemp < lMaxDist) - { - lTemp2=klabs(sprite[g_i].z-sprite[j].z); - if (lTemp2 < lMaxZDist) - { - lFound=j; - j = MAXSPRITES; - break; - } - } - } - j = nextspritestat[j]; - } - if (tw==CON_FINDNEARACTORZ || j == MAXSPRITES) - break; - } - SetGameVarID(lVarID, lFound, g_i, g_p); - break; - } - - case CON_FINDPLAYER: - case CON_FINDOTHERPLAYER: - { - // syntax findnearactorvar - // gets the sprite ID of the nearest actor within max dist - // that is of into - // -1 for none found - // - short j=0; - long var1, d; - - insptr++; - var1 = *insptr++; - - if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); - else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); - - SetGameVarID(g_iReturnVarID, j, g_i, g_p); - SetGameVarID(var1, d, g_i, g_p); - - break; - } - - case CON_SETPLAYER: - case CON_GETPLAYER: - { - // syntax [gs]etplayer[].x - // - long lLabelID; - long lVar1, lVar2; - long lParm2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - // HACK: need to have access to labels structure at run-time... - - switch (lLabelID) - { - case PLAYER_AMMO_AMOUNT: - case PLAYER_GOTWEAPON: - case PLAYER_PALS: - case PLAYER_LOOGIEX: - case PLAYER_LOOGIEY: - lParm2=GetGameVarID(*insptr++, g_i, g_p); - break; - default: - lParm2=0; - break; - } - lVar2=*insptr++; - - DoPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); - break; - } - - case CON_SETINPUT: - case CON_GETINPUT: - { - // syntax [gs]etplayer[].x - // - long lLabelID; - long lVar1, lVar2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - - lVar2=*insptr++; - - DoInput(tw==CON_SETINPUT, lVar1, lLabelID, lVar2, g_i, g_p); - break; - } - - case CON_GETUSERDEF: - case CON_SETUSERDEF: - { - // syntax [gs]etuserdef.xxx - // - long lLabelID; - long lVar2; - - insptr++; - lLabelID=*insptr++; - lVar2=*insptr++; - - DoUserDef(tw==CON_SETUSERDEF, lLabelID, lVar2, g_i, g_p); - break; - } - - case CON_GETPROJECTILE: - case CON_SETPROJECTILE: - { - // syntax [gs]etplayer[].x - // - long lLabelID; - long lVar1, lVar2; - - insptr++; - lVar1=GetGameVarID(*insptr++, g_i, g_p); - lLabelID=*insptr++; - lVar2=*insptr++; - DoProjectile(tw==CON_SETPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); - - break; - } - - case CON_SETWALL: - case CON_GETWALL: - { - // syntax [gs]etwall[].x - // - long lLabelID; - long lVar1, lVar2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - lVar2=*insptr++; - - DoWall(tw==CON_SETWALL, lVar1, lLabelID, lVar2, g_i, g_p); - break; - } - case CON_SETACTORVAR: + lTemp=GetGameVarID(lVar3, g_i, g_p); + SetGameVarID(lVar2, lTemp, lSprite, g_p); + break; case CON_GETACTORVAR: - { - // syntax [gs]etactorvar[]. - // gets the value of the per-actor variable varx into VAR - // - long lVar1, lVar2, lVar3; - long lTemp,lSprite; - - insptr++; - - lVar1=*insptr++; - lVar2=*insptr++; - lVar3=*insptr++; - - lSprite=GetGameVarID(lVar1, g_i, g_p); - switch (tw) - { - case CON_SETACTORVAR: - lTemp=GetGameVarID(lVar3, g_i, g_p); - SetGameVarID(lVar2, lTemp, lSprite, g_p); - break; - case CON_GETACTORVAR: - lTemp=GetGameVarID(lVar2, lSprite, g_p); - SetGameVarID(lVar3, lTemp, g_i, g_p); - break; - } + lTemp=GetGameVarID(lVar2, lSprite, g_p); + SetGameVarID(lVar3, lTemp, g_i, g_p); break; } + break; + } + case CON_SETPLAYERVAR: + case CON_GETPLAYERVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + long lVar1, lVar2, lVar3; + long lTemp,lSprite; + + insptr++; + + lVar1=*insptr++; + lVar2=*insptr++; + lVar3=*insptr++; + + lSprite=GetGameVarID(lVar1, g_i, g_p); + switch (tw) + { case CON_SETPLAYERVAR: + lTemp=GetGameVarID(lVar3, g_i, g_p); + SetGameVarID(lVar2, lTemp, g_i, lSprite); + break; case CON_GETPLAYERVAR: - { - // syntax [gs]etactorvar[]. - // gets the value of the per-actor variable varx into VAR - // - long lVar1, lVar2, lVar3; - long lTemp,lSprite; - - insptr++; - - lVar1=*insptr++; - lVar2=*insptr++; - lVar3=*insptr++; - - lSprite=GetGameVarID(lVar1, g_i, g_p); - switch (tw) - { - case CON_SETPLAYERVAR: - lTemp=GetGameVarID(lVar3, g_i, g_p); - SetGameVarID(lVar2, lTemp, g_i, lSprite); - break; - case CON_GETPLAYERVAR: - lTemp=GetGameVarID(lVar2, g_i, lSprite); - SetGameVarID(lVar3, lTemp, g_i, g_p); - break; - } + lTemp=GetGameVarID(lVar2, g_i, lSprite); + SetGameVarID(lVar3, lTemp, g_i, g_p); break; } + break; + } - case CON_SETACTOR: - case CON_GETACTOR: + case CON_SETACTOR: + case CON_GETACTOR: + { + // syntax [gs]etactor[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + + switch (lLabelID) { - // syntax [gs]etactor[].x - // - long lLabelID; - long lVar1, lVar2; - long lParm2; - - insptr++; - lVar1=*insptr++; - lLabelID=*insptr++; - - switch (lLabelID) - { - case ACTOR_HTG_T: - lParm2=GetGameVarID(*insptr++, g_i, g_p); - break; - default: - lParm2=0; - break; - } - lVar2=*insptr++; - - DoActor(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + case ACTOR_HTG_T: + lParm2=GetGameVarID(*insptr++, g_i, g_p); + break; + default: + lParm2=0; break; } + lVar2=*insptr++; - case CON_GETANGLETOTARGET: + DoActor(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + + case CON_GETANGLETOTARGET: + { + int i; + short ang; + + insptr++; + i=*insptr++; // ID of def + + // hittype[g_i].lastvx and lastvy are last known location of target. + ang=getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); + SetGameVarID(i, ang, g_i, g_p); + break; + } + + case CON_ANGOFFVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + spriteext[g_i].angoff=GetGameVarID(i, g_i, g_p); + break; + } + + case CON_LOCKPLAYER: + { + int i; + insptr++; + i=*insptr++; // ID of def + ps[g_p].transporter_hold=GetGameVarID(i, g_i, g_p); + break; + } + + case CON_CHECKAVAILWEAPON: + case CON_CHECKAVAILINVEN: + { + int i; + + insptr++; + + if (*insptr == g_iThisActorID) { - int i; - short ang; - + i = g_p; insptr++; - i=*insptr++; // ID of def - - // hittype[g_i].lastvx and lastvy are last known location of target. - ang=getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); - SetGameVarID(i, ang, g_i, g_p); - break; } - - case CON_ANGOFFVAR: + else + i=GetGameVarID(*insptr++, g_i, g_p); + if (i < MAXPLAYERS) { - int i; - insptr++; - i=*insptr++; // ID of def - spriteext[g_i].angoff=GetGameVarID(i, g_i, g_p); - break; + if (tw == CON_CHECKAVAILWEAPON) + checkavailweapon(&ps[i]); + else checkavailinven(&ps[i]); } + break; + } - case CON_LOCKPLAYER: + case CON_GETPLAYERANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, ps[g_p].ang, g_i, g_p); + break; + } + + case CON_SETPLAYERANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + ps[g_p].ang=GetGameVarID(i, g_i, g_p); + ps[g_p].ang &= 2047; + break; + } + + case CON_GETACTORANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, g_sp->ang, g_i, g_p); + break; + } + + case CON_SETACTORANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + g_sp->ang=GetGameVarID(i, g_i, g_p); + g_sp->ang &= 2047; + break; + } + + case CON_SETVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, *insptr++, g_i, g_p); + break; + } + + case CON_SETVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + break; + } + + case CON_RANDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, mulscale(krand(), *(insptr++)+1, 16), g_i, g_p); + break; + } + + case CON_DISPLAYRANDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, mulscale(rand(), *(insptr++)+1, 15), g_i, g_p); + break; + } + + case CON_MULVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) * *insptr++, g_i, g_p); + break; + } + + case CON_DIVVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + if ((*insptr) == 0) + gameexit("CON_DIVVAR: Divide by zero."); + SetGameVarID(i, GetGameVarID(i, g_i, g_p) / *insptr++, g_i, g_p); + break; + } + + case CON_MODVAR: + { + int i; + long l; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + if (l == 0) + gameexit("CON_MODVAR: Mod by zero."); + SetGameVarID(i,GetGameVarID(i, g_i, g_p)%l, g_i, g_p); + break; + } + + case CON_ANDVAR: + { + int i; + long l; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + SetGameVarID(i,GetGameVarID(i, g_i, g_p) & l, g_i, g_p); + break; + } + + case CON_ORVAR: + { + int i; + long l; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + SetGameVarID(i,GetGameVarID(i, g_i, g_p) | l, g_i, g_p); + break; + } + + case CON_XORVAR: + { + int i; + long l; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + SetGameVarID(i,GetGameVarID(i, g_i, g_p) ^ l, g_i, g_p); + break; + } + + case CON_RANDVARVAR: + { + int i; + long l1; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(i,mulscale(krand(), l1+1, 16), g_i, g_p); + break; + } + + case CON_DISPLAYRANDVARVAR: + { + int i; + long l1; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(*insptr++, g_i, g_p); + + SetGameVarID(i,mulscale(rand(), l1+1, 15), g_i, g_p); + break; + } + + case CON_GMAXAMMO: + { + int i; + long l1; // l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + SetGameVarID(*insptr++, max_ammo_amount[l1], g_i, g_p); + break; + } + + case CON_SMAXAMMO: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + max_ammo_amount[l1]=l2; + break; + } + + case CON_MULVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(i, l1*l2, g_i, g_p); + break; + } + + case CON_DIVVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + if (l2==0) { - int i; - insptr++; - i=*insptr++; // ID of def - ps[g_p].transporter_hold=GetGameVarID(i, g_i, g_p); - break; + gameexit("CON_DIVVARVAR: Divide by zero."); } + SetGameVarID(i, l1/l2 , g_i, g_p); + break; + } - case CON_CHECKAVAILWEAPON: - case CON_CHECKAVAILINVEN: + case CON_MODVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + if (l2==0) + gameexit("CON_MODVARVAR: Mod by zero."); + SetGameVarID(i, l1 % l2, g_i, g_p); + break; + } + + case CON_ANDVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(i, l1 & l2 , g_i, g_p); + break; + } + + case CON_XORVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(i, l1 ^ l2 , g_i, g_p); + break; + } + + case CON_ORVARVAR: + { + int i; + long l1,l2; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(i, l1 | l2 , g_i, g_p); + break; + } + + case CON_SUBVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr++, g_i, g_p); + break; + } + + case CON_SUBVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + break; + } + + case CON_ADDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr++, g_i, g_p); + break; + } + + case CON_SHIFTVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr++, g_i, g_p); + break; + } + + case CON_SHIFTVARR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr++, g_i, g_p); + break; + } + + case CON_SIN: + { + int i; + long lValue; + insptr++; + i=*insptr++; // ID of def + lValue=GetGameVarID(*insptr++, g_i, g_p); + lValue=sintable[lValue&2047]; + SetGameVarID(i, lValue , g_i, g_p); + break; + } + + case CON_COS: + { + int i; + long lValue; + insptr++; + i=*insptr++; // ID of def + lValue=GetGameVarID(*insptr++, g_i, g_p); + lValue=sintable[(lValue+512)&2047]; + SetGameVarID(i, lValue , g_i, g_p); + break; + } + + case CON_ADDVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + break; + } + + case CON_SPGETLOTAG: + { + insptr++; + SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); + break; + } + + case CON_SPGETHITAG: + { + insptr++; + SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); + break; + } + + case CON_SECTGETLOTAG: + { + insptr++; + SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); + break; + } + + case CON_SECTGETHITAG: + { + insptr++; + SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); + break; + } + + case CON_GETTEXTUREFLOOR: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); + break; + } + + case CON_STARTTRACK: + { + insptr++; + music_select=*insptr++; + playmusic(&music_fn[ud.volume_number][music_select][0]); + break; + } + + case CON_GETTEXTURECEILING: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); + break; + } + + case CON_IFVARVARAND: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p)) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARVARN: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p)) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARVARE: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p)) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARVARG: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p)) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p)) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARE: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) == *insptr) + j=1; + parseifelse(j); + break; + } + + case CON_IFVARN: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) != *insptr) + j=1; + parseifelse(j); + break; + } + + case CON_WHILEVARN: + { + int i; + long *savedinsptr; + savedinsptr=insptr; + j=1; + while (j) { - int i; - + insptr=savedinsptr; insptr++; - - if (*insptr == g_iThisActorID) - { - i = g_p; - insptr++; - } - else - i=GetGameVarID(*insptr++, g_i, g_p); - if (i < MAXPLAYERS) - { - if (tw == CON_CHECKAVAILWEAPON) - checkavailweapon(&ps[i]); - else checkavailinven(&ps[i]); - } - break; - } - - case CON_GETPLAYERANGLE: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, ps[g_p].ang, g_i, g_p); - break; - } - - case CON_SETPLAYERANGLE: - { - int i; - insptr++; - i=*insptr++; // ID of def - ps[g_p].ang=GetGameVarID(i, g_i, g_p); - ps[g_p].ang &= 2047; - break; - } - - case CON_GETACTORANGLE: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, g_sp->ang, g_i, g_p); - break; - } - - case CON_SETACTORANGLE: - { - int i; - insptr++; - i=*insptr++; // ID of def - g_sp->ang=GetGameVarID(i, g_i, g_p); - g_sp->ang &= 2047; - break; - } - - case CON_SETVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, *insptr++, g_i, g_p); - break; - } - - case CON_SETVARVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); - break; - } - - case CON_RANDVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, mulscale(krand(), *(insptr++)+1, 16), g_i, g_p); - break; - } - - case CON_DISPLAYRANDVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, mulscale(rand(), *(insptr++)+1, 15), g_i, g_p); - break; - } - - case CON_MULVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) * *insptr++, g_i, g_p); - break; - } - - case CON_DIVVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - if ((*insptr) == 0) - gameexit("CON_DIVVAR: Divide by zero."); - SetGameVarID(i, GetGameVarID(i, g_i, g_p) / *insptr++, g_i, g_p); - break; - } - - case CON_MODVAR: - { - int i; - long l; - insptr++; - i=*insptr++; // ID of def - l=*insptr++; - if (l == 0) - gameexit("CON_MODVAR: Mod by zero."); - SetGameVarID(i,GetGameVarID(i, g_i, g_p)%l, g_i, g_p); - break; - } - - case CON_ANDVAR: - { - int i; - long l; - insptr++; - i=*insptr++; // ID of def - l=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) & l, g_i, g_p); - break; - } - - case CON_ORVAR: - { - int i; - long l; - insptr++; - i=*insptr++; // ID of def - l=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) | l, g_i, g_p); - break; - } - - case CON_XORVAR: - { - int i; - long l; - insptr++; - i=*insptr++; // ID of def - l=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) ^ l, g_i, g_p); - break; - } - - case CON_RANDVARVAR: - { - int i; - long l1; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i,mulscale(krand(), l1+1, 16), g_i, g_p); - break; - } - - case CON_DISPLAYRANDVARVAR: - { - int i; - long l1; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(*insptr++, g_i, g_p); - - SetGameVarID(i,mulscale(rand(), l1+1, 15), g_i, g_p); - break; - } - - case CON_GMAXAMMO: - { - int i; - long l1; // l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - SetGameVarID(*insptr++, max_ammo_amount[l1], g_i, g_p); - break; - } - - case CON_SMAXAMMO: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - max_ammo_amount[l1]=l2; - break; - } - - case CON_MULVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1*l2, g_i, g_p); - break; - } - - case CON_DIVVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - if (l2==0) - { - gameexit("CON_DIVVARVAR: Divide by zero."); - } - SetGameVarID(i, l1/l2 , g_i, g_p); - break; - } - - case CON_MODVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - if (l2==0) - gameexit("CON_MODVARVAR: Mod by zero."); - SetGameVarID(i, l1 % l2, g_i, g_p); - break; - } - - case CON_ANDVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1 & l2 , g_i, g_p); - break; - } - - case CON_XORVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1 ^ l2 , g_i, g_p); - break; - } - - case CON_ORVARVAR: - { - int i; - long l1,l2; - insptr++; - i=*insptr++; // ID of def - l1=GetGameVarID(i, g_i, g_p); - l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1 | l2 , g_i, g_p); - break; - } - - case CON_SUBVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr++, g_i, g_p); - break; - } - - case CON_SUBVARVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); - break; - } - - case CON_ADDVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr++, g_i, g_p); - break; - } - - case CON_SHIFTVARL: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr++, g_i, g_p); - break; - } - - case CON_SHIFTVARR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr++, g_i, g_p); - break; - } - - case CON_SIN: - { - int i; - long lValue; - insptr++; - i=*insptr++; // ID of def - lValue=GetGameVarID(*insptr++, g_i, g_p); - lValue=sintable[lValue&2047]; - SetGameVarID(i, lValue , g_i, g_p); - break; - } - - case CON_COS: - { - int i; - long lValue; - insptr++; - i=*insptr++; // ID of def - lValue=GetGameVarID(*insptr++, g_i, g_p); - lValue=sintable[(lValue+512)&2047]; - SetGameVarID(i, lValue , g_i, g_p); - break; - } - - case CON_ADDVARVAR: - { - int i; - insptr++; - i=*insptr++; // ID of def - SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); - break; - } - - case CON_SPGETLOTAG: - { - insptr++; - SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); - break; - } - - case CON_SPGETHITAG: - { - insptr++; - SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); - break; - } - - case CON_SECTGETLOTAG: - { - insptr++; - SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); - break; - } - - case CON_SECTGETHITAG: - { - insptr++; - SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); - break; - } - - case CON_GETTEXTUREFLOOR: - { - insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); - break; - } - - case CON_STARTTRACK: - { - insptr++; - music_select=*insptr++; - playmusic(&music_fn[ud.volume_number][music_select][0]); - break; - } - - case CON_GETTEXTURECEILING: - { - insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); - break; - } - - case CON_IFVARVARAND: - { - int i; - insptr++; - i=*insptr++; // ID of def + i=*insptr++; // ID of def j=0; - if (GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); - break; - } - case CON_IFVARVARN: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARVARE: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARVARG: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARVARL: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARE: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) == *insptr) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARN: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; if (GetGameVarID(i, g_i, g_p) != *insptr) j=1; parseifelse(j); - break; } + break; + } - case CON_WHILEVARN: + case CON_WHILEVARVARN: + { + int i,k; + long *savedinsptr; + savedinsptr=insptr; + j=1; + while (j) { - int i; - long *savedinsptr; - savedinsptr=insptr; - j=1; - while (j) - { - insptr=savedinsptr; - insptr++; - i=*insptr++; // ID of def - j=0; - - if (GetGameVarID(i, g_i, g_p) != *insptr) - j=1; - parseifelse(j); - } - break; - } - - case CON_WHILEVARVARN: - { - int i,k; - long *savedinsptr; - savedinsptr=insptr; - j=1; - while (j) - { - insptr=savedinsptr; - insptr++; - i=*insptr++; // ID of def - k=*(insptr); // ID of def - j=0; - - if (GetGameVarID(i, g_i, g_p) != GetGameVarID(k, g_i, g_p)) - j=1; - parseifelse(j); - } - break; - } - - case CON_IFVARAND: - { - int i; + insptr=savedinsptr; insptr++; - i=*insptr++; // ID of def + i=*insptr++; // ID of def + k=*(insptr); // ID of def j=0; - if (GetGameVarID(i, g_i, g_p) & *insptr) + + if (GetGameVarID(i, g_i, g_p) != GetGameVarID(k, g_i, g_p)) j=1; parseifelse(j); - break; - } - - case CON_IFVARG: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) > *insptr) - j=1; - parseifelse(j); - break; - } - - case CON_IFVARL: - { - int i; - insptr++; - i=*insptr++; // ID of def - j=0; - if (GetGameVarID(i, g_i, g_p) < *insptr) - j=1; - parseifelse(j); - break; - } - - case CON_IFPHEALTHL: - insptr++; - parseifelse(sprite[ps[g_p].i].extra < *insptr); - break; - - case CON_IFPINVENTORY: - { - insptr++; - j = 0; - switch (*insptr++) - { - case GET_STEROIDS: - if (ps[g_p].steroids_amount != *insptr) - j = 1; - break; - case GET_SHIELD: - if (ps[g_p].shield_amount != max_player_health) - j = 1; - break; - case GET_SCUBA: - if (ps[g_p].scuba_amount != *insptr) j = 1; - break; - case GET_HOLODUKE: - if (ps[g_p].holoduke_amount != *insptr) j = 1; - break; - case GET_JETPACK: - if (ps[g_p].jetpack_amount != *insptr) j = 1; - break; - case GET_ACCESS: - switch (g_sp->pal) - { - case 0: - if (ps[g_p].got_access&1) j = 1; - break; - case 21: - if (ps[g_p].got_access&2) j = 1; - break; - case 23: - if (ps[g_p].got_access&4) j = 1; - break; - } - break; - case GET_HEATS: - if (ps[g_p].heat_amount != *insptr) j = 1; - break; - case GET_FIRSTAID: - if (ps[g_p].firstaid_amount != *insptr) j = 1; - break; - case GET_BOOTS: - if (ps[g_p].boot_amount != *insptr) j = 1; - break; - } - - parseifelse(j); - break; - } - - case CON_PSTOMP: - insptr++; - if (ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 40) - if (cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum)) - { - int i; - for (i=0;isectnum; - - j = 0; - - updatesector(g_sp->x+108,g_sp->y+108,&s1); - if (s1 == g_sp->sectnum) - { - updatesector(g_sp->x-108,g_sp->y-108,&s1); - if (s1 == g_sp->sectnum) - { - updatesector(g_sp->x+108,g_sp->y-108,&s1); - if (s1 == g_sp->sectnum) - { - updatesector(g_sp->x-108,g_sp->y+108,&s1); - if (s1 == g_sp->sectnum) - j = 1; - } - } - } - parseifelse(j); } break; + } - case CON_QUOTE: - insptr++; - if (fta_quotes[*insptr] != NULL) - FTA(*insptr++,&ps[g_p]); - else - { - OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); - insptr++; - } - break; + case CON_IFVARAND: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) & *insptr) + j=1; + parseifelse(j); + break; + } - case CON_USERQUOTE: - insptr++; - if (fta_quotes[*insptr] != NULL) - adduserquote(fta_quotes[*insptr++]); - else - { - OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); - insptr++; - } - break; + case CON_IFVARG: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) > *insptr) + j=1; + parseifelse(j); + break; + } - case CON_IFINOUTERSPACE: - parseifelse(floorspace(g_sp->sectnum)); - break; + case CON_IFVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if (GetGameVarID(i, g_i, g_p) < *insptr) + j=1; + parseifelse(j); + break; + } - case CON_IFNOTMOVING: - parseifelse((hittype[g_i].movflag&49152) > 16384); - break; + case CON_IFPHEALTHL: + insptr++; + parseifelse(sprite[ps[g_p].i].extra < *insptr); + break; - case CON_RESPAWNHITAG: - insptr++; - switch (dynamictostatic[g_sp->picnum]) - { - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case PODFEM1__STATIC: - case NAKED1__STATIC: - case STATUE__STATIC: - if (g_sp->yvel) operaterespawns(g_sp->yvel); - break; - default: - if (g_sp->hitag >= 0) operaterespawns(g_sp->hitag); - break; - } - break; - - case CON_IFSPRITEPAL: - insptr++; - parseifelse(g_sp->pal == *insptr); - break; - - case CON_IFANGDIFFL: - insptr++; - j = klabs(getincangle(ps[g_p].ang,g_sp->ang)); - parseifelse(j <= *insptr); - break; - - case CON_IFNOSOUNDS: - for (j=1;jpal) + { + case 0: + if (ps[g_p].got_access&1) j = 1; + break; + case 21: + if (ps[g_p].got_access&2) j = 1; + break; + case 23: + if (ps[g_p].got_access&4) j = 1; + break; + } + break; + case GET_HEATS: + if (ps[g_p].heat_amount != *insptr) j = 1; + break; + case GET_FIRSTAID: + if (ps[g_p].firstaid_amount != *insptr) j = 1; + break; + case GET_BOOTS: + if (ps[g_p].boot_amount != *insptr) j = 1; break; } - case CON_GETCURRADDRESS: + parseifelse(j); + break; + } + + case CON_PSTOMP: + insptr++; + if (ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 40) + if (cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum)) + { + int i; + for (i=0;isectnum; + + j = 0; + + updatesector(g_sp->x+108,g_sp->y+108,&s1); + if (s1 == g_sp->sectnum) { - int i; - insptr++; - - i=*insptr++; - SetGameVarID(i, (long)insptr, g_i, g_p); - break; + updatesector(g_sp->x-108,g_sp->y-108,&s1); + if (s1 == g_sp->sectnum) + { + updatesector(g_sp->x+108,g_sp->y-108,&s1); + if (s1 == g_sp->sectnum) + { + updatesector(g_sp->x-108,g_sp->y+108,&s1); + if (s1 == g_sp->sectnum) + j = 1; + } + } } + parseifelse(j); + } + break; - case CON_JUMP: + case CON_QUOTE: + insptr++; + if (fta_quotes[*insptr] != NULL) + FTA(*insptr++,&ps[g_p]); + else { - int ptr; - + OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); insptr++; - ptr = GetGameVarID(*insptr++, g_i, g_p); - insptr = (long *)ptr; - break; } + break; + case CON_USERQUOTE: + insptr++; + if (fta_quotes[*insptr] != NULL) + adduserquote(fta_quotes[*insptr++]); + else + { + OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); + insptr++; + } + break; + + case CON_IFINOUTERSPACE: + parseifelse(floorspace(g_sp->sectnum)); + break; + + case CON_IFNOTMOVING: + parseifelse((hittype[g_i].movflag&49152) > 16384); + break; + + case CON_RESPAWNHITAG: + insptr++; + switch (dynamictostatic[g_sp->picnum]) + { + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + if (g_sp->yvel) operaterespawns(g_sp->yvel); + break; default: - OSD_Printf("fatal error: default processing: %ld, %ld\ncurrent actor: %d (%d)\n",*insptr,*(insptr-1),g_i,g_sp->picnum); - gameexit("An error has occurred in the EDuke32 CON executor.\n\nPlease mail all of your CON files along with the file eduke32.log\nto terminx@gmail.com.\n\nThank you."); + if (g_sp->hitag >= 0) operaterespawns(g_sp->hitag); break; + } + break; + + case CON_IFSPRITEPAL: + insptr++; + parseifelse(g_sp->pal == *insptr); + break; + + case CON_IFANGDIFFL: + insptr++; + j = klabs(getincangle(ps[g_p].ang,g_sp->ang)); + parseifelse(j <= *insptr); + break; + + case CON_IFNOSOUNDS: + for (j=1;jpicnum); + gameexit("An error has occurred in the EDuke32 CON executor.\n\nPlease mail all of your CON files along with the file eduke32.log\nto terminx@gmail.com.\n\nThank you."); + break; } return 0; } @@ -7021,22 +7021,22 @@ void execute(short sActor,short sPlayer,long lDist) else if (g_sp->statnum == 6) switch (dynamictostatic[g_sp->picnum]) { - case RUBBERCAN__STATIC: - case EXPLODINGBARREL__STATIC: - case WOODENHORSE__STATIC: - case HORSEONSIDE__STATIC: - case CANWITHSOMETHING__STATIC: - case FIREBARREL__STATIC: - case NUKEBARREL__STATIC: - case NUKEBARRELDENTED__STATIC: - case NUKEBARRELLEAKED__STATIC: - case TRIPBOMB__STATIC: - case EGG__STATIC: - if (hittype[g_i].timetosleep > 1) - hittype[g_i].timetosleep--; - else if (hittype[g_i].timetosleep == 1) - changespritestat(g_i,2); - break; + case RUBBERCAN__STATIC: + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case CANWITHSOMETHING__STATIC: + case FIREBARREL__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TRIPBOMB__STATIC: + case EGG__STATIC: + if (hittype[g_i].timetosleep > 1) + hittype[g_i].timetosleep--; + else if (hittype[g_i].timetosleep == 1) + changespritestat(g_i,2); + break; } } } diff --git a/polymer/eduke32/source/grpscan.c b/polymer/eduke32/source/grpscan.c index 8806f0277..5c2014986 100755 --- a/polymer/eduke32/source/grpscan.c +++ b/polymer/eduke32/source/grpscan.c @@ -10,15 +10,14 @@ struct grpfile grpfiles[numgrpfiles] = { - { "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL - } - , - { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, - { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, + { "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL }, + { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, + { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, { "Duke Nukem 3D Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL }, { "Duke Nukem 3D Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL }, - { "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL }, + { "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL }, { "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, + { "Napalm", 0x3DE1589A, 44365728, GAMENAM, NULL }, }; struct grpfile *foundgrps = NULL; diff --git a/polymer/eduke32/source/grpscan.h b/polymer/eduke32/source/grpscan.h index 72518a0fc..a9fc72e69 100755 --- a/polymer/eduke32/source/grpscan.h +++ b/polymer/eduke32/source/grpscan.h @@ -2,7 +2,7 @@ #define __grpscan_h__ // List of internally-known GRP files -#define numgrpfiles 7 +#define numgrpfiles 8 struct grpfile { const char *name; int crcval; diff --git a/polymer/eduke32/source/jaudiolib/_multivc.h b/polymer/eduke32/source/jaudiolib/_multivc.h index 78025d88e..5c9220219 100644 --- a/polymer/eduke32/source/jaudiolib/_multivc.h +++ b/polymer/eduke32/source/jaudiolib/_multivc.h @@ -67,8 +67,11 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) #define SILENCE_8BIT 0x80808080 //#define SILENCE_16BIT_PAS 0 -//#define MixBufferSize 256 +#ifdef WINDOWS #define MixBufferSize (MV_GetBufferSize(MV_RequestedMixRate)) +#else +#define MixBufferSize 256 +#endif #define NumberOfBuffers 16 #define TotalBufferSize ( MixBufferSize * NumberOfBuffers ) @@ -269,9 +272,13 @@ parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ]; #define CDEC _cdecl -#else +#elif defined(WINDOWS) -#define CDEC __cdecl +#define CDEC __cdecl + +#else + +#define CDEC #endif diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c index e2e7b1fd3..1c5fb9ea2 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c @@ -31,14 +31,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TRUE (1==1) #define FALSE (1==0) -#define dprintOSD(...) +#define dprintOSD(...) #ifdef WINDOWS extern long hWindow; #endif -void (*FX_CallBackFunc)(unsigned long) = NULL; +void(*FX_CallBackFunc)(unsigned long) = NULL; int FX_ErrorCode = FX_Ok; #define FX_SetErrorCode( status ) \ @@ -66,35 +66,35 @@ int FX_SimulateCallbacks(void); char *FX_ErrorString(int ErrorNumber) { - char *ErrorString; + char *ErrorString; - switch( ErrorNumber ) - { - case FX_Warning : - case FX_Error : - ErrorString = FX_ErrorString( FX_ErrorCode ); - break; + switch (ErrorNumber) + { + case FX_Warning : + case FX_Error : + ErrorString = FX_ErrorString(FX_ErrorCode); + break; - case FX_Ok : - ErrorString = "Fx ok."; - break; + case FX_Ok : + ErrorString = "Fx ok."; + break; - case FX_ASSVersion : - ErrorString = "Apogee Sound System Version WinMM " - "Programmed by Jim Dose, Ported by Jonathon Fowler\n" - "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; - break; + case FX_ASSVersion : + ErrorString = "Apogee Sound System Version WinMM " + "Programmed by Jim Dose, Ported by Jonathon Fowler\n" + "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; + break; - case FX_FMODInit : - ErrorString = "Failed initializing FMOD."; - break; + case FX_FMODInit : + ErrorString = "Failed initializing FMOD."; + break; - default : - ErrorString = "Unknown Fx error code."; - break; - } + default : + ErrorString = "Unknown Fx error code."; + break; + } - return( ErrorString ); + return(ErrorString); } @@ -106,54 +106,57 @@ char *FX_ErrorString(int ErrorNumber) static char *OutputType(int a) { - switch (a) { - case FSOUND_OUTPUT_NOSOUND: return "no-sound"; - case FSOUND_OUTPUT_WINMM: return "WinMM"; - case FSOUND_OUTPUT_DSOUND: return "DirectSound"; - case FSOUND_OUTPUT_A3D: return "Aureal3D"; - case FSOUND_OUTPUT_OSS: return "OSS"; - case FSOUND_OUTPUT_ESD: return "ESD"; - case FSOUND_OUTPUT_ALSA: return "ALSA"; - case FSOUND_OUTPUT_ASIO: return "ASIO"; - case FSOUND_OUTPUT_XBOX: return "Xbox"; - case FSOUND_OUTPUT_PS2: return "Playstation2"; - case FSOUND_OUTPUT_MAC: return "Macintosh Sound Manager"; - default: return "unknown"; - } + switch (a) + { + case FSOUND_OUTPUT_NOSOUND: return "no-sound"; + case FSOUND_OUTPUT_WINMM: return "WinMM"; + case FSOUND_OUTPUT_DSOUND: return "DirectSound"; + case FSOUND_OUTPUT_A3D: return "Aureal3D"; + case FSOUND_OUTPUT_OSS: return "OSS"; + case FSOUND_OUTPUT_ESD: return "ESD"; + case FSOUND_OUTPUT_ALSA: return "ALSA"; + case FSOUND_OUTPUT_ASIO: return "ASIO"; + case FSOUND_OUTPUT_XBOX: return "Xbox"; + case FSOUND_OUTPUT_PS2: return "Playstation2"; + case FSOUND_OUTPUT_MAC: return "Macintosh Sound Manager"; + default: return "unknown"; + } } int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate) { - FSOUND_Close(); + FSOUND_Close(); - memset(FX_Samples, 0, sizeof(FX_Samples)); + memset(FX_Samples, 0, sizeof(FX_Samples)); #ifdef WINDOWS - if (hWindow) { - //FSOUND_SetHWND(&hWindow); - } + if (hWindow) + { + //FSOUND_SetHWND(&hWindow); + } #endif - if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS)) { - FX_SetErrorCode( FX_FMODInit ); - return FX_Error; - } + if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS)) + { + FX_SetErrorCode(FX_FMODInit); + return FX_Error; + } - printOSD("FX_Init(): %d voices, %d channels, %dHz samplerate\n", numvoices,numchannels,FSOUND_GetOutputRate()); - printOSD("FX_Init(): FMOD is using the %s output driver\n", OutputType(FSOUND_GetOutput())); + printOSD("FX_Init(): %d voices, %d channels, %dHz samplerate\n", numvoices,numchannels,FSOUND_GetOutputRate()); + printOSD("FX_Init(): FMOD is using the %s output driver\n", OutputType(FSOUND_GetOutput())); - chtoggle=0; - if (chstates) free(chstates); - chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices); - memset(chstates,0,numvoices*2 + sizeof(long)*numvoices); - - chcallvals = (long*)(chstates + numvoices*2); - chstatesa = chstates; - chstatesb = chstates + numvoices; + chtoggle=0; + if (chstates) free(chstates); + chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices); + memset(chstates,0,numvoices*2 + sizeof(long)*numvoices); - FX_NumVoices = numvoices; - - FX_SetErrorCode(FX_Ok); - return FX_Ok; + chcallvals = (long*)(chstates + numvoices*2); + chstatesa = chstates; + chstatesb = chstates + numvoices; + + FX_NumVoices = numvoices; + + FX_SetErrorCode(FX_Ok); + return FX_Ok; } @@ -165,20 +168,21 @@ int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsig int FX_Shutdown(void) { - unsigned int curalloced, maxalloced; - - if (chstates) { - FSOUND_GetMemoryStats(&curalloced, &maxalloced); - printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced); - } - - FSOUND_Close(); + unsigned int curalloced, maxalloced; - if (chstates) free(chstates); - chstates=chstatesa=chstatesb=0; - - FX_SetErrorCode(FX_Ok); - return FX_Ok; + if (chstates) + { + FSOUND_GetMemoryStats(&curalloced, &maxalloced); + printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced); + } + + FSOUND_Close(); + + if (chstates) free(chstates); + chstates=chstatesa=chstatesb=0; + + FX_SetErrorCode(FX_Ok); + return FX_Ok; } @@ -188,11 +192,11 @@ int FX_Shutdown(void) Sets the function to call when a voice is done. ---------------------------------------------------------------------*/ -int FX_SetCallBack(void ( *function )( unsigned long )) +int FX_SetCallBack(void(*function)(unsigned long)) { - FX_CallBackFunc = function; - FX_SetErrorCode(FX_Ok); - return FX_Ok; + FX_CallBackFunc = function; + FX_SetErrorCode(FX_Ok); + return FX_Ok; } @@ -204,7 +208,7 @@ int FX_SetCallBack(void ( *function )( unsigned long )) void FX_SetVolume(int volume) { - FSOUND_SetSFXMasterVolume(volume); + FSOUND_SetSFXMasterVolume(volume); } @@ -215,8 +219,7 @@ void FX_SetVolume(int volume) ---------------------------------------------------------------------*/ void FX_SetReverseStereo(int setting) -{ -} +{} /*--------------------------------------------------------------------- @@ -227,7 +230,7 @@ void FX_SetReverseStereo(int setting) int FX_GetReverseStereo(void) { - return 0; + return 0; } @@ -238,8 +241,7 @@ int FX_GetReverseStereo(void) ---------------------------------------------------------------------*/ void FX_SetReverb(int reverb) -{ -} +{} /*--------------------------------------------------------------------- @@ -249,8 +251,7 @@ void FX_SetReverb(int reverb) ---------------------------------------------------------------------*/ void FX_SetReverbDelay(int delay) -{ -} +{} /*--------------------------------------------------------------------- @@ -261,8 +262,8 @@ void FX_SetReverbDelay(int delay) int FX_VoiceAvailable(int priority) { - FX_SimulateCallbacks(); - return 1; + FX_SimulateCallbacks(); + return 1; } @@ -278,19 +279,19 @@ int FX_VoiceAvailable(int priority) ---------------------------------------------------------------------*/ int FX_PlayLoopedVOC - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) { - return FX_PlayLoopedSound(pitchoffset, vol, callbackval); + return FX_PlayLoopedSound(pitchoffset, vol, callbackval); } @@ -301,19 +302,19 @@ int FX_PlayLoopedVOC ---------------------------------------------------------------------*/ int FX_PlayLoopedWAV - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) { - return FX_PlayLoopedSound(pitchoffset, vol, callbackval); + return FX_PlayLoopedSound(pitchoffset, vol, callbackval); } @@ -325,16 +326,16 @@ int FX_PlayLoopedWAV ---------------------------------------------------------------------*/ int FX_PlayVOC3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) { - return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); + return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); } @@ -346,16 +347,16 @@ int FX_PlayVOC3D ---------------------------------------------------------------------*/ int FX_PlayWAV3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) { - return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); + return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); } @@ -367,13 +368,13 @@ int FX_PlayWAV3D ---------------------------------------------------------------------*/ int FX_Pan3D - ( - int handle, - int angle, - int distance - ) +( + int handle, + int angle, + int distance +) { - return FX_Ok; + return FX_Ok; } @@ -385,14 +386,14 @@ int FX_Pan3D int FX_StopSound(int handle) { - FX_SimulateCallbacks(); - FSOUND_StopSound(handle); + FX_SimulateCallbacks(); + FSOUND_StopSound(handle); - if (handle>=0 && handle=0 && handle> (channels-1)) / (samplesize>>3), flags, samplerate, -1, -1, priority); - if (samp) { - if (FSOUND_Sample_Lock(samp,0,datalen,&ptr1,&ptr2,&ptr1len,&ptr2len)) { - if (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ; - FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len); - } - } - } - } else { - samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size); - } + if (!memcmp(ptr, "Creative Voice File", 0x13)) + { + // VOC file + if (FX_ReadVOCInfo(ptr,size,&samplerate,&channels,&samplesize,&datalen) == 0) + { + flags |= (channels==2)?FSOUND_STEREO:FSOUND_MONO; + flags |= (samplesize==16)?FSOUND_16BITS:FSOUND_8BITS; + flags |= FSOUND_SIGNED; + samp = FSOUND_Sample_Alloc(number, (datalen >> (channels-1)) / (samplesize>>3), flags, samplerate, -1, -1, priority); + if (samp) + { + if (FSOUND_Sample_Lock(samp,0,datalen,&ptr1,&ptr2,&ptr1len,&ptr2len)) + { + if (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ; + FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len); + } + } + } + } + else + { + samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size); + } - dprintOSD("FX_LoadSample(): loaded sound %d\n",number); - if (samp) FSOUND_Sample_SetDefaults(samp, -1, -1, -1, priority); - FX_Samples[number] = samp; + dprintOSD("FX_LoadSample(): loaded sound %d\n",number); + if (samp) FSOUND_Sample_SetDefaults(samp, -1, -1, -1, priority); + FX_Samples[number] = samp; - return (samp != NULL); + return (samp != NULL); } int FX_SampleLoaded(unsigned long number) { - return (FX_Samples[number] != NULL); + return (FX_Samples[number] != NULL); } @@ -536,202 +543,215 @@ int FX_SampleLoaded(unsigned long number) int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen) { - short version,version2; - char blocktype=0; - int blocklen=0; - char *ptr=data; + short version,version2; + char blocktype=0; + int blocklen=0; + char *ptr=data; - if (memcmp(ptr, "Creative Voice File\x1A", 0x14)) return -1; - ptr += 0x14; - - ptr += 2; - version = ((short*)ptr)[0]; - version2 = ((short*)ptr)[1]; + if (memcmp(ptr, "Creative Voice File\x1A", 0x14)) return -1; + ptr += 0x14; - if (~version + 0x1234 != version2) return -1; + ptr += 2; + version = ((short*)ptr)[0]; + version2 = ((short*)ptr)[1]; - ptr += 4; + if (~version + 0x1234 != version2) return -1; - while (1) { - blocktype = *(ptr++); - if ((ptr-data)>size) return -1; // truncated - - if (blocktype == 0) - break; + ptr += 4; - blocklen = *(ptr++); - blocklen |= *(ptr++) << 8; - blocklen |= *(ptr++) << 16; + while (1) + { + blocktype = *(ptr++); + if ((ptr-data)>size) return -1; // truncated - switch (blocktype) { - case 1: /* sound data begin block */ - if (!*samplerate) - *samplerate = REGRESSSR(ptr[0]); - if (ptr[1] != 0) { - /* only 8-bit files please */ - return -1; - } - if (!*channels) *channels = 1; - *samplesize = 8; - *datalen += blocklen-2; - ptr += blocklen; - break; + if (blocktype == 0) + break; - case 2: /* sound continue */ - *datalen += blocklen; - ptr += blocklen; - break; + blocklen = *(ptr++); + blocklen |= *(ptr++) << 8; + blocklen |= *(ptr++) << 16; + + switch (blocktype) + { + case 1: /* sound data begin block */ + if (!*samplerate) + *samplerate = REGRESSSR(ptr[0]); + if (ptr[1] != 0) + { + /* only 8-bit files please */ + return -1; + } + if (!*channels) *channels = 1; + *samplesize = 8; + *datalen += blocklen-2; + ptr += blocklen; + break; + + case 2: /* sound continue */ + *datalen += blocklen; + ptr += blocklen; + break; #if 0 - case 3: /* silence */ - kread(fh, blockprop, 3); - /* - length = blockprop[0] | (blockprop[1] << 8) - sample rate = REGRESSSR(blockprop[2])) - */ - break; + case 3: /* silence */ + kread(fh, blockprop, 3); + /* + length = blockprop[0] | (blockprop[1] << 8) + sample rate = REGRESSSR(blockprop[2])) + */ + break; - case 4: /* marker */ - kread(fh, &blockprop, 2); - /* - id = blockprop[0] | (blockprop[1] << 8)) - */ - break; + case 4: /* marker */ + kread(fh, &blockprop, 2); + /* + id = blockprop[0] | (blockprop[1] << 8)) + */ + break; - case 5: /* ASCII data */ - klseek(fh, blocklen, SEEK_CUR); - /* - asciiz string - */ - break; + case 5: /* ASCII data */ + klseek(fh, blocklen, SEEK_CUR); + /* + asciiz string + */ + break; - case 6: /* repeat */ - kread(fh, blockprop, 2); - /* - num repetitions = (blockprop[0] | (blockprop[1] << 8)) - 1 - */ - break; + case 6: /* repeat */ + kread(fh, blockprop, 2); + /* + num repetitions = (blockprop[0] | (blockprop[1] << 8)) - 1 + */ + break; - case 7: /* end repeat */ - break; + case 7: /* end repeat */ + break; #endif - case 8: /* sound attribute extension block */ - *samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8)); - *samplesize = 8; - if (ptr[3] == 1) { - *samplerate >>= 1; - *channels = 2; - } else - *channels = 1; - if (ptr[2] != 0) { - /* only 8-bit files please */ - return -1; - } - ptr += 4; - /* a block 1 follows */ - break; + case 8: /* sound attribute extension block */ + *samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8)); + *samplesize = 8; + if (ptr[3] == 1) + { + *samplerate >>= 1; + *channels = 2; + } + else + *channels = 1; + if (ptr[2] != 0) + { + /* only 8-bit files please */ + return -1; + } + ptr += 4; + /* a block 1 follows */ + break; - case 9: /* sound data format 3 */ - *samplerate = *((long*)(ptr)); - *samplesize = ptr[4]; - *channels = ptr[5]; - if ((ptr[6] | (ptr[7] << 8)) != 0 && - (ptr[6] | (ptr[7] << 8)) != 4) { - /* only PCM please */ - return -1; - } - *datalen += blocklen-12; - ptr += blocklen; - break; + case 9: /* sound data format 3 */ + *samplerate = *((long*)(ptr)); + *samplesize = ptr[4]; + *channels = ptr[5]; + if ((ptr[6] | (ptr[7] << 8)) != 0 && + (ptr[6] | (ptr[7] << 8)) != 4) + { + /* only PCM please */ + return -1; + } + *datalen += blocklen-12; + ptr += blocklen; + break; - default: - ptr += blocklen; - break; - } - } + default: + ptr += blocklen; + break; + } + } - return 0; + return 0; } int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit) { - short offset; - char blocktype=0; - int blocklen=0, br; + short offset; + char blocktype=0; + int blocklen=0, br; - data += 0x14 + 2 + 4; + data += 0x14 + 2 + 4; - while (bufferlen>0) { - blocktype = *(data++); - - if (blocktype == 0) - break; + while (bufferlen>0) + { + blocktype = *(data++); - blocklen = *(data++); - blocklen |= *(data++) << 8; - blocklen |= *(data++) << 16; + if (blocktype == 0) + break; - switch (blocktype) { - case 1: /* sound data */ - data += 2; + blocklen = *(data++); + blocklen |= *(data++) << 8; + blocklen |= *(data++) << 16; - br = min(blocklen-2, bufferlen); - goto convertdata; + switch (blocktype) + { + case 1: /* sound data */ + data += 2; - case 2: /* sound continue */ - br = min(blocklen, bufferlen); - goto convertdata; + br = min(blocklen-2, bufferlen); + goto convertdata; - case 9: /* sound data format 3 */ - data += 12; + case 2: /* sound continue */ + br = min(blocklen, bufferlen); + goto convertdata; - br = min(blocklen-12, bufferlen); - goto convertdata; + case 9: /* sound data format 3 */ + data += 12; - default: - data += blocklen; - continue; - } + br = min(blocklen-12, bufferlen); + goto convertdata; + + default: + data += blocklen; + continue; + } convertdata: - bufferlen -= br; - if (eightbit) { - // FMOD wants signed data - for (; br>0; br--) - *(buf++) = (char)((short)(*(data++)) - 0x80); - } else { - memcpy(buf,data,br); - buf += br; - data += br; - } - } + bufferlen -= br; + if (eightbit) + { + // FMOD wants signed data + for (; br>0; br--) + *(buf++) = (char)((short)(*(data++)) - 0x80); + } + else + { + memcpy(buf,data,br); + buf += br; + data += br; + } + } - return 0; + return 0; } int FX_SimulateCallbacks(void) { - int i; - - if (!FX_CallBackFunc || !chstates) return 0; + int i; - chstatesa = chstates + (FX_NumVoices * chtoggle); - chstatesb = chstates + (FX_NumVoices * (chtoggle^1)); + if (!FX_CallBackFunc || !chstates) return 0; - for (i=0;i chstatesb[i]) continue; // channel has begun playing + chstatesa = chstates + (FX_NumVoices * chtoggle); + chstatesb = chstates + (FX_NumVoices * (chtoggle^1)); - // channel has ended playing - FX_CallBackFunc(chcallvals[i]); - dprintOSD("FX_SimulateCallbacks(): channel %d ended sound %d\n",i,chcallvals[i]); - } + for (i=0;i chstatesb[i]) continue; // channel has begun playing - chtoggle ^= 1; + // channel has ended playing + FX_CallBackFunc(chcallvals[i]); + dprintOSD("FX_SimulateCallbacks(): channel %d ended sound %d\n",i,chcallvals[i]); + } - return 0; + chtoggle ^= 1; + + return 0; } diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c index a0bfcc4a2..d44bad716 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c @@ -45,37 +45,37 @@ int FX_ErrorCode = FX_Ok; ---------------------------------------------------------------------*/ char *FX_ErrorString - ( - int ErrorNumber - ) +( + int ErrorNumber +) - { - char *ErrorString; +{ + char *ErrorString; - switch( ErrorNumber ) - { - case FX_Warning : - case FX_Error : - ErrorString = FX_ErrorString( FX_ErrorCode ); - break; + switch (ErrorNumber) + { + case FX_Warning : + case FX_Error : + ErrorString = FX_ErrorString(FX_ErrorCode); + break; - case FX_Ok : - ErrorString = "Fx ok."; - break; + case FX_Ok : + ErrorString = "Fx ok."; + break; - case FX_ASSVersion : - ErrorString = "Apogee Sound System Version 0 " - "Programmed by Jim Dose\n" - "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; - break; + case FX_ASSVersion : + ErrorString = "Apogee Sound System Version 0 " + "Programmed by Jim Dose\n" + "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; + break; - default : - ErrorString = "Unknown Fx error code."; - break; - } + default : + ErrorString = "Unknown Fx error code."; + break; + } - return( ErrorString ); - } + return(ErrorString); +} /*--------------------------------------------------------------------- @@ -85,17 +85,17 @@ char *FX_ErrorString ---------------------------------------------------------------------*/ int FX_Init - ( - int SoundCard, - int numvoices, - int numchannels, - int samplebits, - unsigned mixrate - ) +( + int SoundCard, + int numvoices, + int numchannels, + int samplebits, + unsigned mixrate +) - { - return( FX_Ok ); - } +{ + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -105,13 +105,13 @@ int FX_Init ---------------------------------------------------------------------*/ int FX_Shutdown - ( - void - ) +( + void +) - { - return( FX_Ok ); - } +{ + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -121,13 +121,13 @@ int FX_Shutdown ---------------------------------------------------------------------*/ int FX_SetCallBack - ( - void ( *function )( unsigned long ) - ) +( + void(*function)(unsigned long) +) - { - return( FX_Ok ); - } +{ + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -137,12 +137,11 @@ int FX_SetCallBack ---------------------------------------------------------------------*/ void FX_SetVolume - ( - int volume - ) +( + int volume +) - { - } +{} /*--------------------------------------------------------------------- @@ -152,12 +151,11 @@ void FX_SetVolume ---------------------------------------------------------------------*/ void FX_SetReverseStereo - ( - int setting - ) +( + int setting +) - { - } +{} /*--------------------------------------------------------------------- @@ -167,13 +165,13 @@ void FX_SetReverseStereo ---------------------------------------------------------------------*/ int FX_GetReverseStereo - ( - void - ) +( + void +) - { - return 0; - } +{ + return 0; +} /*--------------------------------------------------------------------- @@ -183,12 +181,11 @@ int FX_GetReverseStereo ---------------------------------------------------------------------*/ void FX_SetReverb - ( - int reverb - ) +( + int reverb +) - { - } +{} /*--------------------------------------------------------------------- @@ -198,12 +195,11 @@ void FX_SetReverb ---------------------------------------------------------------------*/ void FX_SetReverbDelay - ( - int delay - ) +( + int delay +) - { - } +{} /*--------------------------------------------------------------------- @@ -213,13 +209,13 @@ void FX_SetReverbDelay ---------------------------------------------------------------------*/ int FX_VoiceAvailable - ( - int priority - ) +( + int priority +) - { - return 0; - } +{ + return 0; +} /*--------------------------------------------------------------------- @@ -229,21 +225,21 @@ int FX_VoiceAvailable ---------------------------------------------------------------------*/ int FX_PlayLoopedVOC - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -253,21 +249,21 @@ int FX_PlayLoopedVOC ---------------------------------------------------------------------*/ int FX_PlayLoopedWAV - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -278,18 +274,18 @@ int FX_PlayLoopedWAV ---------------------------------------------------------------------*/ int FX_PlayVOC3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -300,18 +296,18 @@ int FX_PlayVOC3D ---------------------------------------------------------------------*/ int FX_PlayWAV3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -322,15 +318,15 @@ int FX_PlayWAV3D ---------------------------------------------------------------------*/ int FX_Pan3D - ( - int handle, - int angle, - int distance - ) +( + int handle, + int angle, + int distance +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -340,13 +336,13 @@ int FX_Pan3D ---------------------------------------------------------------------*/ int FX_StopSound - ( - int handle - ) +( + int handle +) - { - return( FX_Ok ); - } +{ + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -356,13 +352,13 @@ int FX_StopSound ---------------------------------------------------------------------*/ int FX_StopAllSounds - ( - void - ) +( + void +) - { - return( FX_Ok ); - } +{ + return(FX_Ok); +} void AudioUpdate(void) { } diff --git a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c index a8e2e1a2e..0e4b85743 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c @@ -41,60 +41,60 @@ int MUSIC_ErrorCode = MUSIC_Ok; ---------------------------------------------------------------------*/ char *MUSIC_ErrorString - ( - int ErrorNumber - ) +( + int ErrorNumber +) - { - char *ErrorString; +{ + char *ErrorString; - switch( ErrorNumber ) - { - case MUSIC_Warning : - case MUSIC_Error : - ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode ); - break; + switch (ErrorNumber) + { + case MUSIC_Warning : + case MUSIC_Error : + ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode); + break; - case MUSIC_Ok : - ErrorString = "Music ok."; - break; + case MUSIC_Ok : + ErrorString = "Music ok."; + break; - case MUSIC_ASSVersion : - ErrorString = "Apogee Sound System Version " - "Programmed by Jim Dose\n" - "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; - break; + case MUSIC_ASSVersion : + ErrorString = "Apogee Sound System Version " + "Programmed by Jim Dose\n" + "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; + break; - case MUSIC_SoundCardError : - break; + case MUSIC_SoundCardError : + break; - case MUSIC_MPU401Error : - ErrorString = "Could not detect MPU-401."; - break; + case MUSIC_MPU401Error : + ErrorString = "Could not detect MPU-401."; + break; - case MUSIC_InvalidCard : - ErrorString = "Invalid Music device."; - break; + case MUSIC_InvalidCard : + ErrorString = "Invalid Music device."; + break; - case MUSIC_MidiError : - ErrorString = "Error playing MIDI file."; - break; + case MUSIC_MidiError : + ErrorString = "Error playing MIDI file."; + break; - case MUSIC_TaskManError : - ErrorString = "TaskMan error."; - break; + case MUSIC_TaskManError : + ErrorString = "TaskMan error."; + break; - case MUSIC_DPMI_Error : - ErrorString = "DPMI Error in MUSIC."; - break; + case MUSIC_DPMI_Error : + ErrorString = "DPMI Error in MUSIC."; + break; - default : - ErrorString = "Unknown Music error code."; - break; - } + default : + ErrorString = "Unknown Music error code."; + break; + } - return( ErrorString ); - } + return(ErrorString); +} /*--------------------------------------------------------------------- @@ -104,19 +104,19 @@ char *MUSIC_ErrorString ---------------------------------------------------------------------*/ int MUSIC_Init - ( - int SoundCard, - int Address - ) +( + int SoundCard, + int Address +) - { - int i; - int status; +{ + int i; + int status; - status = MUSIC_Ok; + status = MUSIC_Ok; - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -126,18 +126,18 @@ int MUSIC_Init ---------------------------------------------------------------------*/ int MUSIC_Shutdown - ( - void - ) +( + void +) - { - int status; +{ + int status; - status = MUSIC_Ok; + status = MUSIC_Ok; - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -147,12 +147,11 @@ int MUSIC_Shutdown ---------------------------------------------------------------------*/ void MUSIC_SetMaxFMMidiChannel - ( - int channel - ) +( + int channel +) - { - } +{} /*--------------------------------------------------------------------- @@ -162,12 +161,11 @@ void MUSIC_SetMaxFMMidiChannel ---------------------------------------------------------------------*/ void MUSIC_SetVolume - ( - int volume - ) +( + int volume +) - { - } +{} /*--------------------------------------------------------------------- @@ -177,13 +175,12 @@ void MUSIC_SetVolume ---------------------------------------------------------------------*/ void MUSIC_SetMidiChannelVolume - ( - int channel, - int volume - ) +( + int channel, + int volume +) - { - } +{} /*--------------------------------------------------------------------- @@ -193,12 +190,11 @@ void MUSIC_SetMidiChannelVolume ---------------------------------------------------------------------*/ void MUSIC_ResetMidiChannelVolumes - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -208,13 +204,13 @@ void MUSIC_ResetMidiChannelVolumes ---------------------------------------------------------------------*/ int MUSIC_GetVolume - ( - void - ) +( + void +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -225,12 +221,11 @@ int MUSIC_GetVolume ---------------------------------------------------------------------*/ void MUSIC_SetLoopFlag - ( - int loopflag - ) +( + int loopflag +) - { - } +{} /*--------------------------------------------------------------------- @@ -240,13 +235,13 @@ void MUSIC_SetLoopFlag ---------------------------------------------------------------------*/ int MUSIC_SongPlaying - ( - void - ) +( + void +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -256,12 +251,11 @@ int MUSIC_SongPlaying ---------------------------------------------------------------------*/ void MUSIC_Continue - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -271,12 +265,11 @@ void MUSIC_Continue ---------------------------------------------------------------------*/ void MUSIC_Pause - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -286,13 +279,13 @@ void MUSIC_Pause ---------------------------------------------------------------------*/ int MUSIC_StopSong - ( - void - ) +( + void +) - { - return( MUSIC_Ok ); - } +{ + return(MUSIC_Ok); +} /*--------------------------------------------------------------------- @@ -302,14 +295,14 @@ int MUSIC_StopSong ---------------------------------------------------------------------*/ int MUSIC_PlaySong - ( - unsigned char *song, - int loopflag - ) +( + unsigned char *song, + int loopflag +) - { - return( MUSIC_Ok ); - } +{ + return(MUSIC_Ok); +} /*--------------------------------------------------------------------- @@ -319,12 +312,11 @@ int MUSIC_PlaySong ---------------------------------------------------------------------*/ void MUSIC_SetContext - ( - int context - ) +( + int context +) - { - } +{} /*--------------------------------------------------------------------- @@ -334,12 +326,11 @@ void MUSIC_SetContext ---------------------------------------------------------------------*/ int MUSIC_GetContext - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -349,12 +340,11 @@ int MUSIC_GetContext ---------------------------------------------------------------------*/ void MUSIC_SetSongTick - ( - unsigned long PositionInTicks - ) +( + unsigned long PositionInTicks +) - { - } +{} /*--------------------------------------------------------------------- @@ -364,12 +354,11 @@ void MUSIC_SetSongTick ---------------------------------------------------------------------*/ void MUSIC_SetSongTime - ( - unsigned long milliseconds - ) +( + unsigned long milliseconds +) - { - } +{} /*--------------------------------------------------------------------- @@ -379,14 +368,13 @@ void MUSIC_SetSongTime ---------------------------------------------------------------------*/ void MUSIC_SetSongPosition - ( - int measure, - int beat, - int tick - ) +( + int measure, + int beat, + int tick +) - { - } +{} /*--------------------------------------------------------------------- @@ -396,12 +384,11 @@ void MUSIC_SetSongPosition ---------------------------------------------------------------------*/ void MUSIC_GetSongPosition - ( - songposition *pos - ) +( + songposition *pos +) - { - } +{} /*--------------------------------------------------------------------- @@ -411,12 +398,11 @@ void MUSIC_GetSongPosition ---------------------------------------------------------------------*/ void MUSIC_GetSongLength - ( - songposition *pos - ) +( + songposition *pos +) - { - } +{} @@ -431,14 +417,14 @@ void MUSIC_GetSongLength ---------------------------------------------------------------------*/ int MUSIC_FadeVolume - ( - int tovolume, - int milliseconds - ) +( + int tovolume, + int milliseconds +) - { - return( MUSIC_Ok ); - } +{ + return(MUSIC_Ok); +} /*--------------------------------------------------------------------- @@ -448,13 +434,13 @@ int MUSIC_FadeVolume ---------------------------------------------------------------------*/ int MUSIC_FadeActive - ( - void - ) +( + void +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -464,12 +450,11 @@ int MUSIC_FadeActive ---------------------------------------------------------------------*/ void MUSIC_StopFade - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -480,13 +465,12 @@ void MUSIC_StopFade ---------------------------------------------------------------------*/ void MUSIC_RerouteMidiChannel - ( - int channel, - int ( *function )( int event, int c1, int c2 ) - ) +( + int channel, + int(*function)(int event, int c1, int c2) +) - { - } +{} /*--------------------------------------------------------------------- @@ -496,15 +480,13 @@ void MUSIC_RerouteMidiChannel ---------------------------------------------------------------------*/ void MUSIC_RegisterTimbreBank - ( - unsigned char *timbres - ) +( + unsigned char *timbres +) - { - } +{} void MUSIC_Update(void) -{ -} +{} diff --git a/polymer/eduke32/source/jaudiolib/debugio.h b/polymer/eduke32/source/jaudiolib/debugio.h new file mode 100755 index 000000000..a6510ba19 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/debugio.h @@ -0,0 +1,30 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +#ifndef __DEBUGIO_H +#define __DEBUGIO_H + +void DB_SetXY( int x, int y ); +void DB_PutChar( char ch ); +int DB_PrintString( char *string ); +int DB_PrintNum( int number ); +int DB_PrintUnsigned( unsigned long number, int radix ); +int DB_printf( char *fmt, ... ); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/dma.h b/polymer/eduke32/source/jaudiolib/dma.h new file mode 100755 index 000000000..f68d4ea2e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/dma.h @@ -0,0 +1,83 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + file: DMA.H + + author: James R. Dose + date: February 4, 1994 + + Public header file for DMA.C + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __DMA_H +#define __DMA_H + +enum DMA_ERRORS + { + DMA_Error = -1, + DMA_Ok = 0, + DMA_ChannelOutOfRange, + DMA_InvalidChannel + }; + +enum DMA_Modes + { + DMA_SingleShotRead, + DMA_SingleShotWrite, + DMA_AutoInitRead, + DMA_AutoInitWrite + }; + +char *DMA_ErrorString + ( + int ErrorNumber + ); + +int DMA_VerifyChannel + ( + int channel + ); + +int DMA_SetupTransfer + ( + int channel, + char *address, + int length, + int mode + ); + +int DMA_EndTransfer + ( + int channel + ); + +char *DMA_GetCurrentPos + ( + int channel + ); + +int DMA_GetTransferCount + ( + int channel + ); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/dpmi.h b/polymer/eduke32/source/jaudiolib/dpmi.h new file mode 100755 index 000000000..da9409e21 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/dpmi.h @@ -0,0 +1,43 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + module: DPMI.H + + author: James R. Dose + date: March 31, 1994 + + Inline functions for performing DPMI calls. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __DPMI_H +#define __DPMI_H + +enum DPMI_Errors + { + DPMI_Warning = -2, + DPMI_Error = -1, + DPMI_Ok = 0 + }; + +int DPMI_GetDOSMemory( void **ptr, int *descriptor, unsigned length ); +int DPMI_FreeDOSMemory( int descriptor ); +#endif diff --git a/polymer/eduke32/source/jaudiolib/dsl.c b/polymer/eduke32/source/jaudiolib/dsl.c new file mode 100755 index 000000000..21b87a115 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/dsl.c @@ -0,0 +1,266 @@ +/* +Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Originally written by Ryan C. Gordon. (icculus@clutteredmind.org) +Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) + +*/ +#include +#include + +#include "dsl.h" +#include "util.h" + +#include "SDL.h" +#include "SDL_mixer.h" + +extern volatile int MV_MixPage; + +static int DSL_ErrorCode = DSL_Ok; + +static int mixer_initialized; + +static void(*_CallBackFunc)(void); +static volatile char *_BufferStart; +static int _BufferSize; +static int _NumDivisions; +static int _SampleRate; +static int _remainder; + +static Mix_Chunk *blank; +static unsigned char *blank_buf; + +/* +possible todo ideas: cache sdl/sdl mixer error messages. +*/ + +char *DSL_ErrorString(int ErrorNumber) +{ + char *ErrorString; + + switch (ErrorNumber) + { + case DSL_Warning: + case DSL_Error: + ErrorString = DSL_ErrorString(DSL_ErrorCode); + break; + + case DSL_Ok: + ErrorString = "SDL Driver ok."; + break; + + case DSL_SDLInitFailure: + ErrorString = "SDL Audio initialization failed."; + break; + + case DSL_MixerActive: + ErrorString = "SDL Mixer already initialized."; + break; + + case DSL_MixerInitFailure: + ErrorString = "SDL Mixer initialization failed."; + break; + + default: + ErrorString = "Unknown SDL Driver error."; + break; + } + + return ErrorString; +} + +static void DSL_SetErrorCode(int ErrorCode) +{ + DSL_ErrorCode = ErrorCode; +} + +int DSL_Init(void) +{ + DSL_SetErrorCode(DSL_Ok); + + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) + { + DSL_SetErrorCode(DSL_SDLInitFailure); + + return DSL_Error; + } + + return DSL_Ok; +} + +void DSL_Shutdown(void) +{ + DSL_StopPlayback(); +} + +static void mixer_callback(int chan, void *stream, int len, void *udata) +{ + Uint8 *stptr; + Uint8 *fxptr; + int copysize; + + /* len should equal _BufferSize, else this is screwed up */ + + stptr = (Uint8 *)stream; + + if (_remainder > 0) + { + copysize = min(len, _remainder); + + fxptr = (Uint8 *)(&_BufferStart[MV_MixPage * + _BufferSize]); + + memcpy(stptr, fxptr+(_BufferSize-_remainder), copysize); + + len -= copysize; + _remainder -= copysize; + + stptr += copysize; + } + + while (len > 0) + { + /* new buffer */ + + _CallBackFunc(); + + fxptr = (Uint8 *)(&_BufferStart[MV_MixPage * + _BufferSize]); + + copysize = min(len, _BufferSize); + + memcpy(stptr, fxptr, copysize); + + len -= copysize; + + stptr += copysize; + } + + _remainder = len; +} + +int DSL_BeginBufferedPlayback(char *BufferStart, + int BufferSize, int NumDivisions, unsigned SampleRate, + int MixMode, void(*CallBackFunc)(void)) +{ + Uint16 format; + Uint8 *tmp; + int channels; + int chunksize; + + if (mixer_initialized) + { + DSL_SetErrorCode(DSL_MixerActive); + + return DSL_Error; + } + + _CallBackFunc = CallBackFunc; + _BufferStart = BufferStart; + _BufferSize = (BufferSize / NumDivisions); + _NumDivisions = NumDivisions; + _SampleRate = SampleRate; + + _remainder = 0; + + format = (MixMode & SIXTEEN_BIT) ? AUDIO_S16SYS : AUDIO_U8; + channels = (MixMode & STEREO) ? 2 : 1; + + /* + 23ms is typically ideal (11025,22050,44100) + 46ms isn't bad + */ + + chunksize = 512; + + if (SampleRate >= 16000) chunksize *= 2; + if (SampleRate >= 32000) chunksize *= 2; + + /* + // SDL mixer does this already + if (MixMode & SIXTEEN_BIT) chunksize *= 2; + if (MixMode & STEREO) chunksize *= 2; + */ + + if (Mix_OpenAudio(SampleRate, format, channels, chunksize) < 0) + { + DSL_SetErrorCode(DSL_MixerInitFailure); + + return DSL_Error; + } + + /* + Mix_SetPostMix(mixer_callback, NULL); + */ + /* have to use a channel because postmix will overwrite the music... */ + Mix_RegisterEffect(0, mixer_callback, NULL, NULL); + + /* create a dummy sample just to allocate that channel */ + blank_buf = (Uint8 *)malloc(4096); + memset(blank_buf, 0, 4096); + + blank = Mix_QuickLoad_RAW(blank_buf, 4096); + + Mix_PlayChannel(0, blank, -1); + + mixer_initialized = 1; + + return DSL_Ok; +} + +void DSL_StopPlayback(void) +{ + if (mixer_initialized) + { + Mix_HaltChannel(0); + } + + if (blank != NULL) + { + Mix_FreeChunk(blank); + } + + blank = NULL; + + if (blank_buf != NULL) + { + free(blank_buf); + } + + blank_buf = NULL; + + if (mixer_initialized) + { + Mix_CloseAudio(); + } + + mixer_initialized = 0; +} + +unsigned DSL_GetPlaybackRate(void) +{ + return _SampleRate; +} + +unsigned long DisableInterrupts(void) +{ + return 0; +} + +void RestoreInterrupts(unsigned long flags) +{} diff --git a/polymer/eduke32/source/jaudiolib/dsl.h b/polymer/eduke32/source/jaudiolib/dsl.h new file mode 100755 index 000000000..23c7f24fe --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/dsl.h @@ -0,0 +1,50 @@ +/* +Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Originally written by Ryan C. Gordon. (icculus@clutteredmind.org) +Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) + +*/ +#ifndef AUDIOLIB__DSL_H +#define AUDIOLIB__DSL_H + +#define MONO_8BIT 0 +#define STEREO 1 +#define SIXTEEN_BIT 2 +#define STEREO_16BIT ( STEREO | SIXTEEN_BIT ) + +enum DSL_ERRORS + { + DSL_Warning = -2, + DSL_Error = -1, + DSL_Ok = 0, + DSL_SDLInitFailure, + DSL_MixerActive, + DSL_MixerInitFailure + }; + +char *DSL_ErrorString( int ErrorNumber ); +int DSL_Init( void ); +void DSL_StopPlayback( void ); +unsigned DSL_GetPlaybackRate( void ); +int DSL_BeginBufferedPlayback( char *BufferStart, + int BufferSize, int NumDivisions, unsigned SampleRate, + int MixMode, void ( *CallBackFunc )( void ) ); +void DSL_Shutdown( void ); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/dsoundout.c b/polymer/eduke32/source/jaudiolib/dsoundout.c index 0ab98202c..ec1e3e965 100644 --- a/polymer/eduke32/source/jaudiolib/dsoundout.c +++ b/polymer/eduke32/source/jaudiolib/dsoundout.c @@ -58,7 +58,7 @@ static LPDIRECTSOUNDBUFFER lpDSBSecondary = NULL; static LPDIRECTSOUNDNOTIFY lpDSNotify = NULL; static HANDLE *hPosNotify = NULL; -static int (*_DSOUND_CallBack)(int) = NULL; +static int(*_DSOUND_CallBack)(int) = NULL; static int _DSOUND_BufferLength = 0; static int _DSOUND_NumBuffers = 0; static char *_DSOUND_MixBuffer = NULL; @@ -78,11 +78,11 @@ int DSOUND_ErrorCode = DSOUND_Ok; */ int DisableInterrupts(void) { - if (!_DSOUND_CriticalSectionAlloced) return -1; + if (!_DSOUND_CriticalSectionAlloced) return -1; - EnterCriticalSection(&mutex); + EnterCriticalSection(&mutex); - return 0; + return 0; } @@ -92,12 +92,12 @@ int DisableInterrupts(void) */ int RestoreInterrupts(int a) { - if (!_DSOUND_CriticalSectionAlloced) return -1; + if (!_DSOUND_CriticalSectionAlloced) return -1; - LeaveCriticalSection(&mutex); + LeaveCriticalSection(&mutex); - return 0; - a=a; + return 0; + a=a; } @@ -107,59 +107,60 @@ int RestoreInterrupts(int a) */ char *DSOUND_ErrorString(int errorcode) { - switch (errorcode) { - case DSOUND_Warning: - case DSOUND_Error: - return DSOUND_ErrorString(DSOUND_ErrorCode); + switch (errorcode) + { + case DSOUND_Warning: + case DSOUND_Error: + return DSOUND_ErrorString(DSOUND_ErrorCode); - case DSOUND_Ok: - return "DirectSound ok."; + case DSOUND_Ok: + return "DirectSound ok."; - case DSOUND_NoDLL: - return "Failed loading DSOUND.DLL."; + case DSOUND_NoDLL: + return "Failed loading DSOUND.DLL."; - case DSOUND_NoDirectSoundCreate: - return "Failed getting DirectSoundCreate entry point."; + case DSOUND_NoDirectSoundCreate: + return "Failed getting DirectSoundCreate entry point."; - case DSOUND_FailedDSC: - return "DirectSoundCreate failed."; + case DSOUND_FailedDSC: + return "DirectSoundCreate failed."; - case DSOUND_FailedSetCoopLevel: - return "Failed setting cooperative level."; + case DSOUND_FailedSetCoopLevel: + return "Failed setting cooperative level."; - case DSOUND_FailedCreatePrimary: - return "Failed creating primary buffer."; + case DSOUND_FailedCreatePrimary: + return "Failed creating primary buffer."; - case DSOUND_FailedSetFormat: - return "Failed setting primary buffer format."; + case DSOUND_FailedSetFormat: + return "Failed setting primary buffer format."; - case DSOUND_FailedCreateSecondary: - return "Failed creating secondary buffer."; + case DSOUND_FailedCreateSecondary: + return "Failed creating secondary buffer."; - case DSOUND_FailedCreateNotifyEvent: - return "Failed creating notification event object."; + case DSOUND_FailedCreateNotifyEvent: + return "Failed creating notification event object."; - case DSOUND_FailedQueryNotify: - return "Failed querying notification interface."; + case DSOUND_FailedQueryNotify: + return "Failed querying notification interface."; - case DSOUND_FailedSetNotify: - return "Failed setting notification positions."; + case DSOUND_FailedSetNotify: + return "Failed setting notification positions."; - case DSOUND_FailedCreateFinishEvent: - return "Failed creating finish event object."; + case DSOUND_FailedCreateFinishEvent: + return "Failed creating finish event object."; - case DSOUND_FailedCreateThread: - return "Failed creating playback thread."; + case DSOUND_FailedCreateThread: + return "Failed creating playback thread."; - case DSOUND_FailedPlaySecondary: - return "Failed playing secondary buffer."; + case DSOUND_FailedPlaySecondary: + return "Failed playing secondary buffer."; - case DSOUND_FailedGetExitCode: - return "GetExitCodeThread failed."; + case DSOUND_FailedGetExitCode: + return "GetExitCodeThread failed."; - default: - return "Unknown DirectSound error code."; - } + default: + return "Unknown DirectSound error code."; + } } @@ -169,135 +170,148 @@ char *DSOUND_ErrorString(int errorcode) */ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize) { - HRESULT (WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN); - HRESULT hr; - DSBUFFERDESC dsbuf; - WAVEFORMATEX wfex; - DSBPOSITIONNOTIFY posn; - - if (DSOUND_Installed) { - DSOUND_Shutdown(); - } + HRESULT(WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN); + HRESULT hr; + DSBUFFERDESC dsbuf; + WAVEFORMATEX wfex; + DSBPOSITIONNOTIFY posn; - printOSD("Initializing DirectSound...\n"); - - if (!_DSOUND_CriticalSectionAlloced) { - // initialize the critical section object we'll use to - // simulate (dis|en)abling interrupts - InitializeCriticalSection(&mutex); - _DSOUND_CriticalSectionAlloced = TRUE; - } + if (DSOUND_Installed) + { + DSOUND_Shutdown(); + } - printOSD(" - Loading DSOUND.DLL\n"); - hDSoundDLL = LoadLibrary("DSOUND.DLL"); - if (!hDSoundDLL) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_NoDLL); - return DSOUND_Error; - } + printOSD("Initializing DirectSound...\n"); - aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate"); - if (!aDirectSoundCreate) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate); - return DSOUND_Error; - } + if (!_DSOUND_CriticalSectionAlloced) + { + // initialize the critical section object we'll use to + // simulate (dis|en)abling interrupts + InitializeCriticalSection(&mutex); + _DSOUND_CriticalSectionAlloced = TRUE; + } - printOSD(" - Creating DirectSound object\n"); - hr = aDirectSoundCreate(NULL, &lpDS, NULL); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedDSC); - return DSOUND_Error; - } + printOSD(" - Loading DSOUND.DLL\n"); + hDSoundDLL = LoadLibrary("DSOUND.DLL"); + if (!hDSoundDLL) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_NoDLL); + return DSOUND_Error; + } - hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel); - return DSOUND_Error; - } + aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate"); + if (!aDirectSoundCreate) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate); + return DSOUND_Error; + } - printOSD(" - Creating primary buffer\n"); - ZeroMemory(&dsbuf, sizeof(dsbuf)); - dsbuf.dwSize = sizeof(DSBUFFERDESC); - dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; - hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary); - return DSOUND_Error; - } + printOSD(" - Creating DirectSound object\n"); + hr = aDirectSoundCreate(NULL, &lpDS, NULL); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedDSC); + return DSOUND_Error; + } - printOSD(" - Setting primary buffer format\n" - " Channels: %d\n" - " Sample rate: %dHz\n" - " Sample size: %d bits\n", - numchannels, mixrate, samplebits); - ZeroMemory(&wfex, sizeof(wfex)); - wfex.wFormatTag = WAVE_FORMAT_PCM; - wfex.nChannels = numchannels; - wfex.nSamplesPerSec = mixrate; - wfex.wBitsPerSample = samplebits; - wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels; - wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec; - hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedSetFormat); - return DSOUND_Error; - } + hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel); + return DSOUND_Error; + } - printOSD(" - Creating secondary buffer\n"); - ZeroMemory(&dsbuf, sizeof(dsbuf)); - dsbuf.dwSize = sizeof(DSBUFFERDESC); - dsbuf.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE; - dsbuf.dwBufferBytes = buffersize; - dsbuf.lpwfxFormat = &wfex; - hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary); - return DSOUND_Error; - } + printOSD(" - Creating primary buffer\n"); + ZeroMemory(&dsbuf, sizeof(dsbuf)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; + hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary); + return DSOUND_Error; + } - hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedQueryNotify); - return DSOUND_Error; - } + printOSD(" - Setting primary buffer format\n" + " Channels: %d\n" + " Sample rate: %dHz\n" + " Sample size: %d bits\n", + numchannels, mixrate, samplebits); + ZeroMemory(&wfex, sizeof(wfex)); + wfex.wFormatTag = WAVE_FORMAT_PCM; + wfex.nChannels = numchannels; + wfex.nSamplesPerSec = mixrate; + wfex.wBitsPerSample = samplebits; + wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels; + wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec; + hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetFormat); + return DSOUND_Error; + } - hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)); - if (!hPosNotify) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedSetNotify); - return DSOUND_Error; - } - - hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!hPosNotify) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent); - return DSOUND_Error; - } + printOSD(" - Creating secondary buffer\n"); + ZeroMemory(&dsbuf, sizeof(dsbuf)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE; + dsbuf.dwBufferBytes = buffersize; + dsbuf.lpwfxFormat = &wfex; + hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary); + return DSOUND_Error; + } - _DSOUND_BufferLength = 0; - _DSOUND_NumBuffers = 1; - posn.dwOffset = 0; - posn.hEventNotify = hPosNotify[0]; + hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedQueryNotify); + return DSOUND_Error; + } - hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn); - if (hr != DS_OK) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedSetNotify); - return DSOUND_Error; - } + hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)); + if (!hPosNotify) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetNotify); + return DSOUND_Error; + } - DSOUND_Installed = TRUE; - - DSOUND_SetErrorCode(DSOUND_Ok); - return DSOUND_Ok; + hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL); + if (!hPosNotify) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent); + return DSOUND_Error; + } + + _DSOUND_BufferLength = 0; + _DSOUND_NumBuffers = 1; + posn.dwOffset = 0; + posn.hEventNotify = hPosNotify[0]; + + hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn); + if (hr != DS_OK) + { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetNotify); + return DSOUND_Error; + } + + DSOUND_Installed = TRUE; + + DSOUND_SetErrorCode(DSOUND_Ok); + return DSOUND_Ok; } @@ -307,54 +321,61 @@ int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int */ int DSOUND_Shutdown(void) { - int i; + int i; - if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n"); + if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n"); - DSOUND_Installed = FALSE; + DSOUND_Installed = FALSE; - DSOUND_StopPlayback(); + DSOUND_StopPlayback(); - if (lpDSNotify) { - IDirectSoundNotify_Release(lpDSNotify); - lpDSNotify = NULL; - } + if (lpDSNotify) + { + IDirectSoundNotify_Release(lpDSNotify); + lpDSNotify = NULL; + } - if (hPosNotify) { - for (i=0; i<_DSOUND_NumBuffers; i++) { - if (hPosNotify[i]) CloseHandle(hPosNotify[i]); - } - free(hPosNotify); - hPosNotify = NULL; - } + if (hPosNotify) + { + for (i=0; i<_DSOUND_NumBuffers; i++) + { + if (hPosNotify[i]) CloseHandle(hPosNotify[i]); + } + free(hPosNotify); + hPosNotify = NULL; + } - if (lpDSBSecondary) { - printOSD(" - Releasing secondary buffer\n"); - IDirectSoundBuffer_Stop(lpDSBSecondary); - IDirectSoundBuffer_Release(lpDSBSecondary); - lpDSBSecondary = NULL; - } + if (lpDSBSecondary) + { + printOSD(" - Releasing secondary buffer\n"); + IDirectSoundBuffer_Stop(lpDSBSecondary); + IDirectSoundBuffer_Release(lpDSBSecondary); + lpDSBSecondary = NULL; + } - if (lpDSBPrimary) { - printOSD(" - Releasing primary buffer\n"); - IDirectSoundBuffer_Release(lpDSBPrimary); - lpDSBPrimary = NULL; - } + if (lpDSBPrimary) + { + printOSD(" - Releasing primary buffer\n"); + IDirectSoundBuffer_Release(lpDSBPrimary); + lpDSBPrimary = NULL; + } - if (lpDS) { - printOSD(" - Releasing DirectSound object\n"); - IDirectSound_Release(lpDS); - lpDS = NULL; - } + if (lpDS) + { + printOSD(" - Releasing DirectSound object\n"); + IDirectSound_Release(lpDS); + lpDS = NULL; + } - if (hDSoundDLL) { - printOSD(" - Unloading DSOUND.DLL\n"); - FreeLibrary(hDSoundDLL); - hDSoundDLL = NULL; - } - - DSOUND_SetErrorCode(DSOUND_Ok); - return DSOUND_Ok; + if (hDSoundDLL) + { + printOSD(" - Unloading DSOUND.DLL\n"); + FreeLibrary(hDSoundDLL); + hDSoundDLL = NULL; + } + + DSOUND_SetErrorCode(DSOUND_Ok); + return DSOUND_Ok; } @@ -364,7 +385,7 @@ int DSOUND_Shutdown(void) */ int DSOUND_SetMixMode(int mode) { - return mode; + return mode; } @@ -375,73 +396,78 @@ int DSOUND_SetMixMode(int mode) #endif static DWORD WINAPI isr(LPVOID parm) { - HANDLE *handles; - HRESULT hr; - DWORD rv; + HANDLE *handles; + HRESULT hr; + DWORD rv; #ifdef DEBUGAUDIO - int h; + int h; #endif - int p; - LPVOID lockptr; DWORD lockbytes; - LPVOID lockptr2; DWORD lockbytes2; + int p; + LPVOID lockptr; DWORD lockbytes; + LPVOID lockptr2; DWORD lockbytes2; - handles = (HANDLE *)malloc(sizeof(HANDLE)*(1+_DSOUND_NumBuffers)); - if (!handles) return 1; - - handles[0] = isrfinish; - for (p=0; p<_DSOUND_NumBuffers; p++) - handles[p+1] = hPosNotify[p]; + handles = (HANDLE *)malloc(sizeof(HANDLE)*(1+_DSOUND_NumBuffers)); + if (!handles) return 1; + + handles[0] = isrfinish; + for (p=0; p<_DSOUND_NumBuffers; p++) + handles[p+1] = hPosNotify[p]; #ifdef DEBUGAUDIO - h = creat("audio.raw",S_IREAD|S_IWRITE); + h = creat("audio.raw",S_IREAD|S_IWRITE); #endif - - while (1) { - rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE); - if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1; + while (1) + { + rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE); - if (rv == WAIT_OBJECT_0) { - // we've been asked to finish up - break; - } + if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1; - // otherwise we just service the interrupt - if (_DSOUND_CallBack) { - DisableInterrupts(); + if (rv == WAIT_OBJECT_0) + { + // we've been asked to finish up + break; + } - p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); + // otherwise we just service the interrupt + if (_DSOUND_CallBack) + { + DisableInterrupts(); + + p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); #ifdef DEBUGAUDIO - write(h, _DSOUND_MixBuffer + p*_DSOUND_BufferLength, _DSOUND_BufferLength); + write(h, _DSOUND_MixBuffer + p*_DSOUND_BufferLength, _DSOUND_BufferLength); #endif - hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, - &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); - if (hr == DSERR_BUFFERLOST) { - hr = IDirectSoundBuffer_Restore(lpDSBSecondary); - } - if (hr == DS_OK) { - /* -#define copybuf(S,D,c) \ - ({ void *__S=(S), *__D=(D); long __c=(c); \ - __asm__ __volatile__ ("rep; movsl" \ - : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ - 0; }) -*/ - //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); - memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); - IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); - } + hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, + &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); + if (hr == DSERR_BUFFERLOST) + { + hr = IDirectSoundBuffer_Restore(lpDSBSecondary); + } + if (hr == DS_OK) + { + /* + #define copybuf(S,D,c) \ + ({ void *__S=(S), *__D=(D); long __c=(c); \ + __asm__ __volatile__ ("rep; movsl" \ + : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ + 0; }) + */ + //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); + memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); + IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); + } - RestoreInterrupts(0); - } - } + RestoreInterrupts(0); + } + } #ifdef DEBUGAUDIO - close(h); + close(h); #endif - return 0; + return 0; } @@ -449,85 +475,95 @@ static DWORD WINAPI isr(LPVOID parm) * DSOUND_BeginBufferedPlayback * Spins off a thread that behaves somewhat like the SoundBlaster DMA ISR did. */ -int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions) +int DSOUND_BeginBufferedPlayback(char *BufferStart, int(*CallBackFunc)(int), int buffersize, int numdivisions) { - DWORD threadid; - HRESULT hr; - DSBPOSITIONNOTIFY *posns; - int i; - - _DSOUND_CallBack = CallBackFunc; - _DSOUND_MixBuffer = BufferStart; + DWORD threadid; + HRESULT hr; + DSBPOSITIONNOTIFY *posns; + int i; - if (!lpDSBSecondary) return DSOUND_Error; + _DSOUND_CallBack = CallBackFunc; + _DSOUND_MixBuffer = BufferStart; - if (isrthread) { - DSOUND_StopPlayback(); - } - - isrfinish = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!isrfinish) { - DSOUND_SetErrorCode(DSOUND_FailedCreateFinishEvent); - return DSOUND_Error; - } - - isrthread = CreateThread(NULL, 0, isr, NULL, CREATE_SUSPENDED, &threadid); - if (!isrthread) { - DSOUND_SetErrorCode(DSOUND_FailedCreateThread); - return DSOUND_Error; - } + if (!lpDSBSecondary) return DSOUND_Error; - hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)*numdivisions); - if (!hPosNotify) { - DSOUND_Shutdown(); - DSOUND_SetErrorCode(DSOUND_FailedSetNotify); - return DSOUND_Error; - } - - memset(hPosNotify, 0, sizeof(HANDLE)*numdivisions); - for (i=0; iMaxVoices = 32; - BLASTER_GetCardInfo( &device->MaxSampleBits, &device->MaxChannels ); - break; + device->MaxVoices = 32; + BLASTER_GetCardInfo(&device->MaxSampleBits, &device->MaxChannels); + break; - default : - FX_SetErrorCode( FX_InvalidCard ); - status = FX_Error; - } - return( status ); - } + default : + FX_SetErrorCode(FX_InvalidCard); + status = FX_Error; + } + return(status); +} #endif @@ -159,33 +159,33 @@ int FX_SetupCard ---------------------------------------------------------------------*/ int FX_GetBlasterSettings - ( - fx_blaster_config *blaster - ) +( + fx_blaster_config *blaster +) - { - int status; - BLASTER_CONFIG Blaster; +{ + int status; + BLASTER_CONFIG Blaster; - FX_SetErrorCode( FX_Ok ); + FX_SetErrorCode(FX_Ok); - status = BLASTER_GetEnv( &Blaster ); - if ( status != BLASTER_Ok ) - { - FX_SetErrorCode( FX_BlasterError ); - return( FX_Error ); - } + status = BLASTER_GetEnv(&Blaster); + if (status != BLASTER_Ok) + { + FX_SetErrorCode(FX_BlasterError); + return(FX_Error); + } - blaster->Type = Blaster.Type; - blaster->Address = Blaster.Address; - blaster->Interrupt = Blaster.Interrupt; - blaster->Dma8 = Blaster.Dma8; - blaster->Dma16 = Blaster.Dma16; - blaster->Midi = Blaster.Midi; - blaster->Emu = Blaster.Emu; + blaster->Type = Blaster.Type; + blaster->Address = Blaster.Address; + blaster->Interrupt = Blaster.Interrupt; + blaster->Dma8 = Blaster.Dma8; + blaster->Dma16 = Blaster.Dma16; + blaster->Midi = Blaster.Midi; + blaster->Emu = Blaster.Emu; - return( FX_Ok ); - } + return(FX_Ok); +} #endif @@ -197,43 +197,43 @@ int FX_GetBlasterSettings ---------------------------------------------------------------------*/ int FX_SetupSoundBlaster - ( - fx_blaster_config blaster, - int *MaxVoices, - int *MaxSampleBits, - int *MaxChannels - ) +( + fx_blaster_config blaster, + int *MaxVoices, + int *MaxSampleBits, + int *MaxChannels +) - { - int DeviceStatus; - BLASTER_CONFIG Blaster; +{ + int DeviceStatus; + BLASTER_CONFIG Blaster; - FX_SetErrorCode( FX_Ok ); + FX_SetErrorCode(FX_Ok); - FX_SoundDevice = SoundBlaster; + FX_SoundDevice = SoundBlaster; - Blaster.Type = blaster.Type; - Blaster.Address = blaster.Address; - Blaster.Interrupt = blaster.Interrupt; - Blaster.Dma8 = blaster.Dma8; - Blaster.Dma16 = blaster.Dma16; - Blaster.Midi = blaster.Midi; - Blaster.Emu = blaster.Emu; + Blaster.Type = blaster.Type; + Blaster.Address = blaster.Address; + Blaster.Interrupt = blaster.Interrupt; + Blaster.Dma8 = blaster.Dma8; + Blaster.Dma16 = blaster.Dma16; + Blaster.Midi = blaster.Midi; + Blaster.Emu = blaster.Emu; - BLASTER_SetCardSettings( Blaster ); + BLASTER_SetCardSettings(Blaster); - DeviceStatus = BLASTER_Init(); - if ( DeviceStatus != BLASTER_Ok ) - { - FX_SetErrorCode( FX_SoundCardError ); - return( FX_Error ); - } + DeviceStatus = BLASTER_Init(); + if (DeviceStatus != BLASTER_Ok) + { + FX_SetErrorCode(FX_SoundCardError); + return(FX_Error); + } - *MaxVoices = 8; - BLASTER_GetCardInfo( MaxSampleBits, MaxChannels ); + *MaxVoices = 8; + BLASTER_GetCardInfo(MaxSampleBits, MaxChannels); - return( FX_Ok ); - } + return(FX_Ok); +} #endif @@ -244,43 +244,43 @@ int FX_SetupSoundBlaster ---------------------------------------------------------------------*/ int FX_Init - ( - int SoundCard, - int numvoices, - int numchannels, - int samplebits, - unsigned mixrate - ) +( + int SoundCard, + int numvoices, + int numchannels, + int samplebits, + unsigned mixrate +) - { - int status; - int devicestatus; +{ + int status; + int devicestatus; - if ( FX_Installed ) - { - FX_Shutdown(); - } + if (FX_Installed) + { + FX_Shutdown(); + } - FX_MixRate = mixrate; + FX_MixRate = mixrate; - status = FX_Ok; - FX_SoundDevice = SoundCard; - - devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices, - numchannels, samplebits ); - if ( devicestatus != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Error; - } + status = FX_Ok; + FX_SoundDevice = SoundCard; - if ( status == FX_Ok ) - { - FX_Installed = TRUE; - } + devicestatus = MV_Init(SoundCard, FX_MixRate, numvoices, + numchannels, samplebits); + if (devicestatus != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Error; + } - return( status ); - } + if (status == FX_Ok) + { + FX_Installed = TRUE; + } + + return(status); +} /*--------------------------------------------------------------------- @@ -290,29 +290,29 @@ int FX_Init ---------------------------------------------------------------------*/ int FX_Shutdown - ( - void - ) +( + void +) - { - int status; +{ + int status; - if ( !FX_Installed ) - { - return( FX_Ok ); - } + if (!FX_Installed) + { + return(FX_Ok); + } - status = MV_Shutdown(); - if ( status != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Error; - } + status = MV_Shutdown(); + if (status != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Error; + } - FX_Installed = FALSE; + FX_Installed = FALSE; - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -322,15 +322,15 @@ int FX_Shutdown ---------------------------------------------------------------------*/ int FX_SetCallBack - ( - void ( *function )( unsigned long ) - ) +( + void(*function)(unsigned long) +) - { - MV_SetCallBack( function ); +{ + MV_SetCallBack(function); - return( FX_Ok ); - } + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -340,13 +340,13 @@ int FX_SetCallBack ---------------------------------------------------------------------*/ void FX_SetVolume - ( - int volume - ) +( + int volume +) - { - MV_SetVolume( volume ); - } +{ + MV_SetVolume(volume); +} /*--------------------------------------------------------------------- @@ -356,13 +356,13 @@ void FX_SetVolume ---------------------------------------------------------------------*/ int FX_GetVolume - ( - void - ) +( + void +) - { - return MV_GetVolume(); - } +{ + return MV_GetVolume(); +} /*--------------------------------------------------------------------- @@ -372,13 +372,13 @@ int FX_GetVolume ---------------------------------------------------------------------*/ void FX_SetReverseStereo - ( - int setting - ) +( + int setting +) - { - MV_SetReverseStereo( setting ); - } +{ + MV_SetReverseStereo(setting); +} /*--------------------------------------------------------------------- @@ -388,13 +388,13 @@ void FX_SetReverseStereo ---------------------------------------------------------------------*/ int FX_GetReverseStereo - ( - void - ) +( + void +) - { - return MV_GetReverseStereo(); - } +{ + return MV_GetReverseStereo(); +} /*--------------------------------------------------------------------- @@ -404,13 +404,13 @@ int FX_GetReverseStereo ---------------------------------------------------------------------*/ void FX_SetReverb - ( - int reverb - ) +( + int reverb +) - { - MV_SetReverb( reverb ); - } +{ + MV_SetReverb(reverb); +} /*--------------------------------------------------------------------- @@ -420,13 +420,13 @@ void FX_SetReverb ---------------------------------------------------------------------*/ void FX_SetFastReverb - ( - int reverb - ) +( + int reverb +) - { - MV_SetFastReverb( reverb ); - } +{ + MV_SetFastReverb(reverb); +} /*--------------------------------------------------------------------- @@ -436,13 +436,13 @@ void FX_SetFastReverb ---------------------------------------------------------------------*/ int FX_GetMaxReverbDelay - ( - void - ) +( + void +) - { - return MV_GetMaxReverbDelay(); - } +{ + return MV_GetMaxReverbDelay(); +} /*--------------------------------------------------------------------- @@ -452,13 +452,13 @@ int FX_GetMaxReverbDelay ---------------------------------------------------------------------*/ int FX_GetReverbDelay - ( - void - ) +( + void +) - { - return MV_GetReverbDelay(); - } +{ + return MV_GetReverbDelay(); +} /*--------------------------------------------------------------------- @@ -468,13 +468,13 @@ int FX_GetReverbDelay ---------------------------------------------------------------------*/ void FX_SetReverbDelay - ( - int delay - ) +( + int delay +) - { - MV_SetReverbDelay( delay ); - } +{ + MV_SetReverbDelay(delay); +} /*--------------------------------------------------------------------- @@ -484,13 +484,13 @@ void FX_SetReverbDelay ---------------------------------------------------------------------*/ int FX_VoiceAvailable - ( - int priority - ) +( + int priority +) - { - return MV_VoiceAvailable( priority ); - } +{ + return MV_VoiceAvailable(priority); +} /*--------------------------------------------------------------------- Function: FX_EndLooping @@ -500,22 +500,22 @@ int FX_VoiceAvailable ---------------------------------------------------------------------*/ int FX_EndLooping - ( - int handle - ) +( + int handle +) - { - int status; +{ + int status; - status = MV_EndLooping( handle ); - if ( status == MV_Error ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Warning; - } + status = MV_EndLooping(handle); + if (status == MV_Error) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Warning; + } - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- Function: FX_SetPan @@ -525,25 +525,25 @@ int FX_EndLooping ---------------------------------------------------------------------*/ int FX_SetPan - ( - int handle, - int vol, - int left, - int right - ) +( + int handle, + int vol, + int left, + int right +) - { - int status; +{ + int status; - status = MV_SetPan( handle, vol, left, right ); - if ( status == MV_Error ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Warning; - } + status = MV_SetPan(handle, vol, left, right); + if (status == MV_Error) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Warning; + } - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -553,23 +553,23 @@ int FX_SetPan ---------------------------------------------------------------------*/ int FX_SetPitch - ( - int handle, - int pitchoffset - ) +( + int handle, + int pitchoffset +) - { - int status; +{ + int status; - status = MV_SetPitch( handle, pitchoffset ); - if ( status == MV_Error ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Warning; - } + status = MV_SetPitch(handle, pitchoffset); + if (status == MV_Error) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Warning; + } - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -579,23 +579,23 @@ int FX_SetPitch ---------------------------------------------------------------------*/ int FX_SetFrequency - ( - int handle, - int frequency - ) +( + int handle, + int frequency +) - { - int status; +{ + int status; - status = MV_SetFrequency( handle, frequency ); - if ( status == MV_Error ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Warning; - } + status = MV_SetFrequency(handle, frequency); + if (status == MV_Error) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Warning; + } - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -605,29 +605,29 @@ int FX_SetFrequency ---------------------------------------------------------------------*/ int FX_PlayVOC - ( - char *ptr, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right, - priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayVOC(ptr, pitchoffset, vol, left, right, + priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -637,31 +637,31 @@ int FX_PlayVOC ---------------------------------------------------------------------*/ int FX_PlayLoopedVOC - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset, - vol, left, right, priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayLoopedVOC(ptr, loopstart, loopend, pitchoffset, + vol, left, right, priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -671,29 +671,29 @@ int FX_PlayLoopedVOC ---------------------------------------------------------------------*/ int FX_PlayWAV - ( - char *ptr, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right, - priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayWAV(ptr, pitchoffset, vol, left, right, + priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -703,31 +703,31 @@ int FX_PlayWAV ---------------------------------------------------------------------*/ int FX_PlayLoopedWAV - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayLoopedWAV( ptr, loopstart, loopend, - pitchoffset, vol, left, right, priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayLoopedWAV(ptr, loopstart, loopend, + pitchoffset, vol, left, right, priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -738,28 +738,28 @@ int FX_PlayLoopedWAV ---------------------------------------------------------------------*/ int FX_PlayVOC3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance, - priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayVOC3D(ptr, pitchoffset, angle, distance, + priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -770,28 +770,28 @@ int FX_PlayVOC3D ---------------------------------------------------------------------*/ int FX_PlayWAV3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance, - priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayWAV3D(ptr, pitchoffset, angle, distance, + priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -801,31 +801,31 @@ int FX_PlayWAV3D ---------------------------------------------------------------------*/ int FX_PlayRaw - ( - char *ptr, - unsigned long length, - unsigned rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + unsigned long length, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayRaw( ptr, length, rate, pitchoffset, - vol, left, right, priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayRaw(ptr, length, rate, pitchoffset, + vol, left, right, priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -835,33 +835,33 @@ int FX_PlayRaw ---------------------------------------------------------------------*/ int FX_PlayLoopedRaw - ( - char *ptr, - unsigned long length, - char *loopstart, - char *loopend, - unsigned rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + unsigned long length, + char *loopstart, + char *loopend, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend, - rate, pitchoffset, vol, left, right, priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_PlayLoopedRaw(ptr, length, loopstart, loopend, + rate, pitchoffset, vol, left, right, priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} /*--------------------------------------------------------------------- @@ -872,24 +872,24 @@ int FX_PlayLoopedRaw ---------------------------------------------------------------------*/ int FX_Pan3D - ( - int handle, - int angle, - int distance - ) +( + int handle, + int angle, + int distance +) - { - int status; +{ + int status; - status = MV_Pan3D( handle, angle, distance ); - if ( status != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - status = FX_Warning; - } + status = MV_Pan3D(handle, angle, distance); + if (status != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + status = FX_Warning; + } - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -899,13 +899,13 @@ int FX_Pan3D ---------------------------------------------------------------------*/ int FX_SoundActive - ( - int handle - ) +( + int handle +) - { - return( MV_VoicePlaying( handle ) ); - } +{ + return(MV_VoicePlaying(handle)); +} /*--------------------------------------------------------------------- @@ -915,13 +915,13 @@ int FX_SoundActive ---------------------------------------------------------------------*/ int FX_SoundsPlaying - ( - void - ) +( + void +) - { - return( MV_VoicesPlaying() ); - } +{ + return(MV_VoicesPlaying()); +} /*--------------------------------------------------------------------- @@ -931,22 +931,22 @@ int FX_SoundsPlaying ---------------------------------------------------------------------*/ int FX_StopSound - ( - int handle - ) +( + int handle +) - { - int status; +{ + int status; - status = MV_Kill( handle ); - if ( status != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - return( FX_Warning ); - } + status = MV_Kill(handle); + if (status != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + return(FX_Warning); + } - return( FX_Ok ); - } + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -956,22 +956,22 @@ int FX_StopSound ---------------------------------------------------------------------*/ int FX_StopAllSounds - ( - void - ) +( + void +) - { - int status; +{ + int status; - status = MV_KillAllVoices(); - if ( status != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - return( FX_Warning ); - } + status = MV_KillAllVoices(); + if (status != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + return(FX_Warning); + } - return( FX_Ok ); - } + return(FX_Ok); +} /*--------------------------------------------------------------------- @@ -981,30 +981,30 @@ int FX_StopAllSounds ---------------------------------------------------------------------*/ int FX_StartDemandFeedPlayback - ( - void ( *function )( char **ptr, unsigned long *length ), - int rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + void(*function)(char **ptr, unsigned long *length), + int rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int handle; +{ + int handle; - handle = MV_StartDemandFeedPlayback( function, rate, - pitchoffset, vol, left, right, priority, callbackval ); - if ( handle < MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); - handle = FX_Warning; - } + handle = MV_StartDemandFeedPlayback(function, rate, + pitchoffset, vol, left, right, priority, callbackval); + if (handle < MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); + handle = FX_Warning; + } - return( handle ); - } + return(handle); +} #if 0 /*--------------------------------------------------------------------- @@ -1014,37 +1014,37 @@ int FX_StartDemandFeedPlayback ---------------------------------------------------------------------*/ int FX_StartRecording - ( - int MixRate, - void ( *function )( char *ptr, int length ) - ) +( + int MixRate, + void(*function)(char *ptr, int length) +) - { - int status; +{ + int status; - switch( FX_SoundDevice ) - { - case SoundBlaster : - status = MV_StartRecording( MixRate, function ); - if ( status != MV_Ok ) - { - FX_SetErrorCode( FX_MultiVocError ); + switch (FX_SoundDevice) + { + case SoundBlaster : + status = MV_StartRecording(MixRate, function); + if (status != MV_Ok) + { + FX_SetErrorCode(FX_MultiVocError); status = FX_Warning; - } - else - { + } + else + { status = FX_Ok; - } - break; + } + break; - default : - FX_SetErrorCode( FX_InvalidCard ); - status = FX_Warning; - break; - } + default : + FX_SetErrorCode(FX_InvalidCard); + status = FX_Warning; + break; + } - return( status ); - } + return(status); +} #endif #if 0 @@ -1055,19 +1055,19 @@ int FX_StartRecording ---------------------------------------------------------------------*/ void FX_StopRecord - ( - void - ) +( + void +) - { - // Stop sound playback - switch( FX_SoundDevice ) - { - case SoundBlaster : - MV_StopRecord(); - break; - } - } +{ + // Stop sound playback + switch (FX_SoundDevice) + { + case SoundBlaster : + MV_StopRecord(); + break; + } +} #endif extern void MUSIC_Update(void); diff --git a/polymer/eduke32/source/jaudiolib/interrup.h b/polymer/eduke32/source/jaudiolib/interrup.h new file mode 100755 index 000000000..e8d78b90b --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/interrup.h @@ -0,0 +1,50 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + module: INTERRUP.H + + author: James R. Dose + date: March 31, 1994 + + Inline functions for disabling and restoring the interrupt flag. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __INTERRUPT_H +#define __INTERRUPT_H + +unsigned long DisableInterrupts( void ); +void RestoreInterrupts( unsigned long flags ); + +#ifdef PLAT_DOS +#pragma aux DisableInterrupts = \ + "pushfd", \ + "pop eax", \ + "cli" \ + modify [ eax ]; + +#pragma aux RestoreInterrupts = \ + "push eax", \ + "popfd" \ + parm [ eax ]; +#endif + +#endif diff --git a/polymer/eduke32/source/jaudiolib/ll_man.c b/polymer/eduke32/source/jaudiolib/ll_man.c index 9c169d042..159ad8620 100644 --- a/polymer/eduke32/source/jaudiolib/ll_man.c +++ b/polymer/eduke32/source/jaudiolib/ll_man.c @@ -44,60 +44,60 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) void LL_AddNode - ( - char *item, - char **head, - char **tail, - int next, - int prev - ) +( + char *item, + char **head, + char **tail, + int next, + int prev +) - { - OFFSET( item, prev ) = NULL; - OFFSET( item, next ) = *head; +{ + OFFSET(item, prev) = NULL; + OFFSET(item, next) = *head; - if ( *head ) - { - OFFSET( *head, prev ) = item; - } - else - { - *tail = item; - } + if (*head) + { + OFFSET(*head, prev) = item; + } + else + { + *tail = item; + } - *head = item; - } + *head = item; +} void LL_RemoveNode - ( - char *item, - char **head, - char **tail, - int next, - int prev - ) +( + char *item, + char **head, + char **tail, + int next, + int prev +) - { - if ( OFFSET( item, prev ) == NULL ) - { - *head = OFFSET( item, next ); - } - else - { - OFFSET( OFFSET( item, prev ), next ) = OFFSET( item, next ); - } +{ + if (OFFSET(item, prev) == NULL) + { + *head = OFFSET(item, next); + } + else + { + OFFSET(OFFSET(item, prev), next) = OFFSET(item, next); + } - if ( OFFSET( item, next ) == NULL ) - { - *tail = OFFSET( item, prev ); - } - else - { - OFFSET( OFFSET( item, next ), prev ) = OFFSET( item, prev ); - } + if (OFFSET(item, next) == NULL) + { + *tail = OFFSET(item, prev); + } + else + { + OFFSET(OFFSET(item, next), prev) = OFFSET(item, prev); + } - OFFSET( item, next ) = NULL; - OFFSET( item, prev ) = NULL; - } + OFFSET(item, next) = NULL; + OFFSET(item, prev) = NULL; +} diff --git a/polymer/eduke32/source/jaudiolib/midi.c b/polymer/eduke32/source/jaudiolib/midi.c index 2e144587c..c8ee9e283 100644 --- a/polymer/eduke32/source/jaudiolib/midi.c +++ b/polymer/eduke32/source/jaudiolib/midi.c @@ -46,17 +46,20 @@ static __int64 nexttick, tickdelta; extern int MUSIC_SoundDevice; static const int _MIDI_CommandLengths[ NUM_MIDI_CHANNELS ] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0 - }; + { + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0 + }; -static int ( *_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ] ) - ( - int event, - int c1, - int c2 - ) = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static int(*_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ]) +( + int event, + int c1, + int c2 +) = + { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + }; static track *_MIDI_TrackPtr = NULL; static int _MIDI_TrackMemSize; @@ -80,8 +83,8 @@ static int _MIDI_TotalTicks; static int _MIDI_TotalBeats; static int _MIDI_TotalMeasures; - unsigned long _MIDI_PositionInTicks; - unsigned long _MIDI_GlobalPositionInTicks; +unsigned long _MIDI_PositionInTicks; +unsigned long _MIDI_GlobalPositionInTicks; static int _MIDI_Context; @@ -90,10 +93,10 @@ static int _MIDI_TotalVolume = MIDI_MaxVolume; static int _MIDI_ChannelVolume[ NUM_MIDI_CHANNELS ]; static int _MIDI_UserChannelVolume[ NUM_MIDI_CHANNELS ] = - { - 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256 - }; + { + 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256 + }; static midifuncs *_MIDI_Funcs = NULL; @@ -118,31 +121,31 @@ char MIDI_PatchMap[ 128 ]; ---------------------------------------------------------------------*/ static long _MIDI_ReadNumber - ( - void *from, - size_t size - ) +( + void *from, + size_t size +) - { - unsigned char *FromPtr; - long value; +{ + unsigned char *FromPtr; + long value; - if ( size > 4 ) - { - size = 4; - } + if (size > 4) + { + size = 4; + } - FromPtr = ( unsigned char * )from; + FromPtr = (unsigned char *)from; - value = 0; - while( size-- ) - { - value <<= 8; - value += *FromPtr++; - } + value = 0; + while (size--) + { + value <<= 8; + value += *FromPtr++; + } - return( value ); - } + return(value); +} /*--------------------------------------------------------------------- @@ -152,29 +155,29 @@ static long _MIDI_ReadNumber ---------------------------------------------------------------------*/ static long _MIDI_ReadDelta - ( - track *ptr - ) +( + track *ptr +) - { - long value; - unsigned char c; +{ + long value; + unsigned char c; - GET_NEXT_EVENT( ptr, value ); + GET_NEXT_EVENT(ptr, value); - if ( value & 0x80 ) - { - value &= 0x7f; - do - { - GET_NEXT_EVENT( ptr, c ); - value = ( value << 7 ) + ( c & 0x7f ); - } - while ( c & 0x80 ); - } + if (value & 0x80) + { + value &= 0x7f; + do + { + GET_NEXT_EVENT(ptr, c); + value = (value << 7) + (c & 0x7f); + } + while (c & 0x80); + } - return( value ); - } + return(value); +} /*--------------------------------------------------------------------- @@ -184,46 +187,46 @@ static long _MIDI_ReadDelta ---------------------------------------------------------------------*/ static void _MIDI_ResetTracks - ( - void - ) +( + void +) - { - int i; - track *ptr; +{ + int i; + track *ptr; - _MIDI_Tick = 0; - _MIDI_Beat = 1; - _MIDI_Measure = 1; - _MIDI_Time = 0; - _MIDI_BeatsPerMeasure = 4; - _MIDI_TicksPerBeat = _MIDI_Division; - _MIDI_TimeBase = 4; + _MIDI_Tick = 0; + _MIDI_Beat = 1; + _MIDI_Measure = 1; + _MIDI_Time = 0; + _MIDI_BeatsPerMeasure = 4; + _MIDI_TicksPerBeat = _MIDI_Division; + _MIDI_TimeBase = 4; - _MIDI_PositionInTicks = 0; - //_MIDI_GlobalPositionInTicks = 0; - _MIDI_ActiveTracks = 0; - _MIDI_Context = 0; + _MIDI_PositionInTicks = 0; + //_MIDI_GlobalPositionInTicks = 0; + _MIDI_ActiveTracks = 0; + _MIDI_Context = 0; - ptr = _MIDI_TrackPtr; - for( i = 0; i < _MIDI_NumTracks; i++ ) - { - ptr->pos = ptr->start; - ptr->delay = _MIDI_ReadDelta( ptr ); - ptr->active = ptr->EMIDI_IncludeTrack; - ptr->RunningStatus = 0; - ptr->currentcontext = 0; - ptr->context[ 0 ].loopstart = ptr->start; - ptr->context[ 0 ].loopcount = 0; + ptr = _MIDI_TrackPtr; + for (i = 0; i < _MIDI_NumTracks; i++) + { + ptr->pos = ptr->start; + ptr->delay = _MIDI_ReadDelta(ptr); + ptr->active = ptr->EMIDI_IncludeTrack; + ptr->RunningStatus = 0; + ptr->currentcontext = 0; + ptr->context[ 0 ].loopstart = ptr->start; + ptr->context[ 0 ].loopcount = 0; - if ( ptr->active ) - { - _MIDI_ActiveTracks++; - } + if (ptr->active) + { + _MIDI_ActiveTracks++; + } - ptr++; - } - } + ptr++; + } +} /*--------------------------------------------------------------------- @@ -233,26 +236,26 @@ static void _MIDI_ResetTracks ---------------------------------------------------------------------*/ static void _MIDI_AdvanceTick - ( - void - ) +( + void +) - { - _MIDI_PositionInTicks++; - _MIDI_Time += _MIDI_FPSecondsPerTick; +{ + _MIDI_PositionInTicks++; + _MIDI_Time += _MIDI_FPSecondsPerTick; - _MIDI_Tick++; - while( _MIDI_Tick > _MIDI_TicksPerBeat ) - { - _MIDI_Tick -= _MIDI_TicksPerBeat; - _MIDI_Beat++; - } - while( _MIDI_Beat > _MIDI_BeatsPerMeasure ) - { - _MIDI_Beat -= _MIDI_BeatsPerMeasure; - _MIDI_Measure++; - } - } + _MIDI_Tick++; + while (_MIDI_Tick > _MIDI_TicksPerBeat) + { + _MIDI_Tick -= _MIDI_TicksPerBeat; + _MIDI_Beat++; + } + while (_MIDI_Beat > _MIDI_BeatsPerMeasure) + { + _MIDI_Beat -= _MIDI_BeatsPerMeasure; + _MIDI_Measure++; + } +} /*--------------------------------------------------------------------- @@ -262,16 +265,16 @@ static void _MIDI_AdvanceTick ---------------------------------------------------------------------*/ static void _MIDI_SysEx - ( - track *Track - ) +( + track *Track +) - { - int length; +{ + int length; - length = _MIDI_ReadDelta( Track ); - Track->pos += length; - } + length = _MIDI_ReadDelta(Track); + Track->pos += length; +} /*--------------------------------------------------------------------- @@ -281,55 +284,55 @@ static void _MIDI_SysEx ---------------------------------------------------------------------*/ static void _MIDI_MetaEvent - ( - track *Track - ) +( + track *Track +) - { - int command; - int length; - int denominator; - long tempo; +{ + int command; + int length; + int denominator; + long tempo; - GET_NEXT_EVENT( Track, command ); - GET_NEXT_EVENT( Track, length ); + GET_NEXT_EVENT(Track, command); + GET_NEXT_EVENT(Track, length); - switch( command ) - { - case MIDI_END_OF_TRACK : - Track->active = FALSE; + switch (command) + { + case MIDI_END_OF_TRACK : + Track->active = FALSE; - _MIDI_ActiveTracks--; - break; + _MIDI_ActiveTracks--; + break; - case MIDI_TEMPO_CHANGE : - tempo = 60000000L / _MIDI_ReadNumber( Track->pos, 3 ); - MIDI_SetTempo( tempo ); - break; + case MIDI_TEMPO_CHANGE : + tempo = 60000000L / _MIDI_ReadNumber(Track->pos, 3); + MIDI_SetTempo(tempo); + break; - case MIDI_TIME_SIGNATURE : - if ( ( _MIDI_Tick > 0 ) || ( _MIDI_Beat > 1 ) ) - { + case MIDI_TIME_SIGNATURE : + if ((_MIDI_Tick > 0) || (_MIDI_Beat > 1)) + { _MIDI_Measure++; - } + } - _MIDI_Tick = 0; - _MIDI_Beat = 1; + _MIDI_Tick = 0; + _MIDI_Beat = 1; - _MIDI_BeatsPerMeasure = (int)*Track->pos; - denominator = (int)*( Track->pos + 1 ); - _MIDI_TimeBase = 1; - while( denominator > 0 ) - { + _MIDI_BeatsPerMeasure = (int)*Track->pos; + denominator = (int)*(Track->pos + 1); + _MIDI_TimeBase = 1; + while (denominator > 0) + { _MIDI_TimeBase += _MIDI_TimeBase; denominator--; - } - _MIDI_TicksPerBeat = ( _MIDI_Division * 4 ) / _MIDI_TimeBase; - break; - } + } + _MIDI_TicksPerBeat = (_MIDI_Division * 4) / _MIDI_TimeBase; + break; + } - Track->pos += length; - } + Track->pos += length; +} /*--------------------------------------------------------------------- @@ -339,107 +342,107 @@ static void _MIDI_MetaEvent ---------------------------------------------------------------------*/ static int _MIDI_InterpretControllerInfo - ( - track *Track, - int TimeSet, - int channel, - int c1, - int c2 - ) +( + track *Track, + int TimeSet, + int channel, + int c1, + int c2 +) - { - track *trackptr; - int tracknum; - int loopcount; +{ + track *trackptr; + int tracknum; + int loopcount; - switch( c1 ) - { - case MIDI_MONO_MODE_ON : - Track->pos++; - break; + switch (c1) + { + case MIDI_MONO_MODE_ON : + Track->pos++; + break; - case MIDI_VOLUME : - if ( !Track->EMIDI_VolumeChange ) - { - _MIDI_SetChannelVolume( channel, c2 ); - } - break; + case MIDI_VOLUME : + if (!Track->EMIDI_VolumeChange) + { + _MIDI_SetChannelVolume(channel, c2); + } + break; - case EMIDI_INCLUDE_TRACK : - case EMIDI_EXCLUDE_TRACK : - break; + case EMIDI_INCLUDE_TRACK : + case EMIDI_EXCLUDE_TRACK : + break; - case EMIDI_PROGRAM_CHANGE : - if ( Track->EMIDI_ProgramChange ) - { - _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c2 & 0x7f ] ); - } - break; + case EMIDI_PROGRAM_CHANGE : + if (Track->EMIDI_ProgramChange) + { + _MIDI_Funcs->ProgramChange(channel, MIDI_PatchMap[ c2 & 0x7f ]); + } + break; - case EMIDI_VOLUME_CHANGE : - if ( Track->EMIDI_VolumeChange ) - { - _MIDI_SetChannelVolume( channel, c2 ); - } - break; + case EMIDI_VOLUME_CHANGE : + if (Track->EMIDI_VolumeChange) + { + _MIDI_SetChannelVolume(channel, c2); + } + break; - case EMIDI_CONTEXT_START : - break; + case EMIDI_CONTEXT_START : + break; - case EMIDI_CONTEXT_END : - if ( ( Track->currentcontext == _MIDI_Context ) || - ( _MIDI_Context < 0 ) || - ( Track->context[ _MIDI_Context ].pos == NULL ) ) - { + case EMIDI_CONTEXT_END : + if ((Track->currentcontext == _MIDI_Context) || + (_MIDI_Context < 0) || + (Track->context[ _MIDI_Context ].pos == NULL)) + { break; - } + } - Track->currentcontext = _MIDI_Context; - Track->context[ 0 ].loopstart = Track->context[ _MIDI_Context ].loopstart; - Track->context[ 0 ].loopcount = Track->context[ _MIDI_Context ].loopcount; - Track->pos = Track->context[ _MIDI_Context ].pos; - Track->RunningStatus = Track->context[ _MIDI_Context ].RunningStatus; + Track->currentcontext = _MIDI_Context; + Track->context[ 0 ].loopstart = Track->context[ _MIDI_Context ].loopstart; + Track->context[ 0 ].loopcount = Track->context[ _MIDI_Context ].loopcount; + Track->pos = Track->context[ _MIDI_Context ].pos; + Track->RunningStatus = Track->context[ _MIDI_Context ].RunningStatus; - if ( TimeSet ) - { + if (TimeSet) + { break; - } + } - _MIDI_Time = Track->context[ _MIDI_Context ].time; - _MIDI_FPSecondsPerTick = Track->context[ _MIDI_Context ].FPSecondsPerTick; - _MIDI_Tick = Track->context[ _MIDI_Context ].tick; - _MIDI_Beat = Track->context[ _MIDI_Context ].beat; - _MIDI_Measure = Track->context[ _MIDI_Context ].measure; - _MIDI_BeatsPerMeasure = Track->context[ _MIDI_Context ].BeatsPerMeasure; - _MIDI_TicksPerBeat = Track->context[ _MIDI_Context ].TicksPerBeat; - _MIDI_TimeBase = Track->context[ _MIDI_Context ].TimeBase; - TimeSet = TRUE; - break; + _MIDI_Time = Track->context[ _MIDI_Context ].time; + _MIDI_FPSecondsPerTick = Track->context[ _MIDI_Context ].FPSecondsPerTick; + _MIDI_Tick = Track->context[ _MIDI_Context ].tick; + _MIDI_Beat = Track->context[ _MIDI_Context ].beat; + _MIDI_Measure = Track->context[ _MIDI_Context ].measure; + _MIDI_BeatsPerMeasure = Track->context[ _MIDI_Context ].BeatsPerMeasure; + _MIDI_TicksPerBeat = Track->context[ _MIDI_Context ].TicksPerBeat; + _MIDI_TimeBase = Track->context[ _MIDI_Context ].TimeBase; + TimeSet = TRUE; + break; - case EMIDI_LOOP_START : - case EMIDI_SONG_LOOP_START : - if ( c2 == 0 ) - { + case EMIDI_LOOP_START : + case EMIDI_SONG_LOOP_START : + if (c2 == 0) + { loopcount = EMIDI_INFINITE; - } - else - { + } + else + { loopcount = c2; - } + } - if ( c1 == EMIDI_SONG_LOOP_START ) - { + if (c1 == EMIDI_SONG_LOOP_START) + { trackptr = _MIDI_TrackPtr; tracknum = _MIDI_NumTracks; - } - else - { + } + else + { trackptr = Track; tracknum = 1; - } + } - while( tracknum > 0 ) - { + while (tracknum > 0) + { trackptr->context[ 0 ].loopcount = loopcount; trackptr->context[ 0 ].pos = trackptr->pos; trackptr->context[ 0 ].loopstart = trackptr->pos; @@ -456,74 +459,74 @@ static int _MIDI_InterpretControllerInfo trackptr->context[ 0 ].TimeBase = _MIDI_TimeBase; trackptr++; tracknum--; - } - break; + } + break; - case EMIDI_LOOP_END : - case EMIDI_SONG_LOOP_END : - if ( ( c2 != EMIDI_END_LOOP_VALUE ) || - ( Track->context[ 0 ].loopstart == NULL ) || - ( Track->context[ 0 ].loopcount == 0 ) ) - { + case EMIDI_LOOP_END : + case EMIDI_SONG_LOOP_END : + if ((c2 != EMIDI_END_LOOP_VALUE) || + (Track->context[ 0 ].loopstart == NULL) || + (Track->context[ 0 ].loopcount == 0)) + { break; - } + } - if ( c1 == EMIDI_SONG_LOOP_END ) - { + if (c1 == EMIDI_SONG_LOOP_END) + { trackptr = _MIDI_TrackPtr; tracknum = _MIDI_NumTracks; _MIDI_ActiveTracks = 0; - } - else - { + } + else + { trackptr = Track; tracknum = 1; _MIDI_ActiveTracks--; - } + } - while( tracknum > 0 ) + while (tracknum > 0) + { + if (trackptr->context[ 0 ].loopcount != EMIDI_INFINITE) { - if ( trackptr->context[ 0 ].loopcount != EMIDI_INFINITE ) - { - trackptr->context[ 0 ].loopcount--; - } + trackptr->context[ 0 ].loopcount--; + } trackptr->pos = trackptr->context[ 0 ].loopstart; trackptr->RunningStatus = trackptr->context[ 0 ].RunningStatus; trackptr->delay = trackptr->context[ 0 ].delay; trackptr->active = trackptr->context[ 0 ].active; - if ( trackptr->active ) - { - _MIDI_ActiveTracks++; - } + if (trackptr->active) + { + _MIDI_ActiveTracks++; + } - if ( !TimeSet ) - { - _MIDI_Time = trackptr->context[ 0 ].time; - _MIDI_FPSecondsPerTick = trackptr->context[ 0 ].FPSecondsPerTick; - _MIDI_Tick = trackptr->context[ 0 ].tick; - _MIDI_Beat = trackptr->context[ 0 ].beat; - _MIDI_Measure = trackptr->context[ 0 ].measure; - _MIDI_BeatsPerMeasure = trackptr->context[ 0 ].BeatsPerMeasure; - _MIDI_TicksPerBeat = trackptr->context[ 0 ].TicksPerBeat; - _MIDI_TimeBase = trackptr->context[ 0 ].TimeBase; - TimeSet = TRUE; - } + if (!TimeSet) + { + _MIDI_Time = trackptr->context[ 0 ].time; + _MIDI_FPSecondsPerTick = trackptr->context[ 0 ].FPSecondsPerTick; + _MIDI_Tick = trackptr->context[ 0 ].tick; + _MIDI_Beat = trackptr->context[ 0 ].beat; + _MIDI_Measure = trackptr->context[ 0 ].measure; + _MIDI_BeatsPerMeasure = trackptr->context[ 0 ].BeatsPerMeasure; + _MIDI_TicksPerBeat = trackptr->context[ 0 ].TicksPerBeat; + _MIDI_TimeBase = trackptr->context[ 0 ].TimeBase; + TimeSet = TRUE; + } trackptr++; tracknum--; - } - break; + } + break; - default : - if ( _MIDI_Funcs->ControlChange ) - { - _MIDI_Funcs->ControlChange( channel, c1, c2 ); - } - } + default : + if (_MIDI_Funcs->ControlChange) + { + _MIDI_Funcs->ControlChange(channel, c1, c2); + } + } - return TimeSet; - } + return TimeSet; +} /*--------------------------------------------------------------------- @@ -532,137 +535,161 @@ static int _MIDI_InterpretControllerInfo Task that interperates the MIDI data. ---------------------------------------------------------------------*/ -static int _MIDI_ServiceRoutine ( void ) +static int _MIDI_ServiceRoutine(void) { - int event; - int channel; - int command; - track *Track; - int tracknum; - int status; - int c1; - int c2; - int TimeSet = FALSE; - - if ( _MIDI_SongActive ) { - Track = _MIDI_TrackPtr; - tracknum = 0; - while( tracknum < _MIDI_NumTracks ) { - while ( ( Track->active ) && ( Track->delay == 0 ) ) { - GET_NEXT_EVENT( Track, event ); + int event; + int channel; + int command; + track *Track; + int tracknum; + int status; + int c1; + int c2; + int TimeSet = FALSE; - if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) { - switch( event ) { - case MIDI_SYSEX : - case MIDI_SYSEX_CONTINUE : - _MIDI_SysEx( Track ); - break; + if (_MIDI_SongActive) + { + Track = _MIDI_TrackPtr; + tracknum = 0; + while (tracknum < _MIDI_NumTracks) + { + while ((Track->active) && (Track->delay == 0)) + { + GET_NEXT_EVENT(Track, event); - case MIDI_META_EVENT : - _MIDI_MetaEvent( Track ); - break; - } + if (GET_MIDI_COMMAND(event) == MIDI_SPECIAL) + { + switch (event) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx(Track); + break; - if ( Track->active ) { - Track->delay = _MIDI_ReadDelta( Track ); - } - continue; + case MIDI_META_EVENT : + _MIDI_MetaEvent(Track); + break; + } + + if (Track->active) + { + Track->delay = _MIDI_ReadDelta(Track); + } + continue; + } + + if (event & MIDI_RUNNING_STATUS) + { + Track->RunningStatus = event; + } + else + { + event = Track->RunningStatus; + Track->pos--; + } + + channel = GET_MIDI_CHANNEL(event); + command = GET_MIDI_COMMAND(event); + + if (_MIDI_CommandLengths[ command ] > 0) + { + GET_NEXT_EVENT(Track, c1); + if (_MIDI_CommandLengths[ command ] > 1) + { + GET_NEXT_EVENT(Track, c2); + } + } + + if (_MIDI_RerouteFunctions[ channel ] != NULL) + { + status = _MIDI_RerouteFunctions[ channel ](event, c1, c2); + + if (status == MIDI_DONT_PLAY) + { + Track->delay = _MIDI_ReadDelta(Track); + continue; + } + } + + switch (command) + { + case MIDI_NOTE_OFF : + if (_MIDI_Funcs->NoteOff) + { + _MIDI_Funcs->NoteOff(channel, c1, c2); + } + break; + + case MIDI_NOTE_ON : + if (_MIDI_Funcs->NoteOn) + { + _MIDI_Funcs->NoteOn(channel, c1, c2); + } + break; + + case MIDI_POLY_AFTER_TCH : + if (_MIDI_Funcs->PolyAftertouch) + { + _MIDI_Funcs->PolyAftertouch(channel, c1, c2); + } + break; + + case MIDI_CONTROL_CHANGE : + TimeSet = _MIDI_InterpretControllerInfo(Track, TimeSet, channel, c1, c2); + break; + + case MIDI_PROGRAM_CHANGE : + if ((_MIDI_Funcs->ProgramChange) && (!Track->EMIDI_ProgramChange)) + { + _MIDI_Funcs->ProgramChange(channel, MIDI_PatchMap[ c1 & 0x7f ]); + } + break; + + case MIDI_AFTER_TOUCH : + if (_MIDI_Funcs->ChannelAftertouch) + { + _MIDI_Funcs->ChannelAftertouch(channel, c1); + } + break; + + case MIDI_PITCH_BEND : + if (_MIDI_Funcs->PitchBend) + { + _MIDI_Funcs->PitchBend(channel, c1, c2); + } + break; + + default : + break; + } + + Track->delay = _MIDI_ReadDelta(Track); } - if ( event & MIDI_RUNNING_STATUS ) { - Track->RunningStatus = event; - } else { - event = Track->RunningStatus; - Track->pos--; + Track->delay--; + Track++; + tracknum++; + + if (_MIDI_ActiveTracks == 0) + { + _MIDI_ResetTracks(); + if (_MIDI_Loop) + { + tracknum = 0; + Track = _MIDI_TrackPtr; + } + else + { + _MIDI_SongActive = FALSE; + break; + } } + } - channel = GET_MIDI_CHANNEL( event ); - command = GET_MIDI_COMMAND( event ); - - if ( _MIDI_CommandLengths[ command ] > 0 ) { - GET_NEXT_EVENT( Track, c1 ); - if ( _MIDI_CommandLengths[ command ] > 1 ) { - GET_NEXT_EVENT( Track, c2 ); - } - } - - if ( _MIDI_RerouteFunctions[ channel ] != NULL ) { - status = _MIDI_RerouteFunctions[ channel ]( event, c1, c2 ); - - if ( status == MIDI_DONT_PLAY ) { - Track->delay = _MIDI_ReadDelta( Track ); - continue; - } - } - - switch ( command ) { - case MIDI_NOTE_OFF : - if ( _MIDI_Funcs->NoteOff ) { - _MIDI_Funcs->NoteOff( channel, c1, c2 ); - } - break; - - case MIDI_NOTE_ON : - if ( _MIDI_Funcs->NoteOn ) { - _MIDI_Funcs->NoteOn( channel, c1, c2 ); - } - break; - - case MIDI_POLY_AFTER_TCH : - if ( _MIDI_Funcs->PolyAftertouch ) { - _MIDI_Funcs->PolyAftertouch( channel, c1, c2 ); - } - break; - - case MIDI_CONTROL_CHANGE : - TimeSet = _MIDI_InterpretControllerInfo( Track, TimeSet, channel, c1, c2 ); - break; - - case MIDI_PROGRAM_CHANGE : - if ( ( _MIDI_Funcs->ProgramChange ) && ( !Track->EMIDI_ProgramChange ) ) { - _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c1 & 0x7f ] ); - } - break; - - case MIDI_AFTER_TOUCH : - if ( _MIDI_Funcs->ChannelAftertouch ) { - _MIDI_Funcs->ChannelAftertouch( channel, c1 ); - } - break; - - case MIDI_PITCH_BEND : - if ( _MIDI_Funcs->PitchBend ) { - _MIDI_Funcs->PitchBend( channel, c1, c2 ); - } - break; - - default : - break; - } - - Track->delay = _MIDI_ReadDelta( Track ); - } - - Track->delay--; - Track++; - tracknum++; - - if ( _MIDI_ActiveTracks == 0 ) { - _MIDI_ResetTracks(); - if ( _MIDI_Loop ) { - tracknum = 0; - Track = _MIDI_TrackPtr; - } else { - _MIDI_SongActive = FALSE; - break; - } - } - } - - _MIDI_AdvanceTick(); - _MIDI_GlobalPositionInTicks++; - } - return 0; + _MIDI_AdvanceTick(); + _MIDI_GlobalPositionInTicks++; + } + return 0; } @@ -673,39 +700,39 @@ static int _MIDI_ServiceRoutine ( void ) ---------------------------------------------------------------------*/ static int _MIDI_SendControlChange - ( - int channel, - int c1, - int c2 - ) +( + int channel, + int c1, + int c2 +) - { - int status; +{ + int status; - if ( _MIDI_RerouteFunctions[ channel ] != NULL ) - { - status = _MIDI_RerouteFunctions[ channel ]( 0xB0 + channel, - c1, c2 ); - if ( status == MIDI_DONT_PLAY ) - { - return( MIDI_Ok ); - } - } + if (_MIDI_RerouteFunctions[ channel ] != NULL) + { + status = _MIDI_RerouteFunctions[ channel ](0xB0 + channel, + c1, c2); + if (status == MIDI_DONT_PLAY) + { + return(MIDI_Ok); + } + } - if ( _MIDI_Funcs == NULL ) - { - return( MIDI_Error ); - } + if (_MIDI_Funcs == NULL) + { + return(MIDI_Error); + } - if ( _MIDI_Funcs->ControlChange == NULL ) - { - return( MIDI_Error ); - } + if (_MIDI_Funcs->ControlChange == NULL) + { + return(MIDI_Error); + } - _MIDI_Funcs->ControlChange( channel, c1, c2 ); + _MIDI_Funcs->ControlChange(channel, c1, c2); - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -716,17 +743,17 @@ static int _MIDI_SendControlChange ---------------------------------------------------------------------*/ void MIDI_RerouteMidiChannel - ( - int channel, - int ( *function )( int event, int c1, int c2 ) - ) +( + int channel, + int(*function)(int event, int c1, int c2) +) - { - if ( ( channel >= 1 ) && ( channel <= 16 ) ) - { - _MIDI_RerouteFunctions[ channel - 1 ] = function; - } - } +{ + if ((channel >= 1) && (channel <= 16)) + { + _MIDI_RerouteFunctions[ channel - 1 ] = function; + } +} /*--------------------------------------------------------------------- @@ -736,22 +763,22 @@ void MIDI_RerouteMidiChannel ---------------------------------------------------------------------*/ int MIDI_AllNotesOff - ( - void - ) +( + void +) - { - int channel; +{ + int channel; - for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) - { - _MIDI_SendControlChange( channel, 0x40, 0 ); - _MIDI_SendControlChange( channel, MIDI_ALL_NOTES_OFF, 0 ); - _MIDI_SendControlChange( channel, 0x78, 0 ); - } + for (channel = 0; channel < NUM_MIDI_CHANNELS; channel++) + { + _MIDI_SendControlChange(channel, 0x40, 0); + _MIDI_SendControlChange(channel, MIDI_ALL_NOTES_OFF, 0); + _MIDI_SendControlChange(channel, 0x78, 0); + } - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -761,56 +788,56 @@ int MIDI_AllNotesOff ---------------------------------------------------------------------*/ static void _MIDI_SetChannelVolume - ( - int channel, - int volume - ) +( + int channel, + int volume +) - { - int status; - int remotevolume; +{ + int status; + int remotevolume; - _MIDI_ChannelVolume[ channel ] = volume; + _MIDI_ChannelVolume[ channel ] = volume; - if ( _MIDI_RerouteFunctions[ channel ] != NULL ) - { - remotevolume = volume * _MIDI_TotalVolume; - remotevolume *= _MIDI_UserChannelVolume[ channel ]; - remotevolume /= MIDI_MaxVolume; - remotevolume >>= 8; + if (_MIDI_RerouteFunctions[ channel ] != NULL) + { + remotevolume = volume * _MIDI_TotalVolume; + remotevolume *= _MIDI_UserChannelVolume[ channel ]; + remotevolume /= MIDI_MaxVolume; + remotevolume >>= 8; - status = _MIDI_RerouteFunctions[ channel ]( 0xB0 + channel, - MIDI_VOLUME, remotevolume ); - if ( status == MIDI_DONT_PLAY ) - { - return; - } - } + status = _MIDI_RerouteFunctions[ channel ](0xB0 + channel, + MIDI_VOLUME, remotevolume); + if (status == MIDI_DONT_PLAY) + { + return; + } + } - if ( _MIDI_Funcs == NULL ) - { - return; - } + if (_MIDI_Funcs == NULL) + { + return; + } - if ( _MIDI_Funcs->ControlChange == NULL ) - { - return; - } + if (_MIDI_Funcs->ControlChange == NULL) + { + return; + } - // For user volume - volume *= _MIDI_UserChannelVolume[ channel ]; + // For user volume + volume *= _MIDI_UserChannelVolume[ channel ]; - if ( _MIDI_Funcs->SetVolume == NULL ) - { - volume *= _MIDI_TotalVolume; - volume /= MIDI_MaxVolume; - } + if (_MIDI_Funcs->SetVolume == NULL) + { + volume *= _MIDI_TotalVolume; + volume /= MIDI_MaxVolume; + } - // For user volume - volume >>= 8; + // For user volume + volume >>= 8; - _MIDI_Funcs->ControlChange( channel, MIDI_VOLUME, volume ); - } + _MIDI_Funcs->ControlChange(channel, MIDI_VOLUME, volume); +} /*--------------------------------------------------------------------- @@ -820,24 +847,24 @@ static void _MIDI_SetChannelVolume ---------------------------------------------------------------------*/ void MIDI_SetUserChannelVolume - ( - int channel, - int volume - ) +( + int channel, + int volume +) - { - // Convert channel from 1-16 to 0-15 - channel--; +{ + // Convert channel from 1-16 to 0-15 + channel--; - volume = max( 0, volume ); - volume = min( volume, 256 ); + volume = max(0, volume); + volume = min(volume, 256); - if ( ( channel >= 0 ) && ( channel < NUM_MIDI_CHANNELS ) ) - { - _MIDI_UserChannelVolume[ channel ] = volume; - _MIDI_SetChannelVolume( channel, _MIDI_ChannelVolume[ channel ] ); - } - } + if ((channel >= 0) && (channel < NUM_MIDI_CHANNELS)) + { + _MIDI_UserChannelVolume[ channel ] = volume; + _MIDI_SetChannelVolume(channel, _MIDI_ChannelVolume[ channel ]); + } +} /*--------------------------------------------------------------------- @@ -847,20 +874,20 @@ void MIDI_SetUserChannelVolume ---------------------------------------------------------------------*/ void MIDI_ResetUserChannelVolume - ( - void - ) +( + void +) - { - int channel; +{ + int channel; - for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) - { - _MIDI_UserChannelVolume[ channel ] = 256; - } + for (channel = 0; channel < NUM_MIDI_CHANNELS; channel++) + { + _MIDI_UserChannelVolume[ channel ] = 256; + } - _MIDI_SendChannelVolumes(); - } + _MIDI_SendChannelVolumes(); +} /*--------------------------------------------------------------------- @@ -870,18 +897,18 @@ void MIDI_ResetUserChannelVolume ---------------------------------------------------------------------*/ static void _MIDI_SendChannelVolumes - ( - void - ) +( + void +) - { - int channel; +{ + int channel; - for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) - { - _MIDI_SetChannelVolume( channel, _MIDI_ChannelVolume[ channel ] ); - } - } + for (channel = 0; channel < NUM_MIDI_CHANNELS; channel++) + { + _MIDI_SetChannelVolume(channel, _MIDI_ChannelVolume[ channel ]); + } +} /*--------------------------------------------------------------------- @@ -891,33 +918,33 @@ static void _MIDI_SendChannelVolumes ---------------------------------------------------------------------*/ int MIDI_Reset - ( - void - ) +( + void +) - { - int channel; - long time; - unsigned flags; +{ + int channel; + long time; + unsigned flags; - MIDI_AllNotesOff(); + MIDI_AllNotesOff(); - for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) - { - _MIDI_SendControlChange( channel, MIDI_RESET_ALL_CONTROLLERS, 0 ); - _MIDI_SendControlChange( channel, MIDI_RPN_MSB, MIDI_PITCHBEND_MSB ); - _MIDI_SendControlChange( channel, MIDI_RPN_LSB, MIDI_PITCHBEND_LSB ); - _MIDI_SendControlChange( channel, MIDI_DATAENTRY_MSB, 2 ); /* Pitch Bend Sensitivity MSB */ - _MIDI_SendControlChange( channel, MIDI_DATAENTRY_LSB, 0 ); /* Pitch Bend Sensitivity LSB */ - _MIDI_ChannelVolume[ channel ] = GENMIDI_DefaultVolume; - } + for (channel = 0; channel < NUM_MIDI_CHANNELS; channel++) + { + _MIDI_SendControlChange(channel, MIDI_RESET_ALL_CONTROLLERS, 0); + _MIDI_SendControlChange(channel, MIDI_RPN_MSB, MIDI_PITCHBEND_MSB); + _MIDI_SendControlChange(channel, MIDI_RPN_LSB, MIDI_PITCHBEND_LSB); + _MIDI_SendControlChange(channel, MIDI_DATAENTRY_MSB, 2); /* Pitch Bend Sensitivity MSB */ + _MIDI_SendControlChange(channel, MIDI_DATAENTRY_LSB, 0); /* Pitch Bend Sensitivity LSB */ + _MIDI_ChannelVolume[ channel ] = GENMIDI_DefaultVolume; + } - _MIDI_SendChannelVolumes(); + _MIDI_SendChannelVolumes(); - Reset = TRUE; + Reset = TRUE; - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -927,42 +954,42 @@ int MIDI_Reset ---------------------------------------------------------------------*/ int MIDI_SetVolume - ( - int volume - ) +( + int volume +) - { - int i; +{ + int i; - if ( _MIDI_Funcs == NULL ) - { - return( MIDI_NullMidiModule ); - } + if (_MIDI_Funcs == NULL) + { + return(MIDI_NullMidiModule); + } - volume = min( MIDI_MaxVolume, volume ); - volume = max( 0, volume ); + volume = min(MIDI_MaxVolume, volume); + volume = max(0, volume); - _MIDI_TotalVolume = volume; + _MIDI_TotalVolume = volume; - if ( _MIDI_Funcs->SetVolume ) - { - _MIDI_Funcs->SetVolume( volume ); + if (_MIDI_Funcs->SetVolume) + { + _MIDI_Funcs->SetVolume(volume); - for( i = 0; i < NUM_MIDI_CHANNELS; i++ ) - { - if ( _MIDI_RerouteFunctions[ i ] != NULL ) + for (i = 0; i < NUM_MIDI_CHANNELS; i++) + { + if (_MIDI_RerouteFunctions[ i ] != NULL) { - _MIDI_SetChannelVolume( i, _MIDI_ChannelVolume[ i ] ); + _MIDI_SetChannelVolume(i, _MIDI_ChannelVolume[ i ]); } - } - } - else - { - _MIDI_SendChannelVolumes(); - } + } + } + else + { + _MIDI_SendChannelVolumes(); + } - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -972,29 +999,29 @@ int MIDI_SetVolume ---------------------------------------------------------------------*/ int MIDI_GetVolume - ( - void - ) +( + void +) - { - int volume; +{ + int volume; - if ( _MIDI_Funcs == NULL ) - { - return( MIDI_NullMidiModule ); - } + if (_MIDI_Funcs == NULL) + { + return(MIDI_NullMidiModule); + } - if ( _MIDI_Funcs->GetVolume ) - { - volume = _MIDI_Funcs->GetVolume(); - } - else - { - volume = _MIDI_TotalVolume; - } + if (_MIDI_Funcs->GetVolume) + { + volume = _MIDI_Funcs->GetVolume(); + } + else + { + volume = _MIDI_TotalVolume; + } - return( volume ); - } + return(volume); +} /*--------------------------------------------------------------------- @@ -1004,16 +1031,16 @@ int MIDI_GetVolume ---------------------------------------------------------------------*/ void MIDI_SetContext - ( - int context - ) +( + int context +) - { - if ( ( context > 0 ) && ( context < EMIDI_NUM_CONTEXTS ) ) - { - _MIDI_Context = context; - } - } +{ + if ((context > 0) && (context < EMIDI_NUM_CONTEXTS)) + { + _MIDI_Context = context; + } +} /*--------------------------------------------------------------------- @@ -1023,13 +1050,13 @@ void MIDI_SetContext ---------------------------------------------------------------------*/ int MIDI_GetContext - ( - void - ) +( + void +) - { - return _MIDI_Context; - } +{ + return _MIDI_Context; +} /*--------------------------------------------------------------------- @@ -1039,13 +1066,13 @@ int MIDI_GetContext ---------------------------------------------------------------------*/ void MIDI_SetLoopFlag - ( - int loopflag - ) +( + int loopflag +) - { - _MIDI_Loop = loopflag; - } +{ + _MIDI_Loop = loopflag; +} /*--------------------------------------------------------------------- @@ -1055,17 +1082,17 @@ void MIDI_SetLoopFlag ---------------------------------------------------------------------*/ void MIDI_ContinueSong - ( - void - ) +( + void +) - { - if ( _MIDI_SongLoaded ) - { - _MIDI_SongActive = TRUE; - MPU_Unpause(); - } - } +{ + if (_MIDI_SongLoaded) + { + _MIDI_SongActive = TRUE; + MPU_Unpause(); + } +} /*--------------------------------------------------------------------- @@ -1075,18 +1102,18 @@ void MIDI_ContinueSong ---------------------------------------------------------------------*/ void MIDI_PauseSong - ( - void - ) +( + void +) - { - if ( _MIDI_SongLoaded ) - { - _MIDI_SongActive = FALSE; - MIDI_AllNotesOff(); - MPU_Pause(); - } - } +{ + if (_MIDI_SongLoaded) + { + _MIDI_SongActive = FALSE; + MIDI_AllNotesOff(); + MPU_Pause(); + } +} /*--------------------------------------------------------------------- @@ -1096,13 +1123,13 @@ void MIDI_PauseSong ---------------------------------------------------------------------*/ int MIDI_SongPlaying - ( - void - ) +( + void +) - { - return( _MIDI_SongActive ); - } +{ + return(_MIDI_SongActive); +} /*--------------------------------------------------------------------- @@ -1112,13 +1139,13 @@ int MIDI_SongPlaying ---------------------------------------------------------------------*/ void MIDI_SetMidiFuncs - ( - midifuncs *funcs - ) +( + midifuncs *funcs +) - { - _MIDI_Funcs = funcs; - } +{ + _MIDI_Funcs = funcs; +} /*--------------------------------------------------------------------- @@ -1128,38 +1155,38 @@ void MIDI_SetMidiFuncs ---------------------------------------------------------------------*/ void MIDI_StopSong - ( - void - ) +( + void +) - { - if ( _MIDI_SongLoaded ) - { - _MIDI_SongActive = FALSE; - _MIDI_SongLoaded = FALSE; +{ + if (_MIDI_SongLoaded) + { + _MIDI_SongActive = FALSE; + _MIDI_SongLoaded = FALSE; - MIDI_Reset(); - _MIDI_ResetTracks(); + MIDI_Reset(); + _MIDI_ResetTracks(); - if ( _MIDI_Funcs->ReleasePatches ) - { - _MIDI_Funcs->ReleasePatches(); - } + if (_MIDI_Funcs->ReleasePatches) + { + _MIDI_Funcs->ReleasePatches(); + } - USRHOOKS_FreeMem( _MIDI_TrackPtr ); + USRHOOKS_FreeMem(_MIDI_TrackPtr); - _MIDI_TrackPtr = NULL; - _MIDI_NumTracks = 0; - _MIDI_TrackMemSize = 0; + _MIDI_TrackPtr = NULL; + _MIDI_NumTracks = 0; + _MIDI_TrackMemSize = 0; - _MIDI_TotalTime = 0; - _MIDI_TotalTicks = 0; - _MIDI_TotalBeats = 0; - _MIDI_TotalMeasures = 0; + _MIDI_TotalTime = 0; + _MIDI_TotalTicks = 0; + _MIDI_TotalBeats = 0; + _MIDI_TotalMeasures = 0; - MPU_Reset(); - } - } + MPU_Reset(); + } +} /*--------------------------------------------------------------------- @@ -1169,125 +1196,125 @@ void MIDI_StopSong ---------------------------------------------------------------------*/ int MIDI_PlaySong - ( - unsigned char *song, - int loopflag - ) +( + unsigned char *song, + int loopflag +) - { - int numtracks; - int format; - long headersize; - long tracklength; - track *CurrentTrack; - unsigned char *ptr; - int status; - DWORD i; +{ + int numtracks; + int format; + long headersize; + long tracklength; + track *CurrentTrack; + unsigned char *ptr; + int status; + DWORD i; - if ( _MIDI_SongLoaded ) - { - MIDI_StopSong(); - } + if (_MIDI_SongLoaded) + { + MIDI_StopSong(); + } - MPU_Init(MUSIC_SoundDevice); + MPU_Init(MUSIC_SoundDevice); - _MIDI_Loop = loopflag; + _MIDI_Loop = loopflag; - if ( _MIDI_Funcs == NULL ) - { - return( MIDI_NullMidiModule ); - } + if (_MIDI_Funcs == NULL) + { + return(MIDI_NullMidiModule); + } - if ( *( unsigned long * )song != MIDI_HEADER_SIGNATURE ) - { - return( MIDI_InvalidMidiFile ); - } + if (*(unsigned long *)song != MIDI_HEADER_SIGNATURE) + { + return(MIDI_InvalidMidiFile); + } - song += 4; + song += 4; - headersize = _MIDI_ReadNumber( song, 4 ); - song += 4; - format = _MIDI_ReadNumber( song, 2 ); - _MIDI_NumTracks = _MIDI_ReadNumber( song + 2, 2 ); - _MIDI_Division = _MIDI_ReadNumber( song + 4, 2 ); - if ( _MIDI_Division < 0 ) - { - // If a SMPTE time division is given, just set to 96 so no errors occur - _MIDI_Division = 96; - } + headersize = _MIDI_ReadNumber(song, 4); + song += 4; + format = _MIDI_ReadNumber(song, 2); + _MIDI_NumTracks = _MIDI_ReadNumber(song + 2, 2); + _MIDI_Division = _MIDI_ReadNumber(song + 4, 2); + if (_MIDI_Division < 0) + { + // If a SMPTE time division is given, just set to 96 so no errors occur + _MIDI_Division = 96; + } - if ( format > MAX_FORMAT ) - { - return( MIDI_UnknownMidiFormat ); - } + if (format > MAX_FORMAT) + { + return(MIDI_UnknownMidiFormat); + } - ptr = song + headersize; + ptr = song + headersize; - if ( _MIDI_NumTracks == 0 ) - { - return( MIDI_NoTracks ); - } + if (_MIDI_NumTracks == 0) + { + return(MIDI_NoTracks); + } - _MIDI_TrackMemSize = _MIDI_NumTracks * sizeof( track ); - status = USRHOOKS_GetMem( (void**)&_MIDI_TrackPtr, _MIDI_TrackMemSize ); - if ( status != USRHOOKS_Ok ) - { - return( MIDI_NoMemory ); - } + _MIDI_TrackMemSize = _MIDI_NumTracks * sizeof(track); + status = USRHOOKS_GetMem((void**)&_MIDI_TrackPtr, _MIDI_TrackMemSize); + if (status != USRHOOKS_Ok) + { + return(MIDI_NoMemory); + } - CurrentTrack = _MIDI_TrackPtr; - numtracks = _MIDI_NumTracks; - while( numtracks-- ) - { - if ( *( unsigned long * )ptr != MIDI_TRACK_SIGNATURE ) - { - USRHOOKS_FreeMem( _MIDI_TrackPtr ); + CurrentTrack = _MIDI_TrackPtr; + numtracks = _MIDI_NumTracks; + while (numtracks--) + { + if (*(unsigned long *)ptr != MIDI_TRACK_SIGNATURE) + { + USRHOOKS_FreeMem(_MIDI_TrackPtr); - _MIDI_TrackPtr = NULL; - _MIDI_TrackMemSize = 0; + _MIDI_TrackPtr = NULL; + _MIDI_TrackMemSize = 0; - return( MIDI_InvalidTrack ); - } + return(MIDI_InvalidTrack); + } - tracklength = _MIDI_ReadNumber( ptr + 4, 4 ); - ptr += 8; - CurrentTrack->start = ptr; - ptr += tracklength; - CurrentTrack++; - } + tracklength = _MIDI_ReadNumber(ptr + 4, 4); + ptr += 8; + CurrentTrack->start = ptr; + ptr += tracklength; + CurrentTrack++; + } - if ( _MIDI_Funcs->GetVolume != NULL ) - { - _MIDI_TotalVolume = _MIDI_Funcs->GetVolume(); - } + if (_MIDI_Funcs->GetVolume != NULL) + { + _MIDI_TotalVolume = _MIDI_Funcs->GetVolume(); + } - _MIDI_InitEMIDI(); + _MIDI_InitEMIDI(); - if ( _MIDI_Funcs->LoadPatch ) - { - MIDI_LoadTimbres(); - } + if (_MIDI_Funcs->LoadPatch) + { + MIDI_LoadTimbres(); + } - _MIDI_ResetTracks(); + _MIDI_ResetTracks(); - if ( !Reset ) - { - MIDI_Reset(); - } + if (!Reset) + { + MIDI_Reset(); + } - Reset = FALSE; + Reset = FALSE; - MIDI_SetDivision( _MIDI_Division ); - //MIDI_SetTempo( 120 ); + MIDI_SetDivision(_MIDI_Division); + //MIDI_SetTempo( 120 ); - _MIDI_SongLoaded = TRUE; - _MIDI_SongActive = TRUE; + _MIDI_SongLoaded = TRUE; + _MIDI_SongActive = TRUE; - while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); - MPU_BeginPlayback(); + while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); + MPU_BeginPlayback(); - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -1297,22 +1324,22 @@ int MIDI_PlaySong ---------------------------------------------------------------------*/ void MIDI_SetTempo - ( - int tempo - ) +( + int tempo +) - { - long tickspersecond; +{ + long tickspersecond; - MIDI_Tempo = tempo; - tickspersecond = ( ( tempo ) * _MIDI_Division ) / 60; - _MIDI_FPSecondsPerTick = ( 1 << TIME_PRECISION ) / tickspersecond; - MPU_SetTempo(tempo); - } + MIDI_Tempo = tempo; + tickspersecond = ((tempo) * _MIDI_Division) / 60; + _MIDI_FPSecondsPerTick = (1 << TIME_PRECISION) / tickspersecond; + MPU_SetTempo(tempo); +} void MIDI_SetDivision(int division) { - MPU_SetDivision(division); + MPU_SetDivision(division); } @@ -1323,13 +1350,13 @@ void MIDI_SetDivision(int division) ---------------------------------------------------------------------*/ int MIDI_GetTempo - ( - void - ) +( + void +) - { - return( MIDI_Tempo ); - } +{ + return(MIDI_Tempo); +} /*--------------------------------------------------------------------- @@ -1339,147 +1366,147 @@ int MIDI_GetTempo ---------------------------------------------------------------------*/ static int _MIDI_ProcessNextTick - ( - void - ) +( + void +) - { - int event; - int channel; - int command; - track *Track; - int tracknum; - int status; - int c1; - int c2; - int TimeSet = FALSE; +{ + int event; + int channel; + int command; + track *Track; + int tracknum; + int status; + int c1; + int c2; + int TimeSet = FALSE; - Track = _MIDI_TrackPtr; - tracknum = 0; - while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) - { - while ( ( Track->active ) && ( Track->delay == 0 ) ) - { - GET_NEXT_EVENT( Track, event ); + Track = _MIDI_TrackPtr; + tracknum = 0; + while ((tracknum < _MIDI_NumTracks) && (Track != NULL)) + { + while ((Track->active) && (Track->delay == 0)) + { + GET_NEXT_EVENT(Track, event); - if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) + if (GET_MIDI_COMMAND(event) == MIDI_SPECIAL) { - switch( event ) - { - case MIDI_SYSEX : - case MIDI_SYSEX_CONTINUE : - _MIDI_SysEx( Track ); - break; + switch (event) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx(Track); + break; - case MIDI_META_EVENT : - _MIDI_MetaEvent( Track ); - break; - } + case MIDI_META_EVENT : + _MIDI_MetaEvent(Track); + break; + } - if ( Track->active ) - { - Track->delay = _MIDI_ReadDelta( Track ); - } + if (Track->active) + { + Track->delay = _MIDI_ReadDelta(Track); + } - continue; + continue; } - if ( event & MIDI_RUNNING_STATUS ) + if (event & MIDI_RUNNING_STATUS) { - Track->RunningStatus = event; + Track->RunningStatus = event; } - else + else { - event = Track->RunningStatus; - Track->pos--; + event = Track->RunningStatus; + Track->pos--; } - channel = GET_MIDI_CHANNEL( event ); - command = GET_MIDI_COMMAND( event ); + channel = GET_MIDI_CHANNEL(event); + command = GET_MIDI_COMMAND(event); - if ( _MIDI_CommandLengths[ command ] > 0 ) + if (_MIDI_CommandLengths[ command ] > 0) { - GET_NEXT_EVENT( Track, c1 ); - if ( _MIDI_CommandLengths[ command ] > 1 ) - { - GET_NEXT_EVENT( Track, c2 ); - } + GET_NEXT_EVENT(Track, c1); + if (_MIDI_CommandLengths[ command ] > 1) + { + GET_NEXT_EVENT(Track, c2); + } } - if ( _MIDI_RerouteFunctions[ channel ] != NULL ) + if (_MIDI_RerouteFunctions[ channel ] != NULL) { - status = _MIDI_RerouteFunctions[ channel ]( event, c1, c2 ); + status = _MIDI_RerouteFunctions[ channel ](event, c1, c2); - if ( status == MIDI_DONT_PLAY ) - { - Track->delay = _MIDI_ReadDelta( Track ); - continue; - } + if (status == MIDI_DONT_PLAY) + { + Track->delay = _MIDI_ReadDelta(Track); + continue; + } } - switch ( command ) + switch (command) { case MIDI_NOTE_OFF : - break; + break; case MIDI_NOTE_ON : - break; + break; case MIDI_POLY_AFTER_TCH : - if ( _MIDI_Funcs->PolyAftertouch ) - { - _MIDI_Funcs->PolyAftertouch( channel, c1, c2 ); - } - break; + if (_MIDI_Funcs->PolyAftertouch) + { + _MIDI_Funcs->PolyAftertouch(channel, c1, c2); + } + break; case MIDI_CONTROL_CHANGE : - TimeSet = _MIDI_InterpretControllerInfo( Track, TimeSet, - channel, c1, c2 ); - break; + TimeSet = _MIDI_InterpretControllerInfo(Track, TimeSet, + channel, c1, c2); + break; case MIDI_PROGRAM_CHANGE : - if ( ( _MIDI_Funcs->ProgramChange ) && - ( !Track->EMIDI_ProgramChange ) ) - { - _MIDI_Funcs->ProgramChange( channel, c1 ); - } - break; + if ((_MIDI_Funcs->ProgramChange) && + (!Track->EMIDI_ProgramChange)) + { + _MIDI_Funcs->ProgramChange(channel, c1); + } + break; case MIDI_AFTER_TOUCH : - if ( _MIDI_Funcs->ChannelAftertouch ) - { - _MIDI_Funcs->ChannelAftertouch( channel, c1 ); - } - break; + if (_MIDI_Funcs->ChannelAftertouch) + { + _MIDI_Funcs->ChannelAftertouch(channel, c1); + } + break; case MIDI_PITCH_BEND : - if ( _MIDI_Funcs->PitchBend ) - { - _MIDI_Funcs->PitchBend( channel, c1, c2 ); - } - break; + if (_MIDI_Funcs->PitchBend) + { + _MIDI_Funcs->PitchBend(channel, c1, c2); + } + break; default : - break; + break; } - Track->delay = _MIDI_ReadDelta( Track ); - } + Track->delay = _MIDI_ReadDelta(Track); + } - Track->delay--; - Track++; - tracknum++; + Track->delay--; + Track++; + tracknum++; - if ( _MIDI_ActiveTracks == 0 ) - { - break; - } - } + if (_MIDI_ActiveTracks == 0) + { + break; + } + } - _MIDI_AdvanceTick(); + _MIDI_AdvanceTick(); - return( TimeSet ); - } + return(TimeSet); +} /*--------------------------------------------------------------------- @@ -1489,44 +1516,44 @@ static int _MIDI_ProcessNextTick ---------------------------------------------------------------------*/ void MIDI_SetSongTick - ( - unsigned long PositionInTicks - ) +( + unsigned long PositionInTicks +) - { - if ( !_MIDI_SongLoaded ) - { - return; - } +{ + if (!_MIDI_SongLoaded) + { + return; + } - MIDI_PauseSong(); + MIDI_PauseSong(); - if ( PositionInTicks < _MIDI_PositionInTicks ) - { - _MIDI_ResetTracks(); - MIDI_Reset(); - } + if (PositionInTicks < _MIDI_PositionInTicks) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } - while( _MIDI_PositionInTicks < PositionInTicks ) - { - if ( _MIDI_ProcessNextTick() ) - { - break; - } - if ( _MIDI_ActiveTracks == 0 ) - { - _MIDI_ResetTracks(); - if ( !_MIDI_Loop ) + while (_MIDI_PositionInTicks < PositionInTicks) + { + if (_MIDI_ProcessNextTick()) + { + break; + } + if (_MIDI_ActiveTracks == 0) + { + _MIDI_ResetTracks(); + if (!_MIDI_Loop) { - return; + return; } - break; - } - } + break; + } + } - MIDI_SetVolume( _MIDI_TotalVolume ); - MIDI_ContinueSong(); - } + MIDI_SetVolume(_MIDI_TotalVolume); + MIDI_ContinueSong(); +} /*--------------------------------------------------------------------- @@ -1536,52 +1563,52 @@ void MIDI_SetSongTick ---------------------------------------------------------------------*/ void MIDI_SetSongTime - ( - unsigned long milliseconds - ) +( + unsigned long milliseconds +) - { - unsigned long mil; - unsigned long sec; - unsigned long newtime; +{ + unsigned long mil; + unsigned long sec; + unsigned long newtime; - if ( !_MIDI_SongLoaded ) - { - return; - } + if (!_MIDI_SongLoaded) + { + return; + } - MIDI_PauseSong(); + MIDI_PauseSong(); - mil = ( ( milliseconds % 1000 ) << TIME_PRECISION ) / 1000; - sec = ( milliseconds / 1000 ) << TIME_PRECISION; - newtime = sec + mil; + mil = ((milliseconds % 1000) << TIME_PRECISION) / 1000; + sec = (milliseconds / 1000) << TIME_PRECISION; + newtime = sec + mil; - if ( newtime < _MIDI_Time ) - { - _MIDI_ResetTracks(); - MIDI_Reset(); - } + if (newtime < _MIDI_Time) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } - while( _MIDI_Time < newtime ) - { - if ( _MIDI_ProcessNextTick() ) - { - break; - } - if ( _MIDI_ActiveTracks == 0 ) - { - _MIDI_ResetTracks(); - if ( !_MIDI_Loop ) + while (_MIDI_Time < newtime) + { + if (_MIDI_ProcessNextTick()) + { + break; + } + if (_MIDI_ActiveTracks == 0) + { + _MIDI_ResetTracks(); + if (!_MIDI_Loop) { - return; + return; } - break; - } - } + break; + } + } - MIDI_SetVolume( _MIDI_TotalVolume ); - MIDI_ContinueSong(); - } + MIDI_SetVolume(_MIDI_TotalVolume); + MIDI_ContinueSong(); +} /*--------------------------------------------------------------------- @@ -1591,50 +1618,50 @@ void MIDI_SetSongTime ---------------------------------------------------------------------*/ void MIDI_SetSongPosition - ( - int measure, - int beat, - int tick - ) +( + int measure, + int beat, + int tick +) - { - unsigned long pos; +{ + unsigned long pos; - if ( !_MIDI_SongLoaded ) - { - return; - } + if (!_MIDI_SongLoaded) + { + return; + } - MIDI_PauseSong(); + MIDI_PauseSong(); - pos = RELATIVE_BEAT( measure, beat, tick ); + pos = RELATIVE_BEAT(measure, beat, tick); - if ( pos < (unsigned long)RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) ) - { - _MIDI_ResetTracks(); - MIDI_Reset(); - } + if (pos < (unsigned long)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick)) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } - while( (unsigned long)RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) < pos ) - { - if ( _MIDI_ProcessNextTick() ) - { - break; - } - if ( _MIDI_ActiveTracks == 0 ) - { - _MIDI_ResetTracks(); - if ( !_MIDI_Loop ) + while ((unsigned long)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick) < pos) + { + if (_MIDI_ProcessNextTick()) + { + break; + } + if (_MIDI_ActiveTracks == 0) + { + _MIDI_ResetTracks(); + if (!_MIDI_Loop) { - return; + return; } - break; - } - } + break; + } + } - MIDI_SetVolume( _MIDI_TotalVolume ); - MIDI_ContinueSong(); - } + MIDI_SetVolume(_MIDI_TotalVolume); + MIDI_ContinueSong(); +} /*--------------------------------------------------------------------- @@ -1644,22 +1671,22 @@ void MIDI_SetSongPosition ---------------------------------------------------------------------*/ void MIDI_GetSongPosition - ( - songposition *pos - ) +( + songposition *pos +) - { - unsigned long mil; - unsigned long sec; +{ + unsigned long mil; + unsigned long sec; - mil = ( _MIDI_Time & ( ( 1 << TIME_PRECISION ) - 1 ) ) * 1000; - sec = _MIDI_Time >> TIME_PRECISION; - pos->milliseconds = ( mil >> TIME_PRECISION ) + ( sec * 1000 ); - pos->tickposition = _MIDI_PositionInTicks; - pos->measure = _MIDI_Measure; - pos->beat = _MIDI_Beat; - pos->tick = _MIDI_Tick; - } + mil = (_MIDI_Time & ((1 << TIME_PRECISION) - 1)) * 1000; + sec = _MIDI_Time >> TIME_PRECISION; + pos->milliseconds = (mil >> TIME_PRECISION) + (sec * 1000); + pos->tickposition = _MIDI_PositionInTicks; + pos->measure = _MIDI_Measure; + pos->beat = _MIDI_Beat; + pos->tick = _MIDI_Tick; +} /*--------------------------------------------------------------------- @@ -1669,23 +1696,23 @@ void MIDI_GetSongPosition ---------------------------------------------------------------------*/ void MIDI_GetSongLength - ( - songposition *pos - ) +( + songposition *pos +) - { - unsigned long mil; - unsigned long sec; +{ + unsigned long mil; + unsigned long sec; - mil = ( _MIDI_TotalTime & ( ( 1 << TIME_PRECISION ) - 1 ) ) * 1000; - sec = _MIDI_TotalTime >> TIME_PRECISION; + mil = (_MIDI_TotalTime & ((1 << TIME_PRECISION) - 1)) * 1000; + sec = _MIDI_TotalTime >> TIME_PRECISION; - pos->milliseconds = ( mil >> TIME_PRECISION ) + ( sec * 1000 ); - pos->measure = _MIDI_TotalMeasures; - pos->beat = _MIDI_TotalBeats; - pos->tick = _MIDI_TotalTicks; - pos->tickposition = 0; - } + pos->milliseconds = (mil >> TIME_PRECISION) + (sec * 1000); + pos->measure = _MIDI_TotalMeasures; + pos->beat = _MIDI_TotalBeats; + pos->tick = _MIDI_TotalTicks; + pos->tickposition = 0; +} /*--------------------------------------------------------------------- @@ -1695,237 +1722,237 @@ void MIDI_GetSongLength ---------------------------------------------------------------------*/ static void _MIDI_InitEMIDI - ( - void - ) +( + void +) - { - int event; - int command; - int channel; - int length; - int IncludeFound; - track *Track; - int tracknum; - int type; - int c1; - int c2; +{ + int event; + int command; + int channel; + int length; + int IncludeFound; + track *Track; + int tracknum; + int type; + int c1; + int c2; - type = EMIDI_GeneralMIDI; + type = EMIDI_GeneralMIDI; - _MIDI_ResetTracks(); + _MIDI_ResetTracks(); - _MIDI_TotalTime = 0; - _MIDI_TotalTicks = 0; - _MIDI_TotalBeats = 0; - _MIDI_TotalMeasures = 0; + _MIDI_TotalTime = 0; + _MIDI_TotalTicks = 0; + _MIDI_TotalBeats = 0; + _MIDI_TotalMeasures = 0; - Track = _MIDI_TrackPtr; - tracknum = 0; - while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) - { - _MIDI_Tick = 0; - _MIDI_Beat = 1; - _MIDI_Measure = 1; - _MIDI_Time = 0; - _MIDI_BeatsPerMeasure = 4; - _MIDI_TicksPerBeat = _MIDI_Division; - _MIDI_TimeBase = 4; + Track = _MIDI_TrackPtr; + tracknum = 0; + while ((tracknum < _MIDI_NumTracks) && (Track != NULL)) + { + _MIDI_Tick = 0; + _MIDI_Beat = 1; + _MIDI_Measure = 1; + _MIDI_Time = 0; + _MIDI_BeatsPerMeasure = 4; + _MIDI_TicksPerBeat = _MIDI_Division; + _MIDI_TimeBase = 4; - _MIDI_PositionInTicks = 0; - _MIDI_ActiveTracks = 0; - _MIDI_Context = -1; + _MIDI_PositionInTicks = 0; + _MIDI_ActiveTracks = 0; + _MIDI_Context = -1; - Track->RunningStatus = 0; - Track->active = TRUE; + Track->RunningStatus = 0; + Track->active = TRUE; - Track->EMIDI_ProgramChange = FALSE; - Track->EMIDI_VolumeChange = FALSE; - Track->EMIDI_IncludeTrack = TRUE; + Track->EMIDI_ProgramChange = FALSE; + Track->EMIDI_VolumeChange = FALSE; + Track->EMIDI_IncludeTrack = TRUE; - memset( Track->context, 0, sizeof( Track->context ) ); + memset(Track->context, 0, sizeof(Track->context)); - while( Track->delay > 0 ) - { - _MIDI_AdvanceTick(); - Track->delay--; - } - - IncludeFound = FALSE; - while ( Track->active ) - { - GET_NEXT_EVENT( Track, event ); - - if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) - { - switch( event ) - { - case MIDI_SYSEX : - case MIDI_SYSEX_CONTINUE : - _MIDI_SysEx( Track ); - break; - - case MIDI_META_EVENT : - _MIDI_MetaEvent( Track ); - break; - } - - if ( Track->active ) - { - Track->delay = _MIDI_ReadDelta( Track ); - while( Track->delay > 0 ) - { - _MIDI_AdvanceTick(); - Track->delay--; - } - } - - continue; - } - - if ( event & MIDI_RUNNING_STATUS ) - { - Track->RunningStatus = event; - } - else - { - event = Track->RunningStatus; - Track->pos--; - } - - channel = GET_MIDI_CHANNEL( event ); - command = GET_MIDI_COMMAND( event ); - length = _MIDI_CommandLengths[ command ]; - - if ( command == MIDI_CONTROL_CHANGE ) - { - if ( *Track->pos == MIDI_MONO_MODE_ON ) - { - length++; - } - GET_NEXT_EVENT( Track, c1 ); - GET_NEXT_EVENT( Track, c2 ); - length -= 2; - - switch( c1 ) - { - case EMIDI_LOOP_START : - case EMIDI_SONG_LOOP_START : - if ( c2 == 0 ) - { - Track->context[ 0 ].loopcount = EMIDI_INFINITE; - } - else - { - Track->context[ 0 ].loopcount = c2; - } - - Track->context[ 0 ].pos = Track->pos; - Track->context[ 0 ].loopstart = Track->pos; - Track->context[ 0 ].RunningStatus = Track->RunningStatus; - Track->context[ 0 ].time = _MIDI_Time; - Track->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; - Track->context[ 0 ].tick = _MIDI_Tick; - Track->context[ 0 ].beat = _MIDI_Beat; - Track->context[ 0 ].measure = _MIDI_Measure; - Track->context[ 0 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; - Track->context[ 0 ].TicksPerBeat = _MIDI_TicksPerBeat; - Track->context[ 0 ].TimeBase = _MIDI_TimeBase; - break; - - case EMIDI_LOOP_END : - case EMIDI_SONG_LOOP_END : - if ( c2 == EMIDI_END_LOOP_VALUE ) - { - Track->context[ 0 ].loopstart = NULL; - Track->context[ 0 ].loopcount = 0; - } - break; - - case EMIDI_INCLUDE_TRACK : - if ( EMIDI_AffectsCurrentCard( c2, type ) ) - { - //printf( "Include track %d on card %d\n", tracknum, c2 ); - IncludeFound = TRUE; - Track->EMIDI_IncludeTrack = TRUE; - } - else if ( !IncludeFound ) - { - //printf( "Track excluded %d on card %d\n", tracknum, c2 ); - IncludeFound = TRUE; - Track->EMIDI_IncludeTrack = FALSE; - } - break; - - case EMIDI_EXCLUDE_TRACK : - if ( EMIDI_AffectsCurrentCard( c2, type ) ) - { - //printf( "Exclude track %d on card %d\n", tracknum, c2 ); - Track->EMIDI_IncludeTrack = FALSE; - } - break; - - case EMIDI_PROGRAM_CHANGE : - if ( !Track->EMIDI_ProgramChange ) - //printf( "Program change on track %d\n", tracknum ); - Track->EMIDI_ProgramChange = TRUE; - break; - - case EMIDI_VOLUME_CHANGE : - if ( !Track->EMIDI_VolumeChange ) - //printf( "Volume change on track %d\n", tracknum ); - Track->EMIDI_VolumeChange = TRUE; - break; - - case EMIDI_CONTEXT_START : - if ( ( c2 > 0 ) && ( c2 < EMIDI_NUM_CONTEXTS ) ) - { - Track->context[ c2 ].pos = Track->pos; - Track->context[ c2 ].loopstart = Track->context[ 0 ].loopstart; - Track->context[ c2 ].loopcount = Track->context[ 0 ].loopcount; - Track->context[ c2 ].RunningStatus = Track->RunningStatus; - Track->context[ c2 ].time = _MIDI_Time; - Track->context[ c2 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; - Track->context[ c2 ].tick = _MIDI_Tick; - Track->context[ c2 ].beat = _MIDI_Beat; - Track->context[ c2 ].measure = _MIDI_Measure; - Track->context[ c2 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; - Track->context[ c2 ].TicksPerBeat = _MIDI_TicksPerBeat; - Track->context[ c2 ].TimeBase = _MIDI_TimeBase; - } - break; - - case EMIDI_CONTEXT_END : - break; - } - } - - Track->pos += length; - Track->delay = _MIDI_ReadDelta( Track ); - - while( Track->delay > 0 ) - { + while (Track->delay > 0) + { _MIDI_AdvanceTick(); Track->delay--; + } + + IncludeFound = FALSE; + while (Track->active) + { + GET_NEXT_EVENT(Track, event); + + if (GET_MIDI_COMMAND(event) == MIDI_SPECIAL) + { + switch (event) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx(Track); + break; + + case MIDI_META_EVENT : + _MIDI_MetaEvent(Track); + break; + } + + if (Track->active) + { + Track->delay = _MIDI_ReadDelta(Track); + while (Track->delay > 0) + { + _MIDI_AdvanceTick(); + Track->delay--; + } + } + + continue; } - } - _MIDI_TotalTime = max( _MIDI_TotalTime, _MIDI_Time ); - if ( RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) > - RELATIVE_BEAT( _MIDI_TotalMeasures, _MIDI_TotalBeats, - _MIDI_TotalTicks ) ) - { - _MIDI_TotalTicks = _MIDI_Tick; - _MIDI_TotalBeats = _MIDI_Beat; - _MIDI_TotalMeasures = _MIDI_Measure; - } + if (event & MIDI_RUNNING_STATUS) + { + Track->RunningStatus = event; + } + else + { + event = Track->RunningStatus; + Track->pos--; + } - Track++; - tracknum++; - } + channel = GET_MIDI_CHANNEL(event); + command = GET_MIDI_COMMAND(event); + length = _MIDI_CommandLengths[ command ]; - _MIDI_ResetTracks(); - } + if (command == MIDI_CONTROL_CHANGE) + { + if (*Track->pos == MIDI_MONO_MODE_ON) + { + length++; + } + GET_NEXT_EVENT(Track, c1); + GET_NEXT_EVENT(Track, c2); + length -= 2; + + switch (c1) + { + case EMIDI_LOOP_START : + case EMIDI_SONG_LOOP_START : + if (c2 == 0) + { + Track->context[ 0 ].loopcount = EMIDI_INFINITE; + } + else + { + Track->context[ 0 ].loopcount = c2; + } + + Track->context[ 0 ].pos = Track->pos; + Track->context[ 0 ].loopstart = Track->pos; + Track->context[ 0 ].RunningStatus = Track->RunningStatus; + Track->context[ 0 ].time = _MIDI_Time; + Track->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + Track->context[ 0 ].tick = _MIDI_Tick; + Track->context[ 0 ].beat = _MIDI_Beat; + Track->context[ 0 ].measure = _MIDI_Measure; + Track->context[ 0 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + Track->context[ 0 ].TicksPerBeat = _MIDI_TicksPerBeat; + Track->context[ 0 ].TimeBase = _MIDI_TimeBase; + break; + + case EMIDI_LOOP_END : + case EMIDI_SONG_LOOP_END : + if (c2 == EMIDI_END_LOOP_VALUE) + { + Track->context[ 0 ].loopstart = NULL; + Track->context[ 0 ].loopcount = 0; + } + break; + + case EMIDI_INCLUDE_TRACK : + if (EMIDI_AffectsCurrentCard(c2, type)) + { + //printf( "Include track %d on card %d\n", tracknum, c2 ); + IncludeFound = TRUE; + Track->EMIDI_IncludeTrack = TRUE; + } + else if (!IncludeFound) + { + //printf( "Track excluded %d on card %d\n", tracknum, c2 ); + IncludeFound = TRUE; + Track->EMIDI_IncludeTrack = FALSE; + } + break; + + case EMIDI_EXCLUDE_TRACK : + if (EMIDI_AffectsCurrentCard(c2, type)) + { + //printf( "Exclude track %d on card %d\n", tracknum, c2 ); + Track->EMIDI_IncludeTrack = FALSE; + } + break; + + case EMIDI_PROGRAM_CHANGE : + if (!Track->EMIDI_ProgramChange) + //printf( "Program change on track %d\n", tracknum ); + Track->EMIDI_ProgramChange = TRUE; + break; + + case EMIDI_VOLUME_CHANGE : + if (!Track->EMIDI_VolumeChange) + //printf( "Volume change on track %d\n", tracknum ); + Track->EMIDI_VolumeChange = TRUE; + break; + + case EMIDI_CONTEXT_START : + if ((c2 > 0) && (c2 < EMIDI_NUM_CONTEXTS)) + { + Track->context[ c2 ].pos = Track->pos; + Track->context[ c2 ].loopstart = Track->context[ 0 ].loopstart; + Track->context[ c2 ].loopcount = Track->context[ 0 ].loopcount; + Track->context[ c2 ].RunningStatus = Track->RunningStatus; + Track->context[ c2 ].time = _MIDI_Time; + Track->context[ c2 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + Track->context[ c2 ].tick = _MIDI_Tick; + Track->context[ c2 ].beat = _MIDI_Beat; + Track->context[ c2 ].measure = _MIDI_Measure; + Track->context[ c2 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + Track->context[ c2 ].TicksPerBeat = _MIDI_TicksPerBeat; + Track->context[ c2 ].TimeBase = _MIDI_TimeBase; + } + break; + + case EMIDI_CONTEXT_END : + break; + } + } + + Track->pos += length; + Track->delay = _MIDI_ReadDelta(Track); + + while (Track->delay > 0) + { + _MIDI_AdvanceTick(); + Track->delay--; + } + } + + _MIDI_TotalTime = max(_MIDI_TotalTime, _MIDI_Time); + if (RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick) > + RELATIVE_BEAT(_MIDI_TotalMeasures, _MIDI_TotalBeats, + _MIDI_TotalTicks)) + { + _MIDI_TotalTicks = _MIDI_Tick; + _MIDI_TotalBeats = _MIDI_Beat; + _MIDI_TotalMeasures = _MIDI_Measure; + } + + Track++; + tracknum++; + } + + _MIDI_ResetTracks(); +} /*--------------------------------------------------------------------- @@ -1935,114 +1962,114 @@ static void _MIDI_InitEMIDI ---------------------------------------------------------------------*/ void MIDI_LoadTimbres - ( - void - ) +( + void +) - { - int event; - int command; - int channel; - int length; - int Finished; - track *Track; - int tracknum; +{ + int event; + int command; + int channel; + int length; + int Finished; + track *Track; + int tracknum; - Track = _MIDI_TrackPtr; - tracknum = 0; - while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) - { - Finished = FALSE; - while ( !Finished ) - { - GET_NEXT_EVENT( Track, event ); + Track = _MIDI_TrackPtr; + tracknum = 0; + while ((tracknum < _MIDI_NumTracks) && (Track != NULL)) + { + Finished = FALSE; + while (!Finished) + { + GET_NEXT_EVENT(Track, event); - if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) + if (GET_MIDI_COMMAND(event) == MIDI_SPECIAL) { - switch( event ) - { - case MIDI_SYSEX : - case MIDI_SYSEX_CONTINUE : - length = _MIDI_ReadDelta( Track ); - Track->pos += length; - break; + switch (event) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + length = _MIDI_ReadDelta(Track); + Track->pos += length; + break; - case MIDI_META_EVENT : - GET_NEXT_EVENT( Track, command ); - GET_NEXT_EVENT( Track, length ); + case MIDI_META_EVENT : + GET_NEXT_EVENT(Track, command); + GET_NEXT_EVENT(Track, length); - if ( command == MIDI_END_OF_TRACK ) - { - Finished = TRUE; - } + if (command == MIDI_END_OF_TRACK) + { + Finished = TRUE; + } - Track->pos += length; - break; - } + Track->pos += length; + break; + } - if ( !Finished ) - { - _MIDI_ReadDelta( Track ); - } + if (!Finished) + { + _MIDI_ReadDelta(Track); + } - continue; + continue; } - if ( event & MIDI_RUNNING_STATUS ) + if (event & MIDI_RUNNING_STATUS) { - Track->RunningStatus = event; + Track->RunningStatus = event; } - else + else { - event = Track->RunningStatus; - Track->pos--; + event = Track->RunningStatus; + Track->pos--; } - channel = GET_MIDI_CHANNEL( event ); - command = GET_MIDI_COMMAND( event ); - length = _MIDI_CommandLengths[ command ]; + channel = GET_MIDI_CHANNEL(event); + command = GET_MIDI_COMMAND(event); + length = _MIDI_CommandLengths[ command ]; - if ( command == MIDI_CONTROL_CHANGE ) + if (command == MIDI_CONTROL_CHANGE) { - if ( *Track->pos == MIDI_MONO_MODE_ON ) - { - length++; - } + if (*Track->pos == MIDI_MONO_MODE_ON) + { + length++; + } - if ( *Track->pos == EMIDI_PROGRAM_CHANGE ) - { - _MIDI_Funcs->LoadPatch( *( Track->pos + 1 ) ); - } + if (*Track->pos == EMIDI_PROGRAM_CHANGE) + { + _MIDI_Funcs->LoadPatch(*(Track->pos + 1)); + } } - if ( channel == MIDI_RHYTHM_CHANNEL ) + if (channel == MIDI_RHYTHM_CHANNEL) { - if ( command == MIDI_NOTE_ON ) - { - _MIDI_Funcs->LoadPatch( 128 + *Track->pos ); - } + if (command == MIDI_NOTE_ON) + { + _MIDI_Funcs->LoadPatch(128 + *Track->pos); + } } - else + else { - if ( command == MIDI_PROGRAM_CHANGE ) - { - _MIDI_Funcs->LoadPatch( *Track->pos ); - } + if (command == MIDI_PROGRAM_CHANGE) + { + _MIDI_Funcs->LoadPatch(*Track->pos); + } } - Track->pos += length; - _MIDI_ReadDelta( Track ); - } - Track++; - tracknum++; - } + Track->pos += length; + _MIDI_ReadDelta(Track); + } + Track++; + tracknum++; + } - _MIDI_ResetTracks(); - } + _MIDI_ResetTracks(); +} void MIDI_UpdateMusic(void) { - if (!_MIDI_SongLoaded || !_MIDI_SongActive) return; - while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); + if (!_MIDI_SongLoaded || !_MIDI_SongActive) return; + while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); } diff --git a/polymer/eduke32/source/jaudiolib/mpu401.c b/polymer/eduke32/source/jaudiolib/mpu401.c index 988e38a24..ebef3c153 100644 --- a/polymer/eduke32/source/jaudiolib/mpu401.c +++ b/polymer/eduke32/source/jaudiolib/mpu401.c @@ -40,11 +40,13 @@ static HMIDISTRM hmido = (HMIDISTRM)-1; static MIDIOUTCAPS midicaps; static DWORD mididevice = -1; -typedef struct { - long time; - long stream; - long event; -} MIDIEVENTHEAD; +typedef struct +{ + long time; + long stream; + long event; +} +MIDIEVENTHEAD; #define PAD(x) ((((x)+3)&(~3))) #define BUFFERLEN (32*4*4) @@ -52,8 +54,8 @@ typedef struct { static char eventbuf[NUMBUFFERS][BUFFERLEN]; static int eventcnt[NUMBUFFERS]; static MIDIHDR bufferheaders[NUMBUFFERS]; - int _MPU_CurrentBuffer = 0; - int _MPU_BuffersWaiting = 0; +int _MPU_CurrentBuffer = 0; +int _MPU_BuffersWaiting = 0; extern unsigned long _MIDI_GlobalPositionInTicks; unsigned long _MPU_LastEvent=0; @@ -79,54 +81,57 @@ unsigned long _MPU_LastEvent=0; **********************************************************************/ -void MPU_FinishBuffer( int buffer ) +void MPU_FinishBuffer(int buffer) { - if (!eventcnt[buffer]) return; - ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR)); - bufferheaders[buffer].lpData = eventbuf[buffer]; - bufferheaders[buffer].dwBufferLength = - bufferheaders[buffer].dwBytesRecorded = eventcnt[buffer]; - midiOutPrepareHeader((HMIDIOUT)hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); - midiStreamOut(hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); + if (!eventcnt[buffer]) return; + ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR)); + bufferheaders[buffer].lpData = eventbuf[buffer]; + bufferheaders[buffer].dwBufferLength = + bufferheaders[buffer].dwBytesRecorded = eventcnt[buffer]; + midiOutPrepareHeader((HMIDIOUT)hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); + midiStreamOut(hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); // printf("Sending %d bytes (buffer %d)\n",eventcnt[buffer],buffer); - _MPU_BuffersWaiting++; + _MPU_BuffersWaiting++; } -void MPU_BeginPlayback( void ) +void MPU_BeginPlayback(void) { - _MPU_LastEvent = _MIDI_GlobalPositionInTicks; - if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); + _MPU_LastEvent = _MIDI_GlobalPositionInTicks; + if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); } void MPU_Pause(void) { - if (hmido != (HMIDISTRM)-1) midiStreamPause(hmido); + if (hmido != (HMIDISTRM)-1) midiStreamPause(hmido); } void MPU_Unpause(void) { - if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); + if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); } void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { - int i; - switch (uMsg) { - case MOM_DONE: - midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR)); - for (i=0;i BUFFERLEN) { - // buffer over-full - nextbuffer = MPU_GetNextBuffer(); - if (nextbuffer < 0) { + if (count <= 0) return; + if (count <= 3) + { + if (eventcnt[_MPU_CurrentBuffer] + 12 > BUFFERLEN) + { + // buffer over-full + nextbuffer = MPU_GetNextBuffer(); + if (nextbuffer < 0) + { // printf("All buffers full!\n"); - return; - } - MPU_FinishBuffer(_MPU_CurrentBuffer); - _MPU_CurrentBuffer = nextbuffer; - } + return; + } + MPU_FinishBuffer(_MPU_CurrentBuffer); + _MPU_CurrentBuffer = nextbuffer; + } - p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; - ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; - ((long*)p)[1] = 0; - ((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]); - eventcnt[_MPU_CurrentBuffer] += 12; - } else { - padded = PAD(count); - if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN) { - // buffer over-full - nextbuffer = MPU_GetNextBuffer(); - if (nextbuffer < 0) { + p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; + ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; + ((long*)p)[1] = 0; + ((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]); + eventcnt[_MPU_CurrentBuffer] += 12; + } + else + { + padded = PAD(count); + if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN) + { + // buffer over-full + nextbuffer = MPU_GetNextBuffer(); + if (nextbuffer < 0) + { // printf("All buffers full!\n"); - return; - } - MPU_FinishBuffer(_MPU_CurrentBuffer); - _MPU_CurrentBuffer = nextbuffer; - } + return; + } + MPU_FinishBuffer(_MPU_CurrentBuffer); + _MPU_CurrentBuffer = nextbuffer; + } - p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; - ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; - ((long*)p)[1] = 0; - ((long*)p)[2] = (MEVT_LONGMSG<<24) | (count & 0xffffffl); - p+=12; eventcnt[_MPU_CurrentBuffer] += 12; - for (; count>0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++) - *(p++) = *(data++); - for (; padded>0; padded--, eventcnt[_MPU_CurrentBuffer]++) - *(p++) = 0; - } - _MPU_LastEvent = _MIDI_GlobalPositionInTicks; + p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; + ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; + ((long*)p)[1] = 0; + ((long*)p)[2] = (MEVT_LONGMSG<<24) | (count & 0xffffffl); + p+=12; eventcnt[_MPU_CurrentBuffer] += 12; + for (; count>0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++) + *(p++) = *(data++); + for (; padded>0; padded--, eventcnt[_MPU_CurrentBuffer]++) + *(p++) = 0; + } + _MPU_LastEvent = _MIDI_GlobalPositionInTicks; } @@ -201,22 +214,23 @@ void MPU_SendMidi( char *data, int count ) Sends a MIDI message immediately to the the music device. ---------------------------------------------------------------------*/ -void MPU_SendMidiImmediate( char *data, int count ) +void MPU_SendMidiImmediate(char *data, int count) { - MIDIHDR mhdr; - static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl }; + MIDIHDR mhdr; + static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl }; - if (!count) return; - if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]); - else { - ZeroMemory(&mhdr, sizeof(mhdr)); - mhdr.lpData = data; - mhdr.dwBufferLength = count; - midiOutPrepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); - midiOutLongMsg((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); - while (!(mhdr.dwFlags & MHDR_DONE)) ; - midiOutUnprepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); - } + if (!count) return; + if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]); + else + { + ZeroMemory(&mhdr, sizeof(mhdr)); + mhdr.lpData = data; + mhdr.dwBufferLength = count; + midiOutPrepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + midiOutLongMsg((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + while (!(mhdr.dwFlags & MHDR_DONE)) ; + midiOutUnprepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + } } @@ -227,16 +241,16 @@ void MPU_SendMidiImmediate( char *data, int count ) ---------------------------------------------------------------------*/ int MPU_Reset - ( - void - ) +( + void +) - { - midiStreamStop(hmido); - midiStreamClose(hmido); +{ + midiStreamStop(hmido); + midiStreamClose(hmido); - return( MPU_Ok ); - } + return(MPU_Ok); +} /*--------------------------------------------------------------------- @@ -246,23 +260,23 @@ int MPU_Reset ---------------------------------------------------------------------*/ int MPU_Init - ( - int addr - ) +( + int addr +) - { - int i; +{ + int i; - for (i=0;ilength == 0 ) && ( voice->GetSound( voice ) != KeepPlaying ) ) - { - return; - } + if ((voice->length == 0) && (voice->GetSound(voice) != KeepPlaying)) + { + return; + } - length = MixBufferSize; - FixedPointBufferSize = voice->FixedPointBufferSize; + length = MixBufferSize; + FixedPointBufferSize = voice->FixedPointBufferSize; - MV_MixDestination = MV_MixBuffer[ buffer ]; - MV_LeftVolume = voice->LeftVolume; - MV_RightVolume = voice->RightVolume; + MV_MixDestination = MV_MixBuffer[ buffer ]; + MV_LeftVolume = voice->LeftVolume; + MV_RightVolume = voice->RightVolume; - if ( ( MV_Channels == 2 ) && ( IS_QUIET( MV_LeftVolume ) ) ) - { - MV_LeftVolume = MV_RightVolume; - MV_MixDestination += MV_RightChannelOffset; - } + if ((MV_Channels == 2) && (IS_QUIET(MV_LeftVolume))) + { + MV_LeftVolume = MV_RightVolume; + MV_MixDestination += MV_RightChannelOffset; + } - // Add this voice to the mix - while( length > 0 ) - { - start = voice->sound; - rate = voice->RateScale; - position = voice->position; + // Add this voice to the mix + while (length > 0) + { + start = voice->sound; + rate = voice->RateScale; + position = voice->position; - // Check if the last sample in this buffer would be - // beyond the length of the sample block - if ( ( position + FixedPointBufferSize ) >= voice->length ) - { - if ( position < voice->length ) + // Check if the last sample in this buffer would be + // beyond the length of the sample block + if ((position + FixedPointBufferSize) >= voice->length) + { + if (position < voice->length) { - voclength = ( voice->length - position + rate - 1 ) / rate; + voclength = (voice->length - position + rate - 1) / rate; } - else + else { - voice->GetSound( voice ); - return; + voice->GetSound(voice); + return; } - } - else - { - voclength = length; - } + } + else + { + voclength = length; + } - voice->mix( position, rate, start, voclength ); + voice->mix(position, rate, start, voclength); - if ( voclength & 1 ) - { - MV_MixPosition += rate; - voclength -= 1; - } - voice->position = MV_MixPosition; + if (voclength & 1) + { + MV_MixPosition += rate; + voclength -= 1; + } + voice->position = MV_MixPosition; - length -= voclength; + length -= voclength; - if ( voice->position >= voice->length ) - { - // Get the next block of sound - if ( voice->GetSound( voice ) != KeepPlaying ) + if (voice->position >= voice->length) + { + // Get the next block of sound + if (voice->GetSound(voice) != KeepPlaying) { - return; + return; } - if ( length > 0 ) + if (length > 0) { - // Get the position of the last sample in the buffer - FixedPointBufferSize = voice->RateScale * ( length - 1 ); + // Get the position of the last sample in the buffer + FixedPointBufferSize = voice->RateScale * (length - 1); } - } - } - } + } + } +} /*--------------------------------------------------------------------- @@ -351,18 +351,18 @@ static void MV_Mix ---------------------------------------------------------------------*/ void MV_PlayVoice - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - unsigned flags; +{ + unsigned flags; - flags = DisableInterrupts(); - LL_SortedInsertion( &VoiceList, voice, prev, next, VoiceNode, priority ); + flags = DisableInterrupts(); + LL_SortedInsertion(&VoiceList, voice, prev, next, VoiceNode, priority); - RestoreInterrupts( flags ); - } + RestoreInterrupts(flags); +} /*--------------------------------------------------------------------- @@ -372,21 +372,21 @@ void MV_PlayVoice ---------------------------------------------------------------------*/ void MV_StopVoice - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - unsigned flags; +{ + unsigned flags; - flags = DisableInterrupts(); + flags = DisableInterrupts(); - // move the voice from the play list to the free list - LL_Remove( voice, next, prev ); - LL_Add( &VoicePool, voice, next, prev ); + // move the voice from the play list to the free list + LL_Remove(voice, next, prev); + LL_Add(&VoicePool, voice, next, prev); - RestoreInterrupts( flags ); - } + RestoreInterrupts(flags); +} /*--------------------------------------------------------------------- @@ -398,120 +398,120 @@ void MV_StopVoice // static int backcolor = 1; int MV_ServiceVoc - ( - int buffer - ) +( + int buffer +) - { - VoiceNode *voice; - VoiceNode *next; +{ + VoiceNode *voice; + VoiceNode *next; - // Get the currently playing buffer - MV_MixPage = buffer; + // Get the currently playing buffer + MV_MixPage = buffer; - // Toggle which buffer we'll mix next - MV_MixPage++; - if ( MV_MixPage >= MV_NumberOfBuffers ) - { - MV_MixPage -= MV_NumberOfBuffers; - } + // Toggle which buffer we'll mix next + MV_MixPage++; + if (MV_MixPage >= MV_NumberOfBuffers) + { + MV_MixPage -= MV_NumberOfBuffers; + } - if ( MV_ReverbLevel == 0 ) - { - // Initialize buffer - //Commented out so that the buffer is always cleared. - //This is so the guys at Echo Speech can mix into the - //buffer even when no sounds are playing. - //if ( !MV_BufferEmpty[ MV_MixPage ] ) - { - ClearBuffer_DW( MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2 ); - MV_BufferEmpty[ MV_MixPage ] = TRUE; - } - } - else - { - char *end; - char *source; - char *dest; - int count; - int length; + if (MV_ReverbLevel == 0) + { + // Initialize buffer + //Commented out so that the buffer is always cleared. + //This is so the guys at Echo Speech can mix into the + //buffer even when no sounds are playing. + //if ( !MV_BufferEmpty[ MV_MixPage ] ) + { + ClearBuffer_DW(MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2); + MV_BufferEmpty[ MV_MixPage ] = TRUE; + } + } + else + { + char *end; + char *source; + char *dest; + int count; + int length; - end = MV_MixBuffer[ 0 ] + MV_BufferLength; - dest = MV_MixBuffer[ MV_MixPage ]; - source = MV_MixBuffer[ MV_MixPage ] - MV_ReverbDelay; - if ( source < MV_MixBuffer[ 0 ] ) - { - source += MV_BufferLength; - } + end = MV_MixBuffer[ 0 ] + MV_BufferLength; + dest = MV_MixBuffer[ MV_MixPage ]; + source = MV_MixBuffer[ MV_MixPage ] - MV_ReverbDelay; + if (source < MV_MixBuffer[ 0 ]) + { + source += MV_BufferLength; + } - length = MV_BufferSize; - while( length > 0 ) - { - count = length; - if ( source + count > end ) + length = MV_BufferSize; + while (length > 0) + { + count = length; + if (source + count > end) { - count = end - source; + count = end - source; } - if ( MV_Bits == 16 ) + if (MV_Bits == 16) { - if ( MV_ReverbTable != NULL ) - { - MV_16BitReverb( source, dest, MV_ReverbTable, count / 2 ); - } + if (MV_ReverbTable != NULL) + { + MV_16BitReverb(source, dest, MV_ReverbTable, count / 2); + } + else + { + MV_16BitReverbFast(source, dest, count / 2, MV_ReverbLevel); + } + } else - { - MV_16BitReverbFast( source, dest, count / 2, MV_ReverbLevel ); - } - } - else { - if ( MV_ReverbTable != NULL ) - { - MV_8BitReverb( source, dest, MV_ReverbTable, count ); - } - else - { - MV_8BitReverbFast( source, dest, count, MV_ReverbLevel ); - } + if (MV_ReverbTable != NULL) + { + MV_8BitReverb(source, dest, MV_ReverbTable, count); + } + else + { + MV_8BitReverbFast(source, dest, count, MV_ReverbLevel); + } } - // if we go through the loop again, it means that we've wrapped around the buffer - source = MV_MixBuffer[ 0 ]; - dest += count; - length -= count; - } - } + // if we go through the loop again, it means that we've wrapped around the buffer + source = MV_MixBuffer[ 0 ]; + dest += count; + length -= count; + } + } - // Play any waiting voices - for( voice = VoiceList.next; voice != &VoiceList; voice = next ) - { + // Play any waiting voices + for (voice = VoiceList.next; voice != &VoiceList; voice = next) + { // if ( ( voice < &MV_Voices[ 0 ] ) || ( voice > &MV_Voices[ 8 ] ) ) // { // SetBorderColor(backcolor++); // break; // } - MV_BufferEmpty[ MV_MixPage ] = FALSE; + MV_BufferEmpty[ MV_MixPage ] = FALSE; - MV_MixFunction( voice, MV_MixPage ); + MV_MixFunction(voice, MV_MixPage); - next = voice->next; + next = voice->next; - // Is this voice done? - if ( !voice->Playing ) - { - MV_StopVoice( voice ); + // Is this voice done? + if (!voice->Playing) + { + MV_StopVoice(voice); - if ( MV_CallBackFunc ) + if (MV_CallBackFunc) { - MV_CallBackFunc( voice->callbackval ); + MV_CallBackFunc(voice->callbackval); } - } - } + } + } - return MV_MixPage; - } + return MV_MixPage; +} /*--------------------------------------------------------------------- @@ -521,272 +521,272 @@ int MV_ServiceVoc ---------------------------------------------------------------------*/ playbackstatus MV_GetNextVOCBlock - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - unsigned char *ptr; - int blocktype; - int lastblocktype; - unsigned long blocklength; - unsigned long samplespeed; - unsigned int tc; - int packtype; - int voicemode; - int done; - unsigned BitsPerSample; - unsigned Channels; - unsigned Format; +{ + unsigned char *ptr; + int blocktype; + int lastblocktype; + unsigned long blocklength; + unsigned long samplespeed; + unsigned int tc; + int packtype; + int voicemode; + int done; + unsigned BitsPerSample; + unsigned Channels; + unsigned Format; - if ( voice->BlockLength > 0 ) - { - voice->position -= voice->length; - voice->sound += voice->length >> 16; - if ( voice->bits == 16 ) - { - voice->sound += voice->length >> 16; - } - voice->length = min( voice->BlockLength, 0x8000 ); - voice->BlockLength -= voice->length; - voice->length <<= 16; - return( KeepPlaying ); - } + if (voice->BlockLength > 0) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + if (voice->bits == 16) + { + voice->sound += voice->length >> 16; + } + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } - if ( ( voice->length > 0 ) && ( voice->LoopEnd != NULL ) && - ( voice->LoopStart != NULL ) ) - { - voice->BlockLength = voice->LoopSize; - voice->sound = voice->LoopStart; - voice->position = 0; - voice->length = min( voice->BlockLength, 0x8000 ); - voice->BlockLength -= voice->length; - voice->length <<= 16; - return( KeepPlaying ); - } + if ((voice->length > 0) && (voice->LoopEnd != NULL) && + (voice->LoopStart != NULL)) + { + voice->BlockLength = voice->LoopSize; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } - ptr = ( unsigned char * )voice->NextBlock; + ptr = (unsigned char *)voice->NextBlock; - voice->Playing = TRUE; + voice->Playing = TRUE; - voicemode = 0; - lastblocktype = 0; - packtype = 0; + voicemode = 0; + lastblocktype = 0; + packtype = 0; - done = FALSE; - while( !done ) - { - // Stop playing if we get a NULL pointer - if ( ptr == NULL ) - { - voice->Playing = FALSE; - done = TRUE; - break; - } + done = FALSE; + while (!done) + { + // Stop playing if we get a NULL pointer + if (ptr == NULL) + { + voice->Playing = FALSE; + done = TRUE; + break; + } - blocktype = ( int )*ptr; - blocklength = ( *( unsigned long * )( ptr + 1 ) ) & 0x00ffffff; - ptr += 4; + blocktype = (int)*ptr; + blocklength = (*(unsigned long *)(ptr + 1)) & 0x00ffffff; + ptr += 4; - switch( blocktype ) - { - case 0 : + switch (blocktype) + { + case 0 : // End of data - if ( ( voice->LoopStart == NULL ) || - ( voice->LoopStart >= ( ptr - 4 ) ) ) - { - voice->Playing = FALSE; - done = TRUE; - } + if ((voice->LoopStart == NULL) || + (voice->LoopStart >= (ptr - 4))) + { + voice->Playing = FALSE; + done = TRUE; + } else - { - voice->BlockLength = (char*)( ptr - 4 ) - voice->LoopStart; - voice->sound = voice->LoopStart; - voice->position = 0; - voice->length = min( voice->BlockLength, 0x8000 ); - voice->BlockLength -= voice->length; - voice->length <<= 16; - return( KeepPlaying ); - } + { + voice->BlockLength = (char*)(ptr - 4) - voice->LoopStart; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } break; - case 1 : + case 1 : // Sound data block voice->bits = 8; - if ( lastblocktype != 8 ) - { - tc = ( unsigned int )*ptr << 8; - packtype = *( ptr + 1 ); - } + if (lastblocktype != 8) + { + tc = (unsigned int)*ptr << 8; + packtype = *(ptr + 1); + } ptr += 2; blocklength -= 2; - samplespeed = 256000000L / ( 65536 - tc ); + samplespeed = 256000000L / (65536 - tc); // Skip packed or stereo data - if ( ( packtype != 0 ) || ( voicemode != 0 ) ) - { - ptr += blocklength; - } + if ((packtype != 0) || (voicemode != 0)) + { + ptr += blocklength; + } else - { - done = TRUE; - } + { + done = TRUE; + } voicemode = 0; break; - case 2 : + case 2 : // Sound continuation block samplespeed = voice->SamplingRate; done = TRUE; break; - case 3 : + case 3 : // Silence // Not implimented. ptr += blocklength; break; - case 4 : + case 4 : // Marker // Not implimented. ptr += blocklength; break; - case 5 : + case 5 : // ASCII string // Not implimented. ptr += blocklength; break; - case 6 : + case 6 : // Repeat begin - if ( voice->LoopEnd == NULL ) - { - voice->LoopCount = *( unsigned short * )ptr; - voice->LoopStart = ptr + blocklength; - } + if (voice->LoopEnd == NULL) + { + voice->LoopCount = *(unsigned short *)ptr; + voice->LoopStart = ptr + blocklength; + } ptr += blocklength; break; - case 7 : + case 7 : // Repeat end ptr += blocklength; - if ( lastblocktype == 6 ) - { - voice->LoopCount = 0; - } + if (lastblocktype == 6) + { + voice->LoopCount = 0; + } else - { - if ( ( voice->LoopCount > 0 ) && ( voice->LoopStart != NULL ) ) - { - ptr = voice->LoopStart; - if ( voice->LoopCount < 0xffff ) - { - voice->LoopCount--; - if ( voice->LoopCount == 0 ) + { + if ((voice->LoopCount > 0) && (voice->LoopStart != NULL)) + { + ptr = voice->LoopStart; + if (voice->LoopCount < 0xffff) + { + voice->LoopCount--; + if (voice->LoopCount == 0) { - voice->LoopStart = NULL; + voice->LoopStart = NULL; } - } - } - } + } + } + } break; - case 8 : + case 8 : // Extended block voice->bits = 8; - tc = *( unsigned short * )ptr; - packtype = *( ptr + 2 ); - voicemode = *( ptr + 3 ); + tc = *(unsigned short *)ptr; + packtype = *(ptr + 2); + voicemode = *(ptr + 3); ptr += blocklength; break; - case 9 : + case 9 : // New sound data block - samplespeed = *( unsigned long * )ptr; - BitsPerSample = ( unsigned )*( ptr + 4 ); - Channels = ( unsigned )*( ptr + 5 ); - Format = ( unsigned )*( unsigned short * )( ptr + 6 ); + samplespeed = *(unsigned long *)ptr; + BitsPerSample = (unsigned)*(ptr + 4); + Channels = (unsigned)*(ptr + 5); + Format = (unsigned)*(unsigned short *)(ptr + 6); - if ( ( BitsPerSample == 8 ) && ( Channels == 1 ) && - ( Format == VOC_8BIT ) ) - { - ptr += 12; - blocklength -= 12; - voice->bits = 8; - done = TRUE; - } - else if ( ( BitsPerSample == 16 ) && ( Channels == 1 ) && - ( Format == VOC_16BIT ) ) - { - ptr += 12; - blocklength -= 12; - voice->bits = 16; - done = TRUE; - } + if ((BitsPerSample == 8) && (Channels == 1) && + (Format == VOC_8BIT)) + { + ptr += 12; + blocklength -= 12; + voice->bits = 8; + done = TRUE; + } + else if ((BitsPerSample == 16) && (Channels == 1) && + (Format == VOC_16BIT)) + { + ptr += 12; + blocklength -= 12; + voice->bits = 16; + done = TRUE; + } else - { - ptr += blocklength; - } + { + ptr += blocklength; + } break; - default : + default : // Unknown data. Probably not a VOC file. voice->Playing = FALSE; done = TRUE; break; - } + } - lastblocktype = blocktype; - } + lastblocktype = blocktype; + } - if ( voice->Playing ) - { - voice->NextBlock = ptr + blocklength; - voice->sound = ptr; + if (voice->Playing) + { + voice->NextBlock = ptr + blocklength; + voice->sound = ptr; - voice->SamplingRate = samplespeed; - voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate; + voice->SamplingRate = samplespeed; + voice->RateScale = (voice->SamplingRate * voice->PitchScale) / MV_MixRate; - // Multiply by MixBufferSize - 1 - voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - - voice->RateScale; + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = (voice->RateScale * MixBufferSize) - + voice->RateScale; - if ( voice->LoopEnd != NULL ) - { - if ( blocklength > ( unsigned long )voice->LoopEnd ) + if (voice->LoopEnd != NULL) + { + if (blocklength > (unsigned long)voice->LoopEnd) { - blocklength = ( unsigned long )voice->LoopEnd; + blocklength = (unsigned long)voice->LoopEnd; } - else + else { - voice->LoopEnd = ( char * )blocklength; + voice->LoopEnd = (char *)blocklength; } - voice->LoopStart = voice->sound + ( unsigned long )voice->LoopStart; - voice->LoopEnd = voice->sound + ( unsigned long )voice->LoopEnd; - voice->LoopSize = voice->LoopEnd - voice->LoopStart; - } + voice->LoopStart = voice->sound + (unsigned long)voice->LoopStart; + voice->LoopEnd = voice->sound + (unsigned long)voice->LoopEnd; + voice->LoopSize = voice->LoopEnd - voice->LoopStart; + } - if ( voice->bits == 16 ) - { - blocklength /= 2; - } + if (voice->bits == 16) + { + blocklength /= 2; + } - voice->position = 0; - voice->length = min( blocklength, 0x8000 ); - voice->BlockLength = blocklength - voice->length; - voice->length <<= 16; + voice->position = 0; + voice->length = min(blocklength, 0x8000); + voice->BlockLength = blocklength - voice->length; + voice->length <<= 16; - MV_SetVoiceMixMode( voice ); + MV_SetVoiceMixMode(voice); - return( KeepPlaying ); - } + return(KeepPlaying); + } - return( NoMoreData ); - } + return(NoMoreData); +} /*--------------------------------------------------------------------- @@ -796,39 +796,39 @@ playbackstatus MV_GetNextVOCBlock ---------------------------------------------------------------------*/ playbackstatus MV_GetNextDemandFeedBlock - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - if ( voice->BlockLength > 0 ) - { - voice->position -= voice->length; - voice->sound += voice->length >> 16; - voice->length = min( voice->BlockLength, 0x8000 ); - voice->BlockLength -= voice->length; - voice->length <<= 16; +{ + if (voice->BlockLength > 0) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; - return( KeepPlaying ); - } + return(KeepPlaying); + } - if ( voice->DemandFeed == NULL ) - { - return( NoMoreData ); - } + if (voice->DemandFeed == NULL) + { + return(NoMoreData); + } - voice->position = 0; - ( voice->DemandFeed )( &voice->sound, &voice->BlockLength ); - voice->length = min( voice->BlockLength, 0x8000 ); - voice->BlockLength -= voice->length; - voice->length <<= 16; + voice->position = 0; + (voice->DemandFeed)(&voice->sound, &voice->BlockLength); + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; - if ( ( voice->length > 0 ) && ( voice->sound != NULL ) ) - { - return( KeepPlaying ); - } - return( NoMoreData ); - } + if ((voice->length > 0) && (voice->sound != NULL)) + { + return(KeepPlaying); + } + return(NoMoreData); +} /*--------------------------------------------------------------------- @@ -838,38 +838,38 @@ playbackstatus MV_GetNextDemandFeedBlock ---------------------------------------------------------------------*/ playbackstatus MV_GetNextRawBlock - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - if ( voice->BlockLength <= 0 ) - { - if ( voice->LoopStart == NULL ) - { - voice->Playing = FALSE; - return( NoMoreData ); - } +{ + if (voice->BlockLength <= 0) + { + if (voice->LoopStart == NULL) + { + voice->Playing = FALSE; + return(NoMoreData); + } - voice->BlockLength = voice->LoopSize; - voice->NextBlock = voice->LoopStart; - voice->length = 0; - voice->position = 0; - } + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } - voice->sound = voice->NextBlock; - voice->position -= voice->length; - voice->length = min( voice->BlockLength, 0x8000 ); - voice->NextBlock += voice->length; - if ( voice->bits == 16 ) - { - voice->NextBlock += voice->length; - } - voice->BlockLength -= voice->length; - voice->length <<= 16; + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min(voice->BlockLength, 0x8000); + voice->NextBlock += voice->length; + if (voice->bits == 16) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; - return( KeepPlaying ); - } + return(KeepPlaying); +} /*--------------------------------------------------------------------- @@ -879,38 +879,38 @@ playbackstatus MV_GetNextRawBlock ---------------------------------------------------------------------*/ playbackstatus MV_GetNextWAVBlock - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - if ( voice->BlockLength <= 0 ) - { - if ( voice->LoopStart == NULL ) - { - voice->Playing = FALSE; - return( NoMoreData ); - } +{ + if (voice->BlockLength <= 0) + { + if (voice->LoopStart == NULL) + { + voice->Playing = FALSE; + return(NoMoreData); + } - voice->BlockLength = voice->LoopSize; - voice->NextBlock = voice->LoopStart; - voice->length = 0; - voice->position = 0; - } + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } - voice->sound = voice->NextBlock; - voice->position -= voice->length; - voice->length = min( voice->BlockLength, 0x8000 ); - voice->NextBlock += voice->length; - if ( voice->bits == 16 ) - { - voice->NextBlock += voice->length; - } - voice->BlockLength -= voice->length; - voice->length <<= 16; + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min(voice->BlockLength, 0x8000); + voice->NextBlock += voice->length; + if (voice->bits == 16) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; - return( KeepPlaying ); - } + return(KeepPlaying); +} /*--------------------------------------------------------------------- @@ -920,24 +920,24 @@ playbackstatus MV_GetNextWAVBlock ---------------------------------------------------------------------*/ static void MV_ServiceRecord - ( - void - ) +( + void +) - { - if ( MV_RecordFunc ) - { - MV_RecordFunc( MV_MixBuffer[ 0 ] + MV_MixPage * MixBufferSize, - MixBufferSize ); - } +{ + if (MV_RecordFunc) + { + MV_RecordFunc(MV_MixBuffer[ 0 ] + MV_MixPage * MixBufferSize, + MixBufferSize); + } - // Toggle which buffer we'll mix next - MV_MixPage++; - if ( MV_MixPage >= NumberOfBuffers ) - { - MV_MixPage = 0; - } - } + // Toggle which buffer we'll mix next + MV_MixPage++; + if (MV_MixPage >= NumberOfBuffers) + { + MV_MixPage = 0; + } +} /*--------------------------------------------------------------------- @@ -947,34 +947,34 @@ static void MV_ServiceRecord ---------------------------------------------------------------------*/ VoiceNode *MV_GetVoice - ( - int handle - ) +( + int handle +) - { - VoiceNode *voice; - unsigned flags; +{ + VoiceNode *voice; + unsigned flags; - flags = DisableInterrupts(); + flags = DisableInterrupts(); - for( voice = VoiceList.next; voice != &VoiceList; voice = voice->next ) - { - if ( handle == voice->handle ) - { - break; - } - } + for (voice = VoiceList.next; voice != &VoiceList; voice = voice->next) + { + if (handle == voice->handle) + { + break; + } + } - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - if ( voice == &VoiceList ) - { - MV_SetErrorCode( MV_VoiceNotFound ); - voice = NULL; - } + if (voice == &VoiceList) + { + MV_SetErrorCode(MV_VoiceNotFound); + voice = NULL; + } - return( voice ); - } + return(voice); +} /*--------------------------------------------------------------------- @@ -985,28 +985,28 @@ VoiceNode *MV_GetVoice ---------------------------------------------------------------------*/ int MV_VoicePlaying - ( - int handle - ) +( + int handle +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( FALSE ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(FALSE); + } - voice = MV_GetVoice( handle ); + voice = MV_GetVoice(handle); - if ( voice == NULL ) - { - return( FALSE ); - } + if (voice == NULL) + { + return(FALSE); + } - return( TRUE ); - } + return(TRUE); +} /*--------------------------------------------------------------------- @@ -1016,25 +1016,25 @@ int MV_VoicePlaying ---------------------------------------------------------------------*/ int MV_KillAllVoices - ( - void - ) +( + void +) - { - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } +{ + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - // Remove all the voices from the list - while( VoiceList.next != &VoiceList ) - { - MV_Kill( VoiceList.next->handle ); - } + // Remove all the voices from the list + while (VoiceList.next != &VoiceList) + { + MV_Kill(VoiceList.next->handle); + } - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1044,44 +1044,44 @@ int MV_KillAllVoices ---------------------------------------------------------------------*/ int MV_Kill - ( - int handle - ) +( + int handle +) - { - VoiceNode *voice; - unsigned flags; - unsigned long callbackval; +{ + VoiceNode *voice; + unsigned flags; + unsigned long callbackval; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - flags = DisableInterrupts(); + flags = DisableInterrupts(); - voice = MV_GetVoice( handle ); - if ( voice == NULL ) - { - RestoreInterrupts( flags ); - MV_SetErrorCode( MV_VoiceNotFound ); - return( MV_Error ); - } + voice = MV_GetVoice(handle); + if (voice == NULL) + { + RestoreInterrupts(flags); + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } - callbackval = voice->callbackval; + callbackval = voice->callbackval; - MV_StopVoice( voice ); + MV_StopVoice(voice); - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - if ( MV_CallBackFunc ) - { - MV_CallBackFunc( callbackval ); - } + if (MV_CallBackFunc) + { + MV_CallBackFunc(callbackval); + } - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1091,32 +1091,32 @@ int MV_Kill ---------------------------------------------------------------------*/ int MV_VoicesPlaying - ( - void - ) +( + void +) - { - VoiceNode *voice; - int NumVoices = 0; - unsigned flags; +{ + VoiceNode *voice; + int NumVoices = 0; + unsigned flags; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( 0 ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(0); + } - flags = DisableInterrupts(); + flags = DisableInterrupts(); - for( voice = VoiceList.next; voice != &VoiceList; voice = voice->next ) - { - NumVoices++; - } + for (voice = VoiceList.next; voice != &VoiceList; voice = voice->next) + { + NumVoices++; + } - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - return( NumVoices ); - } + return(NumVoices); +} /*--------------------------------------------------------------------- @@ -1126,69 +1126,69 @@ int MV_VoicesPlaying ---------------------------------------------------------------------*/ VoiceNode *MV_AllocVoice - ( - int priority - ) +( + int priority +) - { - VoiceNode *voice; - VoiceNode *node; - unsigned flags; +{ + VoiceNode *voice; + VoiceNode *node; + unsigned flags; //return( NULL ); - if ( MV_Recording ) - { - return( NULL ); - } + if (MV_Recording) + { + return(NULL); + } - flags = DisableInterrupts(); + flags = DisableInterrupts(); - // Check if we have any free voices - if ( LL_Empty( &VoicePool, next, prev ) ) - { - // check if we have a higher priority than a voice that is playing. - voice = VoiceList.next; - for( node = voice->next; node != &VoiceList; node = node->next ) - { - if ( node->priority < voice->priority ) + // Check if we have any free voices + if (LL_Empty(&VoicePool, next, prev)) + { + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for (node = voice->next; node != &VoiceList; node = node->next) + { + if (node->priority < voice->priority) { - voice = node; + voice = node; } - } + } - if ( priority >= voice->priority ) - { - MV_Kill( voice->handle ); - } - } + if (priority >= voice->priority) + { + MV_Kill(voice->handle); + } + } - // Check if any voices are in the voice pool - if ( LL_Empty( &VoicePool, next, prev ) ) - { - // No free voices - RestoreInterrupts( flags ); - return( NULL ); - } + // Check if any voices are in the voice pool + if (LL_Empty(&VoicePool, next, prev)) + { + // No free voices + RestoreInterrupts(flags); + return(NULL); + } - voice = VoicePool.next; - LL_Remove( voice, next, prev ); - RestoreInterrupts( flags ); + voice = VoicePool.next; + LL_Remove(voice, next, prev); + RestoreInterrupts(flags); - // Find a free voice handle - do - { - MV_VoiceHandle++; - if ( MV_VoiceHandle < MV_MinVoiceHandle ) - { - MV_VoiceHandle = MV_MinVoiceHandle; - } - } - while( MV_VoicePlaying( MV_VoiceHandle ) ); + // Find a free voice handle + do + { + MV_VoiceHandle++; + if (MV_VoiceHandle < MV_MinVoiceHandle) + { + MV_VoiceHandle = MV_MinVoiceHandle; + } + } + while (MV_VoicePlaying(MV_VoiceHandle)); - voice->handle = MV_VoiceHandle; + voice->handle = MV_VoiceHandle; - return( voice ); - } + return(voice); +} /*--------------------------------------------------------------------- @@ -1198,42 +1198,42 @@ VoiceNode *MV_AllocVoice ---------------------------------------------------------------------*/ int MV_VoiceAvailable - ( - int priority - ) +( + int priority +) - { - VoiceNode *voice; - VoiceNode *node; - unsigned flags; +{ + VoiceNode *voice; + VoiceNode *node; + unsigned flags; - // Check if we have any free voices - if ( !LL_Empty( &VoicePool, next, prev ) ) - { - return( TRUE ); - } + // Check if we have any free voices + if (!LL_Empty(&VoicePool, next, prev)) + { + return(TRUE); + } - flags = DisableInterrupts(); + flags = DisableInterrupts(); - // check if we have a higher priority than a voice that is playing. - voice = VoiceList.next; - for( node = VoiceList.next; node != &VoiceList; node = node->next ) - { - if ( node->priority < voice->priority ) - { - voice = node; - } - } + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for (node = VoiceList.next; node != &VoiceList; node = node->next) + { + if (node->priority < voice->priority) + { + voice = node; + } + } - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - if ( ( voice != &VoiceList ) && ( priority >= voice->priority ) ) - { - return( TRUE ); - } + if ((voice != &VoiceList) && (priority >= voice->priority)) + { + return(TRUE); + } - return( FALSE ); - } + return(FALSE); +} /*--------------------------------------------------------------------- @@ -1243,21 +1243,21 @@ int MV_VoiceAvailable ---------------------------------------------------------------------*/ void MV_SetVoicePitch - ( - VoiceNode *voice, - unsigned long rate, - int pitchoffset - ) +( + VoiceNode *voice, + unsigned long rate, + int pitchoffset +) - { - voice->SamplingRate = rate; - voice->PitchScale = PITCH_GetScale( pitchoffset ); - voice->RateScale = ( rate * voice->PitchScale ) / MV_MixRate; +{ + voice->SamplingRate = rate; + voice->PitchScale = PITCH_GetScale(pitchoffset); + voice->RateScale = (rate * voice->PitchScale) / MV_MixRate; - // Multiply by MixBufferSize - 1 - voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - - voice->RateScale; - } + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = (voice->RateScale * MixBufferSize) - + voice->RateScale; +} /*--------------------------------------------------------------------- @@ -1267,31 +1267,31 @@ void MV_SetVoicePitch ---------------------------------------------------------------------*/ int MV_SetPitch - ( - int handle, - int pitchoffset - ) +( + int handle, + int pitchoffset +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - voice = MV_GetVoice( handle ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_VoiceNotFound ); - return( MV_Error ); - } + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } - MV_SetVoicePitch( voice, voice->SamplingRate, pitchoffset ); + MV_SetVoicePitch(voice, voice->SamplingRate, pitchoffset); - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1301,31 +1301,31 @@ int MV_SetPitch ---------------------------------------------------------------------*/ int MV_SetFrequency - ( - int handle, - int frequency - ) +( + int handle, + int frequency +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - voice = MV_GetVoice( handle ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_VoiceNotFound ); - return( MV_Error ); - } + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } - MV_SetVoicePitch( voice, frequency, 0 ); + MV_SetVoicePitch(voice, frequency, 0); - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1336,20 +1336,20 @@ int MV_SetFrequency ---------------------------------------------------------------------*/ static short *MV_GetVolumeTable - ( - int vol - ) +( + int vol +) - { - int volume; - short *table; +{ + int volume; + short *table; - volume = MIX_VOLUME( vol ); + volume = MIX_VOLUME(vol); - table = (short*)&MV_VolumeTable[ volume ]; + table = (short*)&MV_VolumeTable[ volume ]; - return( table ); - } + return(table); +} /*--------------------------------------------------------------------- @@ -1359,122 +1359,122 @@ static short *MV_GetVolumeTable ---------------------------------------------------------------------*/ static void MV_SetVoiceMixMode - ( - VoiceNode *voice - ) +( + VoiceNode *voice +) - { - unsigned flags; - int test; +{ + unsigned flags; + int test; - flags = DisableInterrupts(); + flags = DisableInterrupts(); - test = T_DEFAULT; - if ( MV_Bits == 8 ) - { - test |= T_8BITS; - } + test = T_DEFAULT; + if (MV_Bits == 8) + { + test |= T_8BITS; + } - if ( voice->bits == 16 ) - { - test |= T_16BITSOURCE; - } + if (voice->bits == 16) + { + test |= T_16BITSOURCE; + } - if ( MV_Channels == 1 ) - { - test |= T_MONO; - } - else - { - if ( IS_QUIET( voice->RightVolume ) ) - { - test |= T_RIGHTQUIET; - } - else if ( IS_QUIET( voice->LeftVolume ) ) - { - test |= T_LEFTQUIET; - } - } + if (MV_Channels == 1) + { + test |= T_MONO; + } + else + { + if (IS_QUIET(voice->RightVolume)) + { + test |= T_RIGHTQUIET; + } + else if (IS_QUIET(voice->LeftVolume)) + { + test |= T_LEFTQUIET; + } + } - // Default case - voice->mix = MV_Mix8BitMono; + // Default case + voice->mix = MV_Mix8BitMono; - switch( test ) - { - case T_8BITS | T_MONO | T_16BITSOURCE : - voice->mix = MV_Mix8BitMono16; - break; + switch (test) + { + case T_8BITS | T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix8BitMono16; + break; - case T_8BITS | T_MONO : - voice->mix = MV_Mix8BitMono; - break; + case T_8BITS | T_MONO : + voice->mix = MV_Mix8BitMono; + break; - case T_8BITS | T_16BITSOURCE | T_LEFTQUIET : - MV_LeftVolume = MV_RightVolume; - voice->mix = MV_Mix8BitMono16; - break; + case T_8BITS | T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono16; + break; - case T_8BITS | T_LEFTQUIET : - MV_LeftVolume = MV_RightVolume; - voice->mix = MV_Mix8BitMono; - break; + case T_8BITS | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono; + break; - case T_8BITS | T_16BITSOURCE | T_RIGHTQUIET : - voice->mix = MV_Mix8BitMono16; - break; + case T_8BITS | T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono16; + break; - case T_8BITS | T_RIGHTQUIET : - voice->mix = MV_Mix8BitMono; - break; + case T_8BITS | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono; + break; - case T_8BITS | T_16BITSOURCE : - voice->mix = MV_Mix8BitStereo16; - break; + case T_8BITS | T_16BITSOURCE : + voice->mix = MV_Mix8BitStereo16; + break; - case T_8BITS : - voice->mix = MV_Mix8BitStereo; - break; + case T_8BITS : + voice->mix = MV_Mix8BitStereo; + break; - case T_MONO | T_16BITSOURCE : - voice->mix = MV_Mix16BitMono16; - break; + case T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix16BitMono16; + break; - case T_MONO : - voice->mix = MV_Mix16BitMono; - break; + case T_MONO : + voice->mix = MV_Mix16BitMono; + break; - case T_16BITSOURCE | T_LEFTQUIET : - MV_LeftVolume = MV_RightVolume; - voice->mix = MV_Mix16BitMono16; - break; + case T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono16; + break; - case T_LEFTQUIET : - MV_LeftVolume = MV_RightVolume; - voice->mix = MV_Mix16BitMono; - break; + case T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono; + break; - case T_16BITSOURCE | T_RIGHTQUIET : - voice->mix = MV_Mix16BitMono16; - break; + case T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono16; + break; - case T_RIGHTQUIET : - voice->mix = MV_Mix16BitMono; - break; + case T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono; + break; - case T_16BITSOURCE : - voice->mix = MV_Mix16BitStereo16; - break; + case T_16BITSOURCE : + voice->mix = MV_Mix16BitStereo16; + break; - case T_SIXTEENBIT_STEREO : - voice->mix = MV_Mix16BitStereo; - break; + case T_SIXTEENBIT_STEREO : + voice->mix = MV_Mix16BitStereo; + break; - default : - voice->mix = MV_Mix8BitMono; - } + default : + voice->mix = MV_Mix8BitMono; + } - RestoreInterrupts( flags ); - } + RestoreInterrupts(flags); +} /*--------------------------------------------------------------------- @@ -1485,34 +1485,34 @@ static void MV_SetVoiceMixMode ---------------------------------------------------------------------*/ void MV_SetVoiceVolume - ( - VoiceNode *voice, - int vol, - int left, - int right - ) +( + VoiceNode *voice, + int vol, + int left, + int right +) - { - if ( MV_Channels == 1 ) - { - left = vol; - right = vol; - } +{ + if (MV_Channels == 1) + { + left = vol; + right = vol; + } - if ( MV_SwapLeftRight ) - { - // SBPro uses reversed panning - voice->LeftVolume = MV_GetVolumeTable( right ); - voice->RightVolume = MV_GetVolumeTable( left ); - } - else - { - voice->LeftVolume = MV_GetVolumeTable( left ); - voice->RightVolume = MV_GetVolumeTable( right ); - } + if (MV_SwapLeftRight) + { + // SBPro uses reversed panning + voice->LeftVolume = MV_GetVolumeTable(right); + voice->RightVolume = MV_GetVolumeTable(left); + } + else + { + voice->LeftVolume = MV_GetVolumeTable(left); + voice->RightVolume = MV_GetVolumeTable(right); + } - MV_SetVoiceMixMode( voice ); - } + MV_SetVoiceMixMode(voice); +} /*--------------------------------------------------------------------- @@ -1523,38 +1523,38 @@ void MV_SetVoiceVolume ---------------------------------------------------------------------*/ int MV_EndLooping - ( - int handle - ) +( + int handle +) - { - VoiceNode *voice; - unsigned flags; +{ + VoiceNode *voice; + unsigned flags; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - flags = DisableInterrupts(); + flags = DisableInterrupts(); - voice = MV_GetVoice( handle ); - if ( voice == NULL ) - { - RestoreInterrupts( flags ); - MV_SetErrorCode( MV_VoiceNotFound ); - return( MV_Warning ); - } + voice = MV_GetVoice(handle); + if (voice == NULL) + { + RestoreInterrupts(flags); + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Warning); + } - voice->LoopCount = 0; - voice->LoopStart = NULL; - voice->LoopEnd = NULL; + voice->LoopCount = 0; + voice->LoopStart = NULL; + voice->LoopEnd = NULL; - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1565,33 +1565,33 @@ int MV_EndLooping ---------------------------------------------------------------------*/ int MV_SetPan - ( - int handle, - int vol, - int left, - int right - ) +( + int handle, + int vol, + int left, + int right +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - voice = MV_GetVoice( handle ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_VoiceNotFound ); - return( MV_Warning ); - } + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Warning); + } - MV_SetVoiceVolume( voice, vol, left, right ); + MV_SetVoiceVolume(voice, vol, left, right); - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1602,38 +1602,38 @@ int MV_SetPan ---------------------------------------------------------------------*/ int MV_Pan3D - ( - int handle, - int angle, - int distance - ) +( + int handle, + int angle, + int distance +) - { - int left; - int right; - int mid; - int volume; - int status; +{ + int left; + int right; + int mid; + int volume; + int status; - if ( distance < 0 ) - { - distance = -distance; - angle += MV_NumPanPositions / 2; - } + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } - volume = MIX_VOLUME( distance ); + volume = MIX_VOLUME(distance); - // Ensure angle is within 0 - 31 - angle &= MV_MaxPanPosition; + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; - left = MV_PanTable[ angle ][ volume ].left; - right = MV_PanTable[ angle ][ volume ].right; - mid = max( 0, 255 - distance ); + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); - status = MV_SetPan( handle, mid, left, right ); + status = MV_SetPan(handle, mid, left, right); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -1643,14 +1643,14 @@ int MV_Pan3D ---------------------------------------------------------------------*/ void MV_SetReverb - ( - int reverb - ) +( + int reverb +) - { - MV_ReverbLevel = MIX_VOLUME( reverb ); - MV_ReverbTable = &MV_VolumeTable[ MV_ReverbLevel ]; - } +{ + MV_ReverbLevel = MIX_VOLUME(reverb); + MV_ReverbTable = &MV_VolumeTable[ MV_ReverbLevel ]; +} /*--------------------------------------------------------------------- @@ -1660,14 +1660,14 @@ void MV_SetReverb ---------------------------------------------------------------------*/ void MV_SetFastReverb - ( - int reverb - ) +( + int reverb +) - { - MV_ReverbLevel = max( 0, min( 16, reverb ) ); - MV_ReverbTable = NULL; - } +{ + MV_ReverbLevel = max(0, min(16, reverb)); + MV_ReverbTable = NULL; +} /*--------------------------------------------------------------------- @@ -1677,17 +1677,17 @@ void MV_SetFastReverb ---------------------------------------------------------------------*/ int MV_GetMaxReverbDelay - ( - void - ) +( + void +) - { - int maxdelay; +{ + int maxdelay; - maxdelay = MixBufferSize * MV_NumberOfBuffers; + maxdelay = MixBufferSize * MV_NumberOfBuffers; - return maxdelay; - } + return maxdelay; +} /*--------------------------------------------------------------------- @@ -1697,13 +1697,13 @@ int MV_GetMaxReverbDelay ---------------------------------------------------------------------*/ int MV_GetReverbDelay - ( - void - ) +( + void +) - { - return MV_ReverbDelay / MV_SampleSize; - } +{ + return MV_ReverbDelay / MV_SampleSize; +} /*--------------------------------------------------------------------- @@ -1713,17 +1713,17 @@ int MV_GetReverbDelay ---------------------------------------------------------------------*/ void MV_SetReverbDelay - ( - int delay - ) +( + int delay +) - { - int maxdelay; +{ + int maxdelay; - maxdelay = MV_GetMaxReverbDelay(); - MV_ReverbDelay = max( MixBufferSize, min( delay, maxdelay ) ); - MV_ReverbDelay *= MV_SampleSize; - } + maxdelay = MV_GetMaxReverbDelay(); + MV_ReverbDelay = max(MixBufferSize, min(delay, maxdelay)); + MV_ReverbDelay *= MV_SampleSize; +} /*--------------------------------------------------------------------- @@ -1733,66 +1733,66 @@ void MV_SetReverbDelay ---------------------------------------------------------------------*/ int MV_SetMixMode - ( - int numchannels, - int samplebits - ) +( + int numchannels, + int samplebits +) - { - int mode; +{ + int mode; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - mode = 0; - if ( numchannels == 2 ) - { - mode |= STEREO; - } - if ( samplebits == 16 ) - { - mode |= SIXTEEN_BIT; - } + mode = 0; + if (numchannels == 2) + { + mode |= STEREO; + } + if (samplebits == 16) + { + mode |= SIXTEEN_BIT; + } - MV_MixMode = DSOUND_SetMixMode( mode ); + MV_MixMode = DSOUND_SetMixMode(mode); - MV_Channels = 1; - if ( MV_MixMode & STEREO ) - { - MV_Channels = 2; - } + MV_Channels = 1; + if (MV_MixMode & STEREO) + { + MV_Channels = 2; + } - MV_Bits = 8; - if ( MV_MixMode & SIXTEEN_BIT ) - { - MV_Bits = 16; - } + MV_Bits = 8; + if (MV_MixMode & SIXTEEN_BIT) + { + MV_Bits = 16; + } - MV_BuffShift = 7 + MV_Channels; - MV_SampleSize = sizeof( MONO8 ) * MV_Channels; + MV_BuffShift = 7 + MV_Channels; + MV_SampleSize = sizeof(MONO8) * MV_Channels; - if ( MV_Bits == 8 ) - { - MV_Silence = SILENCE_8BIT; - } - else - { - MV_Silence = SILENCE_16BIT; - MV_BuffShift += 1; - MV_SampleSize *= 2; - } + if (MV_Bits == 8) + { + MV_Silence = SILENCE_8BIT; + } + else + { + MV_Silence = SILENCE_16BIT; + MV_BuffShift += 1; + MV_SampleSize *= 2; + } - MV_BufferSize = MixBufferSize * MV_SampleSize; - MV_NumberOfBuffers = TotalBufferSize / MV_BufferSize; - MV_BufferLength = TotalBufferSize; + MV_BufferSize = MixBufferSize * MV_SampleSize; + MV_NumberOfBuffers = TotalBufferSize / MV_BufferSize; + MV_BufferLength = TotalBufferSize; - MV_RightChannelOffset = MV_SampleSize / 2; + MV_RightChannelOffset = MV_SampleSize / 2; - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1802,38 +1802,38 @@ int MV_SetMixMode ---------------------------------------------------------------------*/ int MV_StartPlayback - ( - void - ) +( + void +) - { - int status; - int buffer; +{ + int status; + int buffer; - // Initialize the buffers - ClearBuffer_DW( MV_MixBuffer[ 0 ], MV_Silence, TotalBufferSize >> 2 ); - for( buffer = 0; buffer < MV_NumberOfBuffers; buffer++ ) - { - MV_BufferEmpty[ buffer ] = TRUE; - } + // Initialize the buffers + ClearBuffer_DW(MV_MixBuffer[ 0 ], MV_Silence, TotalBufferSize >> 2); + for (buffer = 0; buffer < MV_NumberOfBuffers; buffer++) + { + MV_BufferEmpty[ buffer ] = TRUE; + } - // Set the mix buffer variables - MV_MixPage = 1; + // Set the mix buffer variables + MV_MixPage = 1; - MV_MixFunction = MV_Mix; + MV_MixFunction = MV_Mix; - MV_MixRate = MV_RequestedMixRate; + MV_MixRate = MV_RequestedMixRate; - // Start playback - status = DSOUND_BeginBufferedPlayback( MV_MixBuffer[ 0 ], MV_ServiceVoc, TotalBufferSize, MV_NumberOfBuffers ); - if ( status != DSOUND_Ok ) - { - MV_SetErrorCode( MV_BlasterError ); - return( MV_Error ); - } + // Start playback + status = DSOUND_BeginBufferedPlayback(MV_MixBuffer[ 0 ], MV_ServiceVoc, TotalBufferSize, MV_NumberOfBuffers); + if (status != DSOUND_Ok) + { + MV_SetErrorCode(MV_BlasterError); + return(MV_Error); + } - return( MV_Ok ); - } + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -1843,35 +1843,35 @@ int MV_StartPlayback ---------------------------------------------------------------------*/ void MV_StopPlayback - ( - void - ) +( + void +) - { - VoiceNode *voice; - VoiceNode *next; - unsigned flags; +{ + VoiceNode *voice; + VoiceNode *next; + unsigned flags; - // Stop sound playback - DSOUND_StopPlayback(); + // Stop sound playback + DSOUND_StopPlayback(); - // Make sure all callbacks are done. - flags = DisableInterrupts(); + // Make sure all callbacks are done. + flags = DisableInterrupts(); - for( voice = VoiceList.next; voice != &VoiceList; voice = next ) - { - next = voice->next; + for (voice = VoiceList.next; voice != &VoiceList; voice = next) + { + next = voice->next; - MV_StopVoice( voice ); + MV_StopVoice(voice); - if ( MV_CallBackFunc ) - { - MV_CallBackFunc( voice->callbackval ); - } - } + if (MV_CallBackFunc) + { + MV_CallBackFunc(voice->callbackval); + } + } - RestoreInterrupts( flags ); - } + RestoreInterrupts(flags); +} #if 0 @@ -1882,60 +1882,60 @@ void MV_StopPlayback ---------------------------------------------------------------------*/ int MV_StartRecording - ( - int MixRate, - void ( *function )( char *ptr, int length ) - ) +( + int MixRate, + void(*function)(char *ptr, int length) +) - { - int status; +{ + int status; - switch( MV_SoundCard ) - { - case SoundBlaster : - break; + switch (MV_SoundCard) + { + case SoundBlaster : + break; - default : - MV_SetErrorCode( MV_UnsupportedCard ); - return( MV_Error ); - break; - } + default : + MV_SetErrorCode(MV_UnsupportedCard); + return(MV_Error); + break; + } - if ( function == NULL ) - { - MV_SetErrorCode( MV_NullRecordFunction ); - return( MV_Error ); - } + if (function == NULL) + { + MV_SetErrorCode(MV_NullRecordFunction); + return(MV_Error); + } - MV_StopPlayback(); + MV_StopPlayback(); - // Initialize the buffers - ClearBuffer_DW( MV_MixBuffer[ 0 ], SILENCE_8BIT, TotalBufferSize >> 2 ); + // Initialize the buffers + ClearBuffer_DW(MV_MixBuffer[ 0 ], SILENCE_8BIT, TotalBufferSize >> 2); - // Set the mix buffer variables - MV_MixPage = 0; + // Set the mix buffer variables + MV_MixPage = 0; - MV_RecordFunc = function; + MV_RecordFunc = function; - // Start playback - switch( MV_SoundCard ) - { - case SoundBlaster : - status = BLASTER_BeginBufferedRecord( MV_MixBuffer[ 0 ], - TotalBufferSize, NumberOfBuffers, MixRate, MONO_8BIT, - MV_ServiceRecord ); + // Start playback + switch (MV_SoundCard) + { + case SoundBlaster : + status = BLASTER_BeginBufferedRecord(MV_MixBuffer[ 0 ], + TotalBufferSize, NumberOfBuffers, MixRate, MONO_8BIT, + MV_ServiceRecord); - if ( status != BLASTER_Ok ) - { - MV_SetErrorCode( MV_BlasterError ); - return( MV_Error ); - } - break; - } + if (status != BLASTER_Ok) + { + MV_SetErrorCode(MV_BlasterError); + return(MV_Error); + } + break; + } - MV_Recording = TRUE; - return( MV_Ok ); - } + MV_Recording = TRUE; + return(MV_Ok); +} #endif #if 0 @@ -1946,22 +1946,22 @@ int MV_StartRecording ---------------------------------------------------------------------*/ void MV_StopRecord - ( - void - ) +( + void +) - { - // Stop sound playback - switch( MV_SoundCard ) - { - case SoundBlaster : - BLASTER_StopPlayback(); - break; - } +{ + // Stop sound playback + switch (MV_SoundCard) + { + case SoundBlaster : + BLASTER_StopPlayback(); + break; + } - MV_Recording = FALSE; - MV_StartPlayback(); - } + MV_Recording = FALSE; + MV_StartPlayback(); +} #endif @@ -1972,58 +1972,58 @@ void MV_StopRecord ---------------------------------------------------------------------*/ int MV_StartDemandFeedPlayback - ( - void ( *function )( char **ptr, unsigned long *length ), - int rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + void(*function)(char **ptr, unsigned long *length), + int rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - // Request a voice from the voice pool - voice = MV_AllocVoice( priority ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_NoVoices ); - return( MV_Error ); - } + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } - voice->wavetype = DemandFeed; - voice->bits = 8; - voice->GetSound = MV_GetNextDemandFeedBlock; - voice->NextBlock = NULL; - voice->DemandFeed = function; - voice->LoopStart = NULL; - voice->LoopCount = 0; - voice->BlockLength = 0; - voice->position = 0; - voice->sound = NULL; - voice->length = 0; - voice->BlockLength = 0; - voice->Playing = TRUE; - voice->next = NULL; - voice->prev = NULL; - voice->priority = priority; - voice->callbackval = callbackval; + voice->wavetype = DemandFeed; + voice->bits = 8; + voice->GetSound = MV_GetNextDemandFeedBlock; + voice->NextBlock = NULL; + voice->DemandFeed = function; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->position = 0; + voice->sound = NULL; + voice->length = 0; + voice->BlockLength = 0; + voice->Playing = TRUE; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; - MV_SetVoicePitch( voice, rate, pitchoffset ); - MV_SetVoiceVolume( voice, vol, left, right ); - MV_PlayVoice( voice ); + MV_SetVoicePitch(voice, rate, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); - return( voice->handle ); - } + return(voice->handle); +} /*--------------------------------------------------------------------- @@ -2034,26 +2034,26 @@ int MV_StartDemandFeedPlayback ---------------------------------------------------------------------*/ int MV_PlayRaw - ( - char *ptr, - unsigned long length, - unsigned rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + unsigned long length, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int status; +{ + int status; - status = MV_PlayLoopedRaw( ptr, length, NULL, NULL, rate, pitchoffset, - vol, left, right, priority, callbackval ); + status = MV_PlayLoopedRaw(ptr, length, NULL, NULL, rate, pitchoffset, + vol, left, right, priority, callbackval); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -2064,59 +2064,59 @@ int MV_PlayRaw ---------------------------------------------------------------------*/ int MV_PlayLoopedRaw - ( - char *ptr, - long length, - char *loopstart, - char *loopend, - unsigned rate, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long length, + char *loopstart, + char *loopend, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - VoiceNode *voice; +{ + VoiceNode *voice; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - // Request a voice from the voice pool - voice = MV_AllocVoice( priority ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_NoVoices ); - return( MV_Error ); - } + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } - voice->wavetype = Raw; - voice->bits = 8; - voice->GetSound = MV_GetNextRawBlock; - voice->Playing = TRUE; - voice->NextBlock = ptr; - voice->position = 0; - voice->BlockLength = length; - voice->length = 0; - voice->next = NULL; - voice->prev = NULL; - voice->priority = priority; - voice->callbackval = callbackval; - voice->LoopStart = loopstart; - voice->LoopEnd = loopend; - voice->LoopSize = ( voice->LoopEnd - voice->LoopStart ) + 1; + voice->wavetype = Raw; + voice->bits = 8; + voice->GetSound = MV_GetNextRawBlock; + voice->Playing = TRUE; + voice->NextBlock = ptr; + voice->position = 0; + voice->BlockLength = length; + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = loopstart; + voice->LoopEnd = loopend; + voice->LoopSize = (voice->LoopEnd - voice->LoopStart) + 1; - MV_SetVoicePitch( voice, rate, pitchoffset ); - MV_SetVoiceVolume( voice, vol, left, right ); - MV_PlayVoice( voice ); + MV_SetVoicePitch(voice, rate, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); - return( voice->handle ); - } + return(voice->handle); +} /*--------------------------------------------------------------------- @@ -2127,24 +2127,24 @@ int MV_PlayLoopedRaw ---------------------------------------------------------------------*/ int MV_PlayWAV - ( - char *ptr, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int status; +{ + int status; - status = MV_PlayLoopedWAV( ptr, -1, -1, pitchoffset, vol, left, right, - priority, callbackval ); + status = MV_PlayLoopedWAV(ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -2155,48 +2155,48 @@ int MV_PlayWAV ---------------------------------------------------------------------*/ int MV_PlayWAV3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - int left; - int right; - int mid; - int volume; - int status; +{ + int left; + int right; + int mid; + int volume; + int status; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - if ( distance < 0 ) - { - distance = -distance; - angle += MV_NumPanPositions / 2; - } + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } - volume = MIX_VOLUME( distance ); + volume = MIX_VOLUME(distance); - // Ensure angle is within 0 - 31 - angle &= MV_MaxPanPosition; + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; - left = MV_PanTable[ angle ][ volume ].left; - right = MV_PanTable[ angle ][ volume ].right; - mid = max( 0, 255 - distance ); + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); - status = MV_PlayWAV( ptr, pitchoffset, mid, left, right, priority, - callbackval ); + status = MV_PlayWAV(ptr, pitchoffset, mid, left, right, priority, + callbackval); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -2207,127 +2207,127 @@ int MV_PlayWAV3D ---------------------------------------------------------------------*/ int MV_PlayLoopedWAV - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - riff_header *riff; - format_header *format; - data_header *data; - VoiceNode *voice; - int length; - int absloopend; - int absloopstart; +{ + riff_header *riff; + format_header *format; + data_header *data; + VoiceNode *voice; + int length; + int absloopend; + int absloopstart; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - riff = ( riff_header * )ptr; + riff = (riff_header *)ptr; - if ( ( strncmp( riff->RIFF, "RIFF", 4 ) != 0 ) || - ( strncmp( riff->WAVE, "WAVE", 4 ) != 0 ) || - ( strncmp( riff->fmt, "fmt ", 4) != 0 ) ) - { - MV_SetErrorCode( MV_InvalidWAVFile ); - return( MV_Error ); - } + if ((strncmp(riff->RIFF, "RIFF", 4) != 0) || + (strncmp(riff->WAVE, "WAVE", 4) != 0) || + (strncmp(riff->fmt, "fmt ", 4) != 0)) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } - format = ( format_header * )( riff + 1 ); - data = ( data_header * )( ( ( char * )format ) + riff->format_size ); + format = (format_header *)(riff + 1); + data = (data_header *)(((char *)format) + riff->format_size); - // Check if it's PCM data. - if ( format->wFormatTag != 1 ) - { - MV_SetErrorCode( MV_InvalidWAVFile ); - return( MV_Error ); - } + // Check if it's PCM data. + if (format->wFormatTag != 1) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } - if ( format->nChannels != 1 ) - { - MV_SetErrorCode( MV_InvalidWAVFile ); - return( MV_Error ); - } + if (format->nChannels != 1) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } - if ( ( format->nBitsPerSample != 8 ) && - ( format->nBitsPerSample != 16 ) ) - { - MV_SetErrorCode( MV_InvalidWAVFile ); - return( MV_Error ); - } + if ((format->nBitsPerSample != 8) && + (format->nBitsPerSample != 16)) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } - if ( strncmp( data->DATA, "data", 4 ) != 0 ) - { - MV_SetErrorCode( MV_InvalidWAVFile ); - return( MV_Error ); - } + if (strncmp(data->DATA, "data", 4) != 0) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } - // Request a voice from the voice pool - voice = MV_AllocVoice( priority ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_NoVoices ); - return( MV_Error ); - } + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } - voice->wavetype = WAV; - voice->bits = format->nBitsPerSample; - voice->GetSound = MV_GetNextWAVBlock; + voice->wavetype = WAV; + voice->bits = format->nBitsPerSample; + voice->GetSound = MV_GetNextWAVBlock; - length = data->size; - absloopstart = loopstart; - absloopend = loopend; - if ( voice->bits == 16 ) - { - loopstart *= 2; - data->size &= ~1; - loopend *= 2; - length /= 2; - } + length = data->size; + absloopstart = loopstart; + absloopend = loopend; + if (voice->bits == 16) + { + loopstart *= 2; + data->size &= ~1; + loopend *= 2; + length /= 2; + } - loopend = min( loopend, data->size ); - absloopend = min( absloopend, length ); + loopend = min(loopend, data->size); + absloopend = min(absloopend, length); - voice->Playing = TRUE; - voice->DemandFeed = NULL; - voice->LoopStart = NULL; - voice->LoopCount = 0; - voice->position = 0; - voice->length = 0; - voice->BlockLength = absloopend; - voice->NextBlock = ( char * )( data + 1 ); - voice->next = NULL; - voice->prev = NULL; - voice->priority = priority; - voice->callbackval = callbackval; - voice->LoopStart = voice->NextBlock + loopstart; - voice->LoopEnd = voice->NextBlock + loopend; - voice->LoopSize = absloopend - absloopstart; + voice->Playing = TRUE; + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->position = 0; + voice->length = 0; + voice->BlockLength = absloopend; + voice->NextBlock = (char *)(data + 1); + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = voice->NextBlock + loopstart; + voice->LoopEnd = voice->NextBlock + loopend; + voice->LoopSize = absloopend - absloopstart; - if ( ( loopstart >= data->size ) || ( loopstart < 0 ) ) - { - voice->LoopStart = NULL; - voice->LoopEnd = NULL; - voice->BlockLength = length; - } + if ((loopstart >= data->size) || (loopstart < 0)) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + voice->BlockLength = length; + } - MV_SetVoicePitch( voice, format->nSamplesPerSec, pitchoffset ); - MV_SetVoiceVolume( voice, vol, left, right ); - MV_PlayVoice( voice ); + MV_SetVoicePitch(voice, format->nSamplesPerSec, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); - return( voice->handle ); - } + return(voice->handle); +} /*--------------------------------------------------------------------- @@ -2338,48 +2338,48 @@ int MV_PlayLoopedWAV ---------------------------------------------------------------------*/ int MV_PlayVOC3D - ( - char *ptr, - int pitchoffset, - int angle, - int distance, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval +) - { - int left; - int right; - int mid; - int volume; - int status; +{ + int left; + int right; + int mid; + int volume; + int status; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - if ( distance < 0 ) - { - distance = -distance; - angle += MV_NumPanPositions / 2; - } + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } - volume = MIX_VOLUME( distance ); + volume = MIX_VOLUME(distance); - // Ensure angle is within 0 - 31 - angle &= MV_MaxPanPosition; + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; - left = MV_PanTable[ angle ][ volume ].left; - right = MV_PanTable[ angle ][ volume ].right; - mid = max( 0, 255 - distance ); + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); - status = MV_PlayVOC( ptr, pitchoffset, mid, left, right, priority, - callbackval ); + status = MV_PlayVOC(ptr, pitchoffset, mid, left, right, priority, + callbackval); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -2390,24 +2390,24 @@ int MV_PlayVOC3D ---------------------------------------------------------------------*/ int MV_PlayVOC - ( - char *ptr, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - int status; +{ + int status; - status = MV_PlayLoopedVOC( ptr, -1, -1, pitchoffset, vol, left, right, - priority, callbackval ); + status = MV_PlayLoopedVOC(ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -2418,73 +2418,73 @@ int MV_PlayVOC ---------------------------------------------------------------------*/ int MV_PlayLoopedVOC - ( - char *ptr, - long loopstart, - long loopend, - int pitchoffset, - int vol, - int left, - int right, - int priority, - unsigned long callbackval - ) +( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval +) - { - VoiceNode *voice; - int status; +{ + VoiceNode *voice; + int status; - if ( !MV_Installed ) - { - MV_SetErrorCode( MV_NotInstalled ); - return( MV_Error ); - } + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } - // Make sure it's a valid VOC file. - status = strncmp( ptr, "Creative Voice File", 19 ); - if ( status != 0 ) - { - MV_SetErrorCode( MV_InvalidVOCFile ); - return( MV_Error ); - } + // Make sure it's a valid VOC file. + status = strncmp(ptr, "Creative Voice File", 19); + if (status != 0) + { + MV_SetErrorCode(MV_InvalidVOCFile); + return(MV_Error); + } - // Request a voice from the voice pool - voice = MV_AllocVoice( priority ); - if ( voice == NULL ) - { - MV_SetErrorCode( MV_NoVoices ); - return( MV_Error ); - } + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } - voice->wavetype = VOC; - voice->bits = 8; - voice->GetSound = MV_GetNextVOCBlock; - voice->NextBlock = ptr + *( unsigned short int * )( ptr + 0x14 ); - voice->DemandFeed = NULL; - voice->LoopStart = NULL; - voice->LoopCount = 0; - voice->BlockLength = 0; - voice->PitchScale = PITCH_GetScale( pitchoffset ); - voice->length = 0; - voice->next = NULL; - voice->prev = NULL; - voice->priority = priority; - voice->callbackval = callbackval; - voice->LoopStart = ( char * )loopstart; - voice->LoopEnd = ( char * )loopend; - voice->LoopSize = loopend - loopstart + 1; + voice->wavetype = VOC; + voice->bits = 8; + voice->GetSound = MV_GetNextVOCBlock; + voice->NextBlock = ptr + *(unsigned short int *)(ptr + 0x14); + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->PitchScale = PITCH_GetScale(pitchoffset); + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = (char *)loopstart; + voice->LoopEnd = (char *)loopend; + voice->LoopSize = loopend - loopstart + 1; - if ( loopstart < 0 ) - { - voice->LoopStart = NULL; - voice->LoopEnd = NULL; - } + if (loopstart < 0) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + } - MV_SetVoiceVolume( voice, vol, left, right ); - MV_PlayVoice( voice ); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); - return( voice->handle ); - } + return(voice->handle); +} /*--------------------------------------------------------------------- @@ -2495,39 +2495,39 @@ int MV_PlayLoopedVOC ---------------------------------------------------------------------*/ void MV_CreateVolumeTable - ( - int index, - int volume, - int MaxVolume - ) +( + int index, + int volume, + int MaxVolume +) - { - int val; - int level; - int i; +{ + int val; + int level; + int i; - level = ( volume * MaxVolume ) / MV_MaxTotalVolume; - if ( MV_Bits == 16 ) - { - for( i = 0; i < 65536; i += 256 ) - { - val = i - 0x8000; - val *= level; - val /= MV_MaxVolume; - MV_VolumeTable[ index ][ i / 256 ] = val; - } - } - else - { - for( i = 0; i < 256; i++ ) - { - val = i - 0x80; - val *= level; - val /= MV_MaxVolume; - MV_VolumeTable[ volume ][ i ] = val; - } - } - } + level = (volume * MaxVolume) / MV_MaxTotalVolume; + if (MV_Bits == 16) + { + for (i = 0; i < 65536; i += 256) + { + val = i - 0x8000; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ index ][ i / 256 ] = val; + } + } + else + { + for (i = 0; i < 256; i++) + { + val = i - 0x80; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ volume ][ i ] = val; + } + } +} /*--------------------------------------------------------------------- @@ -2538,30 +2538,30 @@ void MV_CreateVolumeTable ---------------------------------------------------------------------*/ void MV_CalcVolume - ( - int MaxVolume - ) +( + int MaxVolume +) - { - int volume; +{ + int volume; - for( volume = 0; volume < 128; volume++ ) - { - MV_HarshClipTable[ volume ] = 0; - MV_HarshClipTable[ volume + 384 ] = 255; - } - for( volume = 0; volume < 256; volume++ ) - { - MV_HarshClipTable[ volume + 128 ] = volume; - } + for (volume = 0; volume < 128; volume++) + { + MV_HarshClipTable[ volume ] = 0; + MV_HarshClipTable[ volume + 384 ] = 255; + } + for (volume = 0; volume < 256; volume++) + { + MV_HarshClipTable[ volume + 128 ] = volume; + } - // For each volume level, create a translation table with the - // appropriate volume calculated. - for( volume = 0; volume <= MV_MaxVolume; volume++ ) - { - MV_CreateVolumeTable( volume, volume, MaxVolume ); - } - } + // For each volume level, create a translation table with the + // appropriate volume calculated. + for (volume = 0; volume <= MV_MaxVolume; volume++) + { + MV_CreateVolumeTable(volume, volume, MaxVolume); + } +} /*--------------------------------------------------------------------- @@ -2572,39 +2572,39 @@ void MV_CalcVolume ---------------------------------------------------------------------*/ void MV_CalcPanTable - ( - void - ) +( + void +) - { - int level; - int angle; - int distance; - int HalfAngle; - int ramp; +{ + int level; + int angle; + int distance; + int HalfAngle; + int ramp; - HalfAngle = ( MV_NumPanPositions / 2 ); + HalfAngle = (MV_NumPanPositions / 2); - for( distance = 0; distance <= MV_MaxVolume; distance++ ) - { - level = ( 255 * ( MV_MaxVolume - distance ) ) / MV_MaxVolume; - for( angle = 0; angle <= HalfAngle / 2; angle++ ) - { - ramp = level - ( ( level * angle ) / - ( MV_NumPanPositions / 4 ) ); + for (distance = 0; distance <= MV_MaxVolume; distance++) + { + level = (255 * (MV_MaxVolume - distance)) / MV_MaxVolume; + for (angle = 0; angle <= HalfAngle / 2; angle++) + { + ramp = level - ((level * angle) / + (MV_NumPanPositions / 4)); - MV_PanTable[ angle ][ distance ].left = ramp; - MV_PanTable[ HalfAngle - angle ][ distance ].left = ramp; - MV_PanTable[ HalfAngle + angle ][ distance ].left = level; - MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].left = level; + MV_PanTable[ angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle - angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle + angle ][ distance ].left = level; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].left = level; - MV_PanTable[ angle ][ distance ].right = level; - MV_PanTable[ HalfAngle - angle ][ distance ].right = level; - MV_PanTable[ HalfAngle + angle ][ distance ].right = ramp; - MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].right = ramp; - } - } - } + MV_PanTable[ angle ][ distance ].right = level; + MV_PanTable[ HalfAngle - angle ][ distance ].right = level; + MV_PanTable[ HalfAngle + angle ][ distance ].right = ramp; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].right = ramp; + } + } +} /*--------------------------------------------------------------------- @@ -2614,19 +2614,19 @@ void MV_CalcPanTable ---------------------------------------------------------------------*/ void MV_SetVolume - ( - int volume - ) +( + int volume +) - { - volume = max( 0, volume ); - volume = min( volume, MV_MaxTotalVolume ); +{ + volume = max(0, volume); + volume = min(volume, MV_MaxTotalVolume); - MV_TotalVolume = volume; + MV_TotalVolume = volume; - // Calculate volume table - MV_CalcVolume( volume ); - } + // Calculate volume table + MV_CalcVolume(volume); +} /*--------------------------------------------------------------------- @@ -2636,13 +2636,13 @@ void MV_SetVolume ---------------------------------------------------------------------*/ int MV_GetVolume - ( - void - ) +( + void +) - { - return( MV_TotalVolume ); - } +{ + return(MV_TotalVolume); +} /*--------------------------------------------------------------------- @@ -2652,13 +2652,13 @@ int MV_GetVolume ---------------------------------------------------------------------*/ void MV_SetCallBack - ( - void ( *function )( unsigned long ) - ) +( + void(*function)(unsigned long) +) - { - MV_CallBackFunc = function; - } +{ + MV_CallBackFunc = function; +} /*--------------------------------------------------------------------- @@ -2668,13 +2668,13 @@ void MV_SetCallBack ---------------------------------------------------------------------*/ void MV_SetReverseStereo - ( - int setting - ) +( + int setting +) - { - MV_SwapLeftRight = setting; - } +{ + MV_SwapLeftRight = setting; +} /*--------------------------------------------------------------------- @@ -2684,13 +2684,13 @@ void MV_SetReverseStereo ---------------------------------------------------------------------*/ int MV_GetReverseStereo - ( - void - ) +( + void +) - { - return( MV_SwapLeftRight ); - } +{ + return(MV_SwapLeftRight); +} #if 0 /*--------------------------------------------------------------------- @@ -2700,70 +2700,70 @@ int MV_GetReverseStereo ---------------------------------------------------------------------*/ int MV_TestPlayback - ( - void - ) +( + void +) - { - unsigned flags; - long time; - int start; - int status; - int pos; +{ + unsigned flags; + long time; + int start; + int status; + int pos; - flags = DisableInterrupts(); - _enable(); + flags = DisableInterrupts(); + _enable(); - status = MV_Error; - start = MV_MixPage; - time = clock() + CLOCKS_PER_SEC * 2; + status = MV_Error; + start = MV_MixPage; + time = clock() + CLOCKS_PER_SEC * 2; - while( clock() < time ) - { - if ( MV_MixPage != start ) - { - status = MV_Ok; - } - } + while (clock() < time) + { + if (MV_MixPage != start) + { + status = MV_Ok; + } + } - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - if ( status != MV_Ok ) - { - // Just in case an error doesn't get reported - MV_SetErrorCode( MV_DMAFailure ); + if (status != MV_Ok) + { + // Just in case an error doesn't get reported + MV_SetErrorCode(MV_DMAFailure); - switch( MV_SoundCard ) - { - case SoundBlaster : + switch (MV_SoundCard) + { + case SoundBlaster : pos = BLASTER_GetCurrentPos(); break; - default : - MV_SetErrorCode( MV_UnsupportedCard ); + default : + MV_SetErrorCode(MV_UnsupportedCard); pos = -2; break; - } + } - if ( pos > 0 ) - { - MV_SetErrorCode( MV_IrqFailure ); - } - else if ( pos == 0 ) - { - if ( MV_Bits == 16 ) + if (pos > 0) + { + MV_SetErrorCode(MV_IrqFailure); + } + else if (pos == 0) + { + if (MV_Bits == 16) { - MV_SetErrorCode( MV_DMA16Failure ); + MV_SetErrorCode(MV_DMA16Failure); } - else + else { - MV_SetErrorCode( MV_DMAFailure ); + MV_SetErrorCode(MV_DMAFailure); } - } - } + } + } - return( status ); - } + return(status); +} #endif @@ -2775,133 +2775,133 @@ int MV_TestPlayback ---------------------------------------------------------------------*/ int MV_Init - ( - int soundcard, - int MixRate, - int Voices, - int numchannels, - int samplebits - ) +( + int soundcard, + int MixRate, + int Voices, + int numchannels, + int samplebits +) - { - char *ptr; - int status; - int buffer; - int index; +{ + char *ptr; + int status; + int buffer; + int index; - if ( MV_Installed ) - { - MV_Shutdown(); - } + if (MV_Installed) + { + MV_Shutdown(); + } - printOSD("Initializing MultiVoc...\n"); + printOSD("Initializing MultiVoc...\n"); - MV_SetErrorCode( MV_Ok ); + MV_SetErrorCode(MV_Ok); - MV_TotalMemory = Voices * sizeof( VoiceNode ) + sizeof( HARSH_CLIP_TABLE_8 ); - status = USRHOOKS_GetMem( ( void ** )&ptr, MV_TotalMemory ); - if ( status != USRHOOKS_Ok ) - { - MV_SetErrorCode( MV_NoMem ); - return( MV_Error ); - } + MV_TotalMemory = Voices * sizeof(VoiceNode) + sizeof(HARSH_CLIP_TABLE_8); + status = USRHOOKS_GetMem((void **)&ptr, MV_TotalMemory); + if (status != USRHOOKS_Ok) + { + MV_SetErrorCode(MV_NoMem); + return(MV_Error); + } - MV_Voices = ( VoiceNode * )ptr; - MV_HarshClipTable = ptr + ( MV_TotalMemory - sizeof( HARSH_CLIP_TABLE_8 ) ); + MV_Voices = (VoiceNode *)ptr; + MV_HarshClipTable = ptr + (MV_TotalMemory - sizeof(HARSH_CLIP_TABLE_8)); - // Set number of voices before calculating volume table - MV_MaxVoices = Voices; + // Set number of voices before calculating volume table + MV_MaxVoices = Voices; - printOSD(" - Maximum voices: %d\n", MV_MaxVoices); + printOSD(" - Maximum voices: %d\n", MV_MaxVoices); - LL_Reset( &VoiceList, next, prev ); - LL_Reset( &VoicePool, next, prev ); + LL_Reset(&VoiceList, next, prev); + LL_Reset(&VoicePool, next, prev); - for( index = 0; index < Voices; index++ ) - { - LL_Add( &VoicePool, &MV_Voices[ index ], next, prev ); - } + for (index = 0; index < Voices; index++) + { + LL_Add(&VoicePool, &MV_Voices[ index ], next, prev); + } - // Set the sampling rate - MV_RequestedMixRate = MixRate; + // Set the sampling rate + MV_RequestedMixRate = MixRate; - printOSD(" - Using %d byte mixing buffers\n", MixBufferSize); + printOSD(" - Using %d byte mixing buffers\n", MixBufferSize); - // Allocate mix buffer within 1st megabyte - ptr = (char *)malloc(TotalBufferSize + 4); // FIXME: temporarily fixes bounds error somewhere... - if ( !ptr ) - { - USRHOOKS_FreeMem( MV_Voices ); - MV_Voices = NULL; - MV_TotalMemory = 0; + // Allocate mix buffer within 1st megabyte + ptr = (char *)malloc(TotalBufferSize + 4); // FIXME: temporarily fixes bounds error somewhere... + if (!ptr) + { + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; - MV_SetErrorCode( MV_NoMem ); - return( MV_Error ); - } + MV_SetErrorCode(MV_NoMem); + return(MV_Error); + } - MV_MixBufferPtr = ptr; - - MV_SetReverseStereo( FALSE ); + MV_MixBufferPtr = ptr; - // Initialize the sound card - status = DSOUND_Init(soundcard, MixRate, numchannels, samplebits, - TotalBufferSize); - if ( status != DSOUND_Ok ) - { - MV_SetErrorCode( MV_BlasterError ); - } + MV_SetReverseStereo(FALSE); - if ( MV_ErrorCode != MV_Ok ) - { - status = MV_ErrorCode; + // Initialize the sound card + status = DSOUND_Init(soundcard, MixRate, numchannels, samplebits, + TotalBufferSize); + if (status != DSOUND_Ok) + { + MV_SetErrorCode(MV_BlasterError); + } - USRHOOKS_FreeMem( MV_Voices ); - MV_Voices = NULL; - MV_TotalMemory = 0; + if (MV_ErrorCode != MV_Ok) + { + status = MV_ErrorCode; - free(ptr); - - MV_SetErrorCode( status ); - return( MV_Error ); - } + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; - MV_SoundCard = soundcard; - MV_Installed = TRUE; - MV_CallBackFunc = NULL; - MV_RecordFunc = NULL; - MV_Recording = FALSE; - MV_ReverbLevel = 0; - MV_ReverbTable = NULL; + free(ptr); - // Set Mixer to play stereo digitized sound - MV_SetMixMode( numchannels, samplebits ); - MV_ReverbDelay = MV_BufferSize * 3; + MV_SetErrorCode(status); + return(MV_Error); + } - //MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; - for( buffer = 0; buffer < MV_NumberOfBuffers; buffer++ ) - { - MV_MixBuffer[ buffer ] = ptr; - ptr += MV_BufferSize; - } + MV_SoundCard = soundcard; + MV_Installed = TRUE; + MV_CallBackFunc = NULL; + MV_RecordFunc = NULL; + MV_Recording = FALSE; + MV_ReverbLevel = 0; + MV_ReverbTable = NULL; - // Calculate pan table - MV_CalcPanTable(); + // Set Mixer to play stereo digitized sound + MV_SetMixMode(numchannels, samplebits); + MV_ReverbDelay = MV_BufferSize * 3; - MV_SetVolume( MV_MaxTotalVolume ); + //MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; + for (buffer = 0; buffer < MV_NumberOfBuffers; buffer++) + { + MV_MixBuffer[ buffer ] = ptr; + ptr += MV_BufferSize; + } - // Start the playback engine - status = MV_StartPlayback(); - if ( status != MV_Ok ) - { - // Preserve error code while we shutdown. - status = MV_ErrorCode; - MV_Shutdown(); - MV_SetErrorCode( status ); - return( MV_Error ); - } + // Calculate pan table + MV_CalcPanTable(); - return( MV_Ok ); - } + MV_SetVolume(MV_MaxTotalVolume); + + // Start the playback engine + status = MV_StartPlayback(); + if (status != MV_Ok) + { + // Preserve error code while we shutdown. + status = MV_ErrorCode; + MV_Shutdown(); + MV_SetErrorCode(status); + return(MV_Error); + } + + return(MV_Ok); +} /*--------------------------------------------------------------------- @@ -2911,61 +2911,61 @@ int MV_Init ---------------------------------------------------------------------*/ int MV_Shutdown - ( - void - ) +( + void +) - { - int buffer; - unsigned flags; +{ + int buffer; + unsigned flags; - if ( !MV_Installed ) - { - return( MV_Ok ); - } + if (!MV_Installed) + { + return(MV_Ok); + } - printOSD("Uninitializing MultiVoc...\n"); + printOSD("Uninitializing MultiVoc...\n"); - flags = DisableInterrupts(); + flags = DisableInterrupts(); - MV_KillAllVoices(); + MV_KillAllVoices(); - MV_Installed = FALSE; + MV_Installed = FALSE; - // Stop the sound recording engine - if ( MV_Recording ) - { - //MV_StopRecord(); - } + // Stop the sound recording engine + if (MV_Recording) + { + //MV_StopRecord(); + } - // Stop the sound playback engine - MV_StopPlayback(); + // Stop the sound playback engine + MV_StopPlayback(); - // Shutdown the sound card - DSOUND_Shutdown(); + // Shutdown the sound card + DSOUND_Shutdown(); - RestoreInterrupts( flags ); + RestoreInterrupts(flags); - // Free any voices we allocated - USRHOOKS_FreeMem( MV_Voices ); - MV_Voices = NULL; - MV_TotalMemory = 0; + // Free any voices we allocated + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; - LL_Reset( &VoiceList, next, prev ); - LL_Reset( &VoicePool, next, prev ); + LL_Reset(&VoiceList, next, prev); + LL_Reset(&VoicePool, next, prev); - MV_MaxVoices = 1; + MV_MaxVoices = 1; - // Release the descriptor from our mix buffer - if (MV_MixBufferPtr) free(MV_MixBufferPtr); - MV_MixBufferPtr = NULL; + // Release the descriptor from our mix buffer + if (MV_MixBufferPtr) free(MV_MixBufferPtr); + MV_MixBufferPtr = NULL; - for( buffer = 0; buffer < NumberOfBuffers; buffer++ ) - { - MV_MixBuffer[ buffer ] = NULL; - } + for (buffer = 0; buffer < NumberOfBuffers; buffer++) + { + MV_MixBuffer[ buffer ] = NULL; + } - return( MV_Ok ); - } + return(MV_Ok); +} diff --git a/polymer/eduke32/source/jaudiolib/music.c b/polymer/eduke32/source/jaudiolib/music.c index 2e396d0e1..4e7c4fcb9 100644 --- a/polymer/eduke32/source/jaudiolib/music.c +++ b/polymer/eduke32/source/jaudiolib/music.c @@ -54,7 +54,7 @@ static unsigned MUSIC_CurrentFadeVolume; static unsigned MUSIC_LastFadeVolume; static int MUSIC_EndingFadeVolume; -int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address ); +int MUSIC_InitMidi(int card, midifuncs *Funcs, int Address); #define MUSIC_SetErrorCode( status ) \ MUSIC_ErrorCode = ( status ); @@ -67,58 +67,58 @@ int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address ); ---------------------------------------------------------------------*/ char *MUSIC_ErrorString - ( - int ErrorNumber - ) +( + int ErrorNumber +) - { - char *ErrorString; +{ + char *ErrorString; - switch( ErrorNumber ) - { - case MUSIC_Warning : - case MUSIC_Error : - ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode ); - break; + switch (ErrorNumber) + { + case MUSIC_Warning : + case MUSIC_Error : + ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode); + break; - case MUSIC_Ok : - ErrorString = "Music ok."; - break; + case MUSIC_Ok : + ErrorString = "Music ok."; + break; - case MUSIC_ASSVersion : - ErrorString = "Apogee Sound System Version WinMM " - "Programmed by Jim Dose, Ported by Jonathon Fowler\n" - "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; - break; + case MUSIC_ASSVersion : + ErrorString = "Apogee Sound System Version WinMM " + "Programmed by Jim Dose, Ported by Jonathon Fowler\n" + "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; + break; - case MUSIC_SoundCardError : - case MUSIC_MPU401Error : - ErrorString = "Could not detect MPU-401."; - break; + case MUSIC_SoundCardError : + case MUSIC_MPU401Error : + ErrorString = "Could not detect MPU-401."; + break; - case MUSIC_InvalidCard : - ErrorString = "Invalid Music device."; - break; + case MUSIC_InvalidCard : + ErrorString = "Invalid Music device."; + break; - case MUSIC_MidiError : - ErrorString = "Error playing MIDI file."; - break; + case MUSIC_MidiError : + ErrorString = "Error playing MIDI file."; + break; - case MUSIC_TaskManError : - ErrorString = "TaskMan error."; - break; + case MUSIC_TaskManError : + ErrorString = "TaskMan error."; + break; - case MUSIC_DPMI_Error : - ErrorString = "DPMI Error in MUSIC."; - break; + case MUSIC_DPMI_Error : + ErrorString = "DPMI Error in MUSIC."; + break; - default : - ErrorString = "Unknown Music error code."; - break; - } + default : + ErrorString = "Unknown Music error code."; + break; + } - return( ErrorString ); - } + return(ErrorString); +} /*--------------------------------------------------------------------- @@ -128,26 +128,26 @@ char *MUSIC_ErrorString ---------------------------------------------------------------------*/ int MUSIC_Init - ( - int SoundCard, - int Address - ) +( + int SoundCard, + int Address +) - { - int i; - int status; +{ + int i; + int status; - for( i = 0; i < 128; i++ ) - { - MIDI_PatchMap[ i ] = i; - } + for (i = 0; i < 128; i++) + { + MIDI_PatchMap[ i ] = i; + } - MUSIC_SoundDevice = SoundCard; + MUSIC_SoundDevice = SoundCard; - status = MUSIC_InitMidi( SoundCard, &MUSIC_MidiFunctions, Address ); + status = MUSIC_InitMidi(SoundCard, &MUSIC_MidiFunctions, Address); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -157,21 +157,21 @@ int MUSIC_Init ---------------------------------------------------------------------*/ int MUSIC_Shutdown - ( - void - ) +( + void +) - { - int status; +{ + int status; - status = MUSIC_Ok; + status = MUSIC_Ok; - MIDI_StopSong(); + MIDI_StopSong(); - //MPU_Reset(); + //MPU_Reset(); - return( status ); - } + return(status); +} /*--------------------------------------------------------------------- @@ -181,19 +181,19 @@ int MUSIC_Shutdown ---------------------------------------------------------------------*/ void MUSIC_SetVolume - ( - int volume - ) +( + int volume +) - { - volume = max( 0, volume ); - volume = min( volume, 255 ); +{ + volume = max(0, volume); + volume = min(volume, 255); - if ( MUSIC_SoundDevice != -1 ) - { - MIDI_SetVolume( volume ); - } - } + if (MUSIC_SoundDevice != -1) + { + MIDI_SetVolume(volume); + } +} /*--------------------------------------------------------------------- @@ -203,14 +203,14 @@ void MUSIC_SetVolume ---------------------------------------------------------------------*/ void MUSIC_SetMidiChannelVolume - ( - int channel, - int volume - ) +( + int channel, + int volume +) - { - MIDI_SetUserChannelVolume( channel, volume ); - } +{ + MIDI_SetUserChannelVolume(channel, volume); +} /*--------------------------------------------------------------------- @@ -220,13 +220,13 @@ void MUSIC_SetMidiChannelVolume ---------------------------------------------------------------------*/ void MUSIC_ResetMidiChannelVolumes - ( - void - ) +( + void +) - { - MIDI_ResetUserChannelVolume(); - } +{ + MIDI_ResetUserChannelVolume(); +} /*--------------------------------------------------------------------- @@ -236,17 +236,17 @@ void MUSIC_ResetMidiChannelVolumes ---------------------------------------------------------------------*/ int MUSIC_GetVolume - ( - void - ) +( + void +) - { - if ( MUSIC_SoundDevice == -1 ) - { - return( 0 ); - } - return( MIDI_GetVolume() ); - } +{ + if (MUSIC_SoundDevice == -1) + { + return(0); + } + return(MIDI_GetVolume()); +} /*--------------------------------------------------------------------- @@ -257,13 +257,13 @@ int MUSIC_GetVolume ---------------------------------------------------------------------*/ void MUSIC_SetLoopFlag - ( - int loopflag - ) +( + int loopflag +) - { - MIDI_SetLoopFlag( loopflag ); - } +{ + MIDI_SetLoopFlag(loopflag); +} /*--------------------------------------------------------------------- @@ -273,13 +273,13 @@ void MUSIC_SetLoopFlag ---------------------------------------------------------------------*/ int MUSIC_SongPlaying - ( - void - ) +( + void +) - { - return( MIDI_SongPlaying() ); - } +{ + return(MIDI_SongPlaying()); +} /*--------------------------------------------------------------------- @@ -289,13 +289,13 @@ int MUSIC_SongPlaying ---------------------------------------------------------------------*/ void MUSIC_Continue - ( - void - ) +( + void +) - { - MIDI_ContinueSong(); - } +{ + MIDI_ContinueSong(); +} /*--------------------------------------------------------------------- @@ -305,13 +305,13 @@ void MUSIC_Continue ---------------------------------------------------------------------*/ void MUSIC_Pause - ( - void - ) +( + void +) - { - MIDI_PauseSong(); - } +{ + MIDI_PauseSong(); +} /*--------------------------------------------------------------------- @@ -321,16 +321,16 @@ void MUSIC_Pause ---------------------------------------------------------------------*/ int MUSIC_StopSong - ( - void - ) +( + void +) - { - MUSIC_StopFade(); - MIDI_StopSong(); - MUSIC_SetErrorCode( MUSIC_Ok ); - return( MUSIC_Ok ); - } +{ + MUSIC_StopFade(); + MIDI_StopSong(); + MUSIC_SetErrorCode(MUSIC_Ok); + return(MUSIC_Ok); +} /*--------------------------------------------------------------------- @@ -340,25 +340,25 @@ int MUSIC_StopSong ---------------------------------------------------------------------*/ int MUSIC_PlaySong - ( - unsigned char *song, - int loopflag - ) +( + unsigned char *song, + int loopflag +) - { - int status; +{ + int status; - MUSIC_StopSong(); + MUSIC_StopSong(); - status = MIDI_PlaySong( song, loopflag ); - if ( status != MIDI_Ok ) - { - MUSIC_SetErrorCode( MUSIC_MidiError ); - return( MUSIC_Warning ); - } + status = MIDI_PlaySong(song, loopflag); + if (status != MIDI_Ok) + { + MUSIC_SetErrorCode(MUSIC_MidiError); + return(MUSIC_Warning); + } - return( MUSIC_Ok ); - } + return(MUSIC_Ok); +} /*--------------------------------------------------------------------- @@ -368,13 +368,13 @@ int MUSIC_PlaySong ---------------------------------------------------------------------*/ void MUSIC_SetContext - ( - int context - ) +( + int context +) - { - MIDI_SetContext( context ); - } +{ + MIDI_SetContext(context); +} /*--------------------------------------------------------------------- @@ -384,13 +384,13 @@ void MUSIC_SetContext ---------------------------------------------------------------------*/ int MUSIC_GetContext - ( - void - ) +( + void +) - { - return MIDI_GetContext(); - } +{ + return MIDI_GetContext(); +} /*--------------------------------------------------------------------- @@ -400,13 +400,13 @@ int MUSIC_GetContext ---------------------------------------------------------------------*/ void MUSIC_SetSongTick - ( - unsigned long PositionInTicks - ) +( + unsigned long PositionInTicks +) - { - MIDI_SetSongTick( PositionInTicks ); - } +{ + MIDI_SetSongTick(PositionInTicks); +} /*--------------------------------------------------------------------- @@ -416,13 +416,13 @@ void MUSIC_SetSongTick ---------------------------------------------------------------------*/ void MUSIC_SetSongTime - ( - unsigned long milliseconds - ) +( + unsigned long milliseconds +) - { - MIDI_SetSongTime( milliseconds ); - } +{ + MIDI_SetSongTime(milliseconds); +} /*--------------------------------------------------------------------- @@ -432,15 +432,15 @@ void MUSIC_SetSongTime ---------------------------------------------------------------------*/ void MUSIC_SetSongPosition - ( - int measure, - int beat, - int tick - ) +( + int measure, + int beat, + int tick +) - { - MIDI_SetSongPosition( measure, beat, tick ); - } +{ + MIDI_SetSongPosition(measure, beat, tick); +} /*--------------------------------------------------------------------- @@ -450,13 +450,13 @@ void MUSIC_SetSongPosition ---------------------------------------------------------------------*/ void MUSIC_GetSongPosition - ( - songposition *pos - ) +( + songposition *pos +) - { - MIDI_GetSongPosition( pos ); - } +{ + MIDI_GetSongPosition(pos); +} /*--------------------------------------------------------------------- @@ -466,41 +466,41 @@ void MUSIC_GetSongPosition ---------------------------------------------------------------------*/ void MUSIC_GetSongLength - ( - songposition *pos - ) +( + songposition *pos +) - { - MIDI_GetSongLength( pos ); - } +{ + MIDI_GetSongLength(pos); +} int MUSIC_InitMidi - ( - int card, - midifuncs *Funcs, - int Address - ) +( + int card, + midifuncs *Funcs, + int Address +) - { - int status; +{ + int status; - Funcs->NoteOff = MPU_NoteOff; - Funcs->NoteOn = MPU_NoteOn; - Funcs->PolyAftertouch = MPU_PolyAftertouch; - Funcs->ControlChange = MPU_ControlChange; - Funcs->ProgramChange = MPU_ProgramChange; - Funcs->ChannelAftertouch = MPU_ChannelAftertouch; - Funcs->PitchBend = MPU_PitchBend; - Funcs->ReleasePatches = NULL; - Funcs->LoadPatch = NULL; - Funcs->SetVolume = NULL /*MPU_SetVolume*/; - Funcs->GetVolume = NULL /*MPU_GetVolume*/; + Funcs->NoteOff = MPU_NoteOff; + Funcs->NoteOn = MPU_NoteOn; + Funcs->PolyAftertouch = MPU_PolyAftertouch; + Funcs->ControlChange = MPU_ControlChange; + Funcs->ProgramChange = MPU_ProgramChange; + Funcs->ChannelAftertouch = MPU_ChannelAftertouch; + Funcs->PitchBend = MPU_PitchBend; + Funcs->ReleasePatches = NULL; + Funcs->LoadPatch = NULL; + Funcs->SetVolume = NULL /*MPU_SetVolume*/; + Funcs->GetVolume = NULL /*MPU_GetVolume*/; - MIDI_SetMidiFuncs( Funcs ); + MIDI_SetMidiFuncs(Funcs); - return( MIDI_Ok ); - } + return(MIDI_Ok); +} /*--------------------------------------------------------------------- @@ -511,16 +511,16 @@ int MUSIC_InitMidi ---------------------------------------------------------------------*/ int MUSIC_FadeVolume - ( - int tovolume, - int milliseconds - ) +( + int tovolume, + int milliseconds +) - { - int fromvolume; +{ + int fromvolume; - MIDI_SetVolume( tovolume ); - return( MUSIC_Ok ); + MIDI_SetVolume(tovolume); + return(MUSIC_Ok); } @@ -531,13 +531,13 @@ int MUSIC_FadeVolume ---------------------------------------------------------------------*/ int MUSIC_FadeActive - ( - void - ) +( + void +) - { - return( 0 ); - } +{ + return(0); +} /*--------------------------------------------------------------------- @@ -547,12 +547,11 @@ int MUSIC_FadeActive ---------------------------------------------------------------------*/ void MUSIC_StopFade - ( - void - ) +( + void +) - { - } +{} /*--------------------------------------------------------------------- @@ -563,14 +562,14 @@ void MUSIC_StopFade ---------------------------------------------------------------------*/ void MUSIC_RerouteMidiChannel - ( - int channel, - int ( *function )( int event, int c1, int c2 ) - ) +( + int channel, + int(*function)(int event, int c1, int c2) +) - { - MIDI_RerouteMidiChannel( channel, function ); - } +{ + MIDI_RerouteMidiChannel(channel, function); +} /*--------------------------------------------------------------------- @@ -580,16 +579,15 @@ void MUSIC_RerouteMidiChannel ---------------------------------------------------------------------*/ void MUSIC_RegisterTimbreBank - ( - unsigned char *timbres - ) +( + unsigned char *timbres +) - { - } +{} void MUSIC_Update(void) { - MIDI_UpdateMusic(); + MIDI_UpdateMusic(); } diff --git a/polymer/eduke32/source/jaudiolib/nodpmi.c b/polymer/eduke32/source/jaudiolib/nodpmi.c new file mode 100755 index 000000000..2cd23a6ba --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/nodpmi.c @@ -0,0 +1,50 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + module: NODPMI.C + + Functions for faking DPMI calls. + +**********************************************************************/ + +#include +#include +#include "dpmi.h" + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + +int DPMI_GetDOSMemory(void **ptr, int *descriptor, unsigned length) +{ + /* Lovely... */ + + *ptr = (void *)malloc(length); + + *descriptor = (int) *ptr; + + return (descriptor == 0) ? DPMI_Error : DPMI_Ok; +} + +int DPMI_FreeDOSMemory(int descriptor) +{ + free((void *)descriptor); + + return (descriptor == 0) ? DPMI_Error : DPMI_Ok; +} diff --git a/polymer/eduke32/source/jaudiolib/pitch.c b/polymer/eduke32/source/jaudiolib/pitch.c index a49e2c9e1..be87a3628 100644 --- a/polymer/eduke32/source/jaudiolib/pitch.c +++ b/polymer/eduke32/source/jaudiolib/pitch.c @@ -37,56 +37,58 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) #define MAXDETUNE 25 static unsigned long PitchTable[ 12 ][ MAXDETUNE ] = - { - { 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c, - 0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907, - 0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8, - 0x10e98 }, - { 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5, - 0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9, - 0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06, - 0x11eaf }, - { 0x11f59, 0x12003, 0x120ae, 0x12159, 0x12204, 0x122b0, 0x1235c, 0x12409, - 0x124b6, 0x12563, 0x12611, 0x126bf, 0x1276d, 0x1281c, 0x128cc, 0x1297b, - 0x12a2b, 0x12adc, 0x12b8d, 0x12c3e, 0x12cf0, 0x12da2, 0x12e55, 0x12f08, - 0x12fbc }, - { 0x1306f, 0x13124, 0x131d8, 0x1328d, 0x13343, 0x133f9, 0x134af, 0x13566, - 0x1361d, 0x136d5, 0x1378d, 0x13846, 0x138fe, 0x139b8, 0x13a72, 0x13b2c, - 0x13be6, 0x13ca1, 0x13d5d, 0x13e19, 0x13ed5, 0x13f92, 0x1404f, 0x1410d, - 0x141cb }, - { 0x1428a, 0x14349, 0x14408, 0x144c8, 0x14588, 0x14649, 0x1470a, 0x147cc, - 0x1488e, 0x14951, 0x14a14, 0x14ad7, 0x14b9b, 0x14c5f, 0x14d24, 0x14dea, - 0x14eaf, 0x14f75, 0x1503c, 0x15103, 0x151cb, 0x15293, 0x1535b, 0x15424, - 0x154ee }, - { 0x155b8, 0x15682, 0x1574d, 0x15818, 0x158e4, 0x159b0, 0x15a7d, 0x15b4a, - 0x15c18, 0x15ce6, 0x15db4, 0x15e83, 0x15f53, 0x16023, 0x160f4, 0x161c5, - 0x16296, 0x16368, 0x1643a, 0x1650d, 0x165e1, 0x166b5, 0x16789, 0x1685e, - 0x16934 }, - { 0x16a09, 0x16ae0, 0x16bb7, 0x16c8e, 0x16d66, 0x16e3e, 0x16f17, 0x16ff1, - 0x170ca, 0x171a5, 0x17280, 0x1735b, 0x17437, 0x17513, 0x175f0, 0x176ce, - 0x177ac, 0x1788a, 0x17969, 0x17a49, 0x17b29, 0x17c09, 0x17cea, 0x17dcc, - 0x17eae }, - { 0x17f91, 0x18074, 0x18157, 0x1823c, 0x18320, 0x18406, 0x184eb, 0x185d2, - 0x186b8, 0x187a0, 0x18888, 0x18970, 0x18a59, 0x18b43, 0x18c2d, 0x18d17, - 0x18e02, 0x18eee, 0x18fda, 0x190c7, 0x191b5, 0x192a2, 0x19391, 0x19480, - 0x1956f }, - { 0x1965f, 0x19750, 0x19841, 0x19933, 0x19a25, 0x19b18, 0x19c0c, 0x19d00, - 0x19df4, 0x19ee9, 0x19fdf, 0x1a0d5, 0x1a1cc, 0x1a2c4, 0x1a3bc, 0x1a4b4, - 0x1a5ad, 0x1a6a7, 0x1a7a1, 0x1a89c, 0x1a998, 0x1aa94, 0x1ab90, 0x1ac8d, - 0x1ad8b }, - { 0x1ae89, 0x1af88, 0x1b088, 0x1b188, 0x1b289, 0x1b38a, 0x1b48c, 0x1b58f, - 0x1b692, 0x1b795, 0x1b89a, 0x1b99f, 0x1baa4, 0x1bbaa, 0x1bcb1, 0x1bdb8, - 0x1bec0, 0x1bfc9, 0x1c0d2, 0x1c1dc, 0x1c2e6, 0x1c3f1, 0x1c4fd, 0x1c609, - 0x1c716 }, - { 0x1c823, 0x1c931, 0x1ca40, 0x1cb50, 0x1cc60, 0x1cd70, 0x1ce81, 0x1cf93, - 0x1d0a6, 0x1d1b9, 0x1d2cd, 0x1d3e1, 0x1d4f6, 0x1d60c, 0x1d722, 0x1d839, - 0x1d951, 0x1da69, 0x1db82, 0x1dc9c, 0x1ddb6, 0x1ded1, 0x1dfec, 0x1e109, - 0x1e225 }, - { 0x1e343, 0x1e461, 0x1e580, 0x1e6a0, 0x1e7c0, 0x1e8e0, 0x1ea02, 0x1eb24, - 0x1ec47, 0x1ed6b, 0x1ee8f, 0x1efb4, 0x1f0d9, 0x1f1ff, 0x1f326, 0x1f44e, - 0x1f576, 0x1f69f, 0x1f7c9, 0x1f8f3, 0x1fa1e, 0x1fb4a, 0x1fc76, 0x1fda3, - 0x1fed1 } - }; + { + { + 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c, + 0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907, + 0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8, + 0x10e98 + }, + { 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5, + 0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9, + 0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06, + 0x11eaf }, + { 0x11f59, 0x12003, 0x120ae, 0x12159, 0x12204, 0x122b0, 0x1235c, 0x12409, + 0x124b6, 0x12563, 0x12611, 0x126bf, 0x1276d, 0x1281c, 0x128cc, 0x1297b, + 0x12a2b, 0x12adc, 0x12b8d, 0x12c3e, 0x12cf0, 0x12da2, 0x12e55, 0x12f08, + 0x12fbc }, + { 0x1306f, 0x13124, 0x131d8, 0x1328d, 0x13343, 0x133f9, 0x134af, 0x13566, + 0x1361d, 0x136d5, 0x1378d, 0x13846, 0x138fe, 0x139b8, 0x13a72, 0x13b2c, + 0x13be6, 0x13ca1, 0x13d5d, 0x13e19, 0x13ed5, 0x13f92, 0x1404f, 0x1410d, + 0x141cb }, + { 0x1428a, 0x14349, 0x14408, 0x144c8, 0x14588, 0x14649, 0x1470a, 0x147cc, + 0x1488e, 0x14951, 0x14a14, 0x14ad7, 0x14b9b, 0x14c5f, 0x14d24, 0x14dea, + 0x14eaf, 0x14f75, 0x1503c, 0x15103, 0x151cb, 0x15293, 0x1535b, 0x15424, + 0x154ee }, + { 0x155b8, 0x15682, 0x1574d, 0x15818, 0x158e4, 0x159b0, 0x15a7d, 0x15b4a, + 0x15c18, 0x15ce6, 0x15db4, 0x15e83, 0x15f53, 0x16023, 0x160f4, 0x161c5, + 0x16296, 0x16368, 0x1643a, 0x1650d, 0x165e1, 0x166b5, 0x16789, 0x1685e, + 0x16934 }, + { 0x16a09, 0x16ae0, 0x16bb7, 0x16c8e, 0x16d66, 0x16e3e, 0x16f17, 0x16ff1, + 0x170ca, 0x171a5, 0x17280, 0x1735b, 0x17437, 0x17513, 0x175f0, 0x176ce, + 0x177ac, 0x1788a, 0x17969, 0x17a49, 0x17b29, 0x17c09, 0x17cea, 0x17dcc, + 0x17eae }, + { 0x17f91, 0x18074, 0x18157, 0x1823c, 0x18320, 0x18406, 0x184eb, 0x185d2, + 0x186b8, 0x187a0, 0x18888, 0x18970, 0x18a59, 0x18b43, 0x18c2d, 0x18d17, + 0x18e02, 0x18eee, 0x18fda, 0x190c7, 0x191b5, 0x192a2, 0x19391, 0x19480, + 0x1956f }, + { 0x1965f, 0x19750, 0x19841, 0x19933, 0x19a25, 0x19b18, 0x19c0c, 0x19d00, + 0x19df4, 0x19ee9, 0x19fdf, 0x1a0d5, 0x1a1cc, 0x1a2c4, 0x1a3bc, 0x1a4b4, + 0x1a5ad, 0x1a6a7, 0x1a7a1, 0x1a89c, 0x1a998, 0x1aa94, 0x1ab90, 0x1ac8d, + 0x1ad8b }, + { 0x1ae89, 0x1af88, 0x1b088, 0x1b188, 0x1b289, 0x1b38a, 0x1b48c, 0x1b58f, + 0x1b692, 0x1b795, 0x1b89a, 0x1b99f, 0x1baa4, 0x1bbaa, 0x1bcb1, 0x1bdb8, + 0x1bec0, 0x1bfc9, 0x1c0d2, 0x1c1dc, 0x1c2e6, 0x1c3f1, 0x1c4fd, 0x1c609, + 0x1c716 }, + { 0x1c823, 0x1c931, 0x1ca40, 0x1cb50, 0x1cc60, 0x1cd70, 0x1ce81, 0x1cf93, + 0x1d0a6, 0x1d1b9, 0x1d2cd, 0x1d3e1, 0x1d4f6, 0x1d60c, 0x1d722, 0x1d839, + 0x1d951, 0x1da69, 0x1db82, 0x1dc9c, 0x1ddb6, 0x1ded1, 0x1dfec, 0x1e109, + 0x1e225 }, + { 0x1e343, 0x1e461, 0x1e580, 0x1e6a0, 0x1e7c0, 0x1e8e0, 0x1ea02, 0x1eb24, + 0x1ec47, 0x1ed6b, 0x1ee8f, 0x1efb4, 0x1f0d9, 0x1f1ff, 0x1f326, 0x1f44e, + 0x1f576, 0x1f69f, 0x1f7c9, 0x1f8f3, 0x1fa1e, 0x1fb4a, 0x1fc76, 0x1fda3, + 0x1fed1 } + }; //static int PITCH_Installed = FALSE; @@ -137,61 +139,61 @@ void PITCH_Init ---------------------------------------------------------------------*/ unsigned long PITCH_GetScale - ( - int pitchoffset - ) +( + int pitchoffset +) - { - unsigned long scale; - int octaveshift; - int noteshift; - int note; - int detune; +{ + unsigned long scale; + int octaveshift; + int noteshift; + int note; + int detune; // if ( !PITCH_Installed ) // { // PITCH_Init(); // } - if ( pitchoffset == 0 ) - { - return( PitchTable[ 0 ][ 0 ] ); - } + if (pitchoffset == 0) + { + return(PitchTable[ 0 ][ 0 ]); + } - noteshift = pitchoffset % 1200; - if ( noteshift < 0 ) - { - noteshift += 1200; - } + noteshift = pitchoffset % 1200; + if (noteshift < 0) + { + noteshift += 1200; + } - note = noteshift / 100; - detune = ( noteshift % 100 ) / ( 100 / MAXDETUNE ); - octaveshift = ( pitchoffset - noteshift ) / 1200; + note = noteshift / 100; + detune = (noteshift % 100) / (100 / MAXDETUNE); + octaveshift = (pitchoffset - noteshift) / 1200; - if ( detune < 0 ) - { - detune += ( 100 / MAXDETUNE ); - note--; - if ( note < 0 ) - { - note += 12; - octaveshift--; - } - } + if (detune < 0) + { + detune += (100 / MAXDETUNE); + note--; + if (note < 0) + { + note += 12; + octaveshift--; + } + } - scale = PitchTable[ note ][ detune ]; + scale = PitchTable[ note ][ detune ]; - if ( octaveshift < 0 ) - { - scale >>= -octaveshift; - } - else - { - scale <<= octaveshift; - } + if (octaveshift < 0) + { + scale >>= -octaveshift; + } + else + { + scale <<= octaveshift; + } - return( scale ); - } + return(scale); +} diff --git a/polymer/eduke32/source/jaudiolib/platform.h b/polymer/eduke32/source/jaudiolib/platform.h new file mode 100755 index 000000000..04dc825fb --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/platform.h @@ -0,0 +1,61 @@ +#ifndef _INCLUDE_PLATFORM_H_ +#define _INCLUDE_PLATFORM_H_ + +#if (!defined __EXPORT__) +#define __EXPORT__ +#endif + +#if (defined __WATCOMC__) +#define snprintf _snprintf +#endif + +static __inline unsigned short _swap16(unsigned short D) +{ +#if PLATFORM_MACOSX + register unsigned short returnValue; + __asm__ volatile("lhbrx %0,0,%1" + : "=r" (returnValue) + : "r" (&D) + ); + return returnValue; +#else + return((D<<8)|(D>>8)); +#endif +} + +static __inline unsigned int _swap32(unsigned int D) +{ +#if PLATFORM_MACOSX + register unsigned int returnValue; + __asm__ volatile("lwbrx %0,0,%1" + : "=r" (returnValue) + : "r" (&D) + ); + return returnValue; +#else + return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24)); +#endif +} + +#if PLATFORM_MACOSX +#define PLATFORM_BIGENDIAN 1 +#define BUILDSWAP_INTEL16(x) _swap16(x) +#define BUILDSWAP_INTEL32(x) _swap32(x) +#else +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define PLATFORM_LITTLEENDIAN 1 +#define BUILDSWAP_INTEL16(x) (x) +#define BUILDSWAP_INTEL32(x) (x) +#else +#define PLATFORM_BIGENDIAN 1 +#define BUILDSWAP_INTEL16(x) _swap16(x) +#define BUILDSWAP_INTEL32(x) _swap32(x) +#endif +#endif + +extern int has_altivec; /* PowerPC-specific. */ + +#endif /* !defined _INCLUDE_PLATFORM_H_ */ + +/* end of platform.h ... */ + diff --git a/polymer/eduke32/source/jaudiolib/sdlmusic.c b/polymer/eduke32/source/jaudiolib/sdlmusic.c new file mode 100755 index 000000000..121e1a3ed --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/sdlmusic.c @@ -0,0 +1,477 @@ +/* +Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Originally written by Ryan C. Gordon. (icculus@clutteredmind.org) +Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) + +*/ +/* + * A reimplementation of Jim Dose's FX_MAN routines, using SDL_mixer 1.2. + * Whee. FX_MAN is also known as the "Apogee Sound System", or "ASS" for + * short. How strangely appropriate that seems. + */ + +#include +#include +#include +#include +#include + +#include "duke3d.h" +#include "cache1d.h" + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + +#if (defined __WATCOMC__) +// This is probably out of date. --ryan. +#include "dukesnd_watcom.h" +#endif + +#if (!defined __WATCOMC__) +#define cdecl +#endif + +#include +#include +#include "music.h" + +#define __FX_TRUE (1 == 1) +#define __FX_FALSE (!__FX_TRUE) + +#define DUKESND_DEBUG "DUKESND_DEBUG" + +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename); + +int MUSIC_ErrorCode = MUSIC_Ok; + +static char warningMessage[80]; +static char errorMessage[80]; +static int fx_initialized = 0; +static int numChannels = MIX_CHANNELS; +static void(*callback)(unsigned long); +static int reverseStereo = 0; +static int reverbDelay = 256; +static int reverbLevel = 0; +static int fastReverb = 0; +static FILE *debug_file = NULL; +static int initialized_debugging = 0; +static int mixerIsStereo = 1; + +// This gets called all over the place for information and debugging messages. +// If the user set the DUKESND_DEBUG environment variable, the messages +// go to the file that is specified in that variable. Otherwise, they +// are ignored for the expense of the function call. If DUKESND_DEBUG is +// set to "-" (without the quotes), then the output goes to stdout. +static void musdebug(const char *fmt, ...) +{ + va_list ap; + + if (debug_file) + { + fprintf(debug_file, "DUKEMUS: "); + va_start(ap, fmt); + vfprintf(debug_file, fmt, ap); + va_end(ap); + fprintf(debug_file, "\n"); + fflush(debug_file); + } // if +} // musdebug + +static void init_debugging(void) +{ + const char *envr; + + if (initialized_debugging) + return; + + envr = getenv(DUKESND_DEBUG); + if (envr != NULL) + { + if (strcmp(envr, "-") == 0) + debug_file = stdout; + else + debug_file = fopen(envr, "w"); + + if (debug_file == NULL) + fprintf(stderr, "DUKESND: -WARNING- Could not open debug file!\n"); + else + setbuf(debug_file, NULL); + } // if + + initialized_debugging = 1; +} // init_debugging + +static void setWarningMessage(const char *msg) +{ + strncpy(warningMessage, msg, sizeof(warningMessage)); + // strncpy() doesn't add the null char if there isn't room... + warningMessage[sizeof(warningMessage) - 1] = '\0'; + musdebug("Warning message set to [%s].", warningMessage); +} // setErrorMessage + + +static void setErrorMessage(const char *msg) +{ + strncpy(errorMessage, msg, sizeof(errorMessage)); + // strncpy() doesn't add the null char if there isn't room... + errorMessage[sizeof(errorMessage) - 1] = '\0'; + musdebug("Error message set to [%s].", errorMessage); +} // setErrorMessage + +// The music functions... + +char *MUSIC_ErrorString(int ErrorNumber) +{ + switch (ErrorNumber) + { + case MUSIC_Warning: + return(warningMessage); + + case MUSIC_Error: + return(errorMessage); + + case MUSIC_Ok: + return("OK; no error."); + + case MUSIC_ASSVersion: + return("Incorrect sound library version."); + + case MUSIC_SoundCardError: + return("General sound card error."); + + case MUSIC_InvalidCard: + return("Invalid sound card."); + + case MUSIC_MidiError: + return("MIDI error."); + + case MUSIC_MPU401Error: + return("MPU401 error."); + + case MUSIC_TaskManError: + return("Task Manager error."); + + //case MUSIC_FMNotDetected: + // return("FM not detected error."); + + case MUSIC_DPMI_Error: + return("DPMI error."); + + default: + return("Unknown error."); + } // switch + + assert(0); // shouldn't hit this point. + return(NULL); +} // MUSIC_ErrorString + + +static int music_initialized = 0; +static int music_context = 0; +static int music_loopflag = MUSIC_PlayOnce; +static char *music_songdata = NULL; +static Mix_Music *music_musicchunk = NULL; + +int MUSIC_Init(int SoundCard, int Address) +{ + init_debugging(); + + musdebug("INIT! card=>%d, address=>%d...", SoundCard, Address); + + if (music_initialized) + { + setErrorMessage("Music system is already initialized."); + return(MUSIC_Error); + } // if + + SoundCard = 1; + + music_initialized = 1; + return(MUSIC_Ok); +} // MUSIC_Init + + +int MUSIC_Shutdown(void) +{ + musdebug("shutting down sound subsystem."); + + MUSIC_StopSong(); + music_context = 0; + music_initialized = 0; + music_loopflag = MUSIC_PlayOnce; + return(MUSIC_Ok); +} // MUSIC_Shutdown + + +void MUSIC_SetMaxFMMidiChannel(int channel) +{ + musdebug("STUB ... MUSIC_SetMaxFMMidiChannel(%d).\n", channel); +} // MUSIC_SetMaxFMMidiChannel + + +void MUSIC_SetVolume(int volume) +{ + volume = max(0, volume); + volume = min(volume, 255); + + Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128. +} // MUSIC_SetVolume + + +void MUSIC_SetMidiChannelVolume(int channel, int volume) +{ + musdebug("STUB ... MUSIC_SetMidiChannelVolume(%d, %d).\n", channel, volume); +} // MUSIC_SetMidiChannelVolume + + +void MUSIC_ResetMidiChannelVolumes(void) +{ + musdebug("STUB ... MUSIC_ResetMidiChannelVolumes().\n"); +} // MUSIC_ResetMidiChannelVolumes + + +int MUSIC_GetVolume(void) +{ + return(Mix_VolumeMusic(-1) << 1); // convert 0-128 to 0-255. +} // MUSIC_GetVolume + + +void MUSIC_SetLoopFlag(int loopflag) +{ + music_loopflag = loopflag; +} // MUSIC_SetLoopFlag + + +int MUSIC_SongPlaying(void) +{ + return((Mix_PlayingMusic()) ? __FX_TRUE : __FX_FALSE); +} // MUSIC_SongPlaying + + +void MUSIC_Continue(void) +{ + if (Mix_PausedMusic()) + Mix_ResumeMusic(); + else if (music_songdata) + MUSIC_PlaySong(music_songdata, MUSIC_PlayOnce); +} // MUSIC_Continue + + +void MUSIC_Pause(void) +{ + Mix_PauseMusic(); +} // MUSIC_Pause + + +int MUSIC_StopSong(void) +{ + //if (!fx_initialized) + if (!Mix_QuerySpec(NULL, NULL, NULL)) + { + setErrorMessage("Need FX system initialized, too. Sorry."); + return(MUSIC_Error); + } // if + + if ((Mix_PlayingMusic()) || (Mix_PausedMusic())) + Mix_HaltMusic(); + + if (music_musicchunk) + Mix_FreeMusic(music_musicchunk); + + music_songdata = NULL; + music_musicchunk = NULL; + return(MUSIC_Ok); +} // MUSIC_StopSong + + +int MUSIC_PlaySong(unsigned char *song, int loopflag) +{ + //SDL_RWops *rw; + + MUSIC_StopSong(); + + music_songdata = song; + + // !!! FIXME: This could be a problem...SDL/SDL_mixer wants a RWops, which + // !!! FIXME: is an i/o abstraction. Since we already have the MIDI data + // !!! FIXME: in memory, we fake it with a memory-based RWops. None of + // !!! FIXME: this is a problem, except the RWops wants to know how big + // !!! FIXME: its memory block is (so it can do things like seek on an + // !!! FIXME: offset from the end of the block), and since we don't have + // !!! FIXME: this information, we have to give it SOMETHING. + + /* !!! ARGH! There's no LoadMUS_RW ?! + rw = SDL_RWFromMem((void *) song, (10 * 1024) * 1024); // yikes. + music_musicchunk = Mix_LoadMUS_RW(rw); + Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1); + */ + + return(MUSIC_Ok); +} // MUSIC_PlaySong + + +extern char ApogeePath[256] = "/tmp/"; + +// Duke3D-specific. --ryan. +void PlayMusic(char *_filename) +{ + //char filename[MAX_PATH]; + //strcpy(filename, _filename); + //FixFilePath(filename); + + char filename[MAX_PATH]; + long handle; + long size; + void *song; + long rc; + + MUSIC_StopSong(); + + // Read from a groupfile, write it to disk so SDL_mixer can read it. + // Lame. --ryan. + handle = kopen4load(_filename, 0); + if (handle == -1) + return; + + size = kfilelength(handle); + if (size == -1) + { + kclose(handle); + return; + } // if + + song = malloc(size); + if (song == NULL) + { + kclose(handle); + return; + } // if + + rc = kread(handle, song, size); + kclose(handle); + if (rc != size) + { + free(song); + return; + } // if + + // save the file somewhere, so SDL_mixer can load it + GetUnixPathFromEnvironment(filename, MAX_PATH, "tmpsong.mid"); + handle = SafeOpenWrite(filename, filetype_binary); + + SafeWrite(handle, song, size); + close(handle); + free(song); + + //music_songdata = song; + + music_musicchunk = Mix_LoadMUS(filename); + if (music_musicchunk != NULL) + { + // !!! FIXME: I set the music to loop. Hope that's okay. --ryan. + Mix_PlayMusic(music_musicchunk, -1); + } // if +} + + +void MUSIC_SetContext(int context) +{ + musdebug("STUB ... MUSIC_SetContext().\n"); + music_context = context; +} // MUSIC_SetContext + + +int MUSIC_GetContext(void) +{ + return(music_context); +} // MUSIC_GetContext + + +void MUSIC_SetSongTick(unsigned long PositionInTicks) +{ + musdebug("STUB ... MUSIC_SetSongTick().\n"); +} // MUSIC_SetSongTick + + +void MUSIC_SetSongTime(unsigned long milliseconds) +{ + musdebug("STUB ... MUSIC_SetSongTime().\n"); +}// MUSIC_SetSongTime + + +void MUSIC_SetSongPosition(int measure, int beat, int tick) +{ + musdebug("STUB ... MUSIC_SetSongPosition().\n"); +} // MUSIC_SetSongPosition + + +void MUSIC_GetSongPosition(songposition *pos) +{ + musdebug("STUB ... MUSIC_GetSongPosition().\n"); +} // MUSIC_GetSongPosition + + +void MUSIC_GetSongLength(songposition *pos) +{ + musdebug("STUB ... MUSIC_GetSongLength().\n"); +} // MUSIC_GetSongLength + + +int MUSIC_FadeVolume(int tovolume, int milliseconds) +{ + Mix_FadeOutMusic(milliseconds); + return(MUSIC_Ok); +} // MUSIC_FadeVolume + + +int MUSIC_FadeActive(void) +{ + return((Mix_FadingMusic() == MIX_FADING_OUT) ? __FX_TRUE : __FX_FALSE); +} // MUSIC_FadeActive + + +void MUSIC_StopFade(void) +{ + musdebug("STUB ... MUSIC_StopFade().\n"); +} // MUSIC_StopFade + + +void MUSIC_RerouteMidiChannel(int channel, int cdecl(*function)(int event, int c1, int c2)) +{ + musdebug("STUB ... MUSIC_RerouteMidiChannel().\n"); +} // MUSIC_RerouteMidiChannel + + +void MUSIC_RegisterTimbreBank(unsigned char *timbres) +{ + musdebug("STUB ... MUSIC_RegisterTimbreBank().\n"); +} // MUSIC_RegisterTimbreBank + + +void MUSIC_Update(void) +{} diff --git a/polymer/eduke32/source/jaudiolib/sdlout.c b/polymer/eduke32/source/jaudiolib/sdlout.c index 37c510a16..111c0bae7 100644 --- a/polymer/eduke32/source/jaudiolib/sdlout.c +++ b/polymer/eduke32/source/jaudiolib/sdlout.c @@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #error The SDL output module for AudioLib only works with the SDL interface. #endif -static int (*_SDLSOUND_CallBack)(int) = NULL; +static int(*_SDLSOUND_CallBack)(int) = NULL; static int _SDLSOUND_BufferLength = 0; static int _SDLSOUND_NumBuffers = 0; static char *_SDLSOUND_MixBuffer = NULL; @@ -62,9 +62,9 @@ static void isr(void *userdata, unsigned char *stream, int len); */ int DisableInterrupts(void) { - SDL_LockAudio(); + SDL_LockAudio(); - return 0; + return 0; } @@ -74,10 +74,10 @@ int DisableInterrupts(void) */ int RestoreInterrupts(int a) { - SDL_UnlockAudio(); + SDL_UnlockAudio(); - return 0; - a=a; + return 0; + a=a; } @@ -87,17 +87,18 @@ int RestoreInterrupts(int a) */ char *SDLSOUND_ErrorString(int errorcode) { - switch (errorcode) { - case SDLSOUND_Warning: - case SDLSOUND_Error: - return SDLSOUND_ErrorString(SDLSOUND_ErrorCode); + switch (errorcode) + { + case SDLSOUND_Warning: + case SDLSOUND_Error: + return SDLSOUND_ErrorString(SDLSOUND_ErrorCode); - case SDLSOUND_Ok: - return "SDL Sound ok."; + case SDLSOUND_Ok: + return "SDL Sound ok."; - default: - return "Unknown SDL sound error code."; - } + default: + return "Unknown SDL sound error code."; + } } @@ -107,32 +108,33 @@ char *SDLSOUND_ErrorString(int errorcode) */ int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize) { - SDL_AudioSpec spec,got; - - if (SDLSOUND_Installed) { - SDLSOUND_Shutdown(); - } + SDL_AudioSpec spec,got; - printOSD("Initializing SDL sound...\n"); + if (SDLSOUND_Installed) + { + SDLSOUND_Shutdown(); + } - printOSD(" - Requested sound format\n" - " Channels: %d\n" - " Sample rate: %dHz\n" - " Sample size: %d bits\n", - numchannels, mixrate, samplebits); + printOSD("Initializing SDL sound...\n"); - spec.freq = mixrate; - spec.format = (samplebits == 8 ? AUDIO_U8 : AUDIO_S16LSB); - spec.channels = (numchannels == 1 ? 1:2); - spec.samples = (buffersize >> (spec.channels-1)) >> (samplebits==16); - spec.callback = isr; - spec.userdata = NULL; + printOSD(" - Requested sound format\n" + " Channels: %d\n" + " Sample rate: %dHz\n" + " Sample size: %d bits\n", + numchannels, mixrate, samplebits); + + spec.freq = mixrate; + spec.format = (samplebits == 8 ? AUDIO_U8 : AUDIO_S16LSB); + spec.channels = (numchannels == 1 ? 1:2); + spec.samples = (buffersize >> (spec.channels-1)) >> (samplebits==16); + spec.callback = isr; + spec.userdata = NULL; - SDLSOUND_Installed = TRUE; - - SDLSOUND_SetErrorCode(SDLSOUND_Ok); - return SDLSOUND_Ok; + SDLSOUND_Installed = TRUE; + + SDLSOUND_SetErrorCode(SDLSOUND_Ok); + return SDLSOUND_Ok; } @@ -142,17 +144,17 @@ int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, i */ int SDLSOUND_Shutdown(void) { - int i; + int i; - if (SDLSOUND_Installed) printOSD("Uninitializing SDL sound...\n"); + if (SDLSOUND_Installed) printOSD("Uninitializing SDL sound...\n"); - SDLSOUND_Installed = FALSE; + SDLSOUND_Installed = FALSE; - SDLSOUND_StopPlayback(); + SDLSOUND_StopPlayback(); - - SDLSOUND_SetErrorCode(SDLSOUND_Ok); - return SDLSOUND_Ok; + + SDLSOUND_SetErrorCode(SDLSOUND_Ok); + return SDLSOUND_Ok; } @@ -162,37 +164,40 @@ int SDLSOUND_Shutdown(void) */ int SDLSOUND_SetMixMode(int mode) { - return mode; + return mode; } static void isr(void *userdata, unsigned char *stream, int len) { - // otherwise we just service the interrupt - if (_DSOUND_CallBack) { + // otherwise we just service the interrupt + if (_DSOUND_CallBack) + { - p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); + p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); - hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, - &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); - if (hr == DSERR_BUFFERLOST) { - hr = IDirectSoundBuffer_Restore(lpDSBSecondary); - } - if (hr == DS_OK) { - /* -#define copybuf(S,D,c) \ - ({ void *__S=(S), *__D=(D); long __c=(c); \ - __asm__ __volatile__ ("rep; movsl" \ - : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ - 0; }) -*/ - //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); - memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); - IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); - } + hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, + &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); + if (hr == DSERR_BUFFERLOST) + { + hr = IDirectSoundBuffer_Restore(lpDSBSecondary); + } + if (hr == DS_OK) + { + /* + #define copybuf(S,D,c) \ + ({ void *__S=(S), *__D=(D); long __c=(c); \ + __asm__ __volatile__ ("rep; movsl" \ + : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ + 0; }) + */ + //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); + memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); + IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); + } - } - } + } +} } @@ -200,15 +205,15 @@ static void isr(void *userdata, unsigned char *stream, int len) * SDLSOUND_BeginBufferedPlayback * Unpause SDL sound playback. */ -int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions) +int DSOUND_BeginBufferedPlayback(char *BufferStart, int(*CallBackFunc)(int), int buffersize, int numdivisions) { - _SDLSOUND_CallBack = CallBackFunc; - _SDLSOUND_MixBuffer = BufferStart; + _SDLSOUND_CallBack = CallBackFunc; + _SDLSOUND_MixBuffer = BufferStart; - _SDLSOUND_BufferLength = buffersize/numdivisions; - _SDLSOUND_NumBuffers = numdivisions; + _SDLSOUND_BufferLength = buffersize/numdivisions; + _SDLSOUND_NumBuffers = numdivisions; - return SDLSOUND_Ok; + return SDLSOUND_Ok; } @@ -219,48 +224,53 @@ int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), in int DSOUND_StopPlayback(void) { // DWORD exitcode; - BOOL t; - int i; - - if (isrthread) { - SetEvent(isrfinish); + BOOL t; + int i; - printOSD("DirectSound: Waiting for sound thread to exit\n"); - if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0) - printOSD("DirectSound: Sound thread has exited\n"); - else - printOSD("DirectSound: Sound thread failed to exit!\n"); - /* - while (1) { - if (!GetExitCodeThread(isrthread, &exitcode)) { - DSOUND_SetErrorCode(DSOUND_FailedGetExitCode); - return DSOUND_Warning; - } - if (exitcode != STILL_ACTIVE) break; - }*/ + if (isrthread) + { + SetEvent(isrfinish); - CloseHandle(isrthread); - isrthread = NULL; - } + printOSD("DirectSound: Waiting for sound thread to exit\n"); + if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0) + printOSD("DirectSound: Sound thread has exited\n"); + else + printOSD("DirectSound: Sound thread failed to exit!\n"); + /* + while (1) { + if (!GetExitCodeThread(isrthread, &exitcode)) { + DSOUND_SetErrorCode(DSOUND_FailedGetExitCode); + return DSOUND_Warning; + } + if (exitcode != STILL_ACTIVE) break; + }*/ - if (isrfinish) { - CloseHandle(isrfinish); - isrfinish = NULL; - } + CloseHandle(isrthread); + isrthread = NULL; + } - if (lpDSBSecondary) { - IDirectSoundBuffer_Stop(lpDSBSecondary); - } - - if (hPosNotify) { - for (i=0; i<_DSOUND_NumBuffers; i++) { - if (hPosNotify[i]) CloseHandle(hPosNotify[i]); - } - free(hPosNotify); - hPosNotify = NULL; - } + if (isrfinish) + { + CloseHandle(isrfinish); + isrfinish = NULL; + } - return DSOUND_Ok; + if (lpDSBSecondary) + { + IDirectSoundBuffer_Stop(lpDSBSecondary); + } + + if (hPosNotify) + { + for (i=0; i<_DSOUND_NumBuffers; i++) + { + if (hPosNotify[i]) CloseHandle(hPosNotify[i]); + } + free(hPosNotify); + hPosNotify = NULL; + } + + return DSOUND_Ok; } diff --git a/polymer/eduke32/source/jaudiolib/unixglob.c b/polymer/eduke32/source/jaudiolib/unixglob.c new file mode 100755 index 000000000..5941a31c9 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/unixglob.c @@ -0,0 +1,151 @@ +/* +Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Originally written by Ryan C. Gordon. (icculus@clutteredmind.org) +Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) + +*/ + +static char ApogeePath[256] = "/tmp/"; + +#define PATH_SEP_CHAR '/' +#define PATH_SEP_STR "/" +#define ROOTDIR "/" +#define CURDIR "./" + +#include "duke3d.h" +#include +#include + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + +void FixFilePath(char *filename) +{ + char *ptr; + char *lastsep = filename; + + if ((!filename) || (*filename == '\0')) + return; + + if (access(filename, F_OK) == 0) /* File exists; we're good to go. */ + return; + + for (ptr = filename; 1; ptr++) + { + if (*ptr == '\\') + *ptr = PATH_SEP_CHAR; + + if ((*ptr == PATH_SEP_CHAR) || (*ptr == '\0')) + { + char pch = *ptr; + struct dirent *dent = NULL; + DIR *dir; + + if ((pch == PATH_SEP_CHAR) && (*(ptr + 1) == '\0')) + return; /* eos is pathsep; we're done. */ + + if (lastsep == ptr) + continue; /* absolute path; skip to next one. */ + + *ptr = '\0'; + if (lastsep == filename) + { + dir = opendir((*lastsep == PATH_SEP_CHAR) ? ROOTDIR : CURDIR); + + if (*lastsep == PATH_SEP_CHAR) + { + lastsep++; + } + } + else + { + *lastsep = '\0'; + dir = opendir(filename); + *lastsep = PATH_SEP_CHAR; + lastsep++; + } + + if (dir == NULL) + { + *ptr = PATH_SEP_CHAR; + return; /* maybe dir doesn't exist? give up. */ + } + + while ((dent = readdir(dir)) != NULL) + { + if (strcasecmp(dent->d_name, lastsep) == 0) + { + /* found match; replace it. */ + strcpy(lastsep, dent->d_name); + break; + } + } + + closedir(dir); + *ptr = pch; + lastsep = ptr; + + if (dent == NULL) + return; /* no match. oh well. */ + + if (pch == '\0') /* eos? */ + return; + } + } +} + +int32 SafeOpenWrite(const char *_filename, int32 filetype) +{ + int handle; + char filename[MAX_PATH]; + strncpy(filename, _filename, sizeof(filename)); + filename[sizeof(filename) - 1] = '\0'; + FixFilePath(filename); + + handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC + , S_IREAD | S_IWRITE); + + if (handle == -1) + Error("Error opening %s: %s",filename,strerror(errno)); + + return handle; +} + + +void SafeWrite(int32 handle, void *buffer, int32 count) +{ + unsigned iocount; + + while (count) + { + iocount = count > 0x8000 ? 0x8000 : count; + if (write(handle,buffer,iocount) != (int)iocount) + Error("File write failure writing %ld bytes",count); + buffer = (void *)((byte *)buffer + iocount); + count -= iocount; + } +} + + + +void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename) +{ + snprintf(fullname, length-1, "%s%s", ApogeePath, filename); +} diff --git a/polymer/eduke32/source/jaudiolib/unixpitch.c b/polymer/eduke32/source/jaudiolib/unixpitch.c new file mode 100755 index 000000000..5b94f54a7 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/unixpitch.c @@ -0,0 +1,213 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + module: PITCH.C + + author: James R. Dose + date: June 14, 1993 + + Routines for pitch scaling. + + (c) Copyright 1993 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +//#include +#include "dpmi.h" +#include "standard.h" +#include "pitch.h" + +#define MAXDETUNE 25 + +static unsigned long PitchTable[ 12 ][ MAXDETUNE ] = + { + { + 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c, + 0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907, + 0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8, + 0x10e98 + }, + { 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5, + 0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9, + 0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06, + 0x11eaf }, + { 0x11f59, 0x12003, 0x120ae, 0x12159, 0x12204, 0x122b0, 0x1235c, 0x12409, + 0x124b6, 0x12563, 0x12611, 0x126bf, 0x1276d, 0x1281c, 0x128cc, 0x1297b, + 0x12a2b, 0x12adc, 0x12b8d, 0x12c3e, 0x12cf0, 0x12da2, 0x12e55, 0x12f08, + 0x12fbc }, + { 0x1306f, 0x13124, 0x131d8, 0x1328d, 0x13343, 0x133f9, 0x134af, 0x13566, + 0x1361d, 0x136d5, 0x1378d, 0x13846, 0x138fe, 0x139b8, 0x13a72, 0x13b2c, + 0x13be6, 0x13ca1, 0x13d5d, 0x13e19, 0x13ed5, 0x13f92, 0x1404f, 0x1410d, + 0x141cb }, + { 0x1428a, 0x14349, 0x14408, 0x144c8, 0x14588, 0x14649, 0x1470a, 0x147cc, + 0x1488e, 0x14951, 0x14a14, 0x14ad7, 0x14b9b, 0x14c5f, 0x14d24, 0x14dea, + 0x14eaf, 0x14f75, 0x1503c, 0x15103, 0x151cb, 0x15293, 0x1535b, 0x15424, + 0x154ee }, + { 0x155b8, 0x15682, 0x1574d, 0x15818, 0x158e4, 0x159b0, 0x15a7d, 0x15b4a, + 0x15c18, 0x15ce6, 0x15db4, 0x15e83, 0x15f53, 0x16023, 0x160f4, 0x161c5, + 0x16296, 0x16368, 0x1643a, 0x1650d, 0x165e1, 0x166b5, 0x16789, 0x1685e, + 0x16934 }, + { 0x16a09, 0x16ae0, 0x16bb7, 0x16c8e, 0x16d66, 0x16e3e, 0x16f17, 0x16ff1, + 0x170ca, 0x171a5, 0x17280, 0x1735b, 0x17437, 0x17513, 0x175f0, 0x176ce, + 0x177ac, 0x1788a, 0x17969, 0x17a49, 0x17b29, 0x17c09, 0x17cea, 0x17dcc, + 0x17eae }, + { 0x17f91, 0x18074, 0x18157, 0x1823c, 0x18320, 0x18406, 0x184eb, 0x185d2, + 0x186b8, 0x187a0, 0x18888, 0x18970, 0x18a59, 0x18b43, 0x18c2d, 0x18d17, + 0x18e02, 0x18eee, 0x18fda, 0x190c7, 0x191b5, 0x192a2, 0x19391, 0x19480, + 0x1956f }, + { 0x1965f, 0x19750, 0x19841, 0x19933, 0x19a25, 0x19b18, 0x19c0c, 0x19d00, + 0x19df4, 0x19ee9, 0x19fdf, 0x1a0d5, 0x1a1cc, 0x1a2c4, 0x1a3bc, 0x1a4b4, + 0x1a5ad, 0x1a6a7, 0x1a7a1, 0x1a89c, 0x1a998, 0x1aa94, 0x1ab90, 0x1ac8d, + 0x1ad8b }, + { 0x1ae89, 0x1af88, 0x1b088, 0x1b188, 0x1b289, 0x1b38a, 0x1b48c, 0x1b58f, + 0x1b692, 0x1b795, 0x1b89a, 0x1b99f, 0x1baa4, 0x1bbaa, 0x1bcb1, 0x1bdb8, + 0x1bec0, 0x1bfc9, 0x1c0d2, 0x1c1dc, 0x1c2e6, 0x1c3f1, 0x1c4fd, 0x1c609, + 0x1c716 }, + { 0x1c823, 0x1c931, 0x1ca40, 0x1cb50, 0x1cc60, 0x1cd70, 0x1ce81, 0x1cf93, + 0x1d0a6, 0x1d1b9, 0x1d2cd, 0x1d3e1, 0x1d4f6, 0x1d60c, 0x1d722, 0x1d839, + 0x1d951, 0x1da69, 0x1db82, 0x1dc9c, 0x1ddb6, 0x1ded1, 0x1dfec, 0x1e109, + 0x1e225 }, + { 0x1e343, 0x1e461, 0x1e580, 0x1e6a0, 0x1e7c0, 0x1e8e0, 0x1ea02, 0x1eb24, + 0x1ec47, 0x1ed6b, 0x1ee8f, 0x1efb4, 0x1f0d9, 0x1f1ff, 0x1f326, 0x1f44e, + 0x1f576, 0x1f69f, 0x1f7c9, 0x1f8f3, 0x1fa1e, 0x1fb4a, 0x1fc76, 0x1fda3, + 0x1fed1 } + }; + + +//static int PITCH_Installed = FALSE; + + +/*--------------------------------------------------------------------- + Function: PITCH_Init + + Initializes pitch table. +---------------------------------------------------------------------*/ +/* +void PITCH_Init + ( + void + ) + + { + int note; + int detune; + + if ( !PITCH_Installed ) + { + for( note = 0; note < 12; note++ ) + { + for( detune = 0; detune < MAXDETUNE; detune++ ) + { + PitchTable[ note ][ detune ] = 0x10000 * + pow( 2, ( note * MAXDETUNE + detune ) / ( 12.0 * MAXDETUNE ) ); + } + } + + PITCH_Installed = TRUE; + } + } +*/ + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +#define PITCH_LockStart PITCH_GetScale + + +/*--------------------------------------------------------------------- + Function: PITCH_GetScale + + Returns a fixed-point value to scale number the specified amount. +---------------------------------------------------------------------*/ + +unsigned long PITCH_GetScale +( + int pitchoffset +) + +{ + unsigned long scale; + int octaveshift; + int noteshift; + int note; + int detune; + +// if ( !PITCH_Installed ) +// { +// PITCH_Init(); +// } + + if (pitchoffset == 0) + { + return(PitchTable[ 0 ][ 0 ]); + } + + noteshift = pitchoffset % 1200; + if (noteshift < 0) + { + noteshift += 1200; + } + + note = noteshift / 100; + detune = (noteshift % 100) / (100 / MAXDETUNE); + octaveshift = (pitchoffset - noteshift) / 1200; + + if (detune < 0) + { + detune += (100 / MAXDETUNE); + note--; + if (note < 0) + { + note += 12; + octaveshift--; + } + } + + scale = PitchTable[ note ][ detune ]; + + if (octaveshift < 0) + { + scale >>= -octaveshift; + } + else + { + scale <<= octaveshift; + } + + return(scale); +} + + +/*--------------------------------------------------------------------- + Function: PITCH_LockEnd + + Used for determining the length of the functions to lock in memory. +---------------------------------------------------------------------*/ + +static void PITCH_LockEnd +( + void +) + +{} diff --git a/polymer/eduke32/source/jaudiolib/unixvoc.c b/polymer/eduke32/source/jaudiolib/unixvoc.c new file mode 100755 index 000000000..041cc0d80 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/unixvoc.c @@ -0,0 +1,2710 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +ou should have received a copy of the GNU General Public License +long with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +/********************************************************************** + module: MULTIVOC.C + + author: James R. Dose + date: December 20, 1993 + + Routines to provide multichannel digitized sound playback for + Sound Blaster compatible sound cards. + + (c) Copyright 1993 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +#include +#include +#include + +#include "util.h" +#include "dpmi.h" +#include "usrhooks.h" +#include "interrup.h" +#include "dma.h" +#include "linklist.h" +#include "dsl.h" + +#include "pitch.h" +#include "multivoc.h" +#include "_multivc.h" +#include "debugio.h" + +// platform.h is from the build engine, but I need the byteswapping macros... --ryan. +#include "platform.h" + +#define RoundFixed( fixedval, bits ) \ + ( \ + ( \ + (fixedval) + ( 1 << ( (bits) - 1 ) )\ + ) >> (bits) \ + ) + +#define IS_QUIET( ptr ) ( ( void * )( ptr ) == ( void * )&MV_VolumeTable[ 0 ] ) + +static int MV_ReverbLevel; +static int MV_ReverbDelay; +static VOLUME16 *MV_ReverbTable = NULL; + +//static signed short MV_VolumeTable[ MV_MaxVolume + 1 ][ 256 ]; +static signed short MV_VolumeTable[ 63 + 1 ][ 256 ]; + +//static Pan MV_PanTable[ MV_NumPanPositions ][ MV_MaxVolume + 1 ]; +static Pan MV_PanTable[ MV_NumPanPositions ][ 63 + 1 ]; + +static int MV_Installed = FALSE; +static int MV_SoundCard = 1; +static int MV_TotalVolume = MV_MaxTotalVolume; +static int MV_MaxVoices = 1; +static int MV_Recording; + +static int MV_BufferSize = MixBufferSize; +static int MV_BufferLength; + +static int MV_NumberOfBuffers = NumberOfBuffers; + +static int MV_MixMode = MONO_8BIT; +static int MV_Channels = 1; +static int MV_Bits = 8; + +static int MV_Silence = SILENCE_8BIT; +static int MV_SwapLeftRight = FALSE; + +static int MV_RequestedMixRate; +static int MV_MixRate; + +static int MV_DMAChannel = -1; +static int MV_BuffShift; + +static int MV_TotalMemory; + +static int MV_BufferDescriptor; +static int MV_BufferEmpty[ NumberOfBuffers ]; +char *MV_MixBuffer[ NumberOfBuffers + 1 ]; + +static VoiceNode *MV_Voices = NULL; + +static volatile VoiceNode VoiceList; +static volatile VoiceNode VoicePool; + +/*static*/ int MV_MixPage = 0; +static int MV_VoiceHandle = MV_MinVoiceHandle; + +static void(*MV_CallBackFunc)(unsigned long) = NULL; +static void(*MV_RecordFunc)(char *ptr, int length) = NULL; +static void(*MV_MixFunction)(VoiceNode *voice, int buffer); + +static int MV_MaxVolume = 63; + +char *MV_HarshClipTable; +char *MV_MixDestination; +short *MV_LeftVolume; +short *MV_RightVolume; +int MV_SampleSize = 1; +int MV_RightChannelOffset; + +unsigned long MV_MixPosition; + +int MV_ErrorCode = MV_Ok; + +#define MV_SetErrorCode( status ) \ + MV_ErrorCode = ( status ); + + +/*--------------------------------------------------------------------- + Function: MV_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *MV_ErrorString(int ErrorNumber) + +{ + char *ErrorString; + + switch (ErrorNumber) + { + case MV_Warning : + case MV_Error : + ErrorString = MV_ErrorString(MV_ErrorCode); + break; + + case MV_Ok : + ErrorString = "Multivoc ok."; + break; + + case MV_UnsupportedCard : + ErrorString = "Selected sound card is not supported by Multivoc."; + break; + + case MV_NotInstalled : + ErrorString = "Multivoc not installed."; + break; + + case MV_NoVoices : + ErrorString = "No free voices available to Multivoc."; + break; + + case MV_NoMem : + ErrorString = "Out of memory in Multivoc."; + break; + + case MV_VoiceNotFound : + ErrorString = "No voice with matching handle found."; + break; + + case MV_DPMI_Error : + ErrorString = "DPMI Error in Multivoc."; + break; + + case MV_InvalidVOCFile : + ErrorString = "Invalid VOC file passed in to Multivoc."; + break; + + case MV_InvalidWAVFile : + ErrorString = "Invalid WAV file passed in to Multivoc."; + break; + + case MV_InvalidMixMode : + ErrorString = "Invalid mix mode request in Multivoc."; + break; + + case MV_IrqFailure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting IRQ."; + break; + + case MV_DMAFailure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting DMA channel."; + break; + + case MV_DMA16Failure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting DMA channel. \n" + "Make sure the 16-bit DMA channel is correct."; + break; + + case MV_NullRecordFunction : + ErrorString = "Null record function passed to MV_StartRecording."; + break; + + default : + ErrorString = "Unknown Multivoc error code."; + break; + } + + return(ErrorString); +} + + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +#define MV_LockStart MV_Mix + + +/*--------------------------------------------------------------------- + Function: MV_Mix + + Mixes the sound into the buffer. +---------------------------------------------------------------------*/ + +static void MV_Mix(VoiceNode *voice, + int buffer) + +{ + char *start; + int length; + long voclength; + unsigned long position; + unsigned long rate; + unsigned long FixedPointBufferSize; + + if ((voice->length == 0) && + (voice->GetSound != NULL) && + (voice->GetSound(voice) != KeepPlaying)) + { + return; + } + + length = MixBufferSize; + FixedPointBufferSize = voice->FixedPointBufferSize; + + MV_MixDestination = MV_MixBuffer[ buffer ]; + MV_LeftVolume = voice->LeftVolume; + MV_RightVolume = voice->RightVolume; + + if ((MV_Channels == 2) && (IS_QUIET(MV_LeftVolume))) + { + MV_LeftVolume = MV_RightVolume; + MV_MixDestination += MV_RightChannelOffset; + } + + // Add this voice to the mix + while (length > 0) + { + start = voice->sound; + rate = voice->RateScale; + position = voice->position; + + // Check if the last sample in this buffer would be + // beyond the length of the sample block + if ((position + FixedPointBufferSize) >= voice->length) + { + if (position < voice->length) + { + voclength = (voice->length - position + rate - 1) / rate; + } + else + { + voice->GetSound(voice); + return; + } + } + else + { + voclength = length; + } + + voice->mix(position, rate, start, voclength); + + if (voclength & 1) + { + MV_MixPosition += rate; + voclength -= 1; + } + voice->position = MV_MixPosition; + + length -= voclength; + + if (voice->position >= voice->length) + { + // Get the next block of sound + if (voice->GetSound(voice) != KeepPlaying) + { + return; + } + + if (length > 0) + { + // Get the position of the last sample in the buffer + FixedPointBufferSize = voice->RateScale * (length - 1); + } + } + } +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayVoice + + Adds a voice to the play list. +---------------------------------------------------------------------*/ + +void MV_PlayVoice(VoiceNode *voice) + +{ + unsigned flags; + + flags = DisableInterrupts(); + LL_SortedInsertion(&VoiceList, voice, prev, next, VoiceNode, priority); + + RestoreInterrupts(flags); +} + + +/*--------------------------------------------------------------------- + Function: MV_StopVoice + + Removes the voice from the play list and adds it to the free list. +---------------------------------------------------------------------*/ + +void MV_StopVoice(VoiceNode *voice) + +{ + unsigned flags; + + flags = DisableInterrupts(); + + // move the voice from the play list to the free list + LL_Remove(voice, next, prev); + LL_Add((VoiceNode *)&VoicePool, voice, next, prev); + + RestoreInterrupts(flags); +} + + +/*--------------------------------------------------------------------- + Function: MV_ServiceVoc + + Starts playback of the waiting buffer and mixes the next one. +---------------------------------------------------------------------*/ + +// static int backcolor = 1; + +static int MV_ServiceVoc(int dummy_arg) +{ + VoiceNode *voice; + VoiceNode *next; + char *buffer; + + // Toggle which buffer we'll mix next + MV_MixPage++; + if (MV_MixPage >= MV_NumberOfBuffers) + { + MV_MixPage -= MV_NumberOfBuffers; + } + + if (MV_ReverbLevel == 0) + { + // Initialize buffer + //Commented out so that the buffer is always cleared. + //This is so the guys at Echo Speech can mix into the + //buffer even when no sounds are playing. + //if ( !MV_BufferEmpty[ MV_MixPage ] ) + { + ClearBuffer_DW(MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2); + MV_BufferEmpty[ MV_MixPage ] = TRUE; + } + } + else + { + char *end; + char *source; + char *dest; + int count; + int length; + + end = MV_MixBuffer[ 0 ] + MV_BufferLength;; + dest = MV_MixBuffer[ MV_MixPage ]; + source = MV_MixBuffer[ MV_MixPage ] - MV_ReverbDelay; + if (source < MV_MixBuffer[ 0 ]) + { + source += MV_BufferLength; + } + + length = MV_BufferSize; + while (length > 0) + { + count = length; + if (source + count > end) + { + count = end - source; + } + + if (MV_Bits == 16) + { + if (MV_ReverbTable != NULL) + MV_16BitReverb(source, dest, (const VOLUME16 *)MV_ReverbTable, count / 2); + else + MV_16BitReverbFast(source, dest, count / 2, MV_ReverbLevel); + } + else + { + if (MV_ReverbTable != NULL) + MV_8BitReverb(source, dest, (const VOLUME16 *)MV_ReverbTable, count); + else + MV_8BitReverbFast(source, dest, count, MV_ReverbLevel); + } + + // if we go through the loop again, it means that we've wrapped around the buffer + source = MV_MixBuffer[ 0 ]; + dest += count; + length -= count; + } + } + + // Play any waiting voices + for (voice = VoiceList.next; voice != &VoiceList; voice = next) + { +// if ( ( voice < &MV_Voices[ 0 ] ) || ( voice > &MV_Voices[ 8 ] ) ) +// { +// SetBorderColor(backcolor++); +// break; +// } + + MV_BufferEmpty[ MV_MixPage ] = FALSE; + + if (MV_MixFunction != NULL) + MV_MixFunction(voice, MV_MixPage); + + next = voice->next; + + // Is this voice done? + if (!voice->Playing) + { + MV_StopVoice(voice); + + if (MV_CallBackFunc) + { + MV_CallBackFunc(voice->callbackval); + } + } + } +} + + +int leftpage = -1; +int rightpage = -1; + +void MV_ServiceGus(char **ptr, unsigned long *length) +{ + if (leftpage == MV_MixPage) + { + MV_ServiceVoc(0); + } + + leftpage = MV_MixPage; + + *ptr = MV_MixBuffer[ MV_MixPage ]; + *length = MV_BufferSize; +} + +void MV_ServiceRightGus(char **ptr, unsigned long *length) +{ + if (rightpage == MV_MixPage) + { + MV_ServiceVoc(0); + } + + rightpage = MV_MixPage; + + *ptr = MV_MixBuffer[ MV_MixPage ] + MV_RightChannelOffset; + *length = MV_BufferSize; +} + +/*--------------------------------------------------------------------- + Function: MV_GetNextVOCBlock + + Interperate the information of a VOC format sound file. +---------------------------------------------------------------------*/ +static __inline unsigned int get_le32(void *p0) +{ + //unsigned char *p = p0; + //return p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24); + unsigned int val = *((unsigned int *) p0); + return(BUILDSWAP_INTEL32(val)); +} + +static __inline unsigned int get_le16(void *p0) +{ + //unsigned char *p = p0; + //return p[0] | (p[1]<<8); + unsigned short val = *((unsigned short *) p0); + return((unsigned int)(BUILDSWAP_INTEL16(val))); +} + +playbackstatus MV_GetNextVOCBlock(VoiceNode *voice) + +{ + unsigned char *ptr; + int blocktype=0; + int lastblocktype=0; + unsigned long blocklength=0l; + unsigned long samplespeed=0l; + unsigned int tc=0; + int packtype=0; + int voicemode=0; + int done=0; + unsigned BitsPerSample; + unsigned Channels; + unsigned Format; + + if (voice->BlockLength > 0) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + if (voice->bits == 16) + { + voice->sound += voice->length >> 16; + } + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } + + if ((voice->length > 0) && (voice->LoopEnd != NULL) && + (voice->LoopStart != NULL)) + { + voice->BlockLength = voice->LoopSize; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } + + ptr = (unsigned char *)voice->NextBlock; + + voice->Playing = TRUE; + + voicemode = 0; + lastblocktype = 0; + packtype = 0; + + done = FALSE; + while (!done) + { + // Stop playing if we get a NULL pointer + if (ptr == NULL) + { + voice->Playing = FALSE; + done = TRUE; + break; + } + + { + unsigned tmp = get_le32(ptr); + blocktype = tmp&255; + blocklength = tmp>>8; + } + ptr += 4; + + switch (blocktype) + { + case 0 : + // End of data + if ((voice->LoopStart == NULL) || + ((unsigned char *)voice->LoopStart >= (ptr - 4))) + { + voice->Playing = FALSE; + done = TRUE; + } + else + { + voice->BlockLength = (ptr - 4) - (unsigned char *)voice->LoopStart; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return(KeepPlaying); + } + break; + + case 1 : + // Sound data block + voice->bits = 8; + if (lastblocktype != 8) + { + tc = (unsigned int)*ptr << 8; + packtype = *(ptr + 1); + } + + ptr += 2; + blocklength -= 2; + + samplespeed = 256000000L / (65536 - tc); + + // Skip packed or stereo data + if ((packtype != 0) || (voicemode != 0)) + { + ptr += blocklength; + } + else + { + done = TRUE; + } + voicemode = 0; + break; + + case 2 : + // Sound continuation block + samplespeed = voice->SamplingRate; + done = TRUE; + break; + + case 3 : + // Silence + // Not implimented. + ptr += blocklength; + break; + + case 4 : + // Marker + // Not implimented. + ptr += blocklength; + break; + + case 5 : + // ASCII string + // Not implimented. + ptr += blocklength; + break; + + case 6 : + // Repeat begin + if (voice->LoopEnd == NULL) + { + voice->LoopCount = get_le16(ptr); + voice->LoopStart = ptr + blocklength; + } + ptr += blocklength; + break; + + case 7 : + // Repeat end + ptr += blocklength; + if (lastblocktype == 6) + { + voice->LoopCount = 0; + } + else + { + if ((voice->LoopCount > 0) && (voice->LoopStart != NULL)) + { + ptr = voice->LoopStart; + if (voice->LoopCount < 0xffff) + { + voice->LoopCount--; + if (voice->LoopCount == 0) + { + voice->LoopStart = NULL; + } + } + } + } + break; + + case 8 : + // Extended block + voice->bits = 8; + tc = get_le16(ptr); + packtype = *(ptr + 2); + voicemode = *(ptr + 3); + ptr += blocklength; + break; + + case 9 : + // New sound data block + samplespeed = get_le32(ptr); + BitsPerSample = ptr[4]; + Channels = ptr[5]; + Format = get_le16(ptr+6); + + if ((BitsPerSample == 8) && (Channels == 1) && + (Format == VOC_8BIT)) + { + ptr += 12; + blocklength -= 12; + voice->bits = 8; + done = TRUE; + } + else if ((BitsPerSample == 16) && (Channels == 1) && + (Format == VOC_16BIT)) + { + ptr += 12; + blocklength -= 12; + voice->bits = 16; + done = TRUE; + } + else + { + ptr += blocklength; + } + break; + + default : + // Unknown data. Probably not a VOC file. + voice->Playing = FALSE; + done = TRUE; + break; + } + + lastblocktype = blocktype; + } + + if (voice->Playing) + { + voice->NextBlock = ptr + blocklength; + voice->sound = ptr; + + voice->SamplingRate = samplespeed; + voice->RateScale = (voice->SamplingRate * voice->PitchScale) / MV_MixRate; + + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = (voice->RateScale * MixBufferSize) - + voice->RateScale; + + if (voice->LoopEnd != NULL) + { + if (blocklength > (unsigned long)voice->LoopEnd) + { + blocklength = (unsigned long)voice->LoopEnd; + } + else + { + voice->LoopEnd = (char *)blocklength; + } + + voice->LoopStart = voice->sound + (unsigned long)voice->LoopStart; + voice->LoopEnd = voice->sound + (unsigned long)voice->LoopEnd; + voice->LoopSize = voice->LoopEnd - voice->LoopStart; + } + + if (voice->bits == 16) + { + blocklength /= 2; + } + + voice->position = 0; + voice->length = min(blocklength, 0x8000); + voice->BlockLength = blocklength - voice->length; + voice->length <<= 16; + + MV_SetVoiceMixMode(voice); + + return(KeepPlaying); + } + + return(NoMoreData); +} + + +/*--------------------------------------------------------------------- + Function: MV_GetNextDemandFeedBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextDemandFeedBlock(VoiceNode *voice) + +{ + if (voice->BlockLength > 0) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return(KeepPlaying); + } + + if (voice->DemandFeed == NULL) + { + return(NoMoreData); + } + + voice->position = 0; + (voice->DemandFeed)(&voice->sound, &voice->BlockLength); + voice->length = min(voice->BlockLength, 0x8000); + voice->BlockLength -= voice->length; + voice->length <<= 16; + + if ((voice->length > 0) && (voice->sound != NULL)) + { + return(KeepPlaying); + } + return(NoMoreData); +} + + +/*--------------------------------------------------------------------- + Function: MV_GetNextRawBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextRawBlock(VoiceNode *voice) + +{ + if (voice->BlockLength <= 0) + { + if (voice->LoopStart == NULL) + { + voice->Playing = FALSE; + return(NoMoreData); + } + + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } + + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min(voice->BlockLength, 0x8000); + voice->NextBlock += voice->length; + if (voice->bits == 16) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return(KeepPlaying); +} + + +/*--------------------------------------------------------------------- + Function: MV_GetNextWAVBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextWAVBlock(VoiceNode *voice) + +{ + if (voice->BlockLength <= 0) + { + if (voice->LoopStart == NULL) + { + voice->Playing = FALSE; + return(NoMoreData); + } + + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } + + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min(voice->BlockLength, 0x8000); + voice->NextBlock += voice->length; + if (voice->bits == 16) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return(KeepPlaying); +} + + +/*--------------------------------------------------------------------- + Function: MV_ServiceRecord + + Starts recording of the waiting buffer. +---------------------------------------------------------------------*/ + +static void MV_ServiceRecord(void) + +{ + if (MV_RecordFunc) + { + MV_RecordFunc(MV_MixBuffer[ 0 ] + MV_MixPage * MixBufferSize, + MixBufferSize); + } + + // Toggle which buffer we'll mix next + MV_MixPage++; + if (MV_MixPage >= NumberOfBuffers) + { + MV_MixPage = 0; + } +} + + +/*--------------------------------------------------------------------- + Function: MV_GetVoice + + Locates the voice with the specified handle. +---------------------------------------------------------------------*/ + +VoiceNode *MV_GetVoice(int handle) + +{ + VoiceNode *voice; + unsigned flags; + + flags = DisableInterrupts(); + + for (voice = VoiceList.next; voice != &VoiceList; voice = voice->next) + { + if (handle == voice->handle) + { + break; + } + } + + RestoreInterrupts(flags); + + if (voice == &VoiceList) + { + MV_SetErrorCode(MV_VoiceNotFound); + + // SBF - should this return null? + return NULL; + } + + return(voice); +} + + +/*--------------------------------------------------------------------- + Function: MV_VoicePlaying + + Checks if the voice associated with the specified handle is + playing. +---------------------------------------------------------------------*/ + +int MV_VoicePlaying(int handle) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(FALSE); + } + + voice = MV_GetVoice(handle); + + if (voice == NULL) + { + return(FALSE); + } + + return(TRUE); +} + + +/*--------------------------------------------------------------------- + Function: MV_KillAllVoices + + Stops output of all currently active voices. +---------------------------------------------------------------------*/ + +int MV_KillAllVoices(void) + +{ + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + // Remove all the voices from the list + while (VoiceList.next != &VoiceList) + { + MV_Kill(VoiceList.next->handle); + } + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_Kill + + Stops output of the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_Kill(int handle) + +{ + VoiceNode *voice; + unsigned flags; + unsigned long callbackval; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + flags = DisableInterrupts(); + + voice = MV_GetVoice(handle); + if (voice == NULL) + { + RestoreInterrupts(flags); + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } + + callbackval = voice->callbackval; + + MV_StopVoice(voice); + + RestoreInterrupts(flags); + + if (MV_CallBackFunc) + { + MV_CallBackFunc(callbackval); + } + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_VoicesPlaying + + Determines the number of currently active voices. +---------------------------------------------------------------------*/ + +int MV_VoicesPlaying(void) + +{ + VoiceNode *voice; + int NumVoices = 0; + unsigned flags; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(0); + } + + flags = DisableInterrupts(); + + for (voice = VoiceList.next; voice != &VoiceList; voice = voice->next) + { + NumVoices++; + } + + RestoreInterrupts(flags); + + return(NumVoices); +} + + +/*--------------------------------------------------------------------- + Function: MV_AllocVoice + + Retrieve an inactive or lower priority voice for output. +---------------------------------------------------------------------*/ + +VoiceNode *MV_AllocVoice(int priority) + +{ + VoiceNode *voice; + VoiceNode *node; + unsigned flags; + +//return( NULL ); + if (MV_Recording) + { + return(NULL); + } + + flags = DisableInterrupts(); + + // Check if we have any free voices + if (LL_Empty(&VoicePool, next, prev)) + { + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for (node = voice->next; node != &VoiceList; node = node->next) + { + if (node->priority < voice->priority) + { + voice = node; + } + } + + if (priority >= voice->priority) + { + MV_Kill(voice->handle); + } + } + + // Check if any voices are in the voice pool + if (LL_Empty(&VoicePool, next, prev)) + { + // No free voices + RestoreInterrupts(flags); + return(NULL); + } + + voice = VoicePool.next; + LL_Remove(voice, next, prev); + RestoreInterrupts(flags); + + // Find a free voice handle + do + { + MV_VoiceHandle++; + if (MV_VoiceHandle < MV_MinVoiceHandle) + { + MV_VoiceHandle = MV_MinVoiceHandle; + } + } + while (MV_VoicePlaying(MV_VoiceHandle)); + + voice->handle = MV_VoiceHandle; + + return(voice); +} + + +/*--------------------------------------------------------------------- + Function: MV_VoiceAvailable + + Checks if a voice can be play at the specified priority. +---------------------------------------------------------------------*/ + +int MV_VoiceAvailable(int priority) + +{ + VoiceNode *voice; + VoiceNode *node; + unsigned flags; + + // Check if we have any free voices + if (!LL_Empty(&VoicePool, next, prev)) + { + return(TRUE); + } + + flags = DisableInterrupts(); + + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for (node = VoiceList.next; node != &VoiceList; node = node->next) + { + if (node->priority < voice->priority) + { + voice = node; + } + } + + RestoreInterrupts(flags); + + if ((voice != &VoiceList) && (priority >= voice->priority)) + { + return(TRUE); + } + + return(FALSE); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetVoicePitch + + Sets the pitch for the specified voice. +---------------------------------------------------------------------*/ + +void MV_SetVoicePitch(VoiceNode *voice, + unsigned long rate, + int pitchoffset) + +{ + voice->SamplingRate = rate; + voice->PitchScale = PITCH_GetScale(pitchoffset); + voice->RateScale = (rate * voice->PitchScale) / MV_MixRate; + + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = (voice->RateScale * MixBufferSize) - + voice->RateScale; +} + + +/*--------------------------------------------------------------------- + Function: MV_SetPitch + + Sets the pitch for the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetPitch(int handle, + int pitchoffset) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } + + MV_SetVoicePitch(voice, voice->SamplingRate, pitchoffset); + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetFrequency + + Sets the frequency for the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetFrequency(int handle, + int frequency) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Error); + } + + MV_SetVoicePitch(voice, frequency, 0); + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_GetVolumeTable + + Returns a pointer to the volume table associated with the specified + volume. +---------------------------------------------------------------------*/ + +static short *MV_GetVolumeTable(int vol) + +{ + int volume; + short *table; + + volume = MIX_VOLUME(vol); + + table = (short *)&MV_VolumeTable[ volume ]; + + return(table); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetVoiceMixMode + + Selects which method should be used to mix the voice. +---------------------------------------------------------------------*/ + +static void MV_SetVoiceMixMode(VoiceNode *voice) + +{ + unsigned flags; + int test; + + flags = DisableInterrupts(); + + test = T_DEFAULT; + if (MV_Bits == 8) + { + test |= T_8BITS; + } + + if (voice->bits == 16) + { + test |= T_16BITSOURCE; + } + + if (MV_Channels == 1) + { + test |= T_MONO; + } + else + { + if (IS_QUIET(voice->RightVolume)) + { + test |= T_RIGHTQUIET; + } + else if (IS_QUIET(voice->LeftVolume)) + { + test |= T_LEFTQUIET; + } + } + + // Default case + voice->mix = MV_Mix8BitMono; + + switch (test) + { + case T_8BITS | T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_MONO : + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE : + voice->mix = MV_Mix8BitStereo16; + break; + + case T_8BITS : + voice->mix = MV_Mix8BitStereo; + break; + + case T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix16BitMono16; + break; + + case T_MONO : + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono16; + break; + + case T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono16; + break; + + case T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE : + voice->mix = MV_Mix16BitStereo16; + break; + + case T_SIXTEENBIT_STEREO : + voice->mix = MV_Mix16BitStereo; + break; + + default : + voice->mix = MV_Mix8BitMono; + } + + RestoreInterrupts(flags); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetVoiceVolume + + Sets the stereo and mono volume level of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +void MV_SetVoiceVolume(VoiceNode *voice, + int vol, + int left, + int right) + +{ + if (MV_Channels == 1) + { + left = vol; + right = vol; + } + + if (MV_SwapLeftRight) + { + // SBPro uses reversed panning + voice->LeftVolume = MV_GetVolumeTable(right); + voice->RightVolume = MV_GetVolumeTable(left); + } + else + { + voice->LeftVolume = MV_GetVolumeTable(left); + voice->RightVolume = MV_GetVolumeTable(right); + } + + MV_SetVoiceMixMode(voice); +} + + +/*--------------------------------------------------------------------- + Function: MV_EndLooping + + Stops the voice associated with the specified handle from looping + without stoping the sound. +---------------------------------------------------------------------*/ + +int MV_EndLooping(int handle) + +{ + VoiceNode *voice; + unsigned flags; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + flags = DisableInterrupts(); + + voice = MV_GetVoice(handle); + if (voice == NULL) + { + RestoreInterrupts(flags); + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Warning); + } + + voice->LoopCount = 0; + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + + RestoreInterrupts(flags); + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetPan + + Sets the stereo and mono volume level of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetPan(int handle, + int vol, + int left, + int right) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + voice = MV_GetVoice(handle); + if (voice == NULL) + { + MV_SetErrorCode(MV_VoiceNotFound); + return(MV_Warning); + } + + MV_SetVoiceVolume(voice, vol, left, right); + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_Pan3D + + Set the angle and distance from the listener of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int MV_Pan3D(int handle, + int angle, + int distance) + +{ + int left; + int right; + int mid; + int volume; + int status; + + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME(distance); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); + + status = MV_SetPan(handle, mid, left, right); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetReverb + + Sets the level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetReverb(int reverb) + +{ + MV_ReverbLevel = MIX_VOLUME(reverb); + MV_ReverbTable = &MV_VolumeTable[ MV_ReverbLevel ]; +} + + +/*--------------------------------------------------------------------- + Function: MV_SetFastReverb + + Sets the level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetFastReverb(int reverb) + +{ + MV_ReverbLevel = max(0, min(16, reverb)); + MV_ReverbTable = NULL; +} + + +/*--------------------------------------------------------------------- + Function: MV_GetMaxReverbDelay + + Returns the maximum delay time for reverb. +---------------------------------------------------------------------*/ + +int MV_GetMaxReverbDelay(void) + +{ + int maxdelay; + + maxdelay = MixBufferSize * MV_NumberOfBuffers; + + return maxdelay; +} + + +/*--------------------------------------------------------------------- + Function: MV_GetReverbDelay + + Returns the current delay time for reverb. +---------------------------------------------------------------------*/ + +int MV_GetReverbDelay(void) + +{ + return MV_ReverbDelay / MV_SampleSize; +} + + +/*--------------------------------------------------------------------- + Function: MV_SetReverbDelay + + Sets the delay level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetReverbDelay(int delay) + +{ + int maxdelay; + + maxdelay = MV_GetMaxReverbDelay(); + MV_ReverbDelay = max(MixBufferSize, min(delay, maxdelay)); + MV_ReverbDelay *= MV_SampleSize; +} + + +/*--------------------------------------------------------------------- + Function: MV_SetMixMode + + Prepares Multivoc to play stereo of mono digitized sounds. +---------------------------------------------------------------------*/ + +int MV_SetMixMode(int numchannels, + int samplebits) + +{ + int mode; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + mode = 0; + if (numchannels == 2) + { + mode |= STEREO; + } + if (samplebits == 16) + { + mode |= SIXTEEN_BIT; + } + + MV_MixMode = mode; + + MV_Channels = 1; + if (MV_MixMode & STEREO) + { + MV_Channels = 2; + } + + MV_Bits = 8; + if (MV_MixMode & SIXTEEN_BIT) + { + MV_Bits = 16; + } + + MV_BuffShift = 7 + MV_Channels; + MV_SampleSize = sizeof(MONO8) * MV_Channels; + + if (MV_Bits == 8) + { + MV_Silence = SILENCE_8BIT; + } + else + { + MV_Silence = SILENCE_16BIT; + MV_BuffShift += 1; + MV_SampleSize *= 2; + } + + MV_BufferSize = MixBufferSize * MV_SampleSize; + MV_NumberOfBuffers = TotalBufferSize / MV_BufferSize; + MV_BufferLength = TotalBufferSize; + + MV_RightChannelOffset = MV_SampleSize / 2; + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_StartPlayback + + Starts the sound playback engine. +---------------------------------------------------------------------*/ + +int MV_StartPlayback(void) + +{ + int status; + int buffer; + + // Initialize the buffers + ClearBuffer_DW(MV_MixBuffer[ 0 ], MV_Silence, TotalBufferSize >> 2); + for (buffer = 0; buffer < MV_NumberOfBuffers; buffer++) + { + MV_BufferEmpty[ buffer ] = TRUE; + } + + // Set the mix buffer variables + MV_MixPage = 1; + + MV_MixFunction = MV_Mix; + + status = DSL_BeginBufferedPlayback(MV_MixBuffer[ 0 ], + TotalBufferSize, MV_NumberOfBuffers, + MV_RequestedMixRate, MV_MixMode, MV_ServiceVoc); + + if (status != DSL_Ok) + { + MV_SetErrorCode(MV_BlasterError); + return(MV_Error); + } + + MV_MixRate = DSL_GetPlaybackRate(); + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_StopPlayback + + Stops the sound playback engine. +---------------------------------------------------------------------*/ + +void MV_StopPlayback(void) + +{ + VoiceNode *voice; + VoiceNode *next; + unsigned flags; + + DSL_StopPlayback(); + + // Make sure all callbacks are done. + flags = DisableInterrupts(); + + for (voice = VoiceList.next; voice != &VoiceList; voice = next) + { + next = voice->next; + + MV_StopVoice(voice); + + if (MV_CallBackFunc) + { + MV_CallBackFunc(voice->callbackval); + } + } + + RestoreInterrupts(flags); +} + + +/*--------------------------------------------------------------------- + Function: MV_StartRecording + + Starts the sound recording engine. +---------------------------------------------------------------------*/ + +int MV_StartRecording(int MixRate, + void(*function)(char *ptr, int length)) + +{ + MV_SetErrorCode(MV_UnsupportedCard); + return(MV_Error); +} + + +/*--------------------------------------------------------------------- + Function: MV_StopRecord + + Stops the sound record engine. +---------------------------------------------------------------------*/ + +void MV_StopRecord(void) + +{} + + +/*--------------------------------------------------------------------- + Function: MV_StartDemandFeedPlayback + + Plays a digitized sound from a user controlled buffering system. +---------------------------------------------------------------------*/ + +int MV_StartDemandFeedPlayback(void(*function)(char **ptr, unsigned long *length), + int rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } + + voice->wavetype = DemandFeed; + voice->bits = 8; + voice->GetSound = MV_GetNextDemandFeedBlock; + voice->NextBlock = NULL; + voice->DemandFeed = function; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->position = 0; + voice->sound = NULL; + voice->length = 0; + voice->BlockLength = 0; + voice->Playing = TRUE; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + + MV_SetVoicePitch(voice, rate, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); + + return(voice->handle); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayRaw + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayRaw(char *ptr, + unsigned long length, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + int status; + + status = MV_PlayLoopedRaw(ptr, length, NULL, NULL, rate, pitchoffset, + vol, left, right, priority, callbackval); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedRaw + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedRaw(char *ptr, + long length, + char *loopstart, + char *loopend, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + VoiceNode *voice; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } + + voice->wavetype = Raw; + voice->bits = 8; + voice->GetSound = MV_GetNextRawBlock; + voice->Playing = TRUE; + voice->NextBlock = ptr; + voice->position = 0; + voice->BlockLength = length; + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = loopstart; + voice->LoopEnd = loopend; + voice->LoopSize = (voice->LoopEnd - voice->LoopStart) + 1; + + MV_SetVoicePitch(voice, rate, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); + + return(voice->handle); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayWAV + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayWAV(char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + int status; + + status = MV_PlayLoopedWAV(ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayWAV3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int MV_PlayWAV3D(char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval) + +{ + int left; + int right; + int mid; + int volume; + int status; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME(distance); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); + + status = MV_PlayWAV(ptr, pitchoffset, mid, left, right, priority, + callbackval); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedWAV + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedWAV(char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + riff_header *riff; + format_header *format; + data_header *data; + VoiceNode *voice; + int length; + int absloopend; + int absloopstart; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + riff = (riff_header *)ptr; + + if ((strncmp(riff->RIFF, "RIFF", 4) != 0) || + (strncmp(riff->WAVE, "WAVE", 4) != 0) || + (strncmp(riff->fmt, "fmt ", 4) != 0)) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } + + format = (format_header *)(riff + 1); + data = (data_header *)(((char *)format) + riff->format_size); + + // Check if it's PCM data. + if (format->wFormatTag != 1) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } + + if (format->nChannels != 1) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } + + if ((format->nBitsPerSample != 8) && + (format->nBitsPerSample != 16)) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } + + if (strncmp(data->DATA, "data", 4) != 0) + { + MV_SetErrorCode(MV_InvalidWAVFile); + return(MV_Error); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } + + voice->wavetype = WAV; + voice->bits = format->nBitsPerSample; + voice->GetSound = MV_GetNextWAVBlock; + + length = data->size; + absloopstart = loopstart; + absloopend = loopend; + if (voice->bits == 16) + { + loopstart *= 2; + data->size &= ~1; + loopend *= 2; + length /= 2; + } + + loopend = min(loopend, (long)data->size); + absloopend = min(absloopend, length); + + voice->Playing = TRUE; + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->position = 0; + voice->length = 0; + voice->BlockLength = absloopend; + voice->NextBlock = (char *)(data + 1); + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = voice->NextBlock + loopstart; + voice->LoopEnd = voice->NextBlock + loopend; + voice->LoopSize = absloopend - absloopstart; + + if ((loopstart >= (long)data->size) || (loopstart < 0)) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + voice->BlockLength = length; + } + + MV_SetVoicePitch(voice, format->nSamplesPerSec, pitchoffset); + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); + + return(voice->handle); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayVOC3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int MV_PlayVOC3D(char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval) + +{ + int left; + int right; + int mid; + int volume; + int status; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + if (distance < 0) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME(distance); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max(0, 255 - distance); + + status = MV_PlayVOC(ptr, pitchoffset, mid, left, right, priority, + callbackval); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayVOC + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayVOC(char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + int status; + + status = MV_PlayLoopedVOC(ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval); + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedVOC + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedVOC(char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval) + +{ + VoiceNode *voice; + int status; + unsigned short nextpos; + + if (!MV_Installed) + { + MV_SetErrorCode(MV_NotInstalled); + return(MV_Error); + } + + // Make sure it's a valid VOC file. + status = strncmp(ptr, "Creative Voice File", 19); + if (status != 0) + { + MV_SetErrorCode(MV_InvalidVOCFile); + return(MV_Error); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice(priority); + if (voice == NULL) + { + MV_SetErrorCode(MV_NoVoices); + return(MV_Error); + } + + voice->wavetype = VOC; + voice->bits = 8; + voice->GetSound = MV_GetNextVOCBlock; + + nextpos = *(unsigned short *)(ptr + 0x14); + voice->NextBlock = ptr + BUILDSWAP_INTEL16(nextpos); + + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->PitchScale = PITCH_GetScale(pitchoffset); + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = (char *)loopstart; + voice->LoopEnd = (char *)loopend; + voice->LoopSize = loopend - loopstart + 1; + + if (loopstart < 0) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + } + + MV_SetVoiceVolume(voice, vol, left, right); + MV_PlayVoice(voice); + + return(voice->handle); +} + + +/*--------------------------------------------------------------------- + Function: MV_LockEnd + + Used for determining the length of the functions to lock in memory. +---------------------------------------------------------------------*/ + +static void MV_LockEnd(void) + +{} + + +/*--------------------------------------------------------------------- + Function: MV_CreateVolumeTable + + Create the table used to convert sound data to a specific volume + level. +---------------------------------------------------------------------*/ + +void MV_CreateVolumeTable(int index, + int volume, + int MaxVolume) + +{ + int val; + int level; + int i; + + level = (volume * MaxVolume) / MV_MaxTotalVolume; + if (MV_Bits == 16) + { + for (i = 0; i < 65536; i += 256) + { + val = i - 0x8000; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ index ][ i / 256 ] = val; + } + } + else + { + for (i = 0; i < 256; i++) + { + val = i - 0x80; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ volume ][ i ] = val; + } + } +} + + +/*--------------------------------------------------------------------- + Function: MV_CalcVolume + + Create the table used to convert sound data to a specific volume + level. +---------------------------------------------------------------------*/ + +void MV_CalcVolume(int MaxVolume) + +{ + int volume; + + for (volume = 0; volume < 128; volume++) + { + MV_HarshClipTable[ volume ] = 0; + MV_HarshClipTable[ volume + 384 ] = 255; + } + for (volume = 0; volume < 256; volume++) + { + MV_HarshClipTable[ volume + 128 ] = volume; + } + + // For each volume level, create a translation table with the + // appropriate volume calculated. + for (volume = 0; volume <= MV_MaxVolume; volume++) + { + MV_CreateVolumeTable(volume, volume, MaxVolume); + } +} + + +/*--------------------------------------------------------------------- + Function: MV_CalcPanTable + + Create the table used to determine the stereo volume level of + a sound located at a specific angle and distance from the listener. +---------------------------------------------------------------------*/ + +void MV_CalcPanTable(void) + +{ + int level; + int angle; + int distance; + int HalfAngle; + int ramp; + + HalfAngle = (MV_NumPanPositions / 2); + + for (distance = 0; distance <= MV_MaxVolume; distance++) + { + level = (255 * (MV_MaxVolume - distance)) / MV_MaxVolume; + for (angle = 0; angle <= HalfAngle / 2; angle++) + { + ramp = level - ((level * angle) / + (MV_NumPanPositions / 4)); + + MV_PanTable[ angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle - angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle + angle ][ distance ].left = level; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].left = level; + + MV_PanTable[ angle ][ distance ].right = level; + MV_PanTable[ HalfAngle - angle ][ distance ].right = level; + MV_PanTable[ HalfAngle + angle ][ distance ].right = ramp; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].right = ramp; + } + } +} + + +/*--------------------------------------------------------------------- + Function: MV_SetVolume + + Sets the volume of digitized sound playback. +---------------------------------------------------------------------*/ + +void MV_SetVolume(int volume) + +{ + volume = max(0, volume); + volume = min(volume, MV_MaxTotalVolume); + + MV_TotalVolume = volume; + + // Calculate volume table + MV_CalcVolume(volume); +} + + +/*--------------------------------------------------------------------- + Function: MV_GetVolume + + Returns the volume of digitized sound playback. +---------------------------------------------------------------------*/ + +int MV_GetVolume(void) + +{ + return(MV_TotalVolume); +} + + +/*--------------------------------------------------------------------- + Function: MV_SetCallBack + + Set the function to call when a voice stops. +---------------------------------------------------------------------*/ + +void MV_SetCallBack(void(*function)(unsigned long)) + +{ + MV_CallBackFunc = function; +} + + +/*--------------------------------------------------------------------- + Function: MV_SetReverseStereo + + Set the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +void MV_SetReverseStereo(int setting) + +{ + MV_SwapLeftRight = setting; +} + + +/*--------------------------------------------------------------------- + Function: MV_GetReverseStereo + + Returns the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +int MV_GetReverseStereo(void) + +{ + return(MV_SwapLeftRight); +} + + +/*--------------------------------------------------------------------- + Function: MV_TestPlayback + + Checks if playback has started. +---------------------------------------------------------------------*/ + +int MV_TestPlayback(void) +{ + return MV_Ok; +} + + +/*--------------------------------------------------------------------- + Function: MV_Init + + Perform the initialization of variables and memory used by + Multivoc. +---------------------------------------------------------------------*/ + +int MV_Init(int soundcard, + int MixRate, + int Voices, + int numchannels, + int samplebits) + +{ + char *ptr; + int status; + int buffer; + int index; + + if (MV_Installed) + { + MV_Shutdown(); + } + + MV_SetErrorCode(MV_Ok); + + MV_TotalMemory = Voices * sizeof(VoiceNode) + sizeof(HARSH_CLIP_TABLE_8); + status = USRHOOKS_GetMem((void **)&ptr, MV_TotalMemory); + if (status != USRHOOKS_Ok) + { + MV_SetErrorCode(MV_NoMem); + return(MV_Error); + } + + MV_Voices = (VoiceNode *)ptr; + MV_HarshClipTable = ptr + (MV_TotalMemory - sizeof(HARSH_CLIP_TABLE_8)); + + // Set number of voices before calculating volume table + MV_MaxVoices = Voices; + + LL_Reset((VoiceNode *)&VoiceList, next, prev); + LL_Reset((VoiceNode *)&VoicePool, next, prev); + + for (index = 0; index < Voices; index++) + { + LL_Add((VoiceNode *)&VoicePool, &MV_Voices[ index ], next, prev); + } + + // Allocate mix buffer within 1st megabyte + status = DPMI_GetDOSMemory((void **)&ptr, &MV_BufferDescriptor, + 2 * TotalBufferSize); + + if (status) + { + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; + + MV_SetErrorCode(MV_NoMem); + return(MV_Error); + } + + MV_SetReverseStereo(FALSE); + + // Initialize the sound card + status = DSL_Init(); + if (status != DSL_Ok) + { + MV_SetErrorCode(MV_BlasterError); + } + + if (MV_ErrorCode != MV_Ok) + { + status = MV_ErrorCode; + + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; + + DPMI_FreeDOSMemory(MV_BufferDescriptor); + + MV_SetErrorCode(status); + return(MV_Error); + } + + MV_SoundCard = soundcard; + MV_Installed = TRUE; + MV_CallBackFunc = NULL; + MV_RecordFunc = NULL; + MV_Recording = FALSE; + MV_ReverbLevel = 0; + MV_ReverbTable = NULL; + + // Set the sampling rate + MV_RequestedMixRate = MixRate; + + // Set Mixer to play stereo digitized sound + MV_SetMixMode(numchannels, samplebits); + MV_ReverbDelay = MV_BufferSize * 3; + + MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; + for (buffer = 0; buffer < MV_NumberOfBuffers; buffer++) + { + MV_MixBuffer[ buffer ] = ptr; + ptr += MV_BufferSize; + } + + // Calculate pan table + MV_CalcPanTable(); + + MV_SetVolume(MV_MaxTotalVolume); + + // Start the playback engine + status = MV_StartPlayback(); + if (status != MV_Ok) + { + // Preserve error code while we shutdown. + status = MV_ErrorCode; + MV_Shutdown(); + MV_SetErrorCode(status); + return(MV_Error); + } + + if (MV_TestPlayback() != MV_Ok) + { + status = MV_ErrorCode; + MV_Shutdown(); + MV_SetErrorCode(status); + return(MV_Error); + } + + return(MV_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MV_Shutdown + + Restore any resources allocated by Multivoc back to the system. +---------------------------------------------------------------------*/ + +int MV_Shutdown(void) + +{ + int buffer; + unsigned flags; + + if (!MV_Installed) + { + return(MV_Ok); + } + + flags = DisableInterrupts(); + + MV_KillAllVoices(); + + MV_Installed = FALSE; + + // Stop the sound recording engine + if (MV_Recording) + { + MV_StopRecord(); + } + + // Stop the sound playback engine + MV_StopPlayback(); + + // Shutdown the sound card + DSL_Shutdown(); + + RestoreInterrupts(flags); + + // Free any voices we allocated + USRHOOKS_FreeMem(MV_Voices); + MV_Voices = NULL; + MV_TotalMemory = 0; + + LL_Reset((VoiceNode *)&VoiceList, next, prev); + LL_Reset((VoiceNode *)&VoicePool, next, prev); + + MV_MaxVoices = 1; + + // Release the descriptor from our mix buffer + DPMI_FreeDOSMemory(MV_BufferDescriptor); + for (buffer = 0; buffer < NumberOfBuffers; buffer++) + { + MV_MixBuffer[ buffer ] = NULL; + } + + return(MV_Ok); +} diff --git a/polymer/eduke32/source/jaudiolib/util.h b/polymer/eduke32/source/jaudiolib/util.h new file mode 100755 index 000000000..95183f34c --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/util.h @@ -0,0 +1,12 @@ +#ifndef AUDIOLIB__UTIL_H +#define AUDIOLIB__UTIL_H + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 3e72758e3..c279257fb 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -41,15 +41,10 @@ static int currentlist=0; static int function, whichkey; static int changesmade, newvidmode, curvidmode, newfullscreen; -static int vidsets[16] = - { - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 - } - , curvidset, newvidset = 0; +static int vidsets[16] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; +static int curvidset, newvidset = 0; -static char *mousebuttonnames[] = - { "Left", "Right", "Middle", "Thumb", "Wheel Down", "Wheel Up" - }; +static char *mousebuttonnames[] = { "Left", "Right", "Middle", "Thumb", "Wheel Down", "Wheel Up" }; extern int gotvote[MAXPLAYERS], votes[MAXPLAYERS], voting; @@ -232,34 +227,34 @@ int menutext_(int x,int y,short s,short p,char *t) ac = *(t+i) - 'A' + BIGALPHANUM; else switch (*(t+i)) { - case '-': - ac = BIGALPHANUM-11; - break; - case '.': - ac = BIGPERIOD; - break; - case '\'': - ac = BIGAPPOS; - break; - case ',': - ac = BIGCOMMA; - break; - case '!': - ac = BIGX; - break; - case '?': - ac = BIGQ; - break; - case ';': - ac = BIGSEMI; - break; - case ':': - ac = BIGSEMI; - break; - default: - centre += 5; - i++; - continue; + case '-': + ac = BIGALPHANUM-11; + break; + case '.': + ac = BIGPERIOD; + break; + case '\'': + ac = BIGAPPOS; + break; + case ',': + ac = BIGCOMMA; + break; + case '!': + ac = BIGX; + break; + case '?': + ac = BIGQ; + break; + case ';': + ac = BIGSEMI; + break; + case ':': + ac = BIGSEMI; + break; + default: + centre += 5; + i++; + continue; } centre += tilesizx[ac]-1; @@ -287,34 +282,34 @@ int menutext_(int x,int y,short s,short p,char *t) ac = *t - 'A' + BIGALPHANUM; else switch (*t) { - case '-': - ac = BIGALPHANUM-11; - break; - case '.': - ac = BIGPERIOD; - break; - case ',': - ac = BIGCOMMA; - break; - case '!': - ac = BIGX; - break; - case '\'': - ac = BIGAPPOS; - break; - case '?': - ac = BIGQ; - break; - case ';': - ac = BIGSEMI; - break; - case ':': - ac = BIGCOLIN; - break; - default: - x += 5; - t++; - continue; + case '-': + ac = BIGALPHANUM-11; + break; + case '.': + ac = BIGPERIOD; + break; + case ',': + ac = BIGCOMMA; + break; + case '!': + ac = BIGX; + break; + case '\'': + ac = BIGAPPOS; + break; + case '?': + ac = BIGQ; + break; + case ';': + ac = BIGSEMI; + break; + case ':': + ac = BIGCOLIN; + break; + default: + x += 5; + t++; + continue; } rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,10+16,0,0,xdim-1,ydim-1); @@ -634,1418 +629,1439 @@ void menus(void) switch (current_menu) { - case 25000: - gametext(160,90,"SELECT A SAVE SPOT BEFORE",0,2+8+16); - gametext(160,90+9,"YOU QUICK RESTORE.",0,2+8+16); + case 25000: + gametext(160,90,"SELECT A SAVE SPOT BEFORE",0,2+8+16); + gametext(160,90+9,"YOU QUICK RESTORE.",0,2+8+16); - x = probe(186,124,0,0); - if (x >= -1) + x = probe(186,124,0,0); + if (x >= -1) + { + if (ud.multimode < 2 && ud.recstat != 2) { - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - ps[myconnectindex].gm &= ~MODE_MENU; + ready2send = 1; + totalclock = ototalclock; } - break; + ps[myconnectindex].gm &= ~MODE_MENU; + } + break; - case 20000: - x = probe(326,190,0,0); - gametext(160,50-8,"YOU ARE PLAYING THE SHAREWARE",0,2+8+16); - gametext(160,59-8,"VERSION OF DUKE NUKEM 3D. WHILE",0,2+8+16); - gametext(160,68-8,"THIS VERSION IS REALLY COOL, YOU",0,2+8+16); - gametext(160,77-8,"ARE MISSING OVER 75%% OF THE TOTAL",0,2+8+16); - gametext(160,86-8,"GAME, ALONG WITH OTHER GREAT EXTRAS",0,2+8+16); - gametext(160,95-8,"AND GAMES, WHICH YOU'LL GET WHEN",0,2+8+16); - gametext(160,104-8,"YOU ORDER THE COMPLETE VERSION AND",0,2+8+16); - gametext(160,113-8,"GET THE FINAL TWO EPISODES.",0,2+8+16); + case 20000: + x = probe(326,190,0,0); + gametext(160,50-8,"YOU ARE PLAYING THE SHAREWARE",0,2+8+16); + gametext(160,59-8,"VERSION OF DUKE NUKEM 3D. WHILE",0,2+8+16); + gametext(160,68-8,"THIS VERSION IS REALLY COOL, YOU",0,2+8+16); + gametext(160,77-8,"ARE MISSING OVER 75%% OF THE TOTAL",0,2+8+16); + gametext(160,86-8,"GAME, ALONG WITH OTHER GREAT EXTRAS",0,2+8+16); + gametext(160,95-8,"AND GAMES, WHICH YOU'LL GET WHEN",0,2+8+16); + gametext(160,104-8,"YOU ORDER THE COMPLETE VERSION AND",0,2+8+16); + gametext(160,113-8,"GET THE FINAL TWO EPISODES.",0,2+8+16); - gametext(160,113+8,"PLEASE READ THE 'HOW TO ORDER' ITEM",0,2+8+16); - gametext(160,122+8,"ON THE MAIN MENU IF YOU WISH TO",0,2+8+16); - gametext(160,131+8,"UPGRADE TO THE FULL REGISTERED",0,2+8+16); - gametext(160,140+8,"VERSION OF DUKE NUKEM 3D.",0,2+8+16); - gametext(160,149+16,"PRESS ANY KEY...",0,2+8+16); + gametext(160,113+8,"PLEASE READ THE 'HOW TO ORDER' ITEM",0,2+8+16); + gametext(160,122+8,"ON THE MAIN MENU IF YOU WISH TO",0,2+8+16); + gametext(160,131+8,"UPGRADE TO THE FULL REGISTERED",0,2+8+16); + gametext(160,140+8,"VERSION OF DUKE NUKEM 3D.",0,2+8+16); + gametext(160,149+16,"PRESS ANY KEY...",0,2+8+16); - if (x >= -1) cmenu(100); - break; + if (x >= -1) cmenu(100); + break; - case 20001: - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"NETWORK GAME"); + case 20001: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"NETWORK GAME"); - x = probe(160,100-18,18,3); + x = probe(160,100-18,18,3); - if (x == -1) cmenu(0); - else if (x == 2) cmenu(20010); - else if (x == 1) cmenu(20020); - else if (x == 0) cmenu(20002); + if (x == -1) cmenu(0); + else if (x == 2) cmenu(20010); + else if (x == 1) cmenu(20020); + else if (x == 0) cmenu(20002); - menutext(160,100-18,MENUHIGHLIGHT(0),0,"PLAYER SETUP"); - menutext(160,100,MENUHIGHLIGHT(1),0,"JOIN GAME"); - menutext(160,100+18,MENUHIGHLIGHT(2),0,"HOST GAME"); - break; + menutext(160,100-18,MENUHIGHLIGHT(0),0,"PLAYER SETUP"); + menutext(160,100,MENUHIGHLIGHT(1),0,"JOIN GAME"); + menutext(160,100+18,MENUHIGHLIGHT(2),0,"HOST GAME"); + break; - case 20002: - case 20003: - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"PLAYER SETUP"); - if (probey == 2) + case 20002: + case 20003: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"PLAYER SETUP"); + if (probey == 2) + { + switch (ud.team) { - switch (ud.team) - { - case 0: - x = 3; - break; - case 1: - x = 21; - break; - } + case 0: + x = 3; + break; + case 1: + x = 21; + break; } - else x = ud.color; - rotatesprite((280)<<16,(37+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,x,10,0,0,xdim-1,ydim-1); - - if (current_menu == 20002) - { - x = probe(40,50,16,7); - switch (x) - { - case -1: - cmenu(202); - probey = 3; - break; - - case 0: - strcpy(buf, myname); - inputloc = strlen(buf); - current_menu = 20003; - - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - break; - - case 1: - ud.color++; - if (ud.color > 23) - ud.color = 0; - check_player_color((int *)&ud.color,-1); - updatenames(); - break; - - case 2: - ud.team = 1-ud.team; - updatenames(); - break; - - case 3: - AutoAim = (AutoAim == 2) ? 0 : AutoAim+1; - updatenames(); - break; - - case 4: - ud.weaponswitch = (ud.weaponswitch == 3) ? 0 : ud.weaponswitch+1; - updatenames(); - break; - case 5: - ud.mouseaiming = !ud.mouseaiming; - updatenames(); - break; - case 6: - cmenu(20004); - break; - } - } - else - { - x = strget(200,50-9,buf,30,0); - - while (Bstrlen(strip_color_codes(buf)) > 10) - { - buf[Bstrlen(buf)-1] = '\0'; - inputloc--; - } - - if (x) - { - if (x == 1) - { - if (buf[0]) - { - Bstrcpy(myname,buf); - } - // send name update - } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - - current_menu = 20002; - updatenames(); - } - } - - menutext(40,50,MENUHIGHLIGHT(0),0,"NAME"); - menutext(40,50+16,MENUHIGHLIGHT(1),0,"COLOR"); - - { - int ud_color = -1, aaim = -1, ud_weaponswitch = -1, ud_maim = -1, ud_team = -1; - - ud_color = ud.color; - aaim = AutoAim; - ud_weaponswitch = ud.weaponswitch; - ud_maim = ud.mouseaiming; - ud_team = ud.team; - modval(0,23,(int *)&ud.color,1,probey==1); - modval(0,1,(int *)&ud.team,1,probey==2); - modval(0,2,(int *)&AutoAim,1,probey==3); - modval(0,3,(int *)&ud.weaponswitch,1,probey==4); - modval(0,1,(int *)&ud.mouseaiming,1,probey==5); - check_player_color((int *)&ud.color,ud_color); - if (ud_color != ud.color || aaim != AutoAim || ud_weaponswitch != ud.weaponswitch || ud_maim != ud.mouseaiming || ud_team != ud.team) - updatenames(); - } - menutext(40,50+16+16,MENUHIGHLIGHT(2),0,"TEAM"); - menutext(40,50+16+16+16,MENUHIGHLIGHT(3),0,"AUTO AIM"); - menutext(40,50+16+16+16+16,MENUHIGHLIGHT(4),0,"WEAPON SWITCH"); - menutext(40,50+16+16+16+16+16,MENUHIGHLIGHT(5),0,"AIMING TYPE"); - menutext(40,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),0,"MACRO SETUP"); - - if (current_menu == 20002) - { - gametext(200,50-9,myname,MENUHIGHLIGHT(0),2+8+16); - } - { - char *s[] = { "Auto","","","","","","","","","Blue","Dk red","Green","Gray","Dk gray","Dk green","Brown", - "Dk blue","","","","","Red","","Yellow","","" }; - gametext(200,50+16-9,s[ud.color],MENUHIGHLIGHT(1),2+8+16); - } - { - char *s[] = { "Blue", "Red" }; - gametext(200,50+16+16-9,s[ud.team],MENUHIGHLIGHT(2),2+8+16); - } - { - char *s[] = { "Off", "Full", "Hitscan" }; - gametext(200,50+16+16+16-9,s[AutoAim],MENUHIGHLIGHT(3),2+8+16); - } - { - char *s[] = { "Off", "On pickup", "When empty", "Both" }; - gametext(200,50+16+16+16+16-9,s[ud.weaponswitch],MENUHIGHLIGHT(4),2+8+16); - } - gametext(200,50+16+16+16+16+16-9,ud.mouseaiming?"Held":"Toggle",MENUHIGHLIGHT(5),2+8+16); - - break; - - case 20004: - case 20005: - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"MACRO SETUP"); - - if (current_menu == 20004) - { - x = probesm(24,45,8,10); - if (x == -1) - { - cmenu(20002); - probey = 6; - } - else if (x >= 0 && x <= 9) - { - strcpy(buf, ud.ridecule[x]); - inputloc = strlen(buf); - last_probey = probey; - current_menu = 20005; - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - } - } - else - { - x = strget(26,40+(8*probey),buf,34,0); - if (x) - { - if (x == 1) - { - Bstrcpy(ud.ridecule[last_probey],buf); - } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - current_menu = 20004; - } - } - for (i=0;i<10;i++) - { - if (current_menu == 20005 && i == last_probey) continue; - gametextpal(26,40+(i<<3),ud.ridecule[i],MENUHIGHLIGHT(i),0); - } - - gametext(160,144,"UP/DOWN = SELECT MACRO",0,2+8+16); - gametext(160,144+9,"ENTER = MODIFY",0,2+8+16); - gametext(160,144+9+9,"ACTIVATE IN GAME WITH SHIFT-F#",0,2+8+16); - - break; - - case 20010: - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"HOST NETWORK GAME"); - - x = probe(46,50,80,2); - - if (x == -1) - { - cmenu(20001); - probey = 2; - } - else if (x == 0) cmenu(20011); - - menutext(40,50,0,0, "GAME OPTIONS"); - minitext(90,60, "GAME TYPE" ,2,26); - minitext(90,60+8, "EPISODE" ,2,26); - minitext(90,60+8+8, "LEVEL" ,2,26); - minitext(90,60+8+8+8, "MONSTERS" ,2,26); - if (ud.m_coop == 0) - minitext(90,60+8+8+8+8, "MARKERS" ,2,26); - else if (ud.m_coop == 1) - minitext(90,60+8+8+8+8, "FRIENDLY FIRE",2,26); - minitext(90,60+8+8+8+8+8, "USER MAP" ,2,26); - - gametext(90+60,60,gametype_names[ud.m_coop],0,26); - - minitext(90+60,60+8, volume_names[ud.m_volume_number],0,26); - minitext(90+60,60+8+8, level_names[11*ud.m_volume_number+ud.m_level_number],0,26); - if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - minitext(90+60,60+8+8+8, skill_names[ud.m_player_skill],0,26); - else minitext(90+60,60+8+8+8, "NONE",0,28); - if (ud.m_coop == 0) - { - if (ud.m_marker) minitext(90+60,60+8+8+8+8,"ON",0,26); - else minitext(90+60,60+8+8+8+8,"OFF",0,26); - } - else if (ud.m_coop == 1) - { - if (ud.m_ffire) minitext(90+60,60+8+8+8+8,"ON",0,26); - else minitext(90+60,60+8+8+8+8,"OFF",0,26); - } - - menutext(40,50+80,0,0,"LAUNCH GAME"); - break; - - case 20011: - c = (320>>1) - 120; - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"NET GAME OPTIONS"); - - x = probe(c,57-8,16,8); + } + else x = ud.color; + rotatesprite((280)<<16,(37+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,x,10,0,0,xdim-1,ydim-1); + if (current_menu == 20002) + { + x = probe(40,50,16,7); switch (x) { - case -1: - cmenu(20010); - break; - case 0: - ud.m_coop++; - if (ud.m_coop == 3) ud.m_coop = 0; - break; - case 1: - if (!VOLUMEONE) - { - ud.m_volume_number++; - if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; - if (ud.m_volume_number == 0 && ud.m_level_number > 6) - ud.m_level_number = 0; - if (ud.m_level_number > 10) ud.m_level_number = 0; - } - break; - case 2: - ud.m_level_number++; - if (!VOLUMEONE) - { - if (ud.m_volume_number == 0 && ud.m_level_number > 6) - ud.m_level_number = 0; - } - else - { - if (ud.m_volume_number == 0 && ud.m_level_number > 5) - ud.m_level_number = 0; - } - if (ud.m_level_number > 10) ud.m_level_number = 0; - break; - case 3: - if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) - ud.m_monsters_off = 0; + case -1: + cmenu(202); + probey = 3; + break; - if (ud.m_monsters_off == 0) - { - ud.m_player_skill++; - if (ud.m_player_skill > 3) - { - ud.m_player_skill = 0; - ud.m_monsters_off = 1; - } - } - else ud.m_monsters_off = 0; + case 0: + strcpy(buf, myname); + inputloc = strlen(buf); + current_menu = 20003; - break; + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + break; - case 4: - if (ud.m_coop == 0) - ud.m_marker = !ud.m_marker; - break; + case 1: + ud.color++; + if (ud.color > 23) + ud.color = 0; + check_player_color((int *)&ud.color,-1); + updatenames(); + break; - case 5: - if (ud.m_coop == 1) - ud.m_ffire = !ud.m_ffire; - break; + case 2: + ud.team = 1-ud.team; + updatenames(); + break; - case 6: - // pick the user map - break; + case 3: + AutoAim = (AutoAim == 2) ? 0 : AutoAim+1; + updatenames(); + break; - case 7: - cmenu(20010); - break; + case 4: + ud.weaponswitch = (ud.weaponswitch == 3) ? 0 : ud.weaponswitch+1; + updatenames(); + break; + case 5: + ud.mouseaiming = !ud.mouseaiming; + updatenames(); + break; + case 6: + cmenu(20004); + break; + } + } + else + { + x = strget(200,50-9,buf,30,0); + + while (Bstrlen(strip_color_codes(buf)) > 10) + { + buf[Bstrlen(buf)-1] = '\0'; + inputloc--; } - c += 40; - - // if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); - // else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); - // else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); - gametext(c+70,57-7-9,gametype_names[ud.m_coop],0,26); - - gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); - - gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],0,2+8+16); - - if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - gametext(c+70,57+16+16+16-7-9,skill_names[ud.m_player_skill],0,2+8+16); - else gametext(c+70,57+16+16+16-7-9,"NONE",0,2+8+16); - - if (ud.m_coop == 0) + if (x) { - if (ud.m_marker) - gametext(c+70,57+16+16+16+16-7-9,"ON",0,2+8+16); - else gametext(c+70,57+16+16+16+16-7-9,"OFF",0,2+8+16); - } - - if (ud.m_coop == 1) - { - if (ud.m_ffire) - gametext(c+70,57+16+16+16+16+16-7-9,"ON",0,2+8+16); - else gametext(c+70,57+16+16+16+16+16-7-9,"OFF",0,2+8+16); - } - - c -= 44; - - menutext(c,57-9,MENUHIGHLIGHT(0),PHX(-2),"GAME TYPE"); - - sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); - menutext(c,57+16-9,MENUHIGHLIGHT(1),PHX(-3),tempbuf); - - sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); - menutext(c,57+16+16-9,MENUHIGHLIGHT(2),PHX(-4),tempbuf); - - menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); - - if (ud.m_coop == 0) - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),PHX(-6),"MARKERS"); - else - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"MARKERS"); - - if (ud.m_coop == 1) - menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),PHX(-6),"FR. FIRE"); - else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),1,"FR. FIRE"); - - if (VOLUMEALL) - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),boardfilename[0] == 0,"USER MAP"); - if (boardfilename[0] != 0) - gametext(c+70+44,57+16+16+16+16+16,boardfilename,0,2+8+16); - } - else - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"USER MAP"); - } - - menutext(c,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),PHX(-8),"ACCEPT"); - break; - - case 20020: - case 20021: // editing server - case 20022: // editing port - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"JOIN NETWORK GAME"); - - if (current_menu == 20020) - { - x = probe(46,50,20,3); - - if (x == -1) + if (x == 1) { - cmenu(20001); - probey = 1; + if (buf[0]) + { + Bstrcpy(myname,buf); + } + // send name update } - else if (x == 0) - { - strcpy(buf, "localhost"); - inputloc = strlen(buf); - current_menu = 20021; - } - else if (x == 1) - { - strcpy(buf, "19014"); - inputloc = strlen(buf); - current_menu = 20022; - } - else if (x == 2) - {} + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20002; + updatenames(); + } + } + + menutext(40,50,MENUHIGHLIGHT(0),0,"NAME"); + menutext(40,50+16,MENUHIGHLIGHT(1),0,"COLOR"); + + { + int ud_color = -1, aaim = -1, ud_weaponswitch = -1, ud_maim = -1, ud_team = -1; + + ud_color = ud.color; + aaim = AutoAim; + ud_weaponswitch = ud.weaponswitch; + ud_maim = ud.mouseaiming; + ud_team = ud.team; + modval(0,23,(int *)&ud.color,1,probey==1); + modval(0,1,(int *)&ud.team,1,probey==2); + modval(0,2,(int *)&AutoAim,1,probey==3); + modval(0,3,(int *)&ud.weaponswitch,1,probey==4); + modval(0,1,(int *)&ud.mouseaiming,1,probey==5); + check_player_color((int *)&ud.color,ud_color); + if (ud_color != ud.color || aaim != AutoAim || ud_weaponswitch != ud.weaponswitch || ud_maim != ud.mouseaiming || ud_team != ud.team) + updatenames(); + } + menutext(40,50+16+16,MENUHIGHLIGHT(2),0,"TEAM"); + menutext(40,50+16+16+16,MENUHIGHLIGHT(3),0,"AUTO AIM"); + menutext(40,50+16+16+16+16,MENUHIGHLIGHT(4),0,"WEAPON SWITCH"); + menutext(40,50+16+16+16+16+16,MENUHIGHLIGHT(5),0,"AIMING TYPE"); + menutext(40,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),0,"MACRO SETUP"); + + if (current_menu == 20002) + { + gametext(200,50-9,myname,MENUHIGHLIGHT(0),2+8+16); + } + { + char *s[] = { "Auto","","","","","","","","","Blue","Dk red","Green","Gray","Dk gray","Dk green","Brown", + "Dk blue","","","","","Red","","Yellow","","" }; + gametext(200,50+16-9,s[ud.color],MENUHIGHLIGHT(1),2+8+16); + } + { + char *s[] = { "Blue", "Red" }; + gametext(200,50+16+16-9,s[ud.team],MENUHIGHLIGHT(2),2+8+16); + } + { + char *s[] = { "Off", "Full", "Hitscan" }; + gametext(200,50+16+16+16-9,s[AutoAim],MENUHIGHLIGHT(3),2+8+16); + } + { + char *s[] = { "Off", "On pickup", "When empty", "Both" }; + gametext(200,50+16+16+16+16-9,s[ud.weaponswitch],MENUHIGHLIGHT(4),2+8+16); + } + gametext(200,50+16+16+16+16+16-9,ud.mouseaiming?"Held":"Toggle",MENUHIGHLIGHT(5),2+8+16); + + break; + + case 20004: + case 20005: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"MACRO SETUP"); + + if (current_menu == 20004) + { + x = probesm(24,45,8,10); + if (x == -1) + { + cmenu(20002); + probey = 6; + } + else if (x >= 0 && x <= 9) + { + strcpy(buf, ud.ridecule[x]); + inputloc = strlen(buf); + last_probey = probey; + current_menu = 20005; KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); } - else if (current_menu == 20021) + } + else + { + x = strget(26,40+(8*probey),buf,34,0); + if (x) { - x = strget(40+100,50-9,buf,31,0); - if (x) + if (x == 1) { - if (x == 1) - { - //strcpy(myname,buf); - } - - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - - current_menu = 20020; + Bstrcpy(ud.ridecule[last_probey],buf); } - } - else if (current_menu == 20022) - { - x = strget(40+100,50+20-9,buf,5,997); - if (x) - { - if (x == 1) - { - //strcpy(myname,buf); - } - - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); - - current_menu = 20020; - } - } - - menutext(40,50,0,0,"SERVER"); - if (current_menu != 20021) gametext(40+100,50-9,"server",0,2+8+16); - - menutext(40,50+20,0,0,"PORT"); - if (current_menu != 20022) - { - sprintf(tempbuf,"%d",19014); - gametext(40+100,50+20-9,tempbuf,0,2+8+16); - } - - menutext(160,50+20+20,0,0,"CONNECT"); - - - // ADDRESS - // PORT - // CONNECT - break; - - case 15001: - case 15000: - - gametext(160,90,"LOAD last game:",0,2+8+16); - - sprintf(tempbuf,"\"%s\"",ud.savegame[lastsavedpos]); - gametext(160,99,tempbuf,0,2+8+16); - - gametext(160,99+9,"(Y/N)",0,2+8+16); - - if (KB_KeyPressed(sc_Escape) || KB_KeyPressed(sc_N) || RMB) - { - if (sprite[ps[myconnectindex].i].extra <= 0) - { - if (enterlevel(MODE_GAME)) backtomenu(); - return; - } - - KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); - - ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) - { + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); - FX_StopAllSounds(); + current_menu = 20004; + } + } + for (i=0;i<10;i++) + { + if (current_menu == 20005 && i == last_probey) continue; + gametextpal(26,40+(i<<3),ud.ridecule[i],MENUHIGHLIGHT(i),0); + } - if (ud.multimode > 1) + gametext(160,144,"UP/DOWN = SELECT MACRO",0,2+8+16); + gametext(160,144+9,"ENTER = MODIFY",0,2+8+16); + gametext(160,144+9+9,"ACTIVATE IN GAME WITH SHIFT-F#",0,2+8+16); + + break; + + case 20010: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"HOST NETWORK GAME"); + + x = probe(46,50,80,2); + + if (x == -1) + { + cmenu(20001); + probey = 2; + } + else if (x == 0) cmenu(20011); + + menutext(40,50,0,0, "GAME OPTIONS"); + minitext(90,60, "GAME TYPE" ,2,26); + minitext(90,60+8, "EPISODE" ,2,26); + minitext(90,60+8+8, "LEVEL" ,2,26); + minitext(90,60+8+8+8, "MONSTERS" ,2,26); + if (ud.m_coop == 0) + minitext(90,60+8+8+8+8, "MARKERS" ,2,26); + else if (ud.m_coop == 1) + minitext(90,60+8+8+8+8, "FRIENDLY FIRE",2,26); + minitext(90,60+8+8+8+8+8, "USER MAP" ,2,26); + + gametext(90+60,60,gametype_names[ud.m_coop],0,26); + + minitext(90+60,60+8, volume_names[ud.m_volume_number],0,26); + minitext(90+60,60+8+8, level_names[11*ud.m_volume_number+ud.m_level_number],0,26); + if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) + minitext(90+60,60+8+8+8, skill_names[ud.m_player_skill],0,26); + else minitext(90+60,60+8+8+8, "NONE",0,28); + if (ud.m_coop == 0) + { + if (ud.m_marker) minitext(90+60,60+8+8+8+8,"ON",0,26); + else minitext(90+60,60+8+8+8+8,"OFF",0,26); + } + else if (ud.m_coop == 1) + { + if (ud.m_ffire) minitext(90+60,60+8+8+8+8,"ON",0,26); + else minitext(90+60,60+8+8+8+8,"OFF",0,26); + } + + menutext(40,50+80,0,0,"LAUNCH GAME"); + break; + + case 20011: + c = (320>>1) - 120; + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"NET GAME OPTIONS"); + + x = probe(c,57-8,16,8); + + switch (x) + { + case -1: + cmenu(20010); + break; + case 0: + ud.m_coop++; + if (ud.m_coop == 3) ud.m_coop = 0; + break; + case 1: + if (!VOLUMEONE) + { + ud.m_volume_number++; + if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if (ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + if (ud.m_level_number > 10) ud.m_level_number = 0; + } + break; + case 2: + ud.m_level_number++; + if (!VOLUMEONE) + { + if (ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + } + else + { + if (ud.m_volume_number == 0 && ud.m_level_number > 5) + ud.m_level_number = 0; + } + if (ud.m_level_number > 10) ud.m_level_number = 0; + break; + case 3: + if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) + ud.m_monsters_off = 0; + + if (ud.m_monsters_off == 0) + { + ud.m_player_skill++; + if (ud.m_player_skill > 3) { - loadplayer(-1-lastsavedpos); - ps[myconnectindex].gm = MODE_GAME; - } - else - { - c = loadplayer(lastsavedpos); - if (c == 0) - ps[myconnectindex].gm = MODE_GAME; + ud.m_player_skill = 0; + ud.m_monsters_off = 1; } } - - probe(186,124+9,0,0); + else ud.m_monsters_off = 0; break; - case 10000: - case 10001: + case 4: + if (ud.m_coop == 0) + ud.m_marker = !ud.m_marker; + break; - c = 60; - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"ADULT MODE"); + case 5: + if (ud.m_coop == 1) + ud.m_ffire = !ud.m_ffire; + break; + + case 6: + // pick the user map + break; + + case 7: + cmenu(20010); + break; + } + + c += 40; + + // if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); + // else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); + // else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); + gametext(c+70,57-7-9,gametype_names[ud.m_coop],0,26); + + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); + + gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],0,2+8+16); + + if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) + gametext(c+70,57+16+16+16-7-9,skill_names[ud.m_player_skill],0,2+8+16); + else gametext(c+70,57+16+16+16-7-9,"NONE",0,2+8+16); + + if (ud.m_coop == 0) + { + if (ud.m_marker) + gametext(c+70,57+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + if (ud.m_coop == 1) + { + if (ud.m_ffire) + gametext(c+70,57+16+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + c -= 44; + + menutext(c,57-9,MENUHIGHLIGHT(0),PHX(-2),"GAME TYPE"); + + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,MENUHIGHLIGHT(1),PHX(-3),tempbuf); + + sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); + menutext(c,57+16+16-9,MENUHIGHLIGHT(2),PHX(-4),tempbuf); + + menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); + + if (ud.m_coop == 0) + menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),PHX(-6),"MARKERS"); + else + menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"MARKERS"); + + if (ud.m_coop == 1) + menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),PHX(-6),"FR. FIRE"); + else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),1,"FR. FIRE"); + + if (VOLUMEALL) + { + menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),boardfilename[0] == 0,"USER MAP"); + if (boardfilename[0] != 0) + gametext(c+70+44,57+16+16+16+16+16,boardfilename,0,2+8+16); + } + else + { + menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"USER MAP"); + } + + menutext(c,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),PHX(-8),"ACCEPT"); + break; + + case 20020: + case 20021: // editing server + case 20022: // editing port + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"JOIN NETWORK GAME"); + + if (current_menu == 20020) + { + x = probe(46,50,20,3); - x = probe(60,50+16,16,2); if (x == -1) { - cmenu(201); - probey = 0; - break; + cmenu(20001); + probey = 1; + } + else if (x == 0) + { + strcpy(buf, "localhost"); + inputloc = strlen(buf); + current_menu = 20021; + } + else if (x == 1) + { + strcpy(buf, "19014"); + inputloc = strlen(buf); + current_menu = 20022; + } + else if (x == 2) + {} + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + } + else if (current_menu == 20021) + { + x = strget(40+100,50-9,buf,31,0); + if (x) + { + if (x == 1) + { + //strcpy(myname,buf); + } + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20020; + } + } + else if (current_menu == 20022) + { + x = strget(40+100,50+20-9,buf,5,997); + if (x) + { + if (x == 1) + { + //strcpy(myname,buf); + } + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20020; + } + } + + menutext(40,50,0,0,"SERVER"); + if (current_menu != 20021) gametext(40+100,50-9,"server",0,2+8+16); + + menutext(40,50+20,0,0,"PORT"); + if (current_menu != 20022) + { + sprintf(tempbuf,"%d",19014); + gametext(40+100,50+20-9,tempbuf,0,2+8+16); + } + + menutext(160,50+20+20,0,0,"CONNECT"); + + + // ADDRESS + // PORT + // CONNECT + break; + + case 15001: + case 15000: + + gametext(160,90,"LOAD last game:",0,2+8+16); + + sprintf(tempbuf,"\"%s\"",ud.savegame[lastsavedpos]); + gametext(160,99,tempbuf,0,2+8+16); + + gametext(160,99+9,"(Y/N)",0,2+8+16); + + if (KB_KeyPressed(sc_Escape) || KB_KeyPressed(sc_N) || RMB) + { + if (sprite[ps[myconnectindex].i].extra <= 0) + { + if (enterlevel(MODE_GAME)) backtomenu(); + return; } - menutext(c,50+16,MENUHIGHLIGHT(0),PHX(-2),"ADULT MODE"); - menutext(c,50+16+16,MENUHIGHLIGHT(1),PHX(-3),"ENTER PASSWORD"); + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); - menutext(c+160+40,50+16,MENUHIGHLIGHT(0),0,ud.lockout?"OFF":"ON"); - - if (current_menu == 10001) + ps[myconnectindex].gm &= ~MODE_MENU; + if (ud.multimode < 2 && ud.recstat != 2) { - gametext(160,50+16+16+16+16-12,"ENTER PASSWORD",0,2+8+16); - x = strget((320>>1),50+16+16+16+16,buf,19, 998); + ready2send = 1; + totalclock = ototalclock; + } + } - if (x) + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + FX_StopAllSounds(); + + if (ud.multimode > 1) + { + loadplayer(-1-lastsavedpos); + ps[myconnectindex].gm = MODE_GAME; + } + else + { + c = loadplayer(lastsavedpos); + if (c == 0) + ps[myconnectindex].gm = MODE_GAME; + } + } + + probe(186,124+9,0,0); + + break; + + case 10000: + case 10001: + + c = 60; + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"ADULT MODE"); + + x = probe(60,50+16,16,2); + if (x == -1) + { + cmenu(201); + probey = 0; + break; + } + + menutext(c,50+16,MENUHIGHLIGHT(0),PHX(-2),"ADULT MODE"); + menutext(c,50+16+16,MENUHIGHLIGHT(1),PHX(-3),"ENTER PASSWORD"); + + menutext(c+160+40,50+16,MENUHIGHLIGHT(0),0,ud.lockout?"OFF":"ON"); + + if (current_menu == 10001) + { + gametext(160,50+16+16+16+16-12,"ENTER PASSWORD",0,2+8+16); + x = strget((320>>1),50+16+16+16+16,buf,19, 998); + + if (x) + { + if (ud.pwlockout[0] == 0 || ud.lockout == 0) + strcpy(&ud.pwlockout[0],buf); + else if (strcmp(buf,&ud.pwlockout[0]) == 0) { - if (ud.pwlockout[0] == 0 || ud.lockout == 0) - strcpy(&ud.pwlockout[0],buf); - else if (strcmp(buf,&ud.pwlockout[0]) == 0) + ud.lockout = 0; + buf[0] = 0; + + for (x=0;x= 0) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; + + } + current_menu = 10000; + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + } + } + else + { + if (x == 0) + { + if (ud.lockout == 1) + { + if (ud.pwlockout[0] == 0) { ud.lockout = 0; - buf[0] = 0; - for (x=0;x= 0) wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; - } - current_menu = 10000; - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + else + { + buf[0] = 0; + current_menu = 10001; + inputloc = 0; + KB_FlushKeyboardQueue(); + } + } + else + { + ud.lockout = 1; + + for (x=0;x>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + + dispnames(); + + sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); + gametext(160,156,tempbuf,0,2+8+16); + + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); + gametext(160,168,tempbuf,0,2+8+16); + + if (savehead.volnum == 0 && savehead.levnum == 7) + gametext(160,180,savehead.boardfn,0,2+8+16); + + gametext(160,90,"LOAD game:",0,2+8+16); + sprintf(tempbuf,"\"%s\"",ud.savegame[current_menu-1000]); + gametext(160,99,tempbuf,0,2+8+16); + gametext(160,99+9,"(Y/N)",0,2+8+16); + + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + lastsavedpos = current_menu-1000; + + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + + if (ud.multimode > 1) + { + if (ps[myconnectindex].gm&MODE_GAME) + { + loadplayer(-1-lastsavedpos); + ps[myconnectindex].gm = MODE_GAME; + } + else + { + tempbuf[0] = 126; + tempbuf[1] = lastsavedpos; + tempbuf[2] = myconnectindex; + for (x=connecthead;x>=0;x=connectpoint2[x]) + { + if (x != myconnectindex) sendpacket(x,tempbuf,3); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + getpackets(); + + loadplayer(lastsavedpos); + + multiflag = 0; } } else { - if (x == 0) - { - if (ud.lockout == 1) - { - if (ud.pwlockout[0] == 0) - { - ud.lockout = 0; - for (x=0;x= 0) - wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; - } - else - { - buf[0] = 0; - current_menu = 10001; - inputloc = 0; - KB_FlushKeyboardQueue(); - } - } - else - { - ud.lockout = 1; - - for (x=0;x>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - - dispnames(); - - sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); - gametext(160,156,tempbuf,0,2+8+16); - - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); - gametext(160,168,tempbuf,0,2+8+16); - - if (savehead.volnum == 0 && savehead.levnum == 7) - gametext(160,180,savehead.boardfn,0,2+8+16); - - gametext(160,90,"LOAD game:",0,2+8+16); - sprintf(tempbuf,"\"%s\"",ud.savegame[current_menu-1000]); - gametext(160,99,tempbuf,0,2+8+16); - gametext(160,99+9,"(Y/N)",0,2+8+16); - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + } + if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); + if (ps[myconnectindex].gm&MODE_DEMO) cmenu(300); + else { - lastsavedpos = current_menu-1000; - - KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - - if (ud.multimode > 1) - { - if (ps[myconnectindex].gm&MODE_GAME) - { - loadplayer(-1-lastsavedpos); - ps[myconnectindex].gm = MODE_GAME; - } - else - { - tempbuf[0] = 126; - tempbuf[1] = lastsavedpos; - tempbuf[2] = myconnectindex; - for (x=connecthead;x>=0;x=connectpoint2[x]) - { - if (x != myconnectindex) sendpacket(x,tempbuf,3); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - getpackets(); - - loadplayer(lastsavedpos); - - multiflag = 0; - } - } - else - { - c = loadplayer(lastsavedpos); - if (c == 0) - ps[myconnectindex].gm = MODE_GAME; - } - - break; - } - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) - { - KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); - if (ps[myconnectindex].gm&MODE_DEMO) cmenu(300); - else - { - ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - } - - probe(186,124+9,0,0); - - break; - - case 1500: - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) - { - KB_FlushKeyboardQueue(); - cmenu(100); - } - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) - { - KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } ps[myconnectindex].gm &= ~MODE_MENU; - sound(EXITMENUSOUND); - break; + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } } - probe(186,124,0,0); - gametext(160,90,"ABORT this game?",0,2+8+16); - gametext(160,90+9,"(Y/N)",0,2+8+16); + } - break; + probe(186,124+9,0,0); - case 2000: - case 2001: - case 2002: - case 2003: - case 2004: - case 2005: - case 2006: - case 2007: - case 2008: - case 2009: + break; - rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"SAVE GAME"); + case 1500: - rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); - gametext(160,156,tempbuf,0,2+8+16); - - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); - gametext(160,168,tempbuf,0,2+8+16); - - if (ud.volume_number == 0 && ud.level_number == 7) - gametext(160,180,boardfilename,0,2+8+16); - - dispnames(); - - gametext(160,90,"OVERWRITE previous SAVED game?",0,2+8+16); - gametext(160,90+9,"(Y/N)",0,2+8+16); - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + KB_FlushKeyboardQueue(); + cmenu(100); + } + if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + if (ud.multimode < 2 && ud.recstat != 2) { - inputloc = strlen(&ud.savegame[current_menu-2000][0]); - - cmenu(current_menu-2000+360); - - KB_FlushKeyboardQueue(); - break; + ready2send = 1; + totalclock = ototalclock; } - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) - { - KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); - cmenu(351); - sound(EXITMENUSOUND); - } - - probe(186,124,0,0); - + ps[myconnectindex].gm &= ~MODE_MENU; + sound(EXITMENUSOUND); break; + } + probe(186,124,0,0); + gametext(160,90,"ABORT this game?",0,2+8+16); + gametext(160,90+9,"(Y/N)",0,2+8+16); + break; + + case 2000: + case 2001: + case 2002: + case 2003: + case 2004: + case 2005: + case 2006: + case 2007: + case 2008: + case 2009: + + rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"SAVE GAME"); + + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + + dispnames(); + + gametext(160,90,"OVERWRITE previous SAVED game?",0,2+8+16); + gametext(160,90+9,"(Y/N)",0,2+8+16); + + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + inputloc = strlen(&ud.savegame[current_menu-2000][0]); + + cmenu(current_menu-2000+360); + + KB_FlushKeyboardQueue(); + break; + } + if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + cmenu(351); + sound(EXITMENUSOUND); + } + + probe(186,124,0,0); + + break; + + case 990: + case 991: + case 992: + case 993: + case 994: + case 995: + case 996: + case 997: + case 998: + c = 160; + if (!VOLUMEALL || !PLUTOPAK) + { + //rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(c,24,0,0,current_menu == 998 ? "ABOUT EDUKE32" : "CREDITS"); + + l = 8; + } + else + { + l = 3; + } + + if (KB_KeyPressed(sc_Escape)) + { + cmenu(0); + break; + } + + if (KB_KeyPressed(sc_LeftArrow) || + KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_UpArrow) || + KB_KeyPressed(sc_PgUp) || + KB_KeyPressed(sc_kpad_8)) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if (current_menu < 990) current_menu = 990+l; + } + else if ( + KB_KeyPressed(sc_PgDn) || + KB_KeyPressed(sc_Enter) || + KB_KeyPressed(sc_Space) || + KB_KeyPressed(sc_kpad_Enter) || + KB_KeyPressed(sc_RightArrow) || + KB_KeyPressed(sc_DownArrow) || + KB_KeyPressed(sc_kpad_2) || + KB_KeyPressed(sc_kpad_9) || + KB_KeyPressed(sc_kpad_6)) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if (current_menu > 990+l) current_menu = 990; + } + + if (!VOLUMEALL || !PLUTOPAK) + { + switch (current_menu) + { + case 990: + gametext(c,40, "ORIGINAL CONCEPT",0,2+8+16); + gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); + gametext(c,40+9+9, "ALLEN H. BLUM III",0,2+8+16); + + gametext(c,40+9+9+9+9, "PRODUCED & DIRECTED BY",0,2+8+16); + gametext(c,40+9+9+9+9+9, "GREG MALONE",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9, "EXECUTIVE PRODUCER",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9, "GEORGE BROUSSARD",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9+9+9+9, "BUILD ENGINE",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"KEN SILVERMAN",0,2+8+16); + break; + case 991: + gametext(c,40, "GAME PROGRAMMING",0,2+8+16); + gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); + + gametext(c,40+9+9+9, "3D ENGINE/TOOLS/NET",0,2+8+16); + gametext(c,40+9+9+9+9, "KEN SILVERMAN",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9, "NETWORK LAYER/SETUP PROGRAM",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9, "MARK DOCHTERMANN",0,2+8+16); + break; + case 992: + gametext(c,40, "MAP DESIGN",0,2+8+16); + gametext(c,40+9, "ALLEN H BLUM III",0,2+8+16); + gametext(c,40+9+9, "RICHARD GRAY",0,2+8+16); + + gametext(c,40+9+9+9+9, "3D MODELING",0,2+8+16); + gametext(c,40+9+9+9+9+9, "CHUCK JONES",0,2+8+16); + gametext(c,40+9+9+9+9+9+9, "SAPPHIRE CORPORATION",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9+9, "ARTWORK",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9, "DIRK JONES, STEPHEN HORNBACK",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9, "JAMES STOREY, DAVID DEMARET",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"DOUGLAS R WOOD",0,2+8+16); + break; + case 993: + gametext(c,40, "SOUND ENGINE",0,2+8+16); + gametext(c,40+9, "JIM DOSE",0,2+8+16); + + gametext(c,40+9+9+9, "SOUND & MUSIC DEVELOPMENT",0,2+8+16); + gametext(c,40+9+9+9+9, "ROBERT PRINCE",0,2+8+16); + gametext(c,40+9+9+9+9+9, "LEE JACKSON",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9, "VOICE TALENT",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9, "LANI MINELLA - VOICE PRODUCER",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9, "JON ST. JOHN AS \"DUKE NUKEM\"",0,2+8+16); + break; + case 994: + gametext(c,60, "GRAPHIC DESIGN",0,2+8+16); + gametext(c,60+9, "PACKAGING, MANUAL, ADS",0,2+8+16); + gametext(c,60+9+9, "ROBERT M. ATKINS",0,2+8+16); + gametext(c,60+9+9+9, "MICHAEL HADWIN",0,2+8+16); + + gametext(c,60+9+9+9+9+9, "SPECIAL THANKS TO",0,2+8+16); + gametext(c,60+9+9+9+9+9+9, "STEVEN BLACKBURN, TOM HALL",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9, "SCOTT MILLER, JOE SIEGLER",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9+9, "TERRY NAGY, COLLEEN COMPTON",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9+9+9, "HASH INC., FORMGEN, INC.",0,2+8+16); + break; + case 995: + gametext(c,49, "THE 3D REALMS BETA TESTERS",0,2+8+16); + + gametext(c,49+9+9, "NATHAN ANDERSON, WAYNE BENNER",0,2+8+16); + gametext(c,49+9+9+9, "GLENN BRENSINGER, ROB BROWN",0,2+8+16); + gametext(c,49+9+9+9+9, "ERIK HARRIS, KEN HECKBERT",0,2+8+16); + gametext(c,49+9+9+9+9+9, "TERRY HERRIN, GREG HIVELY",0,2+8+16); + gametext(c,49+9+9+9+9+9+9, "HANK LEUKART, ERIC BAKER",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9, "JEFF RAUSCH, KELLY ROGERS",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9+9, "MIKE DUNCAN, DOUG HOWELL",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9+9+9, "BILL BLAIR",0,2+8+16); + break; + case 996: + gametext(c,32, "COMPANY PRODUCT SUPPORT",0,2+8+16); + + gametext(c,32+9+9, "THE FOLLOWING COMPANIES WERE COOL",0,2+8+16); + gametext(c,32+9+9+9, "ENOUGH TO GIVE US LOTS OF STUFF",0,2+8+16); + gametext(c,32+9+9+9+9, "DURING THE MAKING OF DUKE NUKEM 3D.",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9, "ALTEC LANSING MULTIMEDIA",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9, "FOR TONS OF SPEAKERS AND THE",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9+9, "THX-LICENSED SOUND SYSTEM",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9+9+9, "FOR INFO CALL 1-800-548-0620",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9+9+9+9+9+9,"CREATIVE LABS, INC.",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9+9+9+9+9+9+9+9,"THANKS FOR THE HARDWARE, GUYS.",0,2+8+16); + break; + case 997: + gametext(c,50, "DUKE NUKEM IS A TRADEMARK OF",0,2+8+16); + gametext(c,50+9, "3D REALMS ENTERTAINMENT",0,2+8+16); + + gametext(c,50+9+9+9, "DUKE NUKEM",0,2+8+16); + gametext(c,50+9+9+9+9, "(C) 1996 3D REALMS ENTERTAINMENT",0,2+8+16); + + if (VOLUMEONE) + { + gametext(c,106, "PLEASE READ LICENSE.DOC FOR SHAREWARE",0,2+8+16); + gametext(c,106+9, "DISTRIBUTION GRANTS AND RESTRICTIONS",0,2+8+16); + } + + gametext(c,VOLUMEONE?134:115, "MADE IN DALLAS, TEXAS USA",0,2+8+16); + break; + case 998: + l = 10; + goto cheat_for_port_credits; + } + break; + } + + // Plutonium pak menus + switch (current_menu) + { case 990: case 991: case 992: - case 993: - case 994: - case 995: - case 996: - case 997: - case 998: - c = 160; - if (!VOLUMEALL || !PLUTOPAK) - { - //rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); - rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(c,24,0,0,current_menu == 998 ? "ABOUT EDUKE32" : "CREDITS"); - - l = 8; - } - else - { - l = 3; - } - - if (KB_KeyPressed(sc_Escape)) - { - cmenu(0); - break; - } - - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8)) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); - - sound(KICK_HIT); - current_menu--; - if (current_menu < 990) current_menu = 990+l; - } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_kpad_6)) - { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 990+l) current_menu = 990; - } - - if (!VOLUMEALL || !PLUTOPAK) - { - switch (current_menu) - { - case 990: - gametext(c,40, "ORIGINAL CONCEPT",0,2+8+16); - gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); - gametext(c,40+9+9, "ALLEN H. BLUM III",0,2+8+16); - - gametext(c,40+9+9+9+9, "PRODUCED & DIRECTED BY",0,2+8+16); - gametext(c,40+9+9+9+9+9, "GREG MALONE",0,2+8+16); - - gametext(c,40+9+9+9+9+9+9+9, "EXECUTIVE PRODUCER",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9, "GEORGE BROUSSARD",0,2+8+16); - - gametext(c,40+9+9+9+9+9+9+9+9+9+9, "BUILD ENGINE",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"KEN SILVERMAN",0,2+8+16); - break; - case 991: - gametext(c,40, "GAME PROGRAMMING",0,2+8+16); - gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); - - gametext(c,40+9+9+9, "3D ENGINE/TOOLS/NET",0,2+8+16); - gametext(c,40+9+9+9+9, "KEN SILVERMAN",0,2+8+16); - - gametext(c,40+9+9+9+9+9+9, "NETWORK LAYER/SETUP PROGRAM",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9, "MARK DOCHTERMANN",0,2+8+16); - break; - case 992: - gametext(c,40, "MAP DESIGN",0,2+8+16); - gametext(c,40+9, "ALLEN H BLUM III",0,2+8+16); - gametext(c,40+9+9, "RICHARD GRAY",0,2+8+16); - - gametext(c,40+9+9+9+9, "3D MODELING",0,2+8+16); - gametext(c,40+9+9+9+9+9, "CHUCK JONES",0,2+8+16); - gametext(c,40+9+9+9+9+9+9, "SAPPHIRE CORPORATION",0,2+8+16); - - gametext(c,40+9+9+9+9+9+9+9+9, "ARTWORK",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9+9, "DIRK JONES, STEPHEN HORNBACK",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9+9+9, "JAMES STOREY, DAVID DEMARET",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"DOUGLAS R WOOD",0,2+8+16); - break; - case 993: - gametext(c,40, "SOUND ENGINE",0,2+8+16); - gametext(c,40+9, "JIM DOSE",0,2+8+16); - - gametext(c,40+9+9+9, "SOUND & MUSIC DEVELOPMENT",0,2+8+16); - gametext(c,40+9+9+9+9, "ROBERT PRINCE",0,2+8+16); - gametext(c,40+9+9+9+9+9, "LEE JACKSON",0,2+8+16); - - gametext(c,40+9+9+9+9+9+9+9, "VOICE TALENT",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9, "LANI MINELLA - VOICE PRODUCER",0,2+8+16); - gametext(c,40+9+9+9+9+9+9+9+9+9, "JON ST. JOHN AS \"DUKE NUKEM\"",0,2+8+16); - break; - case 994: - gametext(c,60, "GRAPHIC DESIGN",0,2+8+16); - gametext(c,60+9, "PACKAGING, MANUAL, ADS",0,2+8+16); - gametext(c,60+9+9, "ROBERT M. ATKINS",0,2+8+16); - gametext(c,60+9+9+9, "MICHAEL HADWIN",0,2+8+16); - - gametext(c,60+9+9+9+9+9, "SPECIAL THANKS TO",0,2+8+16); - gametext(c,60+9+9+9+9+9+9, "STEVEN BLACKBURN, TOM HALL",0,2+8+16); - gametext(c,60+9+9+9+9+9+9+9, "SCOTT MILLER, JOE SIEGLER",0,2+8+16); - gametext(c,60+9+9+9+9+9+9+9+9, "TERRY NAGY, COLLEEN COMPTON",0,2+8+16); - gametext(c,60+9+9+9+9+9+9+9+9+9, "HASH INC., FORMGEN, INC.",0,2+8+16); - break; - case 995: - gametext(c,49, "THE 3D REALMS BETA TESTERS",0,2+8+16); - - gametext(c,49+9+9, "NATHAN ANDERSON, WAYNE BENNER",0,2+8+16); - gametext(c,49+9+9+9, "GLENN BRENSINGER, ROB BROWN",0,2+8+16); - gametext(c,49+9+9+9+9, "ERIK HARRIS, KEN HECKBERT",0,2+8+16); - gametext(c,49+9+9+9+9+9, "TERRY HERRIN, GREG HIVELY",0,2+8+16); - gametext(c,49+9+9+9+9+9+9, "HANK LEUKART, ERIC BAKER",0,2+8+16); - gametext(c,49+9+9+9+9+9+9+9, "JEFF RAUSCH, KELLY ROGERS",0,2+8+16); - gametext(c,49+9+9+9+9+9+9+9+9, "MIKE DUNCAN, DOUG HOWELL",0,2+8+16); - gametext(c,49+9+9+9+9+9+9+9+9+9, "BILL BLAIR",0,2+8+16); - break; - case 996: - gametext(c,32, "COMPANY PRODUCT SUPPORT",0,2+8+16); - - gametext(c,32+9+9, "THE FOLLOWING COMPANIES WERE COOL",0,2+8+16); - gametext(c,32+9+9+9, "ENOUGH TO GIVE US LOTS OF STUFF",0,2+8+16); - gametext(c,32+9+9+9+9, "DURING THE MAKING OF DUKE NUKEM 3D.",0,2+8+16); - - gametext(c,32+9+9+9+9+9+9, "ALTEC LANSING MULTIMEDIA",0,2+8+16); - gametext(c,32+9+9+9+9+9+9+9, "FOR TONS OF SPEAKERS AND THE",0,2+8+16); - gametext(c,32+9+9+9+9+9+9+9+9, "THX-LICENSED SOUND SYSTEM",0,2+8+16); - gametext(c,32+9+9+9+9+9+9+9+9+9, "FOR INFO CALL 1-800-548-0620",0,2+8+16); - - gametext(c,32+9+9+9+9+9+9+9+9+9+9+9,"CREATIVE LABS, INC.",0,2+8+16); - - gametext(c,32+9+9+9+9+9+9+9+9+9+9+9+9+9,"THANKS FOR THE HARDWARE, GUYS.",0,2+8+16); - break; - case 997: - gametext(c,50, "DUKE NUKEM IS A TRADEMARK OF",0,2+8+16); - gametext(c,50+9, "3D REALMS ENTERTAINMENT",0,2+8+16); - - gametext(c,50+9+9+9, "DUKE NUKEM",0,2+8+16); - gametext(c,50+9+9+9+9, "(C) 1996 3D REALMS ENTERTAINMENT",0,2+8+16); - - if (VOLUMEONE) - { - gametext(c,106, "PLEASE READ LICENSE.DOC FOR SHAREWARE",0,2+8+16); - gametext(c,106+9, "DISTRIBUTION GRANTS AND RESTRICTIONS",0,2+8+16); - } - - gametext(c,VOLUMEONE?134:115, "MADE IN DALLAS, TEXAS USA",0,2+8+16); - break; - case 998: - l = 10; - goto cheat_for_port_credits; - } - break; - } - - // Plutonium pak menus - switch (current_menu) - { - case 990: - case 991: - case 992: - rotatesprite(160<<16,200<<15,65536L,0,2504+current_menu-990,0,0,10+64,0,0,xdim-1,ydim-1); - break; - case 993: // JBF 20031220 - rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,0,0,10+64,0,0,xdim-1,ydim-1); - rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,0,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"ABOUT EDUKE32"); + rotatesprite(160<<16,200<<15,65536L,0,2504+current_menu-990,0,0,10+64,0,0,xdim-1,ydim-1); + break; + case 993: // JBF 20031220 + rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,0,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,0,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"ABOUT EDUKE32"); cheat_for_port_credits: - if (conversion == 13) l = (-2); - gametext(160,38-l,"GAME PROGRAMMING",0,2+8+16); - p = "Richard \"TerminX\" Gobeille"; - minitext(161-(Bstrlen(p)<<1), 39+10-l, p, 4, 10+16+128); - minitext(160-(Bstrlen(p)<<1), 38+10-l, p, 8, 10+16+128); + if (conversion == 13) l = (-2); + gametext(160,38-l,"GAME PROGRAMMING",0,2+8+16); + p = "Richard \"TerminX\" Gobeille"; + minitext(161-(Bstrlen(p)<<1), 39+10-l, p, 4, 10+16+128); + minitext(160-(Bstrlen(p)<<1), 38+10-l, p, 8, 10+16+128); - gametext(160,57-l,"\"JFDUKE3D\" AND \"JFBUILD\" CODE",0,2+8+16); - p = "Jonathon \"JonoF\" Fowler"; - minitext(161-(Bstrlen(p)<<1), 58+10-l, p, 4, 10+16+128); - minitext(160-(Bstrlen(p)<<1), 57+10-l, p, 8, 10+16+128); + gametext(160,57-l,"\"JFDUKE3D\" AND \"JFBUILD\" CODE",0,2+8+16); + p = "Jonathon \"JonoF\" Fowler"; + minitext(161-(Bstrlen(p)<<1), 58+10-l, p, 4, 10+16+128); + minitext(160-(Bstrlen(p)<<1), 57+10-l, p, 8, 10+16+128); - gametext(160,76-l,"ORIGINAL \"POLYMOST\" RENDERER",0,2+8+16); - gametext(160,76+8-l,"NETWORKING, OTHER CODE",0,2+8+16); - p = "Ken \"Awesoken\" Silverman"; - minitext(161-(Bstrlen(p)<<1), 77+8+10-l, p, 4, 10+16+128); - minitext(160-(Bstrlen(p)<<1), 76+8+10-l, p, 8, 10+16+128); + gametext(160,76-l,"ORIGINAL \"POLYMOST\" RENDERER",0,2+8+16); + gametext(160,76+8-l,"NETWORKING, OTHER CODE",0,2+8+16); + p = "Ken \"Awesoken\" Silverman"; + minitext(161-(Bstrlen(p)<<1), 77+8+10-l, p, 4, 10+16+128); + minitext(160-(Bstrlen(p)<<1), 76+8+10-l, p, 8, 10+16+128); - gametext(160,103-l,"RENDERING FEATURES",0,2+8+16); - p = "Pierre-Loup \"Plagman\" Griffais"; - minitext(161-(Bstrlen(p)<<1), 104+10-l, p, 4, 10+16+128); - minitext(160-(Bstrlen(p)<<1), 103+10-l, p, 8, 10+16+128); + gametext(160,103-l,"RENDERING FEATURES",0,2+8+16); + p = "Pierre-Loup \"Plagman\" Griffais"; + minitext(161-(Bstrlen(p)<<1), 104+10-l, p, 4, 10+16+128); + minitext(160-(Bstrlen(p)<<1), 103+10-l, p, 8, 10+16+128); - gametext(160,122-l,"LICENSE AND OTHER CONTRIBUTORS",0,2+8+16); + gametext(160,122-l,"LICENSE AND OTHER CONTRIBUTORS",0,2+8+16); + { + const char *scroller[] = { - const char *scroller[] = - { - "This program is distributed under the terms of the", - "GNU General Public License version 2 as published by the", - "Free Software Foundation. See GNU.TXT for details.", - "", - "Thanks to the following people for their contributions:", - "", - "Adam Fazakerley", - "Ed Coolidge", - "Javier Martinez", - "Jeff Hart", - "Jonathan Smith", - "Jose del Castillo", - "Lachlan McDonald", - "Matthew Palmer", - "Peter Green", - "", - "EDuke originally by Matt Saettler", - "", - "--x--", - "", - "", - "", - "", - "", - "" - }; - const int numlines = sizeof(scroller)/sizeof(char *); - for (m=0,i=(totalclock/104)%numlines; m<6; m++,i++) - { - if (i==numlines) i=0; - minitext(161-(Bstrlen(scroller[i])<<1), 101+10+10+8+4+(m*7)-l, (char*)scroller[i], 4, 10+16+128); - minitext(160-(Bstrlen(scroller[i])<<1), 100+10+10+8+4+(m*7)-l, (char*)scroller[i], 8, 10+16+128); - } - } - - p = "Visit www.eduke32.com for news and updates"; - minitext(161-(Bstrlen(p)<<1), 136+10+10+10+10+4-l, p, 4, 10+16+128); - minitext(160-(Bstrlen(p)<<1), 135+10+10+10+10+4-l, p, 8, 10+16+128); - } - break; - - case 0: - c = (320>>1); - rotatesprite(c<<16,28<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); - if (PLUTOPAK) // JBF 20030804 - rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); - x = probe(c,67,16,6); - if (x >= 0) - { - if (ud.multimode > 1 && x == 0 && ud.recstat != 2) + "This program is distributed under the terms of the", + "GNU General Public License version 2 as published by the", + "Free Software Foundation. See GNU.TXT for details.", + "", + "Thanks to the following people for their contributions:", + "", + "Adam Fazakerley", + "Ed Coolidge", + "Javier Martinez", + "Jeff Hart", + "Jonathan Smith", + "Jose del Castillo", + "Lachlan McDonald", + "Matthew Palmer", + "Peter Green", + "", + "EDuke originally by Matt Saettler", + "", + "--x--", + "", + "", + "", + "", + "", + "" + }; + const int numlines = sizeof(scroller)/sizeof(char *); + for (m=0,i=(totalclock/104)%numlines; m<6; m++,i++) { - if (movesperpacket == 4 && myconnectindex != connecthead) - break; - - last_zero = 0; - cmenu(600); - } - else - { - last_zero = x; - switch (x) - { - case 0: - cmenu(100); - break; - //case 1: break;//cmenu(20001);break; // JBF 20031128: I'm taking over the TEN menu option - case 1: - cmenu(202); - break; // JBF 20031205: was 200 - case 2: - if (movesperpacket == 4 && connecthead != myconnectindex) - break; - cmenu(300); - break; - case 3: - KB_FlushKeyboardQueue(); - cmenu(400); - break; - case 4: - cmenu(990); - break; - case 5: - cmenu(500); - break; - } + if (i==numlines) i=0; + minitext(161-(Bstrlen(scroller[i])<<1), 101+10+10+8+4+(m*7)-l, (char*)scroller[i], 4, 10+16+128); + minitext(160-(Bstrlen(scroller[i])<<1), 100+10+10+8+4+(m*7)-l, (char*)scroller[i], 8, 10+16+128); } } - if (KB_KeyPressed(sc_Q)) cmenu(500); + p = "Visit www.eduke32.com for news and updates"; + minitext(161-(Bstrlen(p)<<1), 136+10+10+10+10+4-l, p, 4, 10+16+128); + minitext(160-(Bstrlen(p)<<1), 135+10+10+10+10+4-l, p, 8, 10+16+128); + } + break; - if (x == -1 && (ps[myconnectindex].gm&MODE_GAME || ud.recstat == 2)) + case 0: + c = (320>>1); + rotatesprite(c<<16,28<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); + x = probe(c,67,16,6); + if (x >= 0) + { + if (ud.multimode > 1 && x == 0 && ud.recstat != 2) { - ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } + if (movesperpacket == 4 && myconnectindex != connecthead) + break; - if (movesperpacket == 4) - { - if (myconnectindex == connecthead) - menutext(c,67,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); - else - menutext(c,67,MENUHIGHLIGHT(0),1,"NEW GAME"); - } - else - menutext(c,67,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); - - // menutext(c,67+16,0,1,"NETWORK GAME"); - - menutext(c,67+16/*+16*/,MENUHIGHLIGHT(1),PHX(-3),"OPTIONS"); - - if (movesperpacket == 4 && connecthead != myconnectindex) - menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),1,"LOAD GAME"); - else menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),PHX(-4),"LOAD GAME"); - - if (!VOLUMEALL) - { - - menutext(c,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),PHX(-5),"HOW TO ORDER"); + last_zero = 0; + cmenu(600); } else { - - menutext(c,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),PHX(-5),"HELP"); - } - - menutext(c,67+16+16+16+16/*+16*/,MENUHIGHLIGHT(4),PHX(-6),"CREDITS"); - - - menutext(c,67+16+16+16+16+16/*+16*/,MENUHIGHLIGHT(5),PHX(-7),"QUIT"); - break; - - case 50: - c = (320>>1); - rotatesprite(c<<16,32<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); - if (PLUTOPAK) // JBF 20030804 - rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); - x = probe(c,67,16,7); - switch (x) - { + last_zero = x; + switch (x) + { case 0: - if (movesperpacket == 4 && myconnectindex != connecthead) - break; - if (ud.multimode < 2 || ud.recstat == 2) - cmenu(1500); - else - { - cmenu(600); - last_fifty = 0; - } + cmenu(100); break; + //case 1: break;//cmenu(20001);break; // JBF 20031128: I'm taking over the TEN menu option case 1: - if (movesperpacket == 4 && connecthead != myconnectindex) - break; - if (ud.recstat != 2) - { - last_fifty = 1; - cmenu(350); - setview(0,0,xdim-1,ydim-1); - } - break; + cmenu(202); + break; // JBF 20031205: was 200 case 2: if (movesperpacket == 4 && connecthead != myconnectindex) break; - last_fifty = 2; cmenu(300); break; case 3: - last_fifty = 3; - cmenu(202); // JBF 20031205: was 200 - break; - case 4: - last_fifty = 4; KB_FlushKeyboardQueue(); cmenu(400); break; - case 5: - if (numplayers < 2) - { - last_fifty = 5; - cmenu(501); - } + case 4: + cmenu(990); break; - case 6: - last_fifty = 6; + case 5: cmenu(500); break; - case -1: - ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - break; + } } + } - if (KB_KeyPressed(sc_Q)) - cmenu(500); + if (KB_KeyPressed(sc_Q)) cmenu(500); - if (movesperpacket == 4 && connecthead != myconnectindex) + if (x == -1 && (ps[myconnectindex].gm&MODE_GAME || ud.recstat == 2)) + { + ps[myconnectindex].gm &= ~MODE_MENU; + if (ud.multimode < 2 && ud.recstat != 2) { - menutext(c,67 ,MENUHIGHLIGHT(0),1,"NEW GAME"); - menutext(c,67+16 ,MENUHIGHLIGHT(1),1,"SAVE GAME"); - menutext(c,67+16+16 ,MENUHIGHLIGHT(2),1,"LOAD GAME"); + ready2send = 1; + totalclock = ototalclock; } + } + + if (movesperpacket == 4) + { + if (myconnectindex == connecthead) + menutext(c,67,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); + else + menutext(c,67,MENUHIGHLIGHT(0),1,"NEW GAME"); + } + else + menutext(c,67,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); + + // menutext(c,67+16,0,1,"NETWORK GAME"); + + menutext(c,67+16/*+16*/,MENUHIGHLIGHT(1),PHX(-3),"OPTIONS"); + + if (movesperpacket == 4 && connecthead != myconnectindex) + menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),1,"LOAD GAME"); + else menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),PHX(-4),"LOAD GAME"); + + if (!VOLUMEALL) + { + + menutext(c,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),PHX(-5),"HOW TO ORDER"); + } + else + { + + menutext(c,67+16+16+16/*+16*/,MENUHIGHLIGHT(3),PHX(-5),"HELP"); + } + + menutext(c,67+16+16+16+16/*+16*/,MENUHIGHLIGHT(4),PHX(-6),"CREDITS"); + + + menutext(c,67+16+16+16+16+16/*+16*/,MENUHIGHLIGHT(5),PHX(-7),"QUIT"); + break; + + case 50: + c = (320>>1); + rotatesprite(c<<16,32<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); + x = probe(c,67,16,7); + switch (x) + { + case 0: + if (movesperpacket == 4 && myconnectindex != connecthead) + break; + if (ud.multimode < 2 || ud.recstat == 2) + cmenu(1500); else { - menutext(c,67 ,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); - menutext(c,67+16 ,MENUHIGHLIGHT(1),PHX(-3),"SAVE GAME"); - menutext(c,67+16+16 ,MENUHIGHLIGHT(2),PHX(-4),"LOAD GAME"); + cmenu(600); + last_fifty = 0; } - - menutext(c,67+16+16+16 ,MENUHIGHLIGHT(3),PHX(-5),"OPTIONS"); - if (!VOLUMEALL) - { - menutext(c,67+16+16+16+16 ,MENUHIGHLIGHT(4),PHX(-6),"HOW TO ORDER"); - } - else - { - menutext(c,67+16+16+16+16 ,MENUHIGHLIGHT(4),PHX(-6)," HELP"); - } - if (numplayers > 1) - menutext(c,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),1,"QUIT TO TITLE"); - else menutext(c,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),PHX(-7),"QUIT TO TITLE"); - menutext(c,67+16+16+16+16+16+16,MENUHIGHLIGHT(6),PHX(-8),"QUIT GAME"); break; - - case 100: - rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,24,0,0,"SELECT AN EPISODE"); - x = probe(160,VOLUMEONE?60:60-(num_volumes*2),20,VOLUMEONE?3:num_volumes+1); - if (x >= 0) + case 1: + if (movesperpacket == 4 && connecthead != myconnectindex) + break; + if (ud.recstat != 2) { - if (VOLUMEONE) - { - if (x > 0) - cmenu(20000); - else - { - ud.m_volume_number = x; - ud.m_level_number = 0; - last_onehundred = x; - cmenu(110); - } - } - - if (!VOLUMEONE) - { - if (x == num_volumes /*&& boardfilename[0]*/) - { - //ud.m_volume_number = 0; - //ud.m_level_number = 7; - currentlist = 1; - last_onehundred = x; - cmenu(101); - } - else - { - ud.m_volume_number = x; - ud.m_level_number = 0; - last_onehundred = x; - cmenu(110); - } - } + last_fifty = 1; + cmenu(350); + setview(0,0,xdim-1,ydim-1); } - else if (x == -1) + break; + case 2: + if (movesperpacket == 4 && connecthead != myconnectindex) + break; + last_fifty = 2; + cmenu(300); + break; + case 3: + last_fifty = 3; + cmenu(202); // JBF 20031205: was 200 + break; + case 4: + last_fifty = 4; + KB_FlushKeyboardQueue(); + cmenu(400); + break; + case 5: + if (numplayers < 2) { - if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); - else cmenu(0); + last_fifty = 5; + cmenu(501); } + break; + case 6: + last_fifty = 6; + cmenu(500); + break; + case -1: + ps[myconnectindex].gm &= ~MODE_MENU; + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + break; + } + if (KB_KeyPressed(sc_Q)) + cmenu(500); + if (movesperpacket == 4 && connecthead != myconnectindex) + { + menutext(c,67 ,MENUHIGHLIGHT(0),1,"NEW GAME"); + menutext(c,67+16 ,MENUHIGHLIGHT(1),1,"SAVE GAME"); + menutext(c,67+16+16 ,MENUHIGHLIGHT(2),1,"LOAD GAME"); + } + else + { + menutext(c,67 ,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); + menutext(c,67+16 ,MENUHIGHLIGHT(1),PHX(-3),"SAVE GAME"); + menutext(c,67+16+16 ,MENUHIGHLIGHT(2),PHX(-4),"LOAD GAME"); + } - c = 80; + menutext(c,67+16+16+16 ,MENUHIGHLIGHT(3),PHX(-5),"OPTIONS"); + if (!VOLUMEALL) + { + menutext(c,67+16+16+16+16 ,MENUHIGHLIGHT(4),PHX(-6),"HOW TO ORDER"); + } + else + { + menutext(c,67+16+16+16+16 ,MENUHIGHLIGHT(4),PHX(-6)," HELP"); + } + if (numplayers > 1) + menutext(c,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),1,"QUIT TO TITLE"); + else menutext(c,67+16+16+16+16+16 ,MENUHIGHLIGHT(5),PHX(-7),"QUIT TO TITLE"); + menutext(c,67+16+16+16+16+16+16,MENUHIGHLIGHT(6),PHX(-8),"QUIT GAME"); + break; + + case 100: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"SELECT AN EPISODE"); + x = probe(160,VOLUMEONE?60:60-(num_volumes*2),20,VOLUMEONE?3:num_volumes+1); + if (x >= 0) + { if (VOLUMEONE) { - menutext(160,60,MENUHIGHLIGHT(0),PHX(-2),volume_names[0]); - menutext(160,60+20,MENUHIGHLIGHT(1),1,volume_names[1]); - menutext(160,60+20+20,MENUHIGHLIGHT(2),1,volume_names[2]); - if (PLUTOPAK) - menutext(160,60+20+20,MENUHIGHLIGHT(3),1,volume_names[3]); + if (x > 0) + cmenu(20000); + else + { + ud.m_volume_number = x; + ud.m_level_number = 0; + last_onehundred = x; + cmenu(110); + } + } + + if (!VOLUMEONE) + { + if (x == num_volumes /*&& boardfilename[0]*/) + { + //ud.m_volume_number = 0; + //ud.m_level_number = 7; + currentlist = 1; + last_onehundred = x; + cmenu(101); + } + else + { + ud.m_volume_number = x; + ud.m_level_number = 0; + last_onehundred = x; + cmenu(110); + } + } + } + else if (x == -1) + { + if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + } + + + + c = 80; + if (VOLUMEONE) + { + menutext(160,60,MENUHIGHLIGHT(0),PHX(-2),volume_names[0]); + menutext(160,60+20,MENUHIGHLIGHT(1),1,volume_names[1]); + menutext(160,60+20+20,MENUHIGHLIGHT(2),1,volume_names[2]); + if (PLUTOPAK) + menutext(160,60+20+20,MENUHIGHLIGHT(3),1,volume_names[3]); + } + else + { + for (i=0;i 0) + { + while (KB_KeyPressed(sc_End)?seeker->next:seeker->prev) + seeker = KB_KeyPressed(sc_End)?seeker->next:seeker->prev; + if (seeker) + { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + sound(KICK_HIT); + } + } + else if ((KB_KeyPressed(sc_PgUp)|KB_KeyPressed(sc_PgDn)) > 0) + { + seeker = currentlist?findfileshigh:finddirshigh; + i = 6; + while (i>0) + { + if (KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev) + seeker = KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev; + i--; + } + if (seeker) + { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + sound(KICK_HIT); + } } else { - for (i=0;i 0) + char ch2, ch; + ch = KB_Getch(); + if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { - while (KB_KeyPressed(sc_End)?seeker->next:seeker->prev) - seeker = KB_KeyPressed(sc_End)?seeker->next:seeker->prev; - if (seeker) + if (ch >= 'a') ch -= ('a'-'A'); + while (seeker) { - if (currentlist) findfileshigh = seeker; - else finddirshigh = seeker; - sound(KICK_HIT); - } - } - else if ((KB_KeyPressed(sc_PgUp)|KB_KeyPressed(sc_PgDn)) > 0) - { - seeker = currentlist?findfileshigh:finddirshigh; - i = 6; - while (i>0) - { - if (KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev) - seeker = KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev; - i--; + ch2 = seeker->name[0]; + if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A'); + if (ch2 == ch) break; + seeker = seeker->next; } if (seeker) { @@ -2054,2373 +2070,1877 @@ cheat_for_port_credits: sound(KICK_HIT); } } - else - { - char ch2, ch; - ch = KB_Getch(); - if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) - { - if (ch >= 'a') ch -= ('a'-'A'); - while (seeker) - { - ch2 = seeker->name[0]; - if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A'); - if (ch2 == ch) break; - seeker = seeker->next; - } - if (seeker) - { - if (currentlist) findfileshigh = seeker; - else finddirshigh = seeker; - sound(KICK_HIT); - } - } - } } - gametext(40+4,12+32,"DIRECTORIES",0,2+8+16); + } + gametext(40+4,12+32,"DIRECTORIES",0,2+8+16); - if (finddirshigh) + if (finddirshigh) + { + dir = finddirshigh; + for (i=0; i<2; i++) if (!dir->prev) break; + else dir=dir->prev; + for (i=2; i>-2 && dir; i--, dir=dir->next) { - dir = finddirshigh; - for (i=0; i<2; i++) if (!dir->prev) break; - else dir=dir->prev; - for (i=2; i>-2 && dir; i--, dir=dir->next) - { - if (dir == finddirshigh) c=0; - else c=16; - minitextshade(40,1+12+32+8*(3-i),dir->name,c,0,26); - } + if (dir == finddirshigh) c=0; + else c=16; + minitextshade(40,1+12+32+8*(3-i),dir->name,c,0,26); } + } - gametext(40+4,8+32+40+8-1,"MAP FILES",0,2+8+16); + gametext(40+4,8+32+40+8-1,"MAP FILES",0,2+8+16); - if (findfileshigh) + if (findfileshigh) + { + dir = findfileshigh; + for (i=0; i<4; i++) if (!dir->prev) break; + else dir=dir->prev; + for (i=4; i>-4 && dir; i--, dir=dir->next) { - dir = findfileshigh; - for (i=0; i<4; i++) if (!dir->prev) break; - else dir=dir->prev; - for (i=4; i>-4 && dir; i--, dir=dir->next) - { - if (dir == findfileshigh) c=0; - else c=16; - minitextshade(40,(8+32+8*5)+8*(6-i),dir->name,c,2,26); - } + if (dir == findfileshigh) c=0; + else c=16; + minitextshade(40,(8+32+8*5)+8*(6-i),dir->name,c,2,26); } + } - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && minfo.dyaw < -256) || - KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && minfo.dyaw > 256) || - KB_KeyPressed(sc_Tab)) + if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && minfo.dyaw < -256) || + KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && minfo.dyaw > 256) || + KB_KeyPressed(sc_Tab)) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_Tab); + currentlist = 1-currentlist; + sound(KICK_HIT); + } + + onbar = 0; + probey = 2; + if (currentlist == 0) x = probe(50,12+32+16+4,0,3); + else x = probe(50,8+32+40+40+4,0,3); + + if (probey == 1) + { + if (currentlist == 0) { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_Tab); - currentlist = 1-currentlist; - sound(KICK_HIT); + if (finddirshigh) + if (finddirshigh->prev) finddirshigh = finddirshigh->prev; } - - onbar = 0; - probey = 2; - if (currentlist == 0) x = probe(50,12+32+16+4,0,3); - else x = probe(50,8+32+40+40+4,0,3); - - if (probey == 1) + else { - if (currentlist == 0) - { - if (finddirshigh) - if (finddirshigh->prev) finddirshigh = finddirshigh->prev; - } - else - { - if (findfileshigh) - if (findfileshigh->prev) findfileshigh = findfileshigh->prev; - } + if (findfileshigh) + if (findfileshigh->prev) findfileshigh = findfileshigh->prev; } - else if (probey == 0) + } + else if (probey == 0) + { + if (currentlist == 0) { - if (currentlist == 0) - { - if (finddirshigh) - if (finddirshigh->next) finddirshigh = finddirshigh->next; - } - else - { - if (findfileshigh) - if (findfileshigh->next) findfileshigh = findfileshigh->next; - } + if (finddirshigh) + if (finddirshigh->next) finddirshigh = finddirshigh->next; } - - if (x == -1) + else { - clearfilenames(); - boardfilename[0] = 0; + if (findfileshigh) + if (findfileshigh->next) findfileshigh = findfileshigh->next; + } + } + + if (x == -1) + { + clearfilenames(); + boardfilename[0] = 0; + if (ud.multimode > 1) + { + sendboardname(); + cmenu(600); + probey = last_probey; + } + else cmenu(100); + } + else if (x >= 0) + { + if (currentlist == 0) + { + if (!finddirshigh) break; + strcat(boardfilename, finddirshigh->name); + strcat(boardfilename, "/"); + Bcorrectfilename(boardfilename, 1); + cmenu(101); + KB_FlushKeyboardQueue(); + } + else + { + if (!findfileshigh) break; + strcat(boardfilename, findfileshigh->name); + ud.m_volume_number = 0; + ud.m_level_number = 7; if (ud.multimode > 1) { sendboardname(); cmenu(600); probey = last_probey; } - else cmenu(100); + else cmenu(110); } - else if (x >= 0) + clearfilenames(); + } + break; + + case 110: + c = (320>>1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(c,24,0,0,"SELECT SKILL"); + x = probe(c,70,19,4); + if (x >= 0) + { + switch (x) { - if (currentlist == 0) + case 0: + globalskillsound = JIBBED_ACTOR6; + break; + case 1: + globalskillsound = BONUS_SPEECH1; + break; + case 2: + globalskillsound = DUKE_GETWEAPON2; + break; + case 3: + globalskillsound = JIBBED_ACTOR5; + break; + } + + sound(globalskillsound); + + ud.m_player_skill = x+1; + if (x == 3) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + if (ud.m_volume_number == 3) + { + flushperms(); + setview(0,0,xdim-1,ydim-1); + clearview(0L); + nextpage(); + } + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (enterlevel(MODE_GAME)) backtomenu(); + } + else if (x == -1) + { + cmenu(100); + KB_FlushKeyboardQueue(); + } + + menutext(c,70,MENUHIGHLIGHT(0),PHX(-2),skill_names[0]); + menutext(c,70+19,MENUHIGHLIGHT(1),PHX(-3),skill_names[1]); + menutext(c,70+19+19,MENUHIGHLIGHT(2),PHX(-4),skill_names[2]); + menutext(c,70+19+19+19,MENUHIGHLIGHT(3),PHX(-5),skill_names[3]); + break; + case 230: +#if defined(POLYMOST) && defined(USE_OPENGL) + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"ADVANCED VIDEO"); + + c = (320>>1)-120; + + { + int io, ii, yy, d=c+160+40, enabled; + char *opts[] = { + "Widescreen", + "-", + "Hightile textures", + "Precache textures", + "GL texture compression", + "Cache textures on disk", + "Compress disk cache", + "-", + "Models", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + NULL + }; + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) { - if (!finddirshigh) break; - strcat(boardfilename, finddirshigh->name); - strcat(boardfilename, "/"); - Bcorrectfilename(boardfilename, 1); - cmenu(101); - KB_FlushKeyboardQueue(); + if (io <= probey) yy += 4; + continue; + } + if (io < probey) yy += 8; + io++; + } + + onbar = 0; + x = probesm(c,yy+5,0,io); + + if (x == -1) + { + cmenu(203); + probey = 7; + break; + } + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) + { + yy += 4; + continue; + } + enabled = 1; + switch (io) + { + case 0: + if (x==io) glwidescreen = 1-glwidescreen; + modval(0,1,(int *)&glwidescreen,1,probey==io); + gametextpal(d,yy, glwidescreen ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 1: + if (x==io) usehightile = 1-usehightile; + modval(0,1,(int *)&usehightile,1,probey==io); + gametextpal(d,yy, usehightile ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 2: + enabled = usehightile; + if (enabled && x==io) useprecache = !useprecache; + if (enabled) modval(0,1,(int *)&useprecache,1,probey==io); + gametextpal(d,yy, useprecache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); + break; + case 3: + enabled = usehightile; + if (enabled && x==io) glusetexcompr = !glusetexcompr; + if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io); + gametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); + break; + case 4: + enabled = (glusetexcompr && usehightile && useprecache); + if (enabled && x==io) glusetexcache = !glusetexcache; + if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io); + gametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); + break; + case 5: + enabled = (glusetexcompr && usehightile && useprecache && glusetexcache); + if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression; + if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io); + gametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); + break; + case 6: + if (x==io) usemodels = 1-usemodels; + modval(0,1,(int *)&usemodels,1,probey==io); + gametextpal(d,yy, usemodels ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + default: + break; + } + gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); + io++; + yy += 8; + } + } +#endif + break; + + case 200: + + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"GAME SETUP"); + + c = (320>>1)-120; + + { + int io, ii, yy, d=c+160+40, enabled; + char *opts[] = { + "Crosshair", + "Level stats", + "-", + "Screen size", + "Status bar size", + "-", + "Run key style", + "-", + "Detail", + "Shadows", + "Screen tilting", + "-", + "Show opponent weapon", + "Demo playback cameras", + "Record demo", + "-", + "-", + "-", + "More...", + NULL + }; + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) + { + if (io <= probey) yy += 4; + continue; + } + if (io < probey) yy += 8; + io++; + } + + onbar = (probey == 2 || probey == 3); + x = probesm(c,yy+5,0,io); + + if (x == -1) + { + cmenu(202); + break; + } + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) + { + yy += 4; + continue; + } + enabled = 1; + switch (io) + { + case 0: + if (x==io) ud.crosshair = (ud.crosshair==3)?0:ud.crosshair+1; + modval(0,3,(int *)&ud.crosshair,1,probey==io); + { + char *s[] = { "OFF", "ON [100%]", "ON [50%]", "ON [25%]" }; + gametextpal(d,yy,s[ud.crosshair], MENUHIGHLIGHT(io), 0); + break; + } + case 1: + if (x==io) ud.levelstats = 1-ud.levelstats; + modval(0,1,(int *)&ud.levelstats,1,probey==io); + gametextpal(d,yy, ud.levelstats ? "Shown" : "Hidden", MENUHIGHLIGHT(io), 0); + break; + case 2: + { + int i; + i = ud.screen_size; + barsm(d+8,yy+7, (short *)&ud.screen_size,-4,x==io,MENUHIGHLIGHT(io),PHX(-5)); + if (i < ud.screen_size && i == 8 && ud.statusbarmode == 1 && bpp > 8) + { + ud.statusbarmode = 0; + if (ud.statusbarscale != 100) + ud.screen_size = i; + } + else if (i > ud.screen_size && i == 8 && ud.statusbarmode == 0 && bpp > 8) + { + if (ud.statusbarscale != 100) + { + ud.statusbarmode = 1; + ud.screen_size = i; + } + } + } + break; + case 3: + { + short sbs, sbsl; + sbs = sbsl = ud.statusbarscale-37; + barsm(d+8,yy+7, (short *)&sbs,8,x==io,MENUHIGHLIGHT(io),PHX(-5)); + if (x == io && sbs != sbsl) + { + sbs += 37; + setstatusbarscale(sbs); + } + } + break; + case 4: + if (x==io) ud.runkey_mode = 1-ud.runkey_mode; + modval(0,1,(int *)&ud.runkey_mode,1,probey==io); + gametextpal(d,yy, ud.runkey_mode ? "Classic" : "Modern", MENUHIGHLIGHT(io), 0); + break; + case 5: + if (x==io) ud.detail = 1-ud.detail; + modval(0,1,(int *)&ud.detail,1,probey==io); + gametextpal(d,yy, ud.detail ? "High" : "Low", MENUHIGHLIGHT(io), 0); + break; + case 6: + if (x==io) ud.shadows = 1-ud.shadows; + modval(0,1,(int *)&ud.shadows,1,probey==io); + gametextpal(d,yy, ud.shadows ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 7: + if (x==io) ud.screen_tilting = 1-ud.screen_tilting; + modval(0,1,(int *)&ud.screen_tilting,1,probey==io); + gametextpal(d,yy, ud.screen_tilting ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; // original had a 'full' option + case 8: + if (x==io) ud.showweapons = 1-ud.showweapons; + modval(0,1,(int *)&ud.showweapons,1,probey==io); + ShowOpponentWeapons = ud.showweapons; + gametextpal(d,yy, ShowOpponentWeapons ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 9: + if (x==io) ud.democams = 1-ud.democams; + modval(0,1,(int *)&ud.democams,1,probey==io); + gametextpal(d,yy, ud.democams ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 10: + if (x==io) + { + enabled = !((ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1); + if ((ps[myconnectindex].gm&MODE_GAME)) closedemowrite(); + else ud.m_recstat = !ud.m_recstat; + } + if ((ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1) + enabled = 0; + gametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && ps[myconnectindex].gm&MODE_GAME)?"Recording":"On"):"Off",enabled?MENUHIGHLIGHT(io):15,enabled?0:1); + break; + case 11: + if (x==io) cmenu(201); + break; + default: + break; + } + gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); + io++; + yy += 8; + } + } + break; + + case 201: + + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"GAME SETUP"); + + c = (320>>1)-120; + + { + int io, ii, yy, d=c+160+40, enabled; + char *opts[] = { + "Parental lock", + "-", + "HUD weapon", + "FPS counter", + "-", + "Automatic voting", + "Send MP messages to all", + "Display other player IDs", + "-", + "Show startup window", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "Previous page", + NULL + }; + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) + { + if (io <= probey) yy += 4; + continue; + } + if (io < probey) yy += 8; + io++; + } + + x = probesm(c,yy+5,0,io); + + if (x == -1) + { + cmenu(200); + probey = 11; + break; + } + + yy = 37; + for (ii=io=0; opts[ii]; ii++) + { + if (opts[ii][0] == '-' && !opts[ii][1]) + { + yy += 4; + continue; + } + enabled = 1; + switch (io) + { + case 0: + if (!NAM) + { + if (x==io) cmenu(10000); + } + else enabled = 0; + break; + case 1: + if (x==io) + { + ud.drawweapon = (ud.drawweapon == 2) ? 0 : ud.drawweapon+1; + } + modval(0,2,(int *)&ud.drawweapon,1,probey==io); + { + char *s[] = { "Off", "On", "Icon" }; + gametextpal(d,yy, s[ud.drawweapon], MENUHIGHLIGHT(io), 0); + break; + } + case 2: + if (x==io) ud.tickrate = 1-ud.tickrate; + modval(0,1,(int *)&ud.tickrate,1,probey==io); + gametextpal(d,yy, ud.tickrate ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 3: + if (x==io) + { + ud.autovote = (ud.autovote == 2) ? 0 : ud.autovote+1; + } + modval(0,2,(int *)&ud.autovote,1,probey==io); + { + char *s[] = { "Off", "Vote No", "Vote Yes" }; + gametextpal(d,yy, s[ud.autovote], MENUHIGHLIGHT(io), 0); + break; + } + case 4: + if (x==io) ud.automsg = 1-ud.automsg; + modval(0,1,(int *)&ud.automsg,1,probey==io); + gametextpal(d,yy, ud.automsg ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 5: + if (x==io) ud.idplayers = 1-ud.idplayers; + modval(0,1,(int *)&ud.idplayers,1,probey==io); + gametextpal(d,yy, ud.idplayers ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 6: + if (x==io) ForceSetup = 1-ForceSetup; + modval(0,1,(int *)&ForceSetup,1,probey==io); + gametextpal(d,yy, ForceSetup ? "On" : "Off", MENUHIGHLIGHT(io), 0); + break; + case 7: + if (x==io) cmenu(200); + break; + default: + break; + } + gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); + io++; + yy += 8; + } + } + break; + + // JBF 20031205: Second level options menu selection + case 202: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"OPTIONS"); + + c = 50; + + onbar = 0; + x = probe(160,c,18,7); + + last_twoohtwo = probey; + + switch (x) + { + case -1: + if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + break; + + case 0: + cmenu(200); + break; + + case 1: + cmenu(700); + break; + + case 2: + { + int dax = xdim, day = ydim, daz; + curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen,0); + if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt; + newfullscreen = fullscreen; + changesmade = 0; + + dax = 0; + for (day = 0; day < validmodecnt; day++) + { + if (dax == sizeof(vidsets)/sizeof(vidsets[1])) break; + for (daz = 0; daz < dax; daz++) + if ((validmode[day].bpp|((validmode[day].fs&1)<<16)) == (vidsets[daz]&0x1ffffl)) break; + if (vidsets[daz] != -1) continue; + if (validmode[day].bpp == 8) + { + vidsets[dax++] = 8|((validmode[day].fs&1)<<16); + vidsets[dax++] = 0x20000|8|((validmode[day].fs&1)<<16); + } + else + vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16); + } + for (dax = 0; dax < (long)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++) + if (vidsets[dax] == (((getrendermode()>=2)<<17)|(fullscreen<<16)|bpp)) break; + if (dax < (long)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; + curvidset = newvidset; + + cmenu(203); + } + break; + case 3: + if (ud.recstat != 1) + cmenu(20002); + break; + case 4: + currentlist = 0; + case 5: + case 6: + if (x==6 && !CONTROL_JoyPresent) break; + cmenu(204+x-4); + break; + } + + menutext(160,c, MENUHIGHLIGHT(0),0,"GAME SETUP"); + menutext(160,c+18, MENUHIGHLIGHT(1),0,"SOUND SETUP"); + menutext(160,c+18+18, MENUHIGHLIGHT(2),0,"VIDEO SETUP"); + menutext(160,c+18+18+18, MENUHIGHLIGHT(3),ud.recstat == 1,"PLAYER SETUP"); + menutext(160,c+18+18+18+18, MENUHIGHLIGHT(4),0,"KEYBOARD SETUP"); + menutext(160,c+18+18+18+18+18, MENUHIGHLIGHT(5),0,"MOUSE SETUP"); + menutext(160,c+18+18+18+18+18+18,MENUHIGHLIGHT(6),CONTROL_JoyPresent==0,"JOYSTICK SETUP"); + break; + + // JBF 20031206: Video settings menu + case 203: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"VIDEO SETUP"); + + c = (320>>1)-120; + +#if defined(POLYMOST) && defined(USE_OPENGL) + x = 8; +#else + x = 5; +#endif + onbar = (probey == 4); + if (probey == 0 || probey == 1 || probey == 2) + x = probe(c,50,16,x); + else if (probey == 3) + x = probe(c,50+16+16+22,0,x); + else + x = probe(c,50+62-16-16-16,16,x); + + if (probey==0 && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_RightArrow))) + { + sound(PISTOL_BODYHIT); + x=0; + } + switch (x) + { + case -1: + cmenu(202); + probey = 2; + break; + + case 0: + do + { + if (KB_KeyPressed(sc_LeftArrow)) + { + newvidmode--; + if (newvidmode < 0) newvidmode = validmodecnt-1; } else { - if (!findfileshigh) break; - strcat(boardfilename, findfileshigh->name); - ud.m_volume_number = 0; - ud.m_level_number = 7; - if (ud.multimode > 1) - { - sendboardname(); - cmenu(600); - probey = last_probey; - } - else cmenu(110); - } - clearfilenames(); - } - break; - - case 110: - c = (320>>1); - rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(c,24,0,0,"SELECT SKILL"); - x = probe(c,70,19,4); - if (x >= 0) - { - switch (x) - { - case 0: - globalskillsound = JIBBED_ACTOR6; - break; - case 1: - globalskillsound = BONUS_SPEECH1; - break; - case 2: - globalskillsound = DUKE_GETWEAPON2; - break; - case 3: - globalskillsound = JIBBED_ACTOR5; - break; - } - - sound(globalskillsound); - - ud.m_player_skill = x+1; - if (x == 3) ud.m_respawn_monsters = 1; - else ud.m_respawn_monsters = 0; - - ud.m_monsters_off = ud.monsters_off = 0; - - ud.m_respawn_items = 0; - ud.m_respawn_inventory = 0; - - ud.multimode = 1; - - if (ud.m_volume_number == 3) - { - flushperms(); - setview(0,0,xdim-1,ydim-1); - clearview(0L); - nextpage(); - } - - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); - } - else if (x == -1) - { - cmenu(100); - KB_FlushKeyboardQueue(); - } - - menutext(c,70,MENUHIGHLIGHT(0),PHX(-2),skill_names[0]); - menutext(c,70+19,MENUHIGHLIGHT(1),PHX(-3),skill_names[1]); - menutext(c,70+19+19,MENUHIGHLIGHT(2),PHX(-4),skill_names[2]); - menutext(c,70+19+19+19,MENUHIGHLIGHT(3),PHX(-5),skill_names[3]); - break; - case 230: -#if defined(POLYMOST) && defined(USE_OPENGL) - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"ADVANCED VIDEO"); - - c = (320>>1)-120; - - { - int io, ii, yy, d=c+160+40, enabled; - char *opts[] = { - "Widescreen", - "-", - "Hightile textures", - "Precache textures", - "GL texture compression", - "Cache textures on disk", - "Compress disk cache", - "-", - "Models", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - onbar = 0; - x = probesm(c,yy+5,0,io); - - if (x == -1) - { - cmenu(203); - probey = 7; - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (x==io) glwidescreen = 1-glwidescreen; - modval(0,1,(int *)&glwidescreen,1,probey==io); - gametextpal(d,yy, glwidescreen ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 1: - if (x==io) usehightile = 1-usehightile; - modval(0,1,(int *)&usehightile,1,probey==io); - gametextpal(d,yy, usehightile ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 2: - enabled = usehightile; - if (enabled && x==io) useprecache = !useprecache; - if (enabled) modval(0,1,(int *)&useprecache,1,probey==io); - gametextpal(d,yy, useprecache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); - break; - case 3: - enabled = usehightile; - if (enabled && x==io) glusetexcompr = !glusetexcompr; - if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io); - gametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); - break; - case 4: - enabled = (glusetexcompr && usehightile && useprecache); - if (enabled && x==io) glusetexcache = !glusetexcache; - if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io); - gametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); - break; - case 5: - enabled = (glusetexcompr && usehightile && useprecache && glusetexcache); - if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression; - if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io); - gametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):15, 0); - break; - case 6: - if (x==io) usemodels = 1-usemodels; - modval(0,1,(int *)&usemodels,1,probey==io); - gametextpal(d,yy, usemodels ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - default: - break; - } - gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); - io++; - yy += 8; + newvidmode++; + if (newvidmode >= validmodecnt) newvidmode = 0; } } -#endif - break; - - case 200: - - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"GAME SETUP"); - - c = (320>>1)-120; - - { - int io, ii, yy, d=c+160+40, enabled; - char *opts[] = { - "Crosshair", - "Level stats", - "-", - "Screen size", - "Status bar size", - "-", - "Run key style", - "-", - "Detail", - "Shadows", - "Screen tilting", - "-", - "Show opponent weapon", - "Demo playback cameras", - "Record demo", - "-", - "-", - "-", - "More...", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - onbar = (probey == 2 || probey == 3); - x = probesm(c,yy+5,0,io); - - if (x == -1) - { - cmenu(202); - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (x==io) ud.crosshair = (ud.crosshair==3)?0:ud.crosshair+1; - modval(0,3,(int *)&ud.crosshair,1,probey==io); - { - char *s[] = { "OFF", "ON [100%]", "ON [50%]", "ON [25%]" }; - gametextpal(d,yy,s[ud.crosshair], MENUHIGHLIGHT(io), 0); - break; - } - case 1: - if (x==io) ud.levelstats = 1-ud.levelstats; - modval(0,1,(int *)&ud.levelstats,1,probey==io); - gametextpal(d,yy, ud.levelstats ? "Shown" : "Hidden", MENUHIGHLIGHT(io), 0); - break; - case 2: - { - int i; - i = ud.screen_size; - barsm(d+8,yy+7, (short *)&ud.screen_size,-4,x==io,MENUHIGHLIGHT(io),PHX(-5)); - if (i < ud.screen_size && i == 8 && ud.statusbarmode == 1 && bpp > 8) - { - ud.statusbarmode = 0; - if (ud.statusbarscale != 100) - ud.screen_size = i; - } - else if (i > ud.screen_size && i == 8 && ud.statusbarmode == 0 && bpp > 8) - { - if (ud.statusbarscale != 100) - { - ud.statusbarmode = 1; - ud.screen_size = i; - } - } - } - break; - case 3: - { - short sbs, sbsl; - sbs = sbsl = ud.statusbarscale-37; - barsm(d+8,yy+7, (short *)&sbs,8,x==io,MENUHIGHLIGHT(io),PHX(-5)); - if (x == io && sbs != sbsl) - { - sbs += 37; - setstatusbarscale(sbs); - } - } - break; - case 4: - if (x==io) ud.runkey_mode = 1-ud.runkey_mode; - modval(0,1,(int *)&ud.runkey_mode,1,probey==io); - gametextpal(d,yy, ud.runkey_mode ? "Classic" : "Modern", MENUHIGHLIGHT(io), 0); - break; - case 5: - if (x==io) ud.detail = 1-ud.detail; - modval(0,1,(int *)&ud.detail,1,probey==io); - gametextpal(d,yy, ud.detail ? "High" : "Low", MENUHIGHLIGHT(io), 0); - break; - case 6: - if (x==io) ud.shadows = 1-ud.shadows; - modval(0,1,(int *)&ud.shadows,1,probey==io); - gametextpal(d,yy, ud.shadows ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 7: - if (x==io) ud.screen_tilting = 1-ud.screen_tilting; - modval(0,1,(int *)&ud.screen_tilting,1,probey==io); - gametextpal(d,yy, ud.screen_tilting ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; // original had a 'full' option - case 8: - if (x==io) ud.showweapons = 1-ud.showweapons; - modval(0,1,(int *)&ud.showweapons,1,probey==io); - ShowOpponentWeapons = ud.showweapons; - gametextpal(d,yy, ShowOpponentWeapons ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 9: - if (x==io) ud.democams = 1-ud.democams; - modval(0,1,(int *)&ud.democams,1,probey==io); - gametextpal(d,yy, ud.democams ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 10: - if (x==io) - { - enabled = !((ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1); - if ((ps[myconnectindex].gm&MODE_GAME)) closedemowrite(); - else ud.m_recstat = !ud.m_recstat; - } - if ((ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1) - enabled = 0; - gametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && ps[myconnectindex].gm&MODE_GAME)?"Recording":"On"):"Off",enabled?MENUHIGHLIGHT(io):15,enabled?0:1); - break; - case 11: - if (x==io) cmenu(201); - break; - default: - break; - } - gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); - io++; - yy += 8; - } - } - break; - - case 201: - - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"GAME SETUP"); - - c = (320>>1)-120; - - { - int io, ii, yy, d=c+160+40, enabled; - char *opts[] = { - "Parental lock", - "-", - "HUD weapon", - "FPS counter", - "-", - "Automatic voting", - "Send MP messages to all", - "Display other player IDs", - "-", - "Show startup window", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "-", - "Previous page", - NULL - }; - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - if (io <= probey) yy += 4; - continue; - } - if (io < probey) yy += 8; - io++; - } - - x = probesm(c,yy+5,0,io); - - if (x == -1) - { - cmenu(200); - probey = 11; - break; - } - - yy = 37; - for (ii=io=0; opts[ii]; ii++) - { - if (opts[ii][0] == '-' && !opts[ii][1]) - { - yy += 4; - continue; - } - enabled = 1; - switch (io) - { - case 0: - if (!NAM) - { - if (x==io) cmenu(10000); - } - else enabled = 0; - break; - case 1: - if (x==io) - { - ud.drawweapon = (ud.drawweapon == 2) ? 0 : ud.drawweapon+1; - } - modval(0,2,(int *)&ud.drawweapon,1,probey==io); - { - char *s[] = { "Off", "On", "Icon" }; - gametextpal(d,yy, s[ud.drawweapon], MENUHIGHLIGHT(io), 0); - break; - } - case 2: - if (x==io) ud.tickrate = 1-ud.tickrate; - modval(0,1,(int *)&ud.tickrate,1,probey==io); - gametextpal(d,yy, ud.tickrate ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 3: - if (x==io) - { - ud.autovote = (ud.autovote == 2) ? 0 : ud.autovote+1; - } - modval(0,2,(int *)&ud.autovote,1,probey==io); - { - char *s[] = { "Off", "Vote No", "Vote Yes" }; - gametextpal(d,yy, s[ud.autovote], MENUHIGHLIGHT(io), 0); - break; - } - case 4: - if (x==io) ud.automsg = 1-ud.automsg; - modval(0,1,(int *)&ud.automsg,1,probey==io); - gametextpal(d,yy, ud.automsg ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 5: - if (x==io) ud.idplayers = 1-ud.idplayers; - modval(0,1,(int *)&ud.idplayers,1,probey==io); - gametextpal(d,yy, ud.idplayers ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 6: - if (x==io) ForceSetup = 1-ForceSetup; - modval(0,1,(int *)&ForceSetup,1,probey==io); - gametextpal(d,yy, ForceSetup ? "On" : "Off", MENUHIGHLIGHT(io), 0); - break; - case 7: - if (x==io) cmenu(200); - break; - default: - break; - } - gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); - io++; - yy += 8; - } - } - break; - - // JBF 20031205: Second level options menu selection - case 202: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"OPTIONS"); - - c = 50; - - onbar = 0; - x = probe(160,c,18,7); - - last_twoohtwo = probey; - - switch (x) - { - case -1: - if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); - else cmenu(0); - break; - - case 0: - cmenu(200); - break; - - case 1: - cmenu(700); - break; - - case 2: - { - int dax = xdim, day = ydim, daz; - curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen,0); - if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt; - newfullscreen = fullscreen; - changesmade = 0; - - dax = 0; - for (day = 0; day < validmodecnt; day++) - { - if (dax == sizeof(vidsets)/sizeof(vidsets[1])) break; - for (daz = 0; daz < dax; daz++) - if ((validmode[day].bpp|((validmode[day].fs&1)<<16)) == (vidsets[daz]&0x1ffffl)) break; - if (vidsets[daz] != -1) continue; - if (validmode[day].bpp == 8) - { - vidsets[dax++] = 8|((validmode[day].fs&1)<<16); - vidsets[dax++] = 0x20000|8|((validmode[day].fs&1)<<16); - } - else - vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16); - } - for (dax = 0; dax < (long)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++) - if (vidsets[dax] == (((getrendermode()>=2)<<17)|(fullscreen<<16)|bpp)) break; - if (dax < (long)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; - curvidset = newvidset; - - cmenu(203); - } - break; - case 3: - if (ud.recstat != 1) - cmenu(20002); - break; - case 4: - currentlist = 0; - case 5: - case 6: - if (x==6 && !CONTROL_JoyPresent) break; - cmenu(204+x-4); - break; - } - - menutext(160,c, MENUHIGHLIGHT(0),0,"GAME SETUP"); - menutext(160,c+18, MENUHIGHLIGHT(1),0,"SOUND SETUP"); - menutext(160,c+18+18, MENUHIGHLIGHT(2),0,"VIDEO SETUP"); - menutext(160,c+18+18+18, MENUHIGHLIGHT(3),ud.recstat == 1,"PLAYER SETUP"); - menutext(160,c+18+18+18+18, MENUHIGHLIGHT(4),0,"KEYBOARD SETUP"); - menutext(160,c+18+18+18+18+18, MENUHIGHLIGHT(5),0,"MOUSE SETUP"); - menutext(160,c+18+18+18+18+18+18,MENUHIGHLIGHT(6),CONTROL_JoyPresent==0,"JOYSTICK SETUP"); - break; - - // JBF 20031206: Video settings menu - case 203: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"VIDEO SETUP"); - - c = (320>>1)-120; - -#if defined(POLYMOST) && defined(USE_OPENGL) - x = 8; -#else - x = 5; -#endif - onbar = (probey == 4); - if (probey == 0 || probey == 1 || probey == 2) - x = probe(c,50,16,x); - else if (probey == 3) - x = probe(c,50+16+16+22,0,x); + while ((validmode[newvidmode].fs&1) != ((vidsets[newvidset]>>16)&1) || validmode[newvidmode].bpp != (vidsets[newvidset] & 0x0ffff)); + //OSD_Printf("New mode is %dx%dx%d-%d %d\n",validmode[newvidmode].xdim,validmode[newvidmode].ydim,validmode[newvidmode].bpp,validmode[newvidmode].fs,newvidmode); + if ((curvidmode == 0x7fffffffl && newvidmode == validmodecnt) || curvidmode == newvidmode) + changesmade &= ~1; else - x = probe(c,50+62-16-16-16,16,x); + changesmade |= 1; + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_RightArrow); + break; - if (probey==0 && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_RightArrow))) + case 1: { - sound(PISTOL_BODYHIT); - x=0; - } - switch (x) - { - case -1: - cmenu(202); - probey = 2; + int lastvidset, lastvidmode, safevidmode = -1; + lastvidset = newvidset; + lastvidmode = newvidmode; + // find the next vidset compatible with the current fullscreen setting + while (vidsets[0] != -1) + { + newvidset++; + if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) + { + newvidset = -1; + continue; + } + if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; break; + } - case 0: + if ((vidsets[newvidset] & 0x0ffff) != (vidsets[lastvidset] & 0x0ffff)) + { + // adjust the video mode to something legal for the new vidset do { - if (KB_KeyPressed(sc_LeftArrow)) + newvidmode++; + if (newvidmode == lastvidmode) break; // end of cycle + if (newvidmode >= validmodecnt) { - newvidmode--; - if (newvidmode < 0) newvidmode = validmodecnt-1; - } - else - { - newvidmode++; - if (newvidmode >= validmodecnt) newvidmode = 0; - } - } - while ((validmode[newvidmode].fs&1) != ((vidsets[newvidset]>>16)&1) || validmode[newvidmode].bpp != (vidsets[newvidset] & 0x0ffff)); - //OSD_Printf("New mode is %dx%dx%d-%d %d\n",validmode[newvidmode].xdim,validmode[newvidmode].ydim,validmode[newvidmode].bpp,validmode[newvidmode].fs,newvidmode); - if ((curvidmode == 0x7fffffffl && newvidmode == validmodecnt) || curvidmode == newvidmode) - changesmade &= ~1; - else - changesmade |= 1; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - break; - - case 1: - { - int lastvidset, lastvidmode, safevidmode = -1; - lastvidset = newvidset; - lastvidmode = newvidmode; - // find the next vidset compatible with the current fullscreen setting - while (vidsets[0] != -1) - { - newvidset++; - if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) - { - newvidset = -1; - continue; - } - if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; - break; - } - - if ((vidsets[newvidset] & 0x0ffff) != (vidsets[lastvidset] & 0x0ffff)) - { - // adjust the video mode to something legal for the new vidset - do - { - newvidmode++; - if (newvidmode == lastvidmode) break; // end of cycle - if (newvidmode >= validmodecnt) - { - if (safevidmode != -1) - break; - newvidmode = 0; - } - if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && - validmode[newvidmode].fs == newfullscreen && - validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && - (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && - validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && - (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) - ) - safevidmode = newvidmode; - } - while (1); - if (safevidmode == -1) - { - //OSD_Printf("No best fit!\n"); - newvidmode = lastvidmode; - newvidset = lastvidset; - } - else - { - //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydim,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); - newvidmode = safevidmode; - } - } - if (newvidset != curvidset) changesmade |= 4; - else changesmade &= ~4; - if (newvidmode != curvidmode) changesmade |= 1; - else changesmade &= ~1; - } - break; - - case 2: - newfullscreen = !newfullscreen; - { - int lastvidset, lastvidmode, safevidmode = -1, safevidset = -1; - lastvidset = newvidset; - lastvidmode = newvidmode; - // find the next vidset compatible with the current fullscreen setting - while (vidsets[0] != -1) - { - newvidset++; - if (newvidset == lastvidset) break; - if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) - { - newvidset = -1; - continue; - } - if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; - if ((vidsets[newvidset] & 0x2ffff) != (vidsets[lastvidset] & 0x2ffff)) - { - if ((vidsets[newvidset] & 0x20000) == (vidsets[lastvidset] & 0x20000)) safevidset = newvidset; - continue; - } - break; - } - if (newvidset == lastvidset) - { - if (safevidset == -1) - { - newfullscreen = !newfullscreen; + if (safevidmode != -1) break; - } - else - { - newvidset = safevidset; - } + newvidmode = 0; } - - // adjust the video mode to something legal for the new vidset - do - { - newvidmode++; - if (newvidmode == lastvidmode) break; // end of cycle - if (newvidmode >= validmodecnt) newvidmode = 0; - if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && - validmode[newvidmode].fs == newfullscreen && - validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && - (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && - validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && - (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) - ) - safevidmode = newvidmode; - } - while (1); - if (safevidmode == -1) - { - //OSD_Printf("No best fit!\n"); - newvidmode = lastvidmode; - newvidset = lastvidset; - newfullscreen = !newfullscreen; - } - else - { - //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydo,,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); - newvidmode = safevidmode; - } - if (newvidset != curvidset) changesmade |= 4; - else changesmade &= ~4; - if (newvidmode != curvidmode) changesmade |= 1; - else changesmade &= ~1; + if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && + validmode[newvidmode].fs == newfullscreen && + validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && + (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && + validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && + (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) + ) + safevidmode = newvidmode; } - if (newfullscreen == fullscreen) changesmade &= ~2; - else changesmade |= 2; - break; - - case 3: - if (!changesmade) break; + while (1); + if (safevidmode == -1) { - long pxdim, pydim, pfs, pbpp, prend; - long nxdim, nydim, nfs, nbpp, nrend; - - pxdim = xdim; - pydim = ydim; - pbpp = bpp; - pfs = fullscreen; - prend = getrendermode(); - nxdim = (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim; - nydim = (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim; - nfs = newfullscreen; - nbpp = (newvidmode==validmodecnt)?bpp:validmode[newvidmode].bpp; - nrend = (vidsets[newvidset] & 0x20000) ? (nbpp==8?2:3) : 0; - - if (setgamemode(nfs, nxdim, nydim, nbpp) < 0) - { - if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) - { - setrendermode(prend); - gameexit("Failed restoring old video mode."); - } - else onvideomodechange(pbpp > 8); - } - else onvideomodechange(nbpp > 8); - - restorepalette = 1; - vscrn(); - setrendermode(nrend); - - curvidmode = newvidmode; - curvidset = newvidset; - changesmade = 0; - - ScreenMode = fullscreen; - ScreenWidth = xdim; - ScreenHeight = ydim; - ScreenBPP = bpp; + //OSD_Printf("No best fit!\n"); + newvidmode = lastvidmode; + newvidset = lastvidset; } - break; - - case 4: - break; - -#if defined(POLYMOST) && defined(USE_OPENGL) - case 5: - if (bpp==8) break; - switch (gltexfiltermode) + else { - case 0: - gltexfiltermode = 3; - break; - case 3: - gltexfiltermode = 5; - break; - case 5: - gltexfiltermode = 0; - break; - default: - gltexfiltermode = 3; - break; + //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydim,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); + newvidmode = safevidmode; } - gltexapplyprops(); - break; - - case 6: - if (bpp==8) break; - glanisotropy *= 2; - if (glanisotropy > glinfo.maxanisotropy) glanisotropy = 1; - gltexapplyprops(); - break; - case 7: - if (bpp==8) break; - cmenu(230); - break; -#endif - } - - menutext(c,50,MENUHIGHLIGHT(0),0,"RESOLUTION"); - sprintf(tempbuf,"%ld x %ld", - (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim, - (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim); - gametext(c+154,50-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); - - menutext(c,50+16,MENUHIGHLIGHT(1),0,"VIDEO MODE"); - sprintf(tempbuf, "%dbit %s", vidsets[newvidset]&0x0ffff, (vidsets[newvidset]&0x20000)?"Polymost":"Classic"); - gametext(c+154,50+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); - - menutext(c,50+16+16,MENUHIGHLIGHT(2),0,"FULLSCREEN"); - menutext(c+154,50+16+16,MENUHIGHLIGHT(2),0,newfullscreen?"YES":"NO"); - - menutext(c+16,50+16+16+22,MENUHIGHLIGHT(3),changesmade==0,"APPLY CHANGES"); - - menutext(c,50+62+16,MENUHIGHLIGHT(4),PHX(-6),"BRIGHTNESS"); - { - short ss = ud.brightness; - bar(c+167,50+62+16,&ss,8,x==4,MENUHIGHLIGHT(4),PHX(-6)); - if (x==4) - { - ud.brightness = ss; - setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0],0); } + if (newvidset != curvidset) changesmade |= 4; + else changesmade &= ~4; + if (newvidmode != curvidmode) changesmade |= 1; + else changesmade &= ~1; } - -#if defined(POLYMOST) && defined(USE_OPENGL) - menutext(c,50+62+16+16,MENUHIGHLIGHT(5),bpp==8,"FILTERING"); - switch (gltexfiltermode) - { - case 0: - strcpy(tempbuf,"NEAREST"); - break; - case 3: - strcpy(tempbuf,"BILINEAR"); - break; - case 5: - strcpy(tempbuf,"TRILINEAR"); - break; - default: - strcpy(tempbuf,"OTHER"); - break; - } - menutext(c+154,50+62+16+16,MENUHIGHLIGHT(5),bpp==8,tempbuf); - - menutext(c,50+62+16+16+16,MENUHIGHLIGHT(6),bpp==8,"ANISOTROPY"); - if (glanisotropy == 1) strcpy(tempbuf,"NONE"); - else sprintf(tempbuf,"%ld-tap",glanisotropy); - menutext(c+154,50+62+16+16+16,MENUHIGHLIGHT(6),bpp==8,tempbuf); - menutext(c,50+62+16+16+16+16,MENUHIGHLIGHT(7),bpp==8,"ADVANCED SETTINGS"); - -#endif break; - case 204: + case 2: + newfullscreen = !newfullscreen; + { + int lastvidset, lastvidmode, safevidmode = -1, safevidset = -1; + lastvidset = newvidset; + lastvidmode = newvidmode; + // find the next vidset compatible with the current fullscreen setting + while (vidsets[0] != -1) + { + newvidset++; + if (newvidset == lastvidset) break; + if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) + { + newvidset = -1; + continue; + } + if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; + if ((vidsets[newvidset] & 0x2ffff) != (vidsets[lastvidset] & 0x2ffff)) + { + if ((vidsets[newvidset] & 0x20000) == (vidsets[lastvidset] & 0x20000)) safevidset = newvidset; + continue; + } + break; + } + if (newvidset == lastvidset) + { + if (safevidset == -1) + { + newfullscreen = !newfullscreen; + break; + } + else + { + newvidset = safevidset; + } + } + + // adjust the video mode to something legal for the new vidset + do + { + newvidmode++; + if (newvidmode == lastvidmode) break; // end of cycle + if (newvidmode >= validmodecnt) newvidmode = 0; + if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && + validmode[newvidmode].fs == newfullscreen && + validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && + (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && + validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && + (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) + ) + safevidmode = newvidmode; + } + while (1); + if (safevidmode == -1) + { + //OSD_Printf("No best fit!\n"); + newvidmode = lastvidmode; + newvidset = lastvidset; + newfullscreen = !newfullscreen; + } + else + { + //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydo,,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); + newvidmode = safevidmode; + } + if (newvidset != curvidset) changesmade |= 4; + else changesmade &= ~4; + if (newvidmode != curvidmode) changesmade |= 1; + else changesmade &= ~1; + } + if (newfullscreen == fullscreen) changesmade &= ~2; + else changesmade |= 2; + break; + + case 3: + if (!changesmade) break; + { + long pxdim, pydim, pfs, pbpp, prend; + long nxdim, nydim, nfs, nbpp, nrend; + + pxdim = xdim; + pydim = ydim; + pbpp = bpp; + pfs = fullscreen; + prend = getrendermode(); + nxdim = (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim; + nydim = (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim; + nfs = newfullscreen; + nbpp = (newvidmode==validmodecnt)?bpp:validmode[newvidmode].bpp; + nrend = (vidsets[newvidset] & 0x20000) ? (nbpp==8?2:3) : 0; + + if (setgamemode(nfs, nxdim, nydim, nbpp) < 0) + { + if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) + { + setrendermode(prend); + gameexit("Failed restoring old video mode."); + } + else onvideomodechange(pbpp > 8); + } + else onvideomodechange(nbpp > 8); + + restorepalette = 1; + vscrn(); + setrendermode(nrend); + + curvidmode = newvidmode; + curvidset = newvidset; + changesmade = 0; + + ScreenMode = fullscreen; + ScreenWidth = xdim; + ScreenHeight = ydim; + ScreenBPP = bpp; + } + break; + + case 4: + break; + +#if defined(POLYMOST) && defined(USE_OPENGL) + case 5: + if (bpp==8) break; + switch (gltexfiltermode) + { + case 0: + gltexfiltermode = 3; + break; + case 3: + gltexfiltermode = 5; + break; + case 5: + gltexfiltermode = 0; + break; + default: + gltexfiltermode = 3; + break; + } + gltexapplyprops(); + break; + + case 6: + if (bpp==8) break; + glanisotropy *= 2; + if (glanisotropy > glinfo.maxanisotropy) glanisotropy = 1; + gltexapplyprops(); + break; + case 7: + if (bpp==8) break; + cmenu(230); + break; +#endif + } + + menutext(c,50,MENUHIGHLIGHT(0),0,"RESOLUTION"); + sprintf(tempbuf,"%ld x %ld", + (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim, + (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim); + gametext(c+154,50-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); + + menutext(c,50+16,MENUHIGHLIGHT(1),0,"VIDEO MODE"); + sprintf(tempbuf, "%dbit %s", vidsets[newvidset]&0x0ffff, (vidsets[newvidset]&0x20000)?"Polymost":"Classic"); + gametext(c+154,50+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); + + menutext(c,50+16+16,MENUHIGHLIGHT(2),0,"FULLSCREEN"); + menutext(c+154,50+16+16,MENUHIGHLIGHT(2),0,newfullscreen?"YES":"NO"); + + menutext(c+16,50+16+16+22,MENUHIGHLIGHT(3),changesmade==0,"APPLY CHANGES"); + + menutext(c,50+62+16,MENUHIGHLIGHT(4),PHX(-6),"BRIGHTNESS"); + { + short ss = ud.brightness; + bar(c+167,50+62+16,&ss,8,x==4,MENUHIGHLIGHT(4),PHX(-6)); + if (x==4) + { + ud.brightness = ss; + setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0],0); + } + } + +#if defined(POLYMOST) && defined(USE_OPENGL) + menutext(c,50+62+16+16,MENUHIGHLIGHT(5),bpp==8,"FILTERING"); + switch (gltexfiltermode) + { + case 0: + strcpy(tempbuf,"NEAREST"); + break; + case 3: + strcpy(tempbuf,"BILINEAR"); + break; + case 5: + strcpy(tempbuf,"TRILINEAR"); + break; + default: + strcpy(tempbuf,"OTHER"); + break; + } + menutext(c+154,50+62+16+16,MENUHIGHLIGHT(5),bpp==8,tempbuf); + + menutext(c,50+62+16+16+16,MENUHIGHLIGHT(6),bpp==8,"ANISOTROPY"); + if (glanisotropy == 1) strcpy(tempbuf,"NONE"); + else sprintf(tempbuf,"%ld-tap",glanisotropy); + menutext(c+154,50+62+16+16+16,MENUHIGHLIGHT(6),bpp==8,tempbuf); + menutext(c,50+62+16+16+16+16,MENUHIGHLIGHT(7),bpp==8,"ADVANCED SETTINGS"); + +#endif + break; + + case 204: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"KEYBOARD SETUP"); + + c = (320>>1)-120; + + onbar = 0; + x = probe(0,0,0,NUMGAMEFUNCTIONS); + + if (x==-1) + { + cmenu(202); + probey = 4; + } + else if (x>=0) + { + function = probey; + whichkey = currentlist; + cmenu(210); + KB_FlushKeyboardQueue(); + KB_ClearLastScanCode(); + break; + } + + // the top of our list + m = probey - 6; + if (m < 0) m = 0; + else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; + + if (probey == gamefunc_Show_Console) currentlist = 0; + else if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || + KB_KeyPressed(sc_Tab)) + { + currentlist ^= 1; + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_Tab); + sound(KICK_HIT); + } + else if (KB_KeyPressed(sc_Delete)) + { + KeyboardKeys[probey][currentlist] = 0; + CONTROL_MapKey(probey, KeyboardKeys[probey][0], KeyboardKeys[probey][1]); + sound(KICK_HIT); + KB_ClearKeyDown(sc_Delete); + } + + for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) + { + p = CONFIG_FunctionNumToName(m+l); + if (!p) continue; + + strcpy(tempbuf, p); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(70,34+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); + + //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][0])); + strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][0])); + if (!tempbuf[0]) strcpy(tempbuf, " -"); + minitextshade(70+100,34+l*8,tempbuf, + (m+l == probey && !currentlist?0:16),2,10+16); + + //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][1])); + strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][1])); + if (!tempbuf[0]) strcpy(tempbuf, " -"); + minitextshade(70+120+34,34+l*8,tempbuf, + (m+l == probey && currentlist?0:16),2,10+16); + } + + gametext(160,144,"UP/DOWN = SELECT ACTION",0,2+8+16); + gametext(160,144+9,"LEFT/RIGHT = SELECT LIST",0,2+8+16); + gametext(160,144+9+9,"ENTER = MODIFY DELETE = CLEAR",0,2+8+16); + + break; + + case 210: + { + int32 sc; rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,24,0,0,"KEYBOARD SETUP"); - c = (320>>1)-120; + gametext(320>>1,90,"PRESS THE KEY TO ASSIGN AS",0,2+8+16); + sprintf(tempbuf,"%s FOR \"%s\"", whichkey?"SECONDARY":"PRIMARY", CONFIG_FunctionNumToName(function)); + gametext(320>>1,90+9,tempbuf,0,2+8+16); + gametext(320>>1,90+9+9+9,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); - onbar = 0; - x = probe(0,0,0,NUMGAMEFUNCTIONS); - - if (x==-1) + sc = KB_GetLastScanCode(); + if (sc != sc_None) { - cmenu(202); - probey = 4; - } - else if (x>=0) - { - function = probey; - whichkey = currentlist; - cmenu(210); - KB_FlushKeyboardQueue(); - KB_ClearLastScanCode(); - break; - } - - // the top of our list - m = probey - 6; - if (m < 0) m = 0; - else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; - - if (probey == gamefunc_Show_Console) currentlist = 0; - else if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || - KB_KeyPressed(sc_Tab)) - { - currentlist ^= 1; - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_Tab); - sound(KICK_HIT); - } - else if (KB_KeyPressed(sc_Delete)) - { - KeyboardKeys[probey][currentlist] = 0; - CONTROL_MapKey(probey, KeyboardKeys[probey][0], KeyboardKeys[probey][1]); - sound(KICK_HIT); - KB_ClearKeyDown(sc_Delete); - } - - for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) - { - p = CONFIG_FunctionNumToName(m+l); - if (!p) continue; - - strcpy(tempbuf, p); - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(70,34+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); - - //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][0])); - strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][0])); - if (!tempbuf[0]) strcpy(tempbuf, " -"); - minitextshade(70+100,34+l*8,tempbuf, - (m+l == probey && !currentlist?0:16),2,10+16); - - //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][1])); - strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][1])); - if (!tempbuf[0]) strcpy(tempbuf, " -"); - minitextshade(70+120+34,34+l*8,tempbuf, - (m+l == probey && currentlist?0:16),2,10+16); - } - - gametext(160,144,"UP/DOWN = SELECT ACTION",0,2+8+16); - gametext(160,144+9,"LEFT/RIGHT = SELECT LIST",0,2+8+16); - gametext(160,144+9+9,"ENTER = MODIFY DELETE = CLEAR",0,2+8+16); - - break; - - case 210: - { - int32 sc; - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"KEYBOARD SETUP"); - - gametext(320>>1,90,"PRESS THE KEY TO ASSIGN AS",0,2+8+16); - sprintf(tempbuf,"%s FOR \"%s\"", whichkey?"SECONDARY":"PRIMARY", CONFIG_FunctionNumToName(function)); - gametext(320>>1,90+9,tempbuf,0,2+8+16); - gametext(320>>1,90+9+9+9,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); - - sc = KB_GetLastScanCode(); - if (sc != sc_None) + if (sc == sc_Escape) { - if (sc == sc_Escape) - { - sound(EXITMENUSOUND); - } + sound(EXITMENUSOUND); + } + else + { + sound(PISTOL_BODYHIT); + + KeyboardKeys[function][whichkey] = KB_GetLastScanCode(); + if (function == gamefunc_Show_Console) + OSD_CaptureKey(KB_GetLastScanCode()); else - { - sound(PISTOL_BODYHIT); - - KeyboardKeys[function][whichkey] = KB_GetLastScanCode(); - if (function == gamefunc_Show_Console) - OSD_CaptureKey(KB_GetLastScanCode()); - else - CONTROL_MapKey(function, KeyboardKeys[function][0], KeyboardKeys[function][1]); - } - - cmenu(204); - - currentlist = whichkey; - probey = function; - - KB_ClearKeyDown(sc); + CONTROL_MapKey(function, KeyboardKeys[function][0], KeyboardKeys[function][1]); } - break; + cmenu(204); + + currentlist = whichkey; + probey = function; + + KB_ClearKeyDown(sc); } - case 205: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"MOUSE SETUP"); - c = 60-4; + break; + } + case 205: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"MOUSE SETUP"); - onbar = (probey == (MAXMOUSEBUTTONS-2)*2+2); - if (probey < (MAXMOUSEBUTTONS-2)*2+2) - x = probesm(73,40,8,(MAXMOUSEBUTTONS-2)*2+2+2+2); + c = 60-4; + + onbar = (probey == (MAXMOUSEBUTTONS-2)*2+2); + if (probey < (MAXMOUSEBUTTONS-2)*2+2) + x = probesm(73,40,8,(MAXMOUSEBUTTONS-2)*2+2+2+2); + else + x = probesm(40,128-((MAXMOUSEBUTTONS-2)*2+2)*9,9,(MAXMOUSEBUTTONS-2)*2+2+2+2); + + if (x==-1) + { + cmenu(202); + probey = 5; + break; + } + else if (x == (MAXMOUSEBUTTONS-2)*2+2) + { + // sensitivity + } + else if (x == (MAXMOUSEBUTTONS-2)*2+2+1) + { + // mouse aiming toggle + if (!ud.mouseaiming) myaimmode = 1-myaimmode; + } + else if (x == (MAXMOUSEBUTTONS-2)*2+2+2) + { + // invert mouse aim + ud.mouseflip = 1-ud.mouseflip; + } + else if (x == (MAXMOUSEBUTTONS-2)*2+2+2+1) + { + //advanced + cmenu(212); + break; + } + else if (x >= 0) + { + //set an option + cmenu(211); + function = 0; + whichkey = x; + if (x < (MAXMOUSEBUTTONS-2)*2) + probey = MouseFunctions[x>>1][x&1]; else - x = probesm(40,128-((MAXMOUSEBUTTONS-2)*2+2)*9,9,(MAXMOUSEBUTTONS-2)*2+2+2+2); + probey = MouseFunctions[x-4][0]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + } - if (x==-1) + for (l=0; l < (MAXMOUSEBUTTONS-2)*2+2; l++) + { + tempbuf[0] = 0; + if (l < (MAXMOUSEBUTTONS-2)*2) { - cmenu(202); - probey = 5; - break; + if (l&1) + { + Bstrcpy(tempbuf, "Double "); + m = MouseFunctions[l>>1][1]; + } + else + m = MouseFunctions[l>>1][0]; + Bstrcat(tempbuf, mousebuttonnames[l>>1]); } - else if (x == (MAXMOUSEBUTTONS-2)*2+2) + else { - // sensitivity + Bstrcpy(tempbuf, mousebuttonnames[l-(MAXMOUSEBUTTONS-2)]); + m = MouseFunctions[l-(MAXMOUSEBUTTONS-2)][0]; } - else if (x == (MAXMOUSEBUTTONS-2)*2+2+1) + + minitextshade(c+20,36+l*8,tempbuf,(l==probey)?0:16,1,10+16); + + if (m == -1) + minitextshade(c+100+20,36+l*8," -NONE-",(l==probey)?0:16,2,10+16); + else { - // mouse aiming toggle - if (!ud.mouseaiming) myaimmode = 1-myaimmode; + strcpy(tempbuf, CONFIG_FunctionNumToName(m)); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+100+20,36+l*8,tempbuf,(l==probey)?0:16,2,10+16); } - else if (x == (MAXMOUSEBUTTONS-2)*2+2+2) - { - // invert mouse aim - ud.mouseflip = 1-ud.mouseflip; + } + + gametextpal(40,122,"SENSITIVITY",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),2); + gametextpal(40,122+9,"MOUSE AIMING TOGGLE",!ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):15,2); + gametextpal(40,122+9+9,"INVERT MOUSE AIM",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2),2); + gametextpal(40,122+9+9+9,"ADVANCED...",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2+1),2); + + { + short sense; + sense = CONTROL_GetMouseSensitivity()-1; + barsm(248,128,&sense,2,x==(MAXMOUSEBUTTONS-2)*2+2,MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),PHX(-7)); + CONTROL_SetMouseSensitivity(sense+1); + } + + if (!ud.mouseaiming) modval(0,1,(int *)&myaimmode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1); + modval(0,1,(int *)&ud.mouseflip,1,probey == (MAXMOUSEBUTTONS-2)*2+2+2); + + gametextpal(240,122+9, myaimmode && !ud.mouseaiming ? "On" : "Off", !ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):15, 0); + gametextpal(240,122+9+9, !ud.mouseflip ? "On" : "Off", MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2), 0); + + if (probey < (MAXMOUSEBUTTONS-2)*2+2) + { + gametext(160,164,"UP/DOWN = SELECT BUTTON",0,2+8+16); + gametext(160,164+9,"ENTER = MODIFY",0,2+8+16); + } + break; + + case 211: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + if (function == 0) menutext(320>>1,24,0,0,"MOUSE SETUP"); + else if (function == 1) menutext(320>>1,24,0,0,"ADVANCED MOUSE"); + else if (function == 2) menutext(320>>1,24,0,0,"JOYSTICK BUTTONS"); + else if (function == 3) menutext(320>>1,24,0,0,"JOYSTICK AXES"); + + x = probe(0,0,0,NUMGAMEFUNCTIONS); + + if (x==-1) + { + if (function == 0) + { // mouse button + cmenu(205); + probey = whichkey; } - else if (x == (MAXMOUSEBUTTONS-2)*2+2+2+1) - { - //advanced + else if (function == 1) + { // mouse digital axis cmenu(212); - break; + probey = 3+(whichkey^2); } - else if (x >= 0) - { - //set an option - cmenu(211); - function = 0; - whichkey = x; - if (x < (MAXMOUSEBUTTONS-2)*2) - probey = MouseFunctions[x>>1][x&1]; - else - probey = MouseFunctions[x-4][0]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; + else if (function == 2) + { // joystick button/hat + cmenu(207); + probey = whichkey; } - - for (l=0; l < (MAXMOUSEBUTTONS-2)*2+2; l++) - { - tempbuf[0] = 0; - if (l < (MAXMOUSEBUTTONS-2)*2) - { - if (l&1) - { - Bstrcpy(tempbuf, "Double "); - m = MouseFunctions[l>>1][1]; - } - else - m = MouseFunctions[l>>1][0]; - Bstrcat(tempbuf, mousebuttonnames[l>>1]); - } - else - { - Bstrcpy(tempbuf, mousebuttonnames[l-(MAXMOUSEBUTTONS-2)]); - m = MouseFunctions[l-(MAXMOUSEBUTTONS-2)][0]; - } - - minitextshade(c+20,36+l*8,tempbuf,(l==probey)?0:16,1,10+16); - - if (m == -1) - minitextshade(c+100+20,36+l*8," -NONE-",(l==probey)?0:16,2,10+16); - else - { - strcpy(tempbuf, CONFIG_FunctionNumToName(m)); - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(c+100+20,36+l*8,tempbuf,(l==probey)?0:16,2,10+16); - } - } - - gametextpal(40,122,"SENSITIVITY",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),2); - gametextpal(40,122+9,"MOUSE AIMING TOGGLE",!ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):15,2); - gametextpal(40,122+9+9,"INVERT MOUSE AIM",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2),2); - gametextpal(40,122+9+9+9,"ADVANCED...",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2+1),2); - - { - short sense; - sense = CONTROL_GetMouseSensitivity()-1; - barsm(248,128,&sense,2,x==(MAXMOUSEBUTTONS-2)*2+2,MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),PHX(-7)); - CONTROL_SetMouseSensitivity(sense+1); - } - - if (!ud.mouseaiming) modval(0,1,(int *)&myaimmode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1); - modval(0,1,(int *)&ud.mouseflip,1,probey == (MAXMOUSEBUTTONS-2)*2+2+2); - - gametextpal(240,122+9, myaimmode && !ud.mouseaiming ? "On" : "Off", !ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):15, 0); - gametextpal(240,122+9+9, !ud.mouseflip ? "On" : "Off", MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2), 0); - - if (probey < (MAXMOUSEBUTTONS-2)*2+2) - { - gametext(160,164,"UP/DOWN = SELECT BUTTON",0,2+8+16); - gametext(160,164+9,"ENTER = MODIFY",0,2+8+16); + else if (function == 3) + { // joystick digital axis + cmenu((whichkey>>2)+208); + probey = 1+((whichkey>>1)&1)*4+(whichkey&1); } break; - - case 211: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - if (function == 0) menutext(320>>1,24,0,0,"MOUSE SETUP"); - else if (function == 1) menutext(320>>1,24,0,0,"ADVANCED MOUSE"); - else if (function == 2) menutext(320>>1,24,0,0,"JOYSTICK BUTTONS"); - else if (function == 3) menutext(320>>1,24,0,0,"JOYSTICK AXES"); - - x = probe(0,0,0,NUMGAMEFUNCTIONS); - - if (x==-1) - { - if (function == 0) - { // mouse button - cmenu(205); - probey = whichkey; - } - else if (function == 1) - { // mouse digital axis - cmenu(212); - probey = 3+(whichkey^2); - } - else if (function == 2) - { // joystick button/hat - cmenu(207); - probey = whichkey; - } - else if (function == 3) - { // joystick digital axis - cmenu((whichkey>>2)+208); - probey = 1+((whichkey>>1)&1)*4+(whichkey&1); - } - break; - } - else if (x >= 0) - { - if (x == NUMGAMEFUNCTIONS-1) x = -1; - - if (function == 0) - { - if (whichkey < (MAXMOUSEBUTTONS-2)*2) - { - MouseFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_mouse); - } - else - { - MouseFunctions[whichkey-(MAXMOUSEBUTTONS-2)][0] = x; - CONTROL_MapButton(x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse); - } - cmenu(205); - probey = whichkey; - } - else if (function == 1) - { - MouseDigitalFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_mouse); - cmenu(212); - probey = 3+(whichkey^2); - } - else if (function == 2) - { - if (whichkey < 2*joynumbuttons) - { - JoystickFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_joystick); - } - else - { - JoystickFunctions[joynumbuttons + (whichkey-2*joynumbuttons)][0] = x; - CONTROL_MapButton(x, joynumbuttons + (whichkey-2*joynumbuttons), 0, controldevice_joystick); - } - cmenu(207); - probey = whichkey; - } - else if (function == 3) - { - JoystickDigitalFunctions[whichkey>>1][whichkey&1] = x; - CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_joystick); - cmenu((whichkey>>2)+208); - probey = 1+((whichkey>>1)&1)*4+(whichkey&1); - } - break; - } - - gametext(320>>1,31,"SELECT A FUNCTION TO ASSIGN",0,2+8+16); + } + else if (x >= 0) + { + if (x == NUMGAMEFUNCTIONS-1) x = -1; if (function == 0) { if (whichkey < (MAXMOUSEBUTTONS-2)*2) - sprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", mousebuttonnames[whichkey>>1]); + { + MouseFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_mouse); + } else - Bstrcpy(tempbuf, mousebuttonnames[whichkey-(MAXMOUSEBUTTONS-2)]); + { + MouseFunctions[whichkey-(MAXMOUSEBUTTONS-2)][0] = x; + CONTROL_MapButton(x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse); + } + cmenu(205); + probey = whichkey; } else if (function == 1) { - Bstrcpy(tempbuf,"TO DIGITAL "); - switch (whichkey) - { - case 0: - Bstrcat(tempbuf, "LEFT"); - break; - case 1: - Bstrcat(tempbuf, "RIGHT"); - break; - case 2: - Bstrcat(tempbuf, "UP"); - break; - case 3: - Bstrcat(tempbuf, "DOWN"); - break; - } + MouseDigitalFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_mouse); + cmenu(212); + probey = 3+(whichkey^2); } else if (function == 2) { - static char *directions[] = - { "UP", "RIGHT", "DOWN", "LEFT" - }; if (whichkey < 2*joynumbuttons) - Bsprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", getjoyname(1,whichkey>>1)); + { + JoystickFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapButton(x, whichkey>>1, whichkey&1, controldevice_joystick); + } else - Bsprintf(tempbuf,"TO HAT %s", directions[whichkey-2*joynumbuttons]); + { + JoystickFunctions[joynumbuttons + (whichkey-2*joynumbuttons)][0] = x; + CONTROL_MapButton(x, joynumbuttons + (whichkey-2*joynumbuttons), 0, controldevice_joystick); + } + cmenu(207); + probey = whichkey; } else if (function == 3) { - Bsprintf(tempbuf,"TO DIGITAL %s %s",getjoyname(0,whichkey>>1),(whichkey&1)?"POSITIVE":"NEGATIVE"); + JoystickDigitalFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_joystick); + cmenu((whichkey>>2)+208); + probey = 1+((whichkey>>1)&1)*4+(whichkey&1); } + break; + } - gametext(320>>1,31+9,tempbuf,0,2+8+16); + gametext(320>>1,31,"SELECT A FUNCTION TO ASSIGN",0,2+8+16); - if (KB_KeyPressed(sc_End)) + if (function == 0) + { + if (whichkey < (MAXMOUSEBUTTONS-2)*2) + sprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", mousebuttonnames[whichkey>>1]); + else + Bstrcpy(tempbuf, mousebuttonnames[whichkey-(MAXMOUSEBUTTONS-2)]); + } + else if (function == 1) + { + Bstrcpy(tempbuf,"TO DIGITAL "); + switch (whichkey) { - KB_ClearKeyDown(sc_End); - probey = NUMGAMEFUNCTIONS-1; - sound(KICK_HIT); - } - else if (KB_KeyPressed(sc_Home)) - { - KB_ClearKeyDown(sc_Home); - probey = 0; - sound(KICK_HIT); + case 0: + Bstrcat(tempbuf, "LEFT"); + break; + case 1: + Bstrcat(tempbuf, "RIGHT"); + break; + case 2: + Bstrcat(tempbuf, "UP"); + break; + case 3: + Bstrcat(tempbuf, "DOWN"); + break; } + } + else if (function == 2) + { + static char *directions[] = + { "UP", "RIGHT", "DOWN", "LEFT" + }; + if (whichkey < 2*joynumbuttons) + Bsprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", getjoyname(1,whichkey>>1)); + else + Bsprintf(tempbuf,"TO HAT %s", directions[whichkey-2*joynumbuttons]); + } + else if (function == 3) + { + Bsprintf(tempbuf,"TO DIGITAL %s %s",getjoyname(0,whichkey>>1),(whichkey&1)?"POSITIVE":"NEGATIVE"); + } + gametext(320>>1,31+9,tempbuf,0,2+8+16); + + if (KB_KeyPressed(sc_End)) + { + KB_ClearKeyDown(sc_End); + probey = NUMGAMEFUNCTIONS-1; + sound(KICK_HIT); + } + else if (KB_KeyPressed(sc_Home)) + { + KB_ClearKeyDown(sc_Home); + probey = 0; + sound(KICK_HIT); + } + + m = probey - 6; + if (m < 0) m = 0; + else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; + + for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) + { + if (l+m == NUMGAMEFUNCTIONS-1) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(m+l)); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(100,51+l*8,tempbuf,(m+l == probey)?0:16,10+16); + } + + gametext(320>>1,161,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); + + break; + + case 212: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"ADVANCED MOUSE"); + + c = (320>>1)-120; + + onbar = (probey == 0 || probey == 1 || probey == 2); + if (probey < 3) + x = probe(c,46,16,7); + else if (probey < 7) + { + m=50; + x = probesm(c+10,96+16-(10+10+10),10,7); + } + else + { + x = probe(c,146+16-(16+16+16+16+16+16),16,7); + } + + switch (x) + { + case -1: + cmenu(205); + probey = (MAXMOUSEBUTTONS-2)*2+2+2+1; + break; + + case 0: + // x-axis scale + case 1: + // y-axis scale + case 2: + // mouse filter + break; + + case 3: + // digital up + case 4: + // digital down + case 5: + // digital left + case 6: + // digital right + function = 1; + whichkey = (x-3)^2; // flip the actual axis number + cmenu(211); + probey = MouseDigitalFunctions[whichkey>>1][whichkey&1]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + } + + menutext(c,46,MENUHIGHLIGHT(0),0,"X-AXIS SCALE"); + l = (MouseAnalogueScale[0]+262144) >> 13; + bar(c+160+40,46,(short *)&l,1,x==0,MENUHIGHLIGHT(0),0); + l = (l<<13)-262144; + if (l != MouseAnalogueScale[0]) + { + CONTROL_SetAnalogAxisScale(0, l, controldevice_mouse); + MouseAnalogueScale[0] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(c+160-16,46-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); + + menutext(c,46+16,MENUHIGHLIGHT(1),0,"Y-AXIS SCALE"); + l = (MouseAnalogueScale[1]+262144) >> 13; + bar(c+160+40,46+16,(short *)&l,1,x==1,MENUHIGHLIGHT(1),0); + l = (l<<13)-262144; + if (l != MouseAnalogueScale[1]) + { + CONTROL_SetAnalogAxisScale(1, l, controldevice_mouse); + MouseAnalogueScale[1] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(c+160-16,46+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); + + menutext(c,46+16+16,MENUHIGHLIGHT(2),0,"DEAD ZONE"); + l = MouseFilter>>1; + bar(c+160+40,46+16+16,(short *)&l,2,x==2,MENUHIGHLIGHT(2),0); + MouseFilter = l<<1; + menutext(c,46+16+16+16+8,/*(MENUHIGHLIGHT(3))+(MENUHIGHLIGHT(4))+(MENUHIGHLIGHT(5))+(MENUHIGHLIGHT(6))-24*/0,0,"DIGITAL AXES ACTIONS"); + + if (MouseFilter == 0) + Bsprintf(tempbuf," OFF"); + else if (MouseFilter < 48) + Bsprintf(tempbuf," LOW"); + else if (MouseFilter < 96) + Bsprintf(tempbuf," MED"); + else if (MouseFilter < 128) + Bsprintf(tempbuf,"HIGH"); + + gametext(c+160-16,46+16+16-8,tempbuf,MENUHIGHLIGHT(2),2+8+16); + + + gametext(c+10,90+16,"UP:",MENUHIGHLIGHT(3),2+8+16); + if (MouseDigitalFunctions[1][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+10+60,91+16,tempbuf,MENUHIGHLIGHT(3),0,10+16); + + gametext(c+10,90+16+10,"DOWN:",MENUHIGHLIGHT(4),2+8+16); + if (MouseDigitalFunctions[1][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+10+60,91+16+10,tempbuf,MENUHIGHLIGHT(4),0,10+16); + + gametext(c+10,90+16+10+10,"LEFT:",MENUHIGHLIGHT(5),2+8+16); + if (MouseDigitalFunctions[0][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+10+60,91+16+10+10,tempbuf,MENUHIGHLIGHT(5),0,10+16); + + gametext(c+10,90+16+10+10+10,"RIGHT:",MENUHIGHLIGHT(6),2+8+16); + if (MouseDigitalFunctions[0][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+10+60,91+16+10+10+10,tempbuf,MENUHIGHLIGHT(6),0,10+16); + + break; + + case 206: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"JOYSTICK SETUP"); + + x = probe(160,100-18,18,3); + + switch (x) + { + case -1: + cmenu(202); + probey = 6; + break; + case 0: + case 1: + cmenu(207+x); + break; + case 2: + cmenu(213); + break; + } + + menutext(160,100-18,0,0,"EDIT BUTTONS"); + menutext(160,100,0,0,"EDIT AXES"); + menutext(160,100+18,0,0,"DEAD ZONES"); + + break; + + case 207: + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"JOYSTICK BUTTONS"); + + c = 2*joynumbuttons + 4*(joynumhats>0); + + x = probe(0,0,0,c); + + if (x == -1) + { + cmenu(206); + probey = 0; + break; + } + else if (x >= 0) + { + function = 2; + whichkey = x; + cmenu(211); + if (x < 2*joynumbuttons) + { + probey = JoystickFunctions[x>>1][x&1]; + } + else + { + probey = JoystickFunctions[joynumbuttons + (x-2*joynumbuttons)][0]; + } + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + } + + // the top of our list + if (c < 13) m = 0; + else + { m = probey - 6; if (m < 0) m = 0; - else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; + else if (m + 13 >= c) m = c-13; + } - for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) + for (l=0; l>1,161,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); - - break; - - case 212: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"ADVANCED MOUSE"); - - c = (320>>1)-120; - - onbar = (probey == 0 || probey == 1 || probey == 2); - if (probey < 3) - x = probe(c,46,16,7); - else if (probey < 7) - { - m=50; - x = probesm(c+10,96+16-(10+10+10),10,7); + sprintf(tempbuf, "%s%s", ((l+m)&1)?"Double ":"", getjoyname(1,(l+m)>>1)); + x = JoystickFunctions[(l+m)>>1][(l+m)&1]; } else { - x = probe(c,146+16-(16+16+16+16+16+16),16,7); + static char *directions[] = + { "Up", "Right", "Down", "Left" + }; + sprintf(tempbuf, "Hat %s", directions[(l+m)-2*joynumbuttons]); + x = JoystickFunctions[joynumbuttons + ((l+m)-2*joynumbuttons)][0]; } - - switch (x) - { - case -1: - cmenu(205); - probey = (MAXMOUSEBUTTONS-2)*2+2+2+1; - break; - - case 0: - // x-axis scale - case 1: - // y-axis scale - case 2: - // mouse filter - break; - - case 3: - // digital up - case 4: - // digital down - case 5: - // digital left - case 6: - // digital right - function = 1; - whichkey = (x-3)^2; // flip the actual axis number - cmenu(211); - probey = MouseDigitalFunctions[whichkey>>1][whichkey&1]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - } - - menutext(c,46,MENUHIGHLIGHT(0),0,"X-AXIS SCALE"); - l = (MouseAnalogueScale[0]+262144) >> 13; - bar(c+160+40,46,(short *)&l,1,x==0,MENUHIGHLIGHT(0),0); - l = (l<<13)-262144; - if (l != MouseAnalogueScale[0]) - { - CONTROL_SetAnalogAxisScale(0, l, controldevice_mouse); - MouseAnalogueScale[0] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - gametext(c+160-16,46-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); - - menutext(c,46+16,MENUHIGHLIGHT(1),0,"Y-AXIS SCALE"); - l = (MouseAnalogueScale[1]+262144) >> 13; - bar(c+160+40,46+16,(short *)&l,1,x==1,MENUHIGHLIGHT(1),0); - l = (l<<13)-262144; - if (l != MouseAnalogueScale[1]) - { - CONTROL_SetAnalogAxisScale(1, l, controldevice_mouse); - MouseAnalogueScale[1] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - gametext(c+160-16,46+16-8,tempbuf,MENUHIGHLIGHT(1),2+8+16); - - menutext(c,46+16+16,MENUHIGHLIGHT(2),0,"DEAD ZONE"); - l = MouseFilter>>1; - bar(c+160+40,46+16+16,(short *)&l,2,x==2,MENUHIGHLIGHT(2),0); - MouseFilter = l<<1; - menutext(c,46+16+16+16+8,/*(MENUHIGHLIGHT(3))+(MENUHIGHLIGHT(4))+(MENUHIGHLIGHT(5))+(MENUHIGHLIGHT(6))-24*/0,0,"DIGITAL AXES ACTIONS"); - - if (MouseFilter == 0) - Bsprintf(tempbuf," OFF"); - else if (MouseFilter < 48) - Bsprintf(tempbuf," LOW"); - else if (MouseFilter < 96) - Bsprintf(tempbuf," MED"); - else if (MouseFilter < 128) - Bsprintf(tempbuf,"HIGH"); - - gametext(c+160-16,46+16+16-8,tempbuf,MENUHIGHLIGHT(2),2+8+16); - - - gametext(c+10,90+16,"UP:",MENUHIGHLIGHT(3),2+8+16); - if (MouseDigitalFunctions[1][0] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][0])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(c+10+60,91+16,tempbuf,MENUHIGHLIGHT(3),0,10+16); - - gametext(c+10,90+16+10,"DOWN:",MENUHIGHLIGHT(4),2+8+16); - if (MouseDigitalFunctions[1][1] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][1])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(c+10+60,91+16+10,tempbuf,MENUHIGHLIGHT(4),0,10+16); - - gametext(c+10,90+16+10+10,"LEFT:",MENUHIGHLIGHT(5),2+8+16); - if (MouseDigitalFunctions[0][0] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][0])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(c+10+60,91+16+10+10,tempbuf,MENUHIGHLIGHT(5),0,10+16); - - gametext(c+10,90+16+10+10+10,"RIGHT:",MENUHIGHLIGHT(6),2+8+16); - if (MouseDigitalFunctions[0][1] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][1])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(c+10+60,91+16+10+10+10,tempbuf,MENUHIGHLIGHT(6),0,10+16); - - break; - - case 206: - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"JOYSTICK SETUP"); - - x = probe(160,100-18,18,3); - - switch (x) - { - case -1: - cmenu(202); - probey = 6; - break; - case 0: - case 1: - cmenu(207+x); - break; - case 2: - cmenu(213); - break; - } - - menutext(160,100-18,0,0,"EDIT BUTTONS"); - menutext(160,100,0,0,"EDIT AXES"); - menutext(160,100+18,0,0,"DEAD ZONES"); - - break; - - case 207: - rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,15,0,0,"JOYSTICK BUTTONS"); - - c = 2*joynumbuttons + 4*(joynumhats>0); - - x = probe(0,0,0,c); + minitextshade(80-4,33+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); if (x == -1) + minitextshade(176,33+l*8," -NONE-",(m+l==probey)?0:16,2,10+16); + else + { + strcpy(tempbuf, CONFIG_FunctionNumToName(x)); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(176,33+l*8,tempbuf,(m+l==probey)?0:16,2,10+16); + } + } + + gametext(160,149,"UP/DOWN = SELECT BUTTON",0,2+8+16); + gametext(160,149+9,"ENTER = MODIFY",0,2+8+16); + break; + + case 208: + case 209: + case 217: + case 218: + case 219: + case 220: + case 221: + case 222: + { + int thispage, twothispage; + + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"JOYSTICK AXES"); + + thispage = (current_menu < 217) ? (current_menu-208) : (current_menu-217)+2; + twothispage = (thispage*2+1 < joynumaxes); + + onbar = 0; + switch (probey) + { + case 0: + case 4: + onbar = 1; + x = probe(88,45+(probey==4)*64,0,1+(4< 2) + { + if (thispage == ((joynumaxes+1)/2)-1) cmenu(208); + else + { + if (current_menu == 209) cmenu(217); + else cmenu(current_menu+1); + } + } + break; + + case 4: // bar + if (!twothispage && joynumaxes > 2) + cmenu(208); + case 0: + break; + + case 1: // digitals + case 2: + case 5: + case 6: + function = 3; + whichkey = ((thispage*2+(x==5||x==6)) << 1) + (x==2||x==6); + cmenu(211); + probey = JoystickDigitalFunctions[whichkey>>1][whichkey&1]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + + case 3: // analogues + case 7: + l = JoystickAnalogueAxes[thispage*2+(x==7)]; + if (l == analog_turning) l = analog_strafing; + else if (l == analog_strafing) l = analog_lookingupanddown; + else if (l == analog_lookingupanddown) l = analog_moving; + else if (l == analog_moving) l = -1; + else l = analog_turning; + JoystickAnalogueAxes[thispage*2+(x==7)] = l; + CONTROL_MapAnalogAxis(thispage*2+(x==7),l,controldevice_joystick); + { + extern int32 mouseyaxismode; // player.c + mouseyaxismode = -1; + } + break; + default: + break; + } + + Bsprintf(tempbuf,getjoyname(0,thispage*2)); + menutext(42,32,0,0,tempbuf); + if (twothispage) + { + Bsprintf(tempbuf,getjoyname(0,thispage*2+1)); + menutext(42,32+64,0,0,tempbuf); + } + gametext(76,38,"SCALE",0,2+8+16); + l = (JoystickAnalogueScale[thispage*2]+262144) >> 13; + bar(140+56,38+8,(short *)&l,1,x==0,0,0); + l = (l<<13)-262144; + if (l != JoystickAnalogueScale[thispage*2]) + { + CONTROL_SetAnalogAxisScale(thispage*2, l, controldevice_joystick); + JoystickAnalogueScale[thispage*2] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(140,38,tempbuf,0,2+8+16); + + gametext(76,38+15,"DIGITAL",0,2+8+16); + if (JoystickDigitalFunctions[thispage*2][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12,38+15,tempbuf,0,10+16); + + if (JoystickDigitalFunctions[thispage*2][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12+72,38+15,tempbuf,0,10+16); + + gametext(76,38+15+15,"ANALOG",0,2+8+16); + if (CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2])) + { + p = CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2]); + if (p) + { + gametext(140+12,38+15+15, strchr(p,'_')+1, 0, 2+8+16); + } + } + + if (twothispage) + { + gametext(76,38+64,"SCALE",0,2+8+16); + l = (JoystickAnalogueScale[thispage*2+1]+262144) >> 13; + bar(140+56,38+8+64,(short *)&l,1,x==4,0,0); + l = (l<<13)-262144; + if (l != JoystickAnalogueScale[thispage*2+1]) + { + CONTROL_SetAnalogAxisScale(thispage*2+1, l, controldevice_joystick); + JoystickAnalogueScale[thispage*2+1] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(140,38+64,tempbuf,0,2+8+16); + + gametext(76,38+64+15,"DIGITAL",0,2+8+16); + if (JoystickDigitalFunctions[thispage*2+1][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12,38+15+64,tempbuf,0,10+16); + + if (JoystickDigitalFunctions[thispage*2+1][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12+72,38+15+64,tempbuf,0,10+16); + + gametext(76,38+64+15+15,"ANALOG",0,2+8+16); + if (CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2+1])) + { + p = CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2+1]); + if (p) + { + gametext(140+12,38+64+15+15, strchr(p,'_')+1, 0, 2+8+16); + } + } + } + + if (joynumaxes > 2) + { + menutext(320>>1,twothispage?158:108,SHX(-10),(joynumaxes<=2),"NEXT..."); + sprintf(tempbuf,"Page %d of %d",thispage+1,(joynumaxes+1)/2); + gametext(320-100,158,tempbuf,0,2+8+16); + } + break; + } + + case 213: + case 214: + case 215: + case 216: + { // Pray this is enough pages for now :-| + int first,last; + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"JOY DEAD ZONES"); + + first = 4*(current_menu-213); + last = min(4*(current_menu-213)+4,joynumaxes); + + onbar = 1; + x = probe(320,48,15,2*(last-first)+(joynumaxes>4)); + + if (x==-1) { cmenu(206); + probey = 2; + break; + } + else if (x==2*(last-first) && joynumaxes>4) + { + cmenu((current_menu-213) == (joynumaxes/4) ? 213 : (current_menu+1)); probey = 0; break; } - else if (x >= 0) + + for (m=first;m>1][x&1]; - } - else - { - probey = JoystickFunctions[joynumbuttons + (x-2*joynumbuttons)][0]; - } - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - } + unsigned short odx,dx,ody,dy; + Bsprintf(tempbuf,getjoyname(0,m)); + menutext(32,48+30*(m-first),0,0,tempbuf); - // the top of our list - if (c < 13) m = 0; - else + gametext(128,48+30*(m-first)-8,"DEAD",0,2+8+16); + gametext(128,48+30*(m-first)-8+15,"SATU",0,2+8+16); + + dx = odx = min(64,64l*JoystickAnalogueDead[m]/10000l); + dy = ody = min(64,64l*JoystickAnalogueSaturate[m]/10000l); + + bar(217,48+30*(m-first),&dx,4,x==((m-first)*2),0,0); + bar(217,48+30*(m-first)+15,&dy,4,x==((m-first)*2+1),0,0); + + Bsprintf(tempbuf,"%3d%%",100*dx/64); + gametext(217-49,48+30*(m-first)-8,tempbuf,0,2+8+16); + Bsprintf(tempbuf,"%3d%%",100*dy/64); + gametext(217-49,48+30*(m-first)-8+15,tempbuf,0,2+8+16); + + if (dx != odx) JoystickAnalogueDead[m] = 10000l*dx/64l; + if (dy != ody) JoystickAnalogueSaturate[m] = 10000l*dy/64l; + if (dx != odx || dy != ody) + setjoydeadzone(m,JoystickAnalogueDead[m],JoystickAnalogueSaturate[m]); + } + //gametext(160,158,"DEAD = DEAD ZONE, SAT. = SATURATION",0,2+8+16); + if (joynumaxes>4) { - m = probey - 6; - if (m < 0) m = 0; - else if (m + 13 >= c) m = c-13; + menutext(32,48+30*(last-first),0,0,"NEXT..."); + sprintf(tempbuf,"Page %d of %d", 1+(current_menu-213), (joynumaxes+3)/4); + gametext(320-100,158,tempbuf,0,2+8+16); } - - for (l=0; l>1)); - x = JoystickFunctions[(l+m)>>1][(l+m)&1]; - } - else - { - static char *directions[] = - { "Up", "Right", "Down", "Left" - }; - sprintf(tempbuf, "Hat %s", directions[(l+m)-2*joynumbuttons]); - x = JoystickFunctions[joynumbuttons + ((l+m)-2*joynumbuttons)][0]; - } - minitextshade(80-4,33+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); - - if (x == -1) - minitextshade(176,33+l*8," -NONE-",(m+l==probey)?0:16,2,10+16); - else - { - strcpy(tempbuf, CONFIG_FunctionNumToName(x)); - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitextshade(176,33+l*8,tempbuf,(m+l==probey)?0:16,2,10+16); - } - } - - gametext(160,149,"UP/DOWN = SELECT BUTTON",0,2+8+16); - gametext(160,149+9,"ENTER = MODIFY",0,2+8+16); break; - - case 208: - case 209: - case 217: - case 218: - case 219: - case 220: - case 221: - case 222: - { - int thispage, twothispage; - - rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,15,0,0,"JOYSTICK AXES"); - - thispage = (current_menu < 217) ? (current_menu-208) : (current_menu-217)+2; - twothispage = (thispage*2+1 < joynumaxes); - - onbar = 0; - switch (probey) - { - case 0: - case 4: - onbar = 1; - x = probe(88,45+(probey==4)*64,0,1+(4< 2) - { - if (thispage == ((joynumaxes+1)/2)-1) cmenu(208); - else - { - if (current_menu == 209) cmenu(217); - else cmenu(current_menu+1); - } - } - break; - - case 4: // bar - if (!twothispage && joynumaxes > 2) - cmenu(208); - case 0: - break; - - case 1: // digitals - case 2: - case 5: - case 6: - function = 3; - whichkey = ((thispage*2+(x==5||x==6)) << 1) + (x==2||x==6); - cmenu(211); - probey = JoystickDigitalFunctions[whichkey>>1][whichkey&1]; - if (probey < 0) probey = NUMGAMEFUNCTIONS-1; - break; - - case 3: // analogues - case 7: - l = JoystickAnalogueAxes[thispage*2+(x==7)]; - if (l == analog_turning) l = analog_strafing; - else if (l == analog_strafing) l = analog_lookingupanddown; - else if (l == analog_lookingupanddown) l = analog_moving; - else if (l == analog_moving) l = -1; - else l = analog_turning; - JoystickAnalogueAxes[thispage*2+(x==7)] = l; - CONTROL_MapAnalogAxis(thispage*2+(x==7),l,controldevice_joystick); - { - extern int32 mouseyaxismode; // player.c - mouseyaxismode = -1; - } - break; - default: - break; - } - - Bsprintf(tempbuf,getjoyname(0,thispage*2)); - menutext(42,32,0,0,tempbuf); - if (twothispage) - { - Bsprintf(tempbuf,getjoyname(0,thispage*2+1)); - menutext(42,32+64,0,0,tempbuf); - } - gametext(76,38,"SCALE",0,2+8+16); - l = (JoystickAnalogueScale[thispage*2]+262144) >> 13; - bar(140+56,38+8,(short *)&l,1,x==0,0,0); - l = (l<<13)-262144; - if (l != JoystickAnalogueScale[thispage*2]) - { - CONTROL_SetAnalogAxisScale(thispage*2, l, controldevice_joystick); - JoystickAnalogueScale[thispage*2] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - gametext(140,38,tempbuf,0,2+8+16); - - gametext(76,38+15,"DIGITAL",0,2+8+16); - if (JoystickDigitalFunctions[thispage*2][0] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][0])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitext(140+12,38+15,tempbuf,0,10+16); - - if (JoystickDigitalFunctions[thispage*2][1] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][1])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitext(140+12+72,38+15,tempbuf,0,10+16); - - gametext(76,38+15+15,"ANALOG",0,2+8+16); - if (CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2])) - { - p = CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2]); - if (p) - { - gametext(140+12,38+15+15, strchr(p,'_')+1, 0, 2+8+16); - } - } - - if (twothispage) - { - gametext(76,38+64,"SCALE",0,2+8+16); - l = (JoystickAnalogueScale[thispage*2+1]+262144) >> 13; - bar(140+56,38+8+64,(short *)&l,1,x==4,0,0); - l = (l<<13)-262144; - if (l != JoystickAnalogueScale[thispage*2+1]) - { - CONTROL_SetAnalogAxisScale(thispage*2+1, l, controldevice_joystick); - JoystickAnalogueScale[thispage*2+1] = l; - } - Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); - gametext(140,38+64,tempbuf,0,2+8+16); - - gametext(76,38+64+15,"DIGITAL",0,2+8+16); - if (JoystickDigitalFunctions[thispage*2+1][0] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][0])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitext(140+12,38+15+64,tempbuf,0,10+16); - - if (JoystickDigitalFunctions[thispage*2+1][1] < 0) - strcpy(tempbuf, " -NONE-"); - else - strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][1])); - - for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; - minitext(140+12+72,38+15+64,tempbuf,0,10+16); - - gametext(76,38+64+15+15,"ANALOG",0,2+8+16); - if (CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2+1])) - { - p = CONFIG_AnalogNumToName(JoystickAnalogueAxes[thispage*2+1]); - if (p) - { - gametext(140+12,38+64+15+15, strchr(p,'_')+1, 0, 2+8+16); - } - } - } - - if (joynumaxes > 2) - { - menutext(320>>1,twothispage?158:108,SHX(-10),(joynumaxes<=2),"NEXT..."); - sprintf(tempbuf,"Page %d of %d",thispage+1,(joynumaxes+1)/2); - gametext(320-100,158,tempbuf,0,2+8+16); - } - break; - } - - case 213: - case 214: - case 215: - case 216: - { // Pray this is enough pages for now :-| - int first,last; - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"JOY DEAD ZONES"); - - first = 4*(current_menu-213); - last = min(4*(current_menu-213)+4,joynumaxes); - - onbar = 1; - x = probe(320,48,15,2*(last-first)+(joynumaxes>4)); - - if (x==-1) - { - cmenu(206); - probey = 2; - break; - } - else if (x==2*(last-first) && joynumaxes>4) - { - cmenu((current_menu-213) == (joynumaxes/4) ? 213 : (current_menu+1)); - probey = 0; - break; - } - - for (m=first;m4) - { - menutext(32,48+30*(last-first),0,0,"NEXT..."); - sprintf(tempbuf,"Page %d of %d", 1+(current_menu-213), (joynumaxes+3)/4); - gametext(320-100,158,tempbuf,0,2+8+16); - } - break; - } - - case 700: - case 701: - c = (320>>1)-120; - rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,24,0,0,"SOUND SETUP"); - onbar = (probey == 2 || probey == 3); - - x = probe(c,50,16,7); - switch (x) - { - case -1: - if (ps[myconnectindex].gm&MODE_GAME && current_menu == 701) - { - ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - - else cmenu(202); - probey = 1; - break; - case 0: - if (FXDevice >= 0) - { - SoundToggle = 1-SoundToggle; - if (SoundToggle == 0) - { - FX_StopAllSounds(); - clearsoundlocks(); - } - onbar = 0; - } - break; - case 1: - if (MusicDevice >= 0 && (numplayers < 2 || MusicToggle)) - { - MusicToggle = 1-MusicToggle; - if (MusicToggle == 0) MUSIC_Pause(); - else - { - if (ud.recstat != 2 && ps[myconnectindex].gm&MODE_GAME) - playmusic(&music_fn[0][music_select][0]); - else playmusic(&env_music_fn[0][0]); - - MUSIC_Continue(); - } - } - onbar = 0; - - break; - case 4: - if (SoundToggle && (FXDevice >= 0)) - { - VoiceToggle = (VoiceToggle == 2) ? 0 : VoiceToggle+1; - } - onbar = 0; - break; - case 5: - if (SoundToggle && (FXDevice >= 0)) AmbienceToggle = 1-AmbienceToggle; - onbar = 0; - break; - case 6: - if (SoundToggle && (FXDevice >= 0)) - { - ReverseStereo = 1-ReverseStereo; - FX_SetReverseStereo(ReverseStereo); - } - onbar = 0; - break; - default: - onbar = 1; - break; - } - - menutext(c+160+40,50,MENUHIGHLIGHT(0),(FXDevice<0),SoundToggle && FXDevice >= 0?"ON":"OFF"); - - menutext(c+160+40,50+16,MENUHIGHLIGHT(1),(MusicDevice<0||(numplayers > 1 && !MusicToggle)),(MusicToggle && (MusicDevice >= 0))?"ON":"OFF"); - - menutext(c,50,MENUHIGHLIGHT(0),(FXDevice<0),"SOUND"); - menutext(c,50+16+16,MENUHIGHLIGHT(2),(FXDevice<0)||SoundToggle==0,"SOUND VOLUME"); - { - l = FXVolume; - FXVolume >>= 2; - bar(c+167+40,50+16+16,(short *)&FXVolume,4,(FXDevice>=0)&&x==2,MENUHIGHLIGHT(2),SoundToggle==0||(FXDevice<0)); - if (l != FXVolume) - FXVolume <<= 2; - if (l != FXVolume) - FX_SetVolume((short) FXVolume); - } - menutext(c,50+16,MENUHIGHLIGHT(1),(MusicDevice<0||(numplayers > 1 && !MusicToggle)),"MUSIC"); - menutext(c,50+16+16+16,MENUHIGHLIGHT(3),(MusicDevice<0)||MusicToggle==0,"MUSIC VOLUME"); - { - l = MusicVolume; - MusicVolume >>= 2; - bar(c+167+40,50+16+16+16, - (short *)&MusicVolume,4, - (MusicDevice>=0) && x==3,MENUHIGHLIGHT(3), - MusicToggle==0||(MusicDevice<0)); - MusicVolume <<= 2; - if (l != MusicVolume) - MUSIC_SetVolume((short) MusicVolume); - - } - menutext(c,50+16+16+16+16,MENUHIGHLIGHT(4),(FXDevice<0)||SoundToggle==0,"DUKE TALK"); - menutext(c,50+16+16+16+16+16,MENUHIGHLIGHT(5),(FXDevice<0)||SoundToggle==0,"AMBIENCE"); - - menutext(c,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),(FXDevice<0)||SoundToggle==0,"FLIP STEREO"); - - { - char *s[] = { "OFF", "LOCAL", "ALL" }; - menutext(c+160+40,50+16+16+16+16,MENUHIGHLIGHT(4),(FXDevice<0)||SoundToggle==0,s[VoiceToggle]); - } - - menutext(c+160+40,50+16+16+16+16+16,MENUHIGHLIGHT(5),(FXDevice<0)||SoundToggle==0,AmbienceToggle?"ON":"OFF"); - - menutext(c+160+40,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),(FXDevice<0)||SoundToggle==0,ReverseStereo?"ON":"OFF"); - - break; - - case 350: - cmenu(351); - screencapt = 1; - displayrooms(myconnectindex,65536); - //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); - screencapt = 0; - break; - - case 360: - case 361: - case 362: - case 363: - case 364: - case 365: - case 366: - case 367: - case 368: - case 369: - case 351: - case 300: - - c = 320>>1; - rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); - rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - - if (current_menu == 300) menutext(c,24,0,0,"LOAD GAME"); - else menutext(c,24,0,0,"SAVE GAME"); - - if (current_menu >= 360 && current_menu <= 369) - { - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); - gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); - gametext(160,168,tempbuf,0,2+8+16); - if (ud.volume_number == 0 && ud.level_number == 7) - gametext(160,180,boardfilename,0,2+8+16); - - x = strget((320>>1),184,&ud.savegame[current_menu-360][0],19, 999); - - if (x == -1) - { - // readsavenames(); - ps[myconnectindex].gm = MODE_GAME; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - goto DISPLAYNAMES; - } - - if (x == 1) - { - if (ud.savegame[current_menu-360][0] == 0) - { - KB_FlushKeyboardQueue(); - cmenu(351); - } - else - { - if (ud.multimode > 1) - saveplayer(-1-(current_menu-360)); - else saveplayer(current_menu-360); - lastsavedpos = current_menu-360; - ps[myconnectindex].gm = MODE_GAME; - - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); - } - } - - rotatesprite(101<<16,97<<16,65536>>1,512,TILE_SAVESHOT,-32,0,2+4+8+64,0,0,xdim-1,ydim-1); - dispnames(); - rotatesprite((c+67+strlen(&ud.savegame[current_menu-360][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10,0,0,xdim-1,ydim-1); - break; - } - - last_threehundred = probey; - - x = probe(c+68,54,12,10); - - if (current_menu == 300) - { - if (ud.savegame[probey][0]) - { - if (lastprobey != probey) - { - loadpheader(probey,&savehead); - lastprobey = probey; - } - - rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); - gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); - gametext(160,168,tempbuf,0,2+8+16); - if (savehead.volnum == 0 && savehead.levnum == 7) - gametext(160,180,savehead.boardfn,0,2+8+16); - } - else menutext(69,70,0,0,"EMPTY"); - } - else - { - if (ud.savegame[probey][0]) - { - if (lastprobey != probey) - loadpheader(probey,&savehead); - lastprobey = probey; - rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - } - else menutext(69,70,0,0,"EMPTY"); - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); - gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); - gametext(160,168,tempbuf,0,2+8+16); - if (ud.volume_number == 0 && ud.level_number == 7) - gametext(160,180,boardfilename,0,2+8+16); - } - - switch (x) - { - case -1: - if (current_menu == 300) - { - if ((ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) - { - cmenu(0); - break; - } - else - ps[myconnectindex].gm &= ~MODE_MENU; - } - else - ps[myconnectindex].gm = MODE_GAME; - - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - - break; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - if (current_menu == 300) - { - if (ud.savegame[x][0]) - current_menu = (1000+x); - } - else - { - if (ud.savegame[x][0] != 0) - current_menu = 2000+x; - else - { - KB_FlushKeyboardQueue(); - current_menu = (360+x); - ud.savegame[x][0] = 0; - inputloc = 0; - } - } - break; - } - -DISPLAYNAMES: - dispnames(); - break; - - case 400: - case 401: - if (VOLUMEALL) goto VOLUME_ALL_40x; - case 402: - case 403: - - c = 320>>1; - - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8)) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); - - sound(KICK_HIT); - current_menu--; - if (current_menu < 400) current_menu = 403; - } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_6)) - { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 403) current_menu = 400; - } - - if (KB_KeyPressed(sc_Escape)) - { - if (ps[myconnectindex].gm&MODE_GAME) - cmenu(50); - else cmenu(0); - return; - } - - flushperms(); - rotatesprite(0,0,65536L,0,ORDERING+current_menu-400,0,0,10+16+64,0,0,xdim-1,ydim-1); - - break; -VOLUME_ALL_40x: - - c = 320>>1; - - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8)) - { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); - - sound(KICK_HIT); - current_menu--; - if (current_menu < 400) current_menu = 401; - } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_6)) - { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 401) current_menu = 400; - } - - if (KB_KeyPressed(sc_Escape)) - { - if (ps[myconnectindex].gm&MODE_GAME) - cmenu(50); - else cmenu(0); - return; - } - - flushperms(); - switch (current_menu) - { - case 400: - rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); - break; - case 401: - rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); - break; - } - - break; - - case 500: - case 502: - c = 320>>1; - - gametext(c,90,"Are you sure you want to quit?",0,2+8+16); - gametext(c,99,"(Y/N)",0,2+8+16); - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) - { - KB_FlushKeyboardQueue(); - - sendquit(); - } - - x = probe(186,124,0,0); - if (x == -1 || KB_KeyPressed(sc_N) || RMB) - { - KB_ClearKeyDown(sc_N); - quittimer = 0; - if (ps[myconnectindex].gm&MODE_DEMO && ud.recstat == 2) - ps[myconnectindex].gm = MODE_DEMO; - else - { - if (current_menu == 502) - { - cmenu(last_menu); - probey = last_probey; - } - else if (!(ps[myconnectindex].gm & MODE_GAME || ud.recstat == 2)) - cmenu(0); - else ps[myconnectindex].gm &= ~MODE_MENU; - if (ud.multimode < 2 && ud.recstat != 2) - { - ready2send = 1; - totalclock = ototalclock; - } - } - } - - break; - case 501: - c = 320>>1; - gametext(c,90,"Quit to Title?",0,2+8+16); - gametext(c,99,"(Y/N)",0,2+8+16); - - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) - { - KB_FlushKeyboardQueue(); - ps[myconnectindex].gm = MODE_DEMO; - if (ud.recstat == 1) - closedemowrite(); - cmenu(0); - } - - x = probe(186,124,0,0); - - if (x == -1 || KB_KeyPressed(sc_N) || RMB) + } + + case 700: + case 701: + c = (320>>1)-120; + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"SOUND SETUP"); + onbar = (probey == 2 || probey == 3); + + x = probe(c,50,16,7); + switch (x) + { + case -1: + if (ps[myconnectindex].gm&MODE_GAME && current_menu == 701) { ps[myconnectindex].gm &= ~MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) @@ -4430,330 +3950,805 @@ VOLUME_ALL_40x: } } + else cmenu(202); + probey = 1; break; - - case 601: - displayfragbar(); - rotatesprite(160<<16,29<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(320>>1,34,0,0,&ud.user_name[myconnectindex][0]); - - sprintf(tempbuf,"Waiting for master"); - gametext(160,50,tempbuf,0,2+8+16); - gametext(160,59,"to select level",0,2+8+16); - - if (KB_KeyPressed(sc_Escape)) + case 0: + if (FXDevice >= 0) { - KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); - cmenu(0); + SoundToggle = 1-SoundToggle; + if (SoundToggle == 0) + { + FX_StopAllSounds(); + clearsoundlocks(); + } + onbar = 0; } break; - - case 602: - if (menunamecnt == 0) + case 1: + if (MusicDevice >= 0 && (numplayers < 2 || MusicToggle)) { - // getfilenames("SUBD"); - getfilenames(".","*.MAP"); - if (menunamecnt == 0) - cmenu(600); + MusicToggle = 1-MusicToggle; + if (MusicToggle == 0) MUSIC_Pause(); + else + { + if (ud.recstat != 2 && ps[myconnectindex].gm&MODE_GAME) + playmusic(&music_fn[0][music_select][0]); + else playmusic(&env_music_fn[0][0]); + + MUSIC_Continue(); + } + } + onbar = 0; + + break; + case 4: + if (SoundToggle && (FXDevice >= 0)) + { + VoiceToggle = (VoiceToggle == 2) ? 0 : VoiceToggle+1; + } + onbar = 0; + break; + case 5: + if (SoundToggle && (FXDevice >= 0)) AmbienceToggle = 1-AmbienceToggle; + onbar = 0; + break; + case 6: + if (SoundToggle && (FXDevice >= 0)) + { + ReverseStereo = 1-ReverseStereo; + FX_SetReverseStereo(ReverseStereo); + } + onbar = 0; + break; + default: + onbar = 1; + break; + } + + menutext(c+160+40,50,MENUHIGHLIGHT(0),(FXDevice<0),SoundToggle && FXDevice >= 0?"ON":"OFF"); + + menutext(c+160+40,50+16,MENUHIGHLIGHT(1),(MusicDevice<0||(numplayers > 1 && !MusicToggle)),(MusicToggle && (MusicDevice >= 0))?"ON":"OFF"); + + menutext(c,50,MENUHIGHLIGHT(0),(FXDevice<0),"SOUND"); + menutext(c,50+16+16,MENUHIGHLIGHT(2),(FXDevice<0)||SoundToggle==0,"SOUND VOLUME"); + { + l = FXVolume; + FXVolume >>= 2; + bar(c+167+40,50+16+16,(short *)&FXVolume,4,(FXDevice>=0)&&x==2,MENUHIGHLIGHT(2),SoundToggle==0||(FXDevice<0)); + if (l != FXVolume) + FXVolume <<= 2; + if (l != FXVolume) + FX_SetVolume((short) FXVolume); + } + menutext(c,50+16,MENUHIGHLIGHT(1),(MusicDevice<0||(numplayers > 1 && !MusicToggle)),"MUSIC"); + menutext(c,50+16+16+16,MENUHIGHLIGHT(3),(MusicDevice<0)||MusicToggle==0,"MUSIC VOLUME"); + { + l = MusicVolume; + MusicVolume >>= 2; + bar(c+167+40,50+16+16+16, + (short *)&MusicVolume,4, + (MusicDevice>=0) && x==3,MENUHIGHLIGHT(3), + MusicToggle==0||(MusicDevice<0)); + MusicVolume <<= 2; + if (l != MusicVolume) + MUSIC_SetVolume((short) MusicVolume); + + } + menutext(c,50+16+16+16+16,MENUHIGHLIGHT(4),(FXDevice<0)||SoundToggle==0,"DUKE TALK"); + menutext(c,50+16+16+16+16+16,MENUHIGHLIGHT(5),(FXDevice<0)||SoundToggle==0,"AMBIENCE"); + + menutext(c,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),(FXDevice<0)||SoundToggle==0,"FLIP STEREO"); + + { + char *s[] = { "OFF", "LOCAL", "ALL" }; + menutext(c+160+40,50+16+16+16+16,MENUHIGHLIGHT(4),(FXDevice<0)||SoundToggle==0,s[VoiceToggle]); + } + + menutext(c+160+40,50+16+16+16+16+16,MENUHIGHLIGHT(5),(FXDevice<0)||SoundToggle==0,AmbienceToggle?"ON":"OFF"); + + menutext(c+160+40,50+16+16+16+16+16+16,MENUHIGHLIGHT(6),(FXDevice<0)||SoundToggle==0,ReverseStereo?"ON":"OFF"); + + break; + + case 350: + cmenu(351); + screencapt = 1; + displayrooms(myconnectindex,65536); + //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); + screencapt = 0; + break; + + case 360: + case 361: + case 362: + case 363: + case 364: + case 365: + case 366: + case 367: + case 368: + case 369: + case 351: + case 300: + + c = 320>>1; + rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + + if (current_menu == 300) menutext(c,24,0,0,"LOAD GAME"); + else menutext(c,24,0,0,"SAVE GAME"); + + if (current_menu >= 360 && current_menu <= 369) + { + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + + x = strget((320>>1),184,&ud.savegame[current_menu-360][0],19, 999); + + if (x == -1) + { + // readsavenames(); + ps[myconnectindex].gm = MODE_GAME; + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + goto DISPLAYNAMES; } - case 603: + if (x == 1) { - int plrvotes = 0, j = 0; - - x = probe(186,124,0,0); - - if (voting != myconnectindex) - ps[myconnectindex].gm &= ~MODE_MENU; - - if (x == -1) + if (ud.savegame[current_menu-360][0] == 0) { - if (voting == myconnectindex) - { - Bmemset(votes,0,sizeof(votes)); - Bmemset(gotvote,0,sizeof(gotvote)); - - tempbuf[0] = 18; - tempbuf[1] = 2; - tempbuf[2] = myconnectindex; - - for (c=connecthead;c>=0;c=connectpoint2[c]) - { - if (c != myconnectindex) sendpacket(c,tempbuf,3); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - voting = -1; - } - cmenu(0); - } - - for (i=0;i (numplayers>>1)) || (!networkmode && myconnectindex == connecthead)) - { - if (plrvotes > (numplayers>>1) || !ps[myconnectindex].i || (!networkmode && myconnectindex == connecthead)) - { - tempbuf[0] = 5; - tempbuf[1] = ud.m_level_number; - tempbuf[2] = ud.m_volume_number; - tempbuf[3] = ud.m_player_skill+1; - - if (ud.m_player_skill == 3) ud.m_respawn_monsters = 1; - else ud.m_respawn_monsters = 0; - - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN)) ud.m_respawn_items = 1; - else ud.m_respawn_items = 0; - - ud.m_respawn_inventory = 1; - - tempbuf[4] = ud.m_monsters_off; - tempbuf[5] = ud.m_respawn_monsters; - tempbuf[6] = ud.m_respawn_items; - tempbuf[7] = ud.m_respawn_inventory; - tempbuf[8] = ud.m_coop; - tempbuf[9] = ud.m_marker; - tempbuf[10] = ud.m_ffire; - tempbuf[11] = ud.m_noexits; - - for (c=connecthead;c>=0;c=connectpoint2[c]) - { - resetweapons(c); - resetinventory(c); - - } - for (c=connecthead;c>=0;c=connectpoint2[c]) - { - if (c != myconnectindex) sendpacket(c,tempbuf,12); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - - if (voting == myconnectindex) - adduserquote("VOTE SUCCEEDED"); - - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); - if (enterlevel(MODE_GAME)) backtomenu(); - - return; - } - else if (j == numplayers) - { - Bmemset(votes,0,sizeof(votes)); - Bmemset(gotvote,0,sizeof(gotvote)); - voting = -1; - - tempbuf[0] = 18; - tempbuf[1] = 2; - tempbuf[2] = myconnectindex; - tempbuf[3] = 1; - - for (c=connecthead;c>=0;c=connectpoint2[c]) - { - if (c != myconnectindex) sendpacket(c,tempbuf,4); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - - Bsprintf(fta_quotes[116],"VOTE FAILED"); - FTA(116,&ps[myconnectindex]); - ps[myconnectindex].gm &= ~MODE_MENU; - } + KB_FlushKeyboardQueue(); + cmenu(351); } else { - gametext(160,90,"WAITING FOR VOTES",0,2); + if (ud.multimode > 1) + saveplayer(-1-(current_menu-360)); + else saveplayer(current_menu-360); + lastsavedpos = current_menu-360; + ps[myconnectindex].gm = MODE_GAME; + + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); } - break; - } - case 600: - c = (320>>1) - 120; - if ((ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) - displayfragbar(); - rotatesprite(160<<16,26<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(160,31,0,0,&ud.user_name[myconnectindex][0]); - - x = probe(c,57-8,16,8); - - modval(0,num_gametypes-1,(int *)&ud.m_coop,1,probey==0); - if (!VOLUMEONE) - modval(0,num_volumes-1,(int *)&ud.m_volume_number,1,probey==1); - modval(0,ud.m_volume_number == 0?6+(boardfilename[0]!=0):10,(int *)&ud.m_level_number,1,probey==2); - - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) - modval(0,1,(int *)&ud.m_marker,1,probey==4); - if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) - modval(0,1,(int *)&ud.m_ffire,1,probey==5); - else modval(0,1,(int *)&ud.m_noexits,1,probey==5); - - switch (x) - { - case -1: - ud.m_recstat = 0; - if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); - else cmenu(0); - break; - case 0: - ud.m_coop++; - if (ud.m_coop == num_gametypes) ud.m_coop = 0; - break; - case 1: - if (!VOLUMEONE) - { - ud.m_volume_number++; - if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; - if (ud.m_volume_number == 0 && ud.m_level_number > 6) - ud.m_level_number = 0; - if (ud.m_level_number > 10) ud.m_level_number = 0; - } - break; - case 2: - ud.m_level_number++; - if (!VOLUMEONE) - { - if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) - ud.m_level_number = 0; - } - else - { - if (ud.m_volume_number == 0 && ud.m_level_number > 5) - ud.m_level_number = 0; - } - if (ud.m_level_number > 10) ud.m_level_number = 0; - break; - case 3: - if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) - ud.m_monsters_off = 0; - - if (ud.m_monsters_off == 0) - { - ud.m_player_skill++; - if (ud.m_player_skill > 3) - { - ud.m_player_skill = 0; - ud.m_monsters_off = 1; - } - } - else ud.m_monsters_off = 0; - - break; - - case 4: - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) - ud.m_marker = !ud.m_marker; - break; - - case 5: - if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) - ud.m_ffire = !ud.m_ffire; - else ud.m_noexits = !ud.m_noexits; - break; - - case 6: - if (VOLUMEALL) - { - currentlist = 1; - last_probey = probey; - cmenu(101); - } - break; - case 7: - if (voting == -1) - { - if (ps[myconnectindex].i) - { - Bmemset(votes,0,sizeof(votes)); - Bmemset(gotvote,0,sizeof(gotvote)); - votes[myconnectindex] = gotvote[myconnectindex] = 1; - voting = myconnectindex; - - tempbuf[0] = 18; - tempbuf[1] = 1; - tempbuf[2] = myconnectindex; - tempbuf[3] = ud.m_volume_number; - tempbuf[4] = ud.m_level_number; - - for (c=connecthead;c>=0;c=connectpoint2[c]) - { - if (c != myconnectindex) sendpacket(c,tempbuf,5); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - } - cmenu(603); - } - break; } - c += 40; + rotatesprite(101<<16,97<<16,65536>>1,512,TILE_SAVESHOT,-32,0,2+4+8+64,0,0,xdim-1,ydim-1); + dispnames(); + rotatesprite((c+67+strlen(&ud.savegame[current_menu-360][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10,0,0,xdim-1,ydim-1); + break; + } - //if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); - //else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); - //else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); - gametext(c+70,57-7-9,gametype_names[ud.m_coop],MENUHIGHLIGHT(0),2+8+16); - if (VOLUMEONE) + last_threehundred = probey; + + x = probe(c+68,54,12,10); + + if (current_menu == 300) + { + if (ud.savegame[probey][0]) { - gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + if (lastprobey != probey) + { + loadpheader(probey,&savehead); + lastprobey = probey; + } + + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); + gametext(160,168,tempbuf,0,2+8+16); + if (savehead.volnum == 0 && savehead.levnum == 7) + gametext(160,180,savehead.boardfn,0,2+8+16); + } + else menutext(69,70,0,0,"EMPTY"); + } + else + { + if (ud.savegame[probey][0]) + { + if (lastprobey != probey) + loadpheader(probey,&savehead); + lastprobey = probey; + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + } + else menutext(69,70,0,0,"EMPTY"); + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + } + + switch (x) + { + case -1: + if (current_menu == 300) + { + if ((ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) + { + cmenu(0); + break; + } + else + ps[myconnectindex].gm &= ~MODE_MENU; } else + ps[myconnectindex].gm = MODE_GAME; + + if (ud.multimode < 2 && ud.recstat != 2) { - gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + ready2send = 1; + totalclock = ototalclock; } - gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],MENUHIGHLIGHT(2),2+8+16); - - gametext(c+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?skill_names[ud.m_player_skill]:"NONE",MENUHIGHLIGHT(3),2+8+16); - - if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) - gametext(c+70,57+16+16+16+16-7-9,ud.m_marker?"ON":"OFF",MENUHIGHLIGHT(4),2+8+16); - - if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) - gametext(c+70,57+16+16+16+16+16-7-9,ud.m_ffire?"ON":"OFF",MENUHIGHLIGHT(5),2+8+16); - else gametext(c+70,57+16+16+16+16+16-7-9,ud.m_noexits?"OFF":"ON",MENUHIGHLIGHT(5),2+8+16); - - c -= 44; - - menutext(c,57-9,MENUHIGHLIGHT(0),PHX(-2),"GAME TYPE"); - - if (VOLUMEONE) - { - sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); - menutext(c,57+16-9,MENUHIGHLIGHT(1),1,tempbuf); - } - else - { - sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); - menutext(c,57+16-9,MENUHIGHLIGHT(1),PHX(-3),tempbuf); - } - - sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); - menutext(c,57+16+16-9,MENUHIGHLIGHT(2),PHX(-4),tempbuf); - - menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); - - if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),PHX(-6),"MARKERS"); - else - menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"MARKERS"); - - if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) - menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"FR. FIRE"); - else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"MAP EXITS"); - - if (VOLUMEALL) - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),0,"USER MAP"); - if (boardfilename[0] != 0) - gametext(c+70+44,57+16+16+16+16+16,boardfilename,MENUHIGHLIGHT(6),2+8+16); - } - else - { - menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"USER MAP"); - } - - menutext(c,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),voting!=-1,"START GAME"); - break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + if (current_menu == 300) + { + if (ud.savegame[x][0]) + current_menu = (1000+x); + } + else + { + if (ud.savegame[x][0] != 0) + current_menu = 2000+x; + else + { + KB_FlushKeyboardQueue(); + current_menu = (360+x); + ud.savegame[x][0] = 0; + inputloc = 0; + } + } + break; + } + +DISPLAYNAMES: + dispnames(); + break; + + case 400: + case 401: + if (VOLUMEALL) goto VOLUME_ALL_40x; + case 402: + case 403: + + c = 320>>1; + + if (KB_KeyPressed(sc_LeftArrow) || + KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_UpArrow) || + KB_KeyPressed(sc_PgUp) || + KB_KeyPressed(sc_kpad_8)) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if (current_menu < 400) current_menu = 403; + } + else if ( + KB_KeyPressed(sc_PgDn) || + KB_KeyPressed(sc_Enter) || + KB_KeyPressed(sc_kpad_Enter) || + KB_KeyPressed(sc_RightArrow) || + KB_KeyPressed(sc_DownArrow) || + KB_KeyPressed(sc_kpad_2) || + KB_KeyPressed(sc_kpad_9) || + KB_KeyPressed(sc_Space) || + KB_KeyPressed(sc_kpad_6)) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if (current_menu > 403) current_menu = 400; + } + + if (KB_KeyPressed(sc_Escape)) + { + if (ps[myconnectindex].gm&MODE_GAME) + cmenu(50); + else cmenu(0); + return; + } + + flushperms(); + rotatesprite(0,0,65536L,0,ORDERING+current_menu-400,0,0,10+16+64,0,0,xdim-1,ydim-1); + + break; +VOLUME_ALL_40x: + + c = 320>>1; + + if (KB_KeyPressed(sc_LeftArrow) || + KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_UpArrow) || + KB_KeyPressed(sc_PgUp) || + KB_KeyPressed(sc_kpad_8)) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if (current_menu < 400) current_menu = 401; + } + else if ( + KB_KeyPressed(sc_PgDn) || + KB_KeyPressed(sc_Enter) || + KB_KeyPressed(sc_kpad_Enter) || + KB_KeyPressed(sc_RightArrow) || + KB_KeyPressed(sc_DownArrow) || + KB_KeyPressed(sc_kpad_2) || + KB_KeyPressed(sc_kpad_9) || + KB_KeyPressed(sc_Space) || + KB_KeyPressed(sc_kpad_6)) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if (current_menu > 401) current_menu = 400; + } + + if (KB_KeyPressed(sc_Escape)) + { + if (ps[myconnectindex].gm&MODE_GAME) + cmenu(50); + else cmenu(0); + return; + } + + flushperms(); + switch (current_menu) + { + case 400: + rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + case 401: + rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + } + + break; + + case 500: + case 502: + c = 320>>1; + + gametext(c,90,"Are you sure you want to quit?",0,2+8+16); + gametext(c,99,"(Y/N)",0,2+8+16); + + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + KB_FlushKeyboardQueue(); + + sendquit(); + } + + x = probe(186,124,0,0); + if (x == -1 || KB_KeyPressed(sc_N) || RMB) + { + KB_ClearKeyDown(sc_N); + quittimer = 0; + if (ps[myconnectindex].gm&MODE_DEMO && ud.recstat == 2) + ps[myconnectindex].gm = MODE_DEMO; + else + { + if (current_menu == 502) + { + cmenu(last_menu); + probey = last_probey; + } + else if (!(ps[myconnectindex].gm & MODE_GAME || ud.recstat == 2)) + cmenu(0); + else ps[myconnectindex].gm &= ~MODE_MENU; + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + } + + break; + case 501: + c = 320>>1; + gametext(c,90,"Quit to Title?",0,2+8+16); + gametext(c,99,"(Y/N)",0,2+8+16); + + if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + { + KB_FlushKeyboardQueue(); + ps[myconnectindex].gm = MODE_DEMO; + if (ud.recstat == 1) + closedemowrite(); + cmenu(0); + } + + x = probe(186,124,0,0); + + if (x == -1 || KB_KeyPressed(sc_N) || RMB) + { + ps[myconnectindex].gm &= ~MODE_MENU; + if (ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + + break; + + case 601: + displayfragbar(); + rotatesprite(160<<16,29<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,34,0,0,&ud.user_name[myconnectindex][0]); + + sprintf(tempbuf,"Waiting for master"); + gametext(160,50,tempbuf,0,2+8+16); + gametext(160,59,"to select level",0,2+8+16); + + if (KB_KeyPressed(sc_Escape)) + { + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); + cmenu(0); + } + break; + + case 602: + if (menunamecnt == 0) + { + // getfilenames("SUBD"); + getfilenames(".","*.MAP"); + if (menunamecnt == 0) + cmenu(600); + } + + case 603: + { + int plrvotes = 0, j = 0; + + x = probe(186,124,0,0); + + if (voting != myconnectindex) + ps[myconnectindex].gm &= ~MODE_MENU; + + if (x == -1) + { + if (voting == myconnectindex) + { + Bmemset(votes,0,sizeof(votes)); + Bmemset(gotvote,0,sizeof(gotvote)); + + tempbuf[0] = 18; + tempbuf[1] = 2; + tempbuf[2] = myconnectindex; + + for (c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,3); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + voting = -1; + } + cmenu(0); + } + + for (i=0;i (numplayers>>1)) || (!networkmode && myconnectindex == connecthead)) + { + if (plrvotes > (numplayers>>1) || !ps[myconnectindex].i || (!networkmode && myconnectindex == connecthead)) + { + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill+1; + + if (ud.m_player_skill == 3) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN)) ud.m_respawn_items = 1; + else ud.m_respawn_items = 0; + + ud.m_respawn_inventory = 1; + + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + tempbuf[11] = ud.m_noexits; + + for (c=connecthead;c>=0;c=connectpoint2[c]) + { + resetweapons(c); + resetinventory(c); + + } + for (c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,12); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + if (voting == myconnectindex) + adduserquote("VOTE SUCCEEDED"); + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); + if (enterlevel(MODE_GAME)) backtomenu(); + + return; + } + else if (j == numplayers) + { + Bmemset(votes,0,sizeof(votes)); + Bmemset(gotvote,0,sizeof(gotvote)); + voting = -1; + + tempbuf[0] = 18; + tempbuf[1] = 2; + tempbuf[2] = myconnectindex; + tempbuf[3] = 1; + + for (c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,4); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + Bsprintf(fta_quotes[116],"VOTE FAILED"); + FTA(116,&ps[myconnectindex]); + ps[myconnectindex].gm &= ~MODE_MENU; + } + } + else + { + gametext(160,90,"WAITING FOR VOTES",0,2); + } + break; + } + case 600: + c = (320>>1) - 120; + if ((ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) + displayfragbar(); + rotatesprite(160<<16,26<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,31,0,0,&ud.user_name[myconnectindex][0]); + + x = probe(c,57-8,16,8); + + modval(0,num_gametypes-1,(int *)&ud.m_coop,1,probey==0); + if (!VOLUMEONE) + modval(0,num_volumes-1,(int *)&ud.m_volume_number,1,probey==1); + modval(0,ud.m_volume_number == 0?6+(boardfilename[0]!=0):10,(int *)&ud.m_level_number,1,probey==2); + + if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) + modval(0,1,(int *)&ud.m_marker,1,probey==4); + if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) + modval(0,1,(int *)&ud.m_ffire,1,probey==5); + else modval(0,1,(int *)&ud.m_noexits,1,probey==5); + + switch (x) + { + case -1: + ud.m_recstat = 0; + if (ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + break; + case 0: + ud.m_coop++; + if (ud.m_coop == num_gametypes) ud.m_coop = 0; + break; + case 1: + if (!VOLUMEONE) + { + ud.m_volume_number++; + if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if (ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + if (ud.m_level_number > 10) ud.m_level_number = 0; + } + break; + case 2: + ud.m_level_number++; + if (!VOLUMEONE) + { + if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) + ud.m_level_number = 0; + } + else + { + if (ud.m_volume_number == 0 && ud.m_level_number > 5) + ud.m_level_number = 0; + } + if (ud.m_level_number > 10) ud.m_level_number = 0; + break; + case 3: + if (ud.m_monsters_off == 1 && ud.m_player_skill > 0) + ud.m_monsters_off = 0; + + if (ud.m_monsters_off == 0) + { + ud.m_player_skill++; + if (ud.m_player_skill > 3) + { + ud.m_player_skill = 0; + ud.m_monsters_off = 1; + } + } + else ud.m_monsters_off = 0; + + break; + + case 4: + if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) + ud.m_marker = !ud.m_marker; + break; + + case 5: + if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) + ud.m_ffire = !ud.m_ffire; + else ud.m_noexits = !ud.m_noexits; + break; + + case 6: + if (VOLUMEALL) + { + currentlist = 1; + last_probey = probey; + cmenu(101); + } + break; + case 7: + if (voting == -1) + { + if (ps[myconnectindex].i) + { + Bmemset(votes,0,sizeof(votes)); + Bmemset(gotvote,0,sizeof(gotvote)); + votes[myconnectindex] = gotvote[myconnectindex] = 1; + voting = myconnectindex; + + tempbuf[0] = 18; + tempbuf[1] = 1; + tempbuf[2] = myconnectindex; + tempbuf[3] = ud.m_volume_number; + tempbuf[4] = ud.m_level_number; + + for (c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,5); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + } + cmenu(603); + } + break; + } + + c += 40; + + //if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); + //else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); + //else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); + gametext(c+70,57-7-9,gametype_names[ud.m_coop],MENUHIGHLIGHT(0),2+8+16); + if (VOLUMEONE) + { + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + } + else + { + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + } + + gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],MENUHIGHLIGHT(2),2+8+16); + + gametext(c+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?skill_names[ud.m_player_skill]:"NONE",MENUHIGHLIGHT(3),2+8+16); + + if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + gametext(c+70,57+16+16+16+16-7-9,ud.m_marker?"ON":"OFF",MENUHIGHLIGHT(4),2+8+16); + + if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) + gametext(c+70,57+16+16+16+16+16-7-9,ud.m_ffire?"ON":"OFF",MENUHIGHLIGHT(5),2+8+16); + else gametext(c+70,57+16+16+16+16+16-7-9,ud.m_noexits?"OFF":"ON",MENUHIGHLIGHT(5),2+8+16); + + c -= 44; + + menutext(c,57-9,MENUHIGHLIGHT(0),PHX(-2),"GAME TYPE"); + + if (VOLUMEONE) + { + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,MENUHIGHLIGHT(1),1,tempbuf); + } + else + { + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,MENUHIGHLIGHT(1),PHX(-3),tempbuf); + } + + sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); + menutext(c,57+16+16-9,MENUHIGHLIGHT(2),PHX(-4),tempbuf); + + menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); + + if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),PHX(-6),"MARKERS"); + else + menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"MARKERS"); + + if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) + menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"FR. FIRE"); + else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"MAP EXITS"); + + if (VOLUMEALL) + { + menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),0,"USER MAP"); + if (boardfilename[0] != 0) + gametext(c+70+44,57+16+16+16+16+16,boardfilename,MENUHIGHLIGHT(6),2+8+16); + } + else + { + menutext(c,57+16+16+16+16+16+16-9,MENUHIGHLIGHT(6),1,"USER MAP"); + } + + menutext(c,57+16+16+16+16+16+16+16-9,MENUHIGHLIGHT(7),voting!=-1,"START GAME"); + + break; } if ((ps[myconnectindex].gm&MODE_MENU) != MODE_MENU) diff --git a/polymer/eduke32/source/namesdyn.c b/polymer/eduke32/source/namesdyn.c index a6ecc8c8b..cf41418ce 100644 --- a/polymer/eduke32/source/namesdyn.c +++ b/polymer/eduke32/source/namesdyn.c @@ -770,791 +770,791 @@ void processnames(char *szLabel, long lValue) { switch (szLabel[0]) { - case 'A': - if (!Bstrcmp(szLabel,"ACTIVATOR")) ACTIVATOR = lValue; - else if (!Bstrcmp(szLabel,"ACTIVATORLOCKED")) ACTIVATORLOCKED = lValue; - else if (!Bstrcmp(szLabel,"ARROW")) ARROW = lValue; - else if (!Bstrcmp(szLabel,"AMMOBOX")) AMMOBOX = lValue; - else if (!Bstrcmp(szLabel,"AMMO")) AMMO = lValue; - else if (!Bstrcmp(szLabel,"AMMOLOTS")) AMMOLOTS = lValue; - else if (!Bstrcmp(szLabel,"AIRTANK")) AIRTANK = lValue; - else if (!Bstrcmp(szLabel,"ACCESSCARD")) ACCESSCARD = lValue; - else if (!Bstrcmp(szLabel,"ATOMICHEALTH")) ATOMICHEALTH = lValue; - else if (!Bstrcmp(szLabel,"ACCESSSWITCH")) ACCESSSWITCH = lValue; - else if (!Bstrcmp(szLabel,"ACCESSSWITCH2")) ACCESSSWITCH2 = lValue; - else if (!Bstrcmp(szLabel,"ANTENNA")) ANTENNA = lValue; - else if (!Bstrcmp(szLabel,"ATM")) ATM = lValue; - else if (!Bstrcmp(szLabel,"ATMBROKE")) ATMBROKE = lValue; - else if (!Bstrcmp(szLabel,"ALIENSWITCH")) ALIENSWITCH = lValue; - else if (!Bstrcmp(szLabel,"APLAYERTOP")) APLAYERTOP = lValue; - else if (!Bstrcmp(szLabel,"APLAYER")) APLAYER = lValue; - else if (!Bstrcmp(szLabel,"ARMJIB1")) ARMJIB1 = lValue; - else if (!Bstrcmp(szLabel,"AIRTANK_ICON")) AIRTANK_ICON = lValue; - else if (!Bstrcmp(szLabel,"ACCESS_ICON")) ACCESS_ICON = lValue; - break; - case 'B': - if (!Bstrcmp(szLabel,"BATTERYAMMO")) BATTERYAMMO = lValue; - else if (!Bstrcmp(szLabel,"BOOTS")) BOOTS = lValue; - else if (!Bstrcmp(szLabel,"BIGORBIT1")) BIGORBIT1 = lValue; - else if (!Bstrcmp(szLabel,"BIGORBIT2")) BIGORBIT2 = lValue; - else if (!Bstrcmp(szLabel,"BIGORBIT3")) BIGORBIT3 = lValue; - else if (!Bstrcmp(szLabel,"BIGORBIT4")) BIGORBIT4 = lValue; - else if (!Bstrcmp(szLabel,"BIGORBIT5")) BIGORBIT5 = lValue; - else if (!Bstrcmp(szLabel,"BIGFORCE")) BIGFORCE = lValue; - else if (!Bstrcmp(szLabel,"BPANNEL1")) BPANNEL1 = lValue; - else if (!Bstrcmp(szLabel,"BROKENCHAIR")) BROKENCHAIR = lValue; - else if (!Bstrcmp(szLabel,"BGRATE1")) BGRATE1 = lValue; - else if (!Bstrcmp(szLabel,"BRICK")) BRICK = lValue; - else if (!Bstrcmp(szLabel,"BOLT1")) BOLT1 = lValue; - else if (!Bstrcmp(szLabel,"BIGHOLE2")) BIGHOLE2 = lValue; - else if (!Bstrcmp(szLabel,"BOUNCEMINE")) BOUNCEMINE = lValue; - else if (!Bstrcmp(szLabel,"BROKEFIREHYDRENT")) BROKEFIREHYDRENT = lValue; - else if (!Bstrcmp(szLabel,"BOX")) BOX = lValue; - else if (!Bstrcmp(szLabel,"BULLETHOLE")) BULLETHOLE = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE1")) BOTTLE1 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE2")) BOTTLE2 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE3")) BOTTLE3 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE4")) BOTTLE4 = lValue; - else if (!Bstrcmp(szLabel,"BROKEHYDROPLANT")) BROKEHYDROPLANT = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE5")) BOTTLE5 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE6")) BOTTLE6 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE8")) BOTTLE8 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE7")) BOTTLE7 = lValue; - else if (!Bstrcmp(szLabel,"BROKENCLOCK")) BROKENCLOCK = lValue; - else if (!Bstrcmp(szLabel,"BIGHOLE")) BIGHOLE = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE10")) BOTTLE10 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE11")) BOTTLE11 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE12")) BOTTLE12 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE13")) BOTTLE13 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE14")) BOTTLE14 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE15")) BOTTLE15 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE16")) BOTTLE16 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE17")) BOTTLE17 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE18")) BOTTLE18 = lValue; - else if (!Bstrcmp(szLabel,"BOTTLE19")) BOTTLE19 = lValue; - else if (!Bstrcmp(szLabel,"BARBROKE")) BARBROKE = lValue; - else if (!Bstrcmp(szLabel,"BLOODPOOL")) BLOODPOOL = lValue; - else if (!Bstrcmp(szLabel,"BANNER")) BANNER = lValue; - else if (!Bstrcmp(szLabel,"BLANKSCREEN")) BLANKSCREEN = lValue; - else if (!Bstrcmp(szLabel,"BLOODYPOLE")) BLOODYPOLE = lValue; - else if (!Bstrcmp(szLabel,"BLOOD")) BLOOD = lValue; - else if (!Bstrcmp(szLabel,"BURNING")) BURNING = lValue; - else if (!Bstrcmp(szLabel,"BLOODSPLAT1")) BLOODSPLAT1 = lValue; - else if (!Bstrcmp(szLabel,"BLOODSPLAT3")) BLOODSPLAT3 = lValue; - else if (!Bstrcmp(szLabel,"BLOODSPLAT2")) BLOODSPLAT2 = lValue; - else if (!Bstrcmp(szLabel,"BLOODSPLAT4")) BLOODSPLAT4 = lValue; - else if (!Bstrcmp(szLabel,"BURNING2")) BURNING2 = lValue; - else if (!Bstrcmp(szLabel,"BETAVERSION")) BETAVERSION = lValue; - else if (!Bstrcmp(szLabel,"BADGUYICON")) BADGUYICON = lValue; - else if (!Bstrcmp(szLabel,"BOTTOMSTATUSBAR")) BOTTOMSTATUSBAR = lValue; - else if (!Bstrcmp(szLabel,"BOOT_ICON")) BOOT_ICON = lValue; - else if (!Bstrcmp(szLabel,"BETASCREEN")) BETASCREEN = lValue; - else if (!Bstrcmp(szLabel,"BOSS1")) BOSS1 = lValue; - else if (!Bstrcmp(szLabel,"BOSS1STAYPUT")) BOSS1STAYPUT = lValue; - else if (!Bstrcmp(szLabel,"BOSS1SHOOT")) BOSS1SHOOT = lValue; - else if (!Bstrcmp(szLabel,"BOSS1LOB")) BOSS1LOB = lValue; - else if (!Bstrcmp(szLabel,"BOSSTOP")) BOSSTOP = lValue; - else if (!Bstrcmp(szLabel,"BOSS2")) BOSS2 = lValue; - else if (!Bstrcmp(szLabel,"BOSS3")) BOSS3 = lValue; - else if (!Bstrcmp(szLabel,"BIGFNTCURSOR")) BIGFNTCURSOR = lValue; - else if (!Bstrcmp(szLabel,"BIGALPHANUM")) BIGALPHANUM = lValue; - else if (!Bstrcmp(szLabel,"BIGPERIOD")) BIGPERIOD = lValue; - else if (!Bstrcmp(szLabel,"BIGCOMMA")) BIGCOMMA = lValue; - else if (!Bstrcmp(szLabel,"BIGX")) BIGX = lValue; - else if (!Bstrcmp(szLabel,"BIGQ")) BIGQ = lValue; - else if (!Bstrcmp(szLabel,"BIGSEMI")) BIGSEMI = lValue; - else if (!Bstrcmp(szLabel,"BIGCOLIN")) BIGCOLIN = lValue; - else if (!Bstrcmp(szLabel,"BIGAPPOS")) BIGAPPOS = lValue; - else if (!Bstrcmp(szLabel,"BLANK")) BLANK = lValue; - else if (!Bstrcmp(szLabel,"BUTTON1")) BUTTON1 = lValue; - else if (!Bstrcmp(szLabel,"BONUSSCREEN")) BONUSSCREEN = lValue; - else if (!Bstrcmp(szLabel,"BORNTOBEWILDSCREEN")) BORNTOBEWILDSCREEN = lValue; - else if (!Bstrcmp(szLabel,"BLIMP")) BLIMP = lValue; - else if (!Bstrcmp(szLabel,"BPANNEL3")) BPANNEL3 = lValue; - else if (!Bstrcmp(szLabel,"BROOM")) BROOM = lValue; - else if (!Bstrcmp(szLabel,"BOSS4")) BOSS4 = lValue; - else if (!Bstrcmp(szLabel,"BOSS4STAYPUT")) BOSS4STAYPUT = lValue; - break; - case 'C': - if (!Bstrcmp(szLabel,"CYCLER")) CYCLER = lValue; - else if (!Bstrcmp(szLabel,"CHAINGUNSPRITE")) CHAINGUNSPRITE = lValue; - else if (!Bstrcmp(szLabel,"CRYSTALAMMO")) CRYSTALAMMO = lValue; - else if (!Bstrcmp(szLabel,"COLA")) COLA = lValue; - else if (!Bstrcmp(szLabel,"CLOUDYOCEAN")) CLOUDYOCEAN = lValue; - else if (!Bstrcmp(szLabel,"CLOUDYSKIES")) CLOUDYSKIES = lValue; - else if (!Bstrcmp(szLabel,"CRACK1")) CRACK1 = lValue; - else if (!Bstrcmp(szLabel,"CRACK2")) CRACK2 = lValue; - else if (!Bstrcmp(szLabel,"CRACK3")) CRACK3 = lValue; - else if (!Bstrcmp(szLabel,"CRACK4")) CRACK4 = lValue; - else if (!Bstrcmp(szLabel,"CAMERAPOLE")) CAMERAPOLE = lValue; - else if (!Bstrcmp(szLabel,"CHAIR1")) CHAIR1 = lValue; - else if (!Bstrcmp(szLabel,"CHAIR2")) CHAIR2 = lValue; - else if (!Bstrcmp(szLabel,"CAMERA1")) CAMERA1 = lValue; - else if (!Bstrcmp(szLabel,"CHAIR3")) CHAIR3 = lValue; - else if (!Bstrcmp(szLabel,"CAMERALIGHT")) CAMERALIGHT = lValue; - else if (!Bstrcmp(szLabel,"CACTUS")) CACTUS = lValue; - else if (!Bstrcmp(szLabel,"CACTUSBROKE")) CACTUSBROKE = lValue; - else if (!Bstrcmp(szLabel,"CONE")) CONE = lValue; - else if (!Bstrcmp(szLabel,"CLOCK")) CLOCK = lValue; - else if (!Bstrcmp(szLabel,"CIRCLEPANNEL")) CIRCLEPANNEL = lValue; - else if (!Bstrcmp(szLabel,"CIRCLEPANNELBROKE")) CIRCLEPANNELBROKE = lValue; - else if (!Bstrcmp(szLabel,"COLAMACHINE")) COLAMACHINE = lValue; - else if (!Bstrcmp(szLabel,"COLAMACHINEBROKE")) COLAMACHINEBROKE = lValue; - else if (!Bstrcmp(szLabel,"CRANEPOLE")) CRANEPOLE = lValue; - else if (!Bstrcmp(szLabel,"CRANE")) CRANE = lValue; - else if (!Bstrcmp(szLabel,"CANWITHSOMETHING")) CANWITHSOMETHING = lValue; - else if (!Bstrcmp(szLabel,"CEILINGSTEAM")) CEILINGSTEAM = lValue; - else if (!Bstrcmp(szLabel,"COOLEXPLOSION1")) COOLEXPLOSION1 = lValue; - else if (!Bstrcmp(szLabel,"CANNONBALL")) CANNONBALL = lValue; - else if (!Bstrcmp(szLabel,"COMMANDER")) COMMANDER = lValue; - else if (!Bstrcmp(szLabel,"COMMANDERSTAYPUT")) COMMANDERSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"CRACKKNUCKLES")) CRACKKNUCKLES = lValue; - else if (!Bstrcmp(szLabel,"CAMCORNER")) CAMCORNER = lValue; - else if (!Bstrcmp(szLabel,"CAMLIGHT")) CAMLIGHT = lValue; - else if (!Bstrcmp(szLabel,"CROSSHAIR")) CROSSHAIR = lValue; - else if (!Bstrcmp(szLabel,"CLIPINHAND")) CLIPINHAND = lValue; - else if (!Bstrcmp(szLabel,"CHAINGUN")) CHAINGUN = lValue; - else if (!Bstrcmp(szLabel,"CATLITE")) CATLITE = lValue; - else if (!Bstrcmp(szLabel,"COFFEEMACHINE")) COFFEEMACHINE = lValue; - else if (!Bstrcmp(szLabel,"CUPS")) CUPS = lValue; - else if (!Bstrcmp(szLabel,"COFFEEMUG")) COFFEEMUG = lValue; - else if (!Bstrcmp(szLabel,"CHESTOFGOLD")) CHESTOFGOLD = lValue; - else if (!Bstrcmp(szLabel,"CANWITHSOMETHING2")) CANWITHSOMETHING2 = lValue; - else if (!Bstrcmp(szLabel,"CANWITHSOMETHING3")) CANWITHSOMETHING3 = lValue; - else if (!Bstrcmp(szLabel,"CANWITHSOMETHING4")) CANWITHSOMETHING4 = lValue; - break; - case 'D': - if (!Bstrcmp(szLabel,"DEVISTATORSPRITE")) DEVISTATORSPRITE = lValue; - else if (!Bstrcmp(szLabel,"DEVISTATORAMMO")) DEVISTATORAMMO = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE5")) DOORTILE5 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE6")) DOORTILE6 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE1")) DOORTILE1 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE2")) DOORTILE2 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE3")) DOORTILE3 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE4")) DOORTILE4 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE7")) DOORTILE7 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE8")) DOORTILE8 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE9")) DOORTILE9 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE10")) DOORTILE10 = lValue; - else if (!Bstrcmp(szLabel,"DOORSHOCK")) DOORSHOCK = lValue; - else if (!Bstrcmp(szLabel,"DIPSWITCH")) DIPSWITCH = lValue; - else if (!Bstrcmp(szLabel,"DIPSWITCH2")) DIPSWITCH2 = lValue; - else if (!Bstrcmp(szLabel,"DIPSWITCH3")) DIPSWITCH3 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE22")) DOORTILE22 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE18")) DOORTILE18 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE19")) DOORTILE19 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE20")) DOORTILE20 = lValue; - else if (!Bstrcmp(szLabel,"DOMELITE")) DOMELITE = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE14")) DOORTILE14 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE16")) DOORTILE16 = lValue; - else if (!Bstrcmp(szLabel,"DONUTS")) DONUTS = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE15")) DOORTILE15 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE21")) DOORTILE21 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE17")) DOORTILE17 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE11")) DOORTILE11 = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE12")) DOORTILE12 = lValue; - else if (!Bstrcmp(szLabel,"DUKELYINGDEAD")) DUKELYINGDEAD = lValue; - else if (!Bstrcmp(szLabel,"DUKETORSO")) DUKETORSO = lValue; - else if (!Bstrcmp(szLabel,"DUKEGUN")) DUKEGUN = lValue; - else if (!Bstrcmp(szLabel,"DUKELEG")) DUKELEG = lValue; - else if (!Bstrcmp(szLabel,"DEVISTATORBLAST")) DEVISTATORBLAST = lValue; - else if (!Bstrcmp(szLabel,"DRONE")) DRONE = lValue; - else if (!Bstrcmp(szLabel,"DUKEICON")) DUKEICON = lValue; - else if (!Bstrcmp(szLabel,"DIGITALNUM")) DIGITALNUM = lValue; - else if (!Bstrcmp(szLabel,"DUKECAR")) DUKECAR = lValue; - else if (!Bstrcmp(szLabel,"DREALMS")) DREALMS = lValue; - else if (!Bstrcmp(szLabel,"DUKENUKEM")) DUKENUKEM = lValue; - else if (!Bstrcmp(szLabel,"DEVISTATOR")) DEVISTATOR = lValue; - else if (!Bstrcmp(szLabel,"DUKECUTOUT")) DUKECUTOUT = lValue; - else if (!Bstrcmp(szLabel,"DUCK")) DUCK = lValue; - else if (!Bstrcmp(szLabel,"DESKLAMP")) DESKLAMP = lValue; - else if (!Bstrcmp(szLabel,"DOORTILE23")) DOORTILE23 = lValue; - else if (!Bstrcmp(szLabel,"DONUTS2")) DONUTS2 = lValue; - else if (!Bstrcmp(szLabel,"DESKPHONE")) DESKPHONE = lValue; - else if (!Bstrcmp(szLabel,"DUKEBURGER")) DUKEBURGER = lValue; - else if (!Bstrcmp(szLabel,"DOLPHIN1")) DOLPHIN1 = lValue; - else if (!Bstrcmp(szLabel,"DOLPHIN2")) DOLPHIN2 = lValue; - else if (!Bstrcmp(szLabel,"DUKETAG")) DUKETAG = lValue; - break; - case 'E': - if (!Bstrcmp(szLabel,"EPISODE")) EPISODE = lValue; - else if (!Bstrcmp(szLabel,"EGG")) EGG = lValue; - else if (!Bstrcmp(szLabel,"EXPLODINGBARREL")) EXPLODINGBARREL = lValue; - else if (!Bstrcmp(szLabel,"EXPLODINGBARREL2")) EXPLODINGBARREL2 = lValue; - else if (!Bstrcmp(szLabel,"EXPLOSION2")) EXPLOSION2 = lValue; - else if (!Bstrcmp(szLabel,"EXPLOSION2BOT")) EXPLOSION2BOT = lValue; - else if (!Bstrcmp(szLabel,"ENDALPHANUM")) ENDALPHANUM = lValue; - break; - case 'F': - if (!Bstrcmp(szLabel,"FOF")) FOF = lValue; - else if (!Bstrcmp(szLabel,"FIRSTGUNSPRITE")) FIRSTGUNSPRITE = lValue; - else if (!Bstrcmp(szLabel,"FREEZESPRITE")) FREEZESPRITE = lValue; - else if (!Bstrcmp(szLabel,"FREEZEAMMO")) FREEZEAMMO = lValue; - else if (!Bstrcmp(szLabel,"FIRSTAID")) FIRSTAID = lValue; - else if (!Bstrcmp(szLabel,"FRANKENSTINESWITCH")) FRANKENSTINESWITCH = lValue; - else if (!Bstrcmp(szLabel,"FLOORSLIME")) FLOORSLIME = lValue; - else if (!Bstrcmp(szLabel,"FANSPRITE")) FANSPRITE = lValue; - else if (!Bstrcmp(szLabel,"FANSPRITEBROKE")) FANSPRITEBROKE = lValue; - else if (!Bstrcmp(szLabel,"FANSHADOW")) FANSHADOW = lValue; - else if (!Bstrcmp(szLabel,"FANSHADOWBROKE")) FANSHADOWBROKE = lValue; - else if (!Bstrcmp(szLabel,"FUELPOD")) FUELPOD = lValue; - else if (!Bstrcmp(szLabel,"FOOTPRINTS")) FOOTPRINTS = lValue; - else if (!Bstrcmp(szLabel,"FEMMAG1")) FEMMAG1 = lValue; - else if (!Bstrcmp(szLabel,"FEMMAG2")) FEMMAG2 = lValue; - else if (!Bstrcmp(szLabel,"FOOTPRINTS2")) FOOTPRINTS2 = lValue; - else if (!Bstrcmp(szLabel,"FOOTPRINTS3")) FOOTPRINTS3 = lValue; - else if (!Bstrcmp(szLabel,"FOOTPRINTS4")) FOOTPRINTS4 = lValue; - else if (!Bstrcmp(szLabel,"FIREEXT")) FIREEXT = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC5")) FEMPIC5 = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC6")) FEMPIC6 = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC7")) FEMPIC7 = lValue; - else if (!Bstrcmp(szLabel,"FLOORPLASMA")) FLOORPLASMA = lValue; - else if (!Bstrcmp(szLabel,"FIREBARREL")) FIREBARREL = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC1")) FEMPIC1 = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC2")) FEMPIC2 = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC3")) FEMPIC3 = lValue; - else if (!Bstrcmp(szLabel,"FEMPIC4")) FEMPIC4 = lValue; - else if (!Bstrcmp(szLabel,"FEM1")) FEM1 = lValue; - else if (!Bstrcmp(szLabel,"FEM2")) FEM2 = lValue; - else if (!Bstrcmp(szLabel,"FEM3")) FEM3 = lValue; - else if (!Bstrcmp(szLabel,"FEM5")) FEM5 = lValue; - else if (!Bstrcmp(szLabel,"FEM4")) FEM4 = lValue; - else if (!Bstrcmp(szLabel,"FEM6")) FEM6 = lValue; - else if (!Bstrcmp(szLabel,"FEM6PAD")) FEM6PAD = lValue; - else if (!Bstrcmp(szLabel,"FEM8")) FEM8 = lValue; - else if (!Bstrcmp(szLabel,"FETUSJIB")) FETUSJIB = lValue; - else if (!Bstrcmp(szLabel,"FETUS")) FETUS = lValue; - else if (!Bstrcmp(szLabel,"FETUSBROKE")) FETUSBROKE = lValue; - else if (!Bstrcmp(szLabel,"FIREVASE")) FIREVASE = lValue; - else if (!Bstrcmp(szLabel,"FEM7")) FEM7 = lValue; - else if (!Bstrcmp(szLabel,"FIRELASER")) FIRELASER = lValue; - else if (!Bstrcmp(szLabel,"FIST")) FIST = lValue; - else if (!Bstrcmp(szLabel,"FREEZEBLAST")) FREEZEBLAST = lValue; - else if (!Bstrcmp(szLabel,"FORCERIPPLE")) FORCERIPPLE = lValue; - else if (!Bstrcmp(szLabel,"FECES")) FECES = lValue; - else if (!Bstrcmp(szLabel,"FIRE")) FIRE = lValue; - else if (!Bstrcmp(szLabel,"FIRE2")) FIRE2 = lValue; - else if (!Bstrcmp(szLabel,"FLOORFLAME")) FLOORFLAME = lValue; - else if (!Bstrcmp(szLabel,"F1HELP")) F1HELP = lValue; - else if (!Bstrcmp(szLabel,"FOODICON")) FOODICON = lValue; - else if (!Bstrcmp(szLabel,"FIRSTAID_ICON")) FIRSTAID_ICON = lValue; - else if (!Bstrcmp(szLabel,"FRAGBAR")) FRAGBAR = lValue; - else if (!Bstrcmp(szLabel,"FIRSTGUN")) FIRSTGUN = lValue; - else if (!Bstrcmp(szLabel,"FIRSTGUNRELOAD")) FIRSTGUNRELOAD = lValue; - else if (!Bstrcmp(szLabel,"FALLINGCLIP")) FALLINGCLIP = lValue; - else if (!Bstrcmp(szLabel,"FREEZE")) FREEZE = lValue; - else if (!Bstrcmp(szLabel,"FORCESPHERE")) FORCESPHERE = lValue; - else if (!Bstrcmp(szLabel,"FEM9")) FEM9 = lValue; - else if (!Bstrcmp(szLabel,"FOOTPRINT")) FOOTPRINT = lValue; - else if (!Bstrcmp(szLabel,"FRAMEEFFECT1")) FRAMEEFFECT1 = lValue; - else if (!Bstrcmp(szLabel,"FRAMEEFFECT1_13")) FRAMEEFFECT1_13 = lValue; - else if (!Bstrcmp(szLabel,"FLOORBASKET")) FLOORBASKET = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT1")) FOODOBJECT1 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT2")) FOODOBJECT2 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT3")) FOODOBJECT3 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT4")) FOODOBJECT4 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT5")) FOODOBJECT5 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT6")) FOODOBJECT6 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT7")) FOODOBJECT7 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT8")) FOODOBJECT8 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT9")) FOODOBJECT9 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT10")) FOODOBJECT10 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT11")) FOODOBJECT11 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT12")) FOODOBJECT12 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT13")) FOODOBJECT13 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT14")) FOODOBJECT14 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT15")) FOODOBJECT15 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT16")) FOODOBJECT16 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT17")) FOODOBJECT17 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT18")) FOODOBJECT18 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT19")) FOODOBJECT19 = lValue; - else if (!Bstrcmp(szLabel,"FOODOBJECT20")) FOODOBJECT20 = lValue; - else if (!Bstrcmp(szLabel,"FEATHEREDCHICKEN")) FEATHEREDCHICKEN = lValue; - else if (!Bstrcmp(szLabel,"FEM10")) FEM10 = lValue; - break; - case 'G': - if (!Bstrcmp(szLabel,"GPSPEED")) GPSPEED = lValue; - else if (!Bstrcmp(szLabel,"GROWSPRITEICON")) GROWSPRITEICON = lValue; - else if (!Bstrcmp(szLabel,"GROWAMMO")) GROWAMMO = lValue; - else if (!Bstrcmp(szLabel,"GLASS")) GLASS = lValue; - else if (!Bstrcmp(szLabel,"GLASS2")) GLASS2 = lValue; - else if (!Bstrcmp(szLabel,"GRATE1")) GRATE1 = lValue; - else if (!Bstrcmp(szLabel,"GENERICPOLE")) GENERICPOLE = lValue; - else if (!Bstrcmp(szLabel,"GLASSPIECES")) GLASSPIECES = lValue; - else if (!Bstrcmp(szLabel,"GREENSLIME")) GREENSLIME = lValue; - else if (!Bstrcmp(szLabel,"GROWSPARK")) GROWSPARK = lValue; - else if (!Bstrcmp(szLabel,"GETICON")) GETICON = lValue; - else if (!Bstrcmp(szLabel,"GLAIR")) GLAIR = lValue; - else if (!Bstrcmp(szLabel,"GLASS3")) GLASS3 = lValue; - else if (!Bstrcmp(szLabel,"GUNPOWDERBARREL")) GUNPOWDERBARREL = lValue; - else if (!Bstrcmp(szLabel,"GAVALS")) GAVALS = lValue; - else if (!Bstrcmp(szLabel,"GAVALS2")) GAVALS2 = lValue; - else if (!Bstrcmp(szLabel,"GUMBALLMACHINE")) GUMBALLMACHINE = lValue; - else if (!Bstrcmp(szLabel,"GUMBALLMACHINEBROKE")) GUMBALLMACHINEBROKE = lValue; - else if (!Bstrcmp(szLabel,"GENERICPOLE2")) GENERICPOLE2 = lValue; - break; - case 'H': - if (!Bstrcmp(szLabel,"HEAVYHBOMB")) HEAVYHBOMB = lValue; - else if (!Bstrcmp(szLabel,"HEALTHBOX")) HEALTHBOX = lValue; - else if (!Bstrcmp(szLabel,"HBOMBAMMO")) HBOMBAMMO = lValue; - else if (!Bstrcmp(szLabel,"HEATSENSOR")) HEATSENSOR = lValue; - else if (!Bstrcmp(szLabel,"HURTRAIL")) HURTRAIL = lValue; - else if (!Bstrcmp(szLabel,"HYDROPLANT")) HYDROPLANT = lValue; - else if (!Bstrcmp(szLabel,"HANGLIGHT")) HANGLIGHT = lValue; - else if (!Bstrcmp(szLabel,"HYDRENT")) HYDRENT = lValue; - else if (!Bstrcmp(szLabel,"HANGOOZ")) HANGOOZ = lValue; - else if (!Bstrcmp(szLabel,"HORSEONSIDE")) HORSEONSIDE = lValue; - else if (!Bstrcmp(szLabel,"HORSELITE")) HORSELITE = lValue; - else if (!Bstrcmp(szLabel,"HANDSWITCH")) HANDSWITCH = lValue; - else if (!Bstrcmp(szLabel,"HANDPRINTSWITCH")) HANDPRINTSWITCH = lValue; - else if (!Bstrcmp(szLabel,"HELECOPT")) HELECOPT = lValue; - else if (!Bstrcmp(szLabel,"HOLODUKE")) HOLODUKE = lValue; - else if (!Bstrcmp(szLabel,"HEADJIB1")) HEADJIB1 = lValue; - else if (!Bstrcmp(szLabel,"HEADERBAR")) HEADERBAR = lValue; - else if (!Bstrcmp(szLabel,"HEAT_ICON")) HEAT_ICON = lValue; - else if (!Bstrcmp(szLabel,"HOLODUKE_ICON")) HOLODUKE_ICON = lValue; - else if (!Bstrcmp(szLabel,"HAND")) HAND = lValue; - else if (!Bstrcmp(szLabel,"HANDHOLDINGLASER")) HANDHOLDINGLASER = lValue; - else if (!Bstrcmp(szLabel,"HANDHOLDINGACCESS")) HANDHOLDINGACCESS = lValue; - else if (!Bstrcmp(szLabel,"HANDREMOTE")) HANDREMOTE = lValue; - else if (!Bstrcmp(szLabel,"HANDTHROW")) HANDTHROW = lValue; - else if (!Bstrcmp(szLabel,"HATRACK")) HATRACK = lValue; - else if (!Bstrcmp(szLabel,"HOTMEAT")) HOTMEAT = lValue; - else if (!Bstrcmp(szLabel,"HEADLAMP")) HEADLAMP = lValue; - break; - case 'I': - if (!Bstrcmp(szLabel,"INVENTORYBOX")) INVENTORYBOX = lValue; - else if (!Bstrcmp(szLabel,"IVUNIT")) IVUNIT = lValue; - else if (!Bstrcmp(szLabel,"INDY")) INDY = lValue; - else if (!Bstrcmp(szLabel,"INNERJAW")) INNERJAW = lValue; - else if (!Bstrcmp(szLabel,"INGAMEDUKETHREEDEE")) INGAMEDUKETHREEDEE = lValue; - break; - case 'J': - if (!Bstrcmp(szLabel,"JETPACK")) JETPACK = lValue; - else if (!Bstrcmp(szLabel,"JAILBARBREAK")) JAILBARBREAK = lValue; - else if (!Bstrcmp(szLabel,"JIBS1")) JIBS1 = lValue; - else if (!Bstrcmp(szLabel,"JIBS2")) JIBS2 = lValue; - else if (!Bstrcmp(szLabel,"JIBS3")) JIBS3 = lValue; - else if (!Bstrcmp(szLabel,"JIBS4")) JIBS4 = lValue; - else if (!Bstrcmp(szLabel,"JIBS5")) JIBS5 = lValue; - else if (!Bstrcmp(szLabel,"JIBS6")) JIBS6 = lValue; - else if (!Bstrcmp(szLabel,"JETPACK_ICON")) JETPACK_ICON = lValue; - else if (!Bstrcmp(szLabel,"JOLLYMEAL")) JOLLYMEAL = lValue; - else if (!Bstrcmp(szLabel,"JURYGUY")) JURYGUY = lValue; - break; - case 'K': - if (!Bstrcmp(szLabel,"KILLSICON")) KILLSICON = lValue; - else if (!Bstrcmp(szLabel,"KNEE")) KNEE = lValue; - break; - case 'L': - if (!Bstrcmp(szLabel,"LOCATORS")) LOCATORS = lValue; - else if (!Bstrcmp(szLabel,"LA")) LA = lValue; - else if (!Bstrcmp(szLabel,"LIGHTSWITCH")) LIGHTSWITCH = lValue; - else if (!Bstrcmp(szLabel,"LIGHTSWITCH2")) LIGHTSWITCH2 = lValue; - else if (!Bstrcmp(szLabel,"LOCKSWITCH1")) LOCKSWITCH1 = lValue; - else if (!Bstrcmp(szLabel,"LUKE")) LUKE = lValue; - else if (!Bstrcmp(szLabel,"LOOGIE")) LOOGIE = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOP")) LIZTROOP = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPRUNNING")) LIZTROOPRUNNING = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPSTAYPUT")) LIZTROOPSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"LIZTOP")) LIZTOP = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPSHOOT")) LIZTROOPSHOOT = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPJETPACK")) LIZTROOPJETPACK = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPDSPRITE")) LIZTROOPDSPRITE = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPONTOILET")) LIZTROOPONTOILET = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPJUSTSIT")) LIZTROOPJUSTSIT = lValue; - else if (!Bstrcmp(szLabel,"LIZTROOPDUCKING")) LIZTROOPDUCKING = lValue; - else if (!Bstrcmp(szLabel,"LEGJIB1")) LEGJIB1 = lValue; - else if (!Bstrcmp(szLabel,"LIZMAN")) LIZMAN = lValue; - else if (!Bstrcmp(szLabel,"LIZMANSTAYPUT")) LIZMANSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"LIZMANSPITTING")) LIZMANSPITTING = lValue; - else if (!Bstrcmp(szLabel,"LIZMANFEEDING")) LIZMANFEEDING = lValue; - else if (!Bstrcmp(szLabel,"LIZMANJUMP")) LIZMANJUMP = lValue; - else if (!Bstrcmp(szLabel,"LIZMANDEADSPRITE")) LIZMANDEADSPRITE = lValue; - else if (!Bstrcmp(szLabel,"LIZMANHEAD1")) LIZMANHEAD1 = lValue; - else if (!Bstrcmp(szLabel,"LIZMANARM1")) LIZMANARM1 = lValue; - else if (!Bstrcmp(szLabel,"LIZMANLEG1")) LIZMANLEG1 = lValue; - else if (!Bstrcmp(szLabel,"LOGO")) LOGO = lValue; - else if (!Bstrcmp(szLabel,"LASERLINE")) LASERLINE = lValue; - else if (!Bstrcmp(szLabel,"LASERSITE")) LASERSITE = lValue; - else if (!Bstrcmp(szLabel,"LOADSCREEN")) LOADSCREEN = lValue; - else if (!Bstrcmp(szLabel,"LAVABUBBLE")) LAVABUBBLE = lValue; - else if (!Bstrcmp(szLabel,"LETTER")) LETTER = lValue; - break; - case 'M': - if (!Bstrcmp(szLabel,"MUSICANDSFX")) MUSICANDSFX = lValue; - else if (!Bstrcmp(szLabel,"MASTERSWITCH")) MASTERSWITCH = lValue; - else if (!Bstrcmp(szLabel,"MIRRORBROKE")) MIRRORBROKE = lValue; - else if (!Bstrcmp(szLabel,"MOONSKY1")) MOONSKY1 = lValue; - else if (!Bstrcmp(szLabel,"MOONSKY2")) MOONSKY2 = lValue; - else if (!Bstrcmp(szLabel,"MOONSKY3")) MOONSKY3 = lValue; - else if (!Bstrcmp(szLabel,"MOONSKY4")) MOONSKY4 = lValue; - else if (!Bstrcmp(szLabel,"MULTISWITCH")) MULTISWITCH = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL9")) MASKWALL9 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL1")) MASKWALL1 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL10")) MASKWALL10 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL11")) MASKWALL11 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL5")) MASKWALL5 = lValue; - else if (!Bstrcmp(szLabel,"MIRROR")) MIRROR = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL12")) MASKWALL12 = lValue; - else if (!Bstrcmp(szLabel,"MOVIECAMERA")) MOVIECAMERA = lValue; - else if (!Bstrcmp(szLabel,"MIKE")) MIKE = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL13")) MASKWALL13 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL2")) MASKWALL2 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL3")) MASKWALL3 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL4")) MASKWALL4 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL14")) MASKWALL14 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL15")) MASKWALL15 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL6")) MASKWALL6 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL8")) MASKWALL8 = lValue; - else if (!Bstrcmp(szLabel,"MASKWALL7")) MASKWALL7 = lValue; - else if (!Bstrcmp(szLabel,"MONEY")) MONEY = lValue; - else if (!Bstrcmp(szLabel,"MONK")) MONK = lValue; - else if (!Bstrcmp(szLabel,"MORTER")) MORTER = lValue; - else if (!Bstrcmp(szLabel,"MENUSCREEN")) MENUSCREEN = lValue; - else if (!Bstrcmp(szLabel,"MENUBAR")) MENUBAR = lValue; - else if (!Bstrcmp(szLabel,"MOUSECURSOR")) MOUSECURSOR = lValue; - else if (!Bstrcmp(szLabel,"MINIFONT")) MINIFONT = lValue; - else if (!Bstrcmp(szLabel,"MAIL")) MAIL = lValue; - else if (!Bstrcmp(szLabel,"MAILBAG")) MAILBAG = lValue; - else if (!Bstrcmp(szLabel,"METER")) METER = lValue; - else if (!Bstrcmp(szLabel,"MACE")) MACE = lValue; - else if (!Bstrcmp(szLabel,"MOP")) MOP = lValue; - else if (!Bstrcmp(szLabel,"MAN")) MAN = lValue; - else if (!Bstrcmp(szLabel,"MAN2")) MAN2 = lValue; - break; - case 'N': - if (!Bstrcmp(szLabel,"NUKEBUTTON")) NUKEBUTTON = lValue; - else if (!Bstrcmp(szLabel,"NAKED1")) NAKED1 = lValue; - else if (!Bstrcmp(szLabel,"NEON1")) NEON1 = lValue; - else if (!Bstrcmp(szLabel,"NEON2")) NEON2 = lValue; - else if (!Bstrcmp(szLabel,"NEON3")) NEON3 = lValue; - else if (!Bstrcmp(szLabel,"NEON4")) NEON4 = lValue; - else if (!Bstrcmp(szLabel,"NEON5")) NEON5 = lValue; - else if (!Bstrcmp(szLabel,"NEON6")) NEON6 = lValue; - else if (!Bstrcmp(szLabel,"NUKEBARREL")) NUKEBARREL = lValue; - else if (!Bstrcmp(szLabel,"NUKEBARRELDENTED")) NUKEBARRELDENTED = lValue; - else if (!Bstrcmp(szLabel,"NUKEBARRELLEAKED")) NUKEBARRELLEAKED = lValue; - else if (!Bstrcmp(szLabel,"NOTCHON")) NOTCHON = lValue; - else if (!Bstrcmp(szLabel,"NOTCHOFF")) NOTCHOFF = lValue; - else if (!Bstrcmp(szLabel,"NUKEWARNINGICON")) NUKEWARNINGICON = lValue; - else if (!Bstrcmp(szLabel,"NEWBEAST")) NEWBEAST = lValue; - else if (!Bstrcmp(szLabel,"NEWBEASTSTAYPUT")) NEWBEASTSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"NEWBEASTJUMP")) NEWBEASTJUMP = lValue; - else if (!Bstrcmp(szLabel,"NEWBEASTHANG")) NEWBEASTHANG = lValue; - else if (!Bstrcmp(szLabel,"NEWBEASTHANGDEAD")) NEWBEASTHANGDEAD = lValue; - else if (!Bstrcmp(szLabel,"NATURALLIGHTNING")) NATURALLIGHTNING = lValue; - break; - case 'O': - if (!Bstrcmp(szLabel,"OJ")) OJ = lValue; - else if (!Bstrcmp(szLabel,"OCEANSPRITE1")) OCEANSPRITE1 = lValue; - else if (!Bstrcmp(szLabel,"OCEANSPRITE2")) OCEANSPRITE2 = lValue; - else if (!Bstrcmp(szLabel,"OCEANSPRITE3")) OCEANSPRITE3 = lValue; - else if (!Bstrcmp(szLabel,"OCEANSPRITE4")) OCEANSPRITE4 = lValue; - else if (!Bstrcmp(szLabel,"OCEANSPRITE5")) OCEANSPRITE5 = lValue; - else if (!Bstrcmp(szLabel,"OOZFILTER")) OOZFILTER = lValue; - else if (!Bstrcmp(szLabel,"OCTABRAIN")) OCTABRAIN = lValue; - else if (!Bstrcmp(szLabel,"OCTABRAINSTAYPUT")) OCTABRAINSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"OCTATOP")) OCTATOP = lValue; - else if (!Bstrcmp(szLabel,"OCTADEADSPRITE")) OCTADEADSPRITE = lValue; - else if (!Bstrcmp(szLabel,"OOZ")) OOZ = lValue; - else if (!Bstrcmp(szLabel,"OOZ2")) OOZ2 = lValue; - else if (!Bstrcmp(szLabel,"ORGANTIC")) ORGANTIC = lValue; - else if (!Bstrcmp(szLabel,"ORDERING")) ORDERING = lValue; - break; - case 'P': - if (!Bstrcmp(szLabel,"PANNEL1")) PANNEL1 = lValue; - else if (!Bstrcmp(szLabel,"PANNEL2")) PANNEL2 = lValue; - else if (!Bstrcmp(szLabel,"PIPE2")) PIPE2 = lValue; - else if (!Bstrcmp(szLabel,"PIPE1B")) PIPE1B = lValue; - else if (!Bstrcmp(szLabel,"PIPE3")) PIPE3 = lValue; - else if (!Bstrcmp(szLabel,"PIPE1")) PIPE1 = lValue; - else if (!Bstrcmp(szLabel,"PIPE2B")) PIPE2B = lValue; - else if (!Bstrcmp(szLabel,"POT1")) POT1 = lValue; - else if (!Bstrcmp(szLabel,"POT2")) POT2 = lValue; - else if (!Bstrcmp(szLabel,"POT3")) POT3 = lValue; - else if (!Bstrcmp(szLabel,"PIPE3B")) PIPE3B = lValue; - else if (!Bstrcmp(szLabel,"POWERSWITCH1")) POWERSWITCH1 = lValue; - else if (!Bstrcmp(szLabel,"POWERSWITCH2")) POWERSWITCH2 = lValue; - else if (!Bstrcmp(szLabel,"POCKET")) POCKET = lValue; - else if (!Bstrcmp(szLabel,"PIPE5")) PIPE5 = lValue; - else if (!Bstrcmp(szLabel,"PIPE6")) PIPE6 = lValue; - else if (!Bstrcmp(szLabel,"PIPE4")) PIPE4 = lValue; - else if (!Bstrcmp(szLabel,"PIPE4B")) PIPE4B = lValue; - else if (!Bstrcmp(szLabel,"PIPE5B")) PIPE5B = lValue; - else if (!Bstrcmp(szLabel,"PLUG")) PLUG = lValue; - else if (!Bstrcmp(szLabel,"PULLSWITCH")) PULLSWITCH = lValue; - else if (!Bstrcmp(szLabel,"PIPE6B")) PIPE6B = lValue; - else if (!Bstrcmp(szLabel,"PODFEM1")) PODFEM1 = lValue; - else if (!Bstrcmp(szLabel,"PLAYERONWATER")) PLAYERONWATER = lValue; - else if (!Bstrcmp(szLabel,"PIGCOP")) PIGCOP = lValue; - else if (!Bstrcmp(szLabel,"PIGCOPSTAYPUT")) PIGCOPSTAYPUT = lValue; - else if (!Bstrcmp(szLabel,"PIGCOPDIVE")) PIGCOPDIVE = lValue; - else if (!Bstrcmp(szLabel,"PIGCOPDEADSPRITE")) PIGCOPDEADSPRITE = lValue; - else if (!Bstrcmp(szLabel,"PIGTOP")) PIGTOP = lValue; - else if (!Bstrcmp(szLabel,"PLAYERISHERE")) PLAYERISHERE = lValue; - else if (!Bstrcmp(szLabel,"PLAYERWASHERE")) PLAYERWASHERE = lValue; - else if (!Bstrcmp(szLabel,"PLUTOPAKSPRITE")) PLUTOPAKSPRITE = lValue; - else if (!Bstrcmp(szLabel,"POOP")) POOP = lValue; - else if (!Bstrcmp(szLabel,"PANNEL3")) PANNEL3 = lValue; - else if (!Bstrcmp(szLabel,"PURPLELAVA")) PURPLELAVA = lValue; - else if (!Bstrcmp(szLabel,"POLICELIGHTPOLE")) POLICELIGHTPOLE = lValue; - else if (!Bstrcmp(szLabel,"PUKE")) PUKE = lValue; - else if (!Bstrcmp(szLabel,"PAPER")) PAPER = lValue; - else if (!Bstrcmp(szLabel,"PIRATE1A")) PIRATE1A = lValue; - else if (!Bstrcmp(szLabel,"PIRATE4A")) PIRATE4A = lValue; - else if (!Bstrcmp(szLabel,"PIRATE2A")) PIRATE2A = lValue; - else if (!Bstrcmp(szLabel,"PIRATE5A")) PIRATE5A = lValue; - else if (!Bstrcmp(szLabel,"PIRATE3A")) PIRATE3A = lValue; - else if (!Bstrcmp(szLabel,"PIRATE6A")) PIRATE6A = lValue; - else if (!Bstrcmp(szLabel,"PIRATEHALF")) PIRATEHALF = lValue; - else if (!Bstrcmp(szLabel,"PLEASEWAIT")) PLEASEWAIT = lValue; - break; - case 'Q': - if (!Bstrcmp(szLabel,"QUEBALL")) QUEBALL = lValue; - break; - case 'R': - if (!Bstrcmp(szLabel,"RESPAWN")) RESPAWN = lValue; - else if (!Bstrcmp(szLabel,"RPGSPRITE")) RPGSPRITE = lValue; - else if (!Bstrcmp(szLabel,"RPGAMMO")) RPGAMMO = lValue; - else if (!Bstrcmp(szLabel,"REDSKY1")) REDSKY1 = lValue; - else if (!Bstrcmp(szLabel,"REDSKY2")) REDSKY2 = lValue; - else if (!Bstrcmp(szLabel,"REFLECTWATERTILE")) REFLECTWATERTILE = lValue; - else if (!Bstrcmp(szLabel,"REACTOR2")) REACTOR2 = lValue; - else if (!Bstrcmp(szLabel,"REACTOR2BURNT")) REACTOR2BURNT = lValue; - else if (!Bstrcmp(szLabel,"REACTOR2SPARK")) REACTOR2SPARK = lValue; - else if (!Bstrcmp(szLabel,"RUBBERCAN")) RUBBERCAN = lValue; - else if (!Bstrcmp(szLabel,"REACTOR")) REACTOR = lValue; - else if (!Bstrcmp(szLabel,"REACTORSPARK")) REACTORSPARK = lValue; - else if (!Bstrcmp(szLabel,"REACTORBURNT")) REACTORBURNT = lValue; - else if (!Bstrcmp(szLabel,"RAT")) RAT = lValue; - else if (!Bstrcmp(szLabel,"RADIUSEXPLOSION")) RADIUSEXPLOSION = lValue; - else if (!Bstrcmp(szLabel,"RECON")) RECON = lValue; - else if (!Bstrcmp(szLabel,"ROTATEGUN")) ROTATEGUN = lValue; - else if (!Bstrcmp(szLabel,"RPGGUN")) RPGGUN = lValue; - else if (!Bstrcmp(szLabel,"RPGMUZZLEFLASH")) RPGMUZZLEFLASH = lValue; - else if (!Bstrcmp(szLabel,"RPG")) RPG = lValue; - else if (!Bstrcmp(szLabel,"RESPAWNMARKERRED")) RESPAWNMARKERRED = lValue; - else if (!Bstrcmp(szLabel,"RESPAWNMARKERYELLOW")) RESPAWNMARKERYELLOW = lValue; - else if (!Bstrcmp(szLabel,"RESPAWNMARKERGREEN")) RESPAWNMARKERGREEN = lValue; - else if (!Bstrcmp(szLabel,"ROBOTDOG")) ROBOTDOG = lValue; - else if (!Bstrcmp(szLabel,"ROBOTPIRATE")) ROBOTPIRATE = lValue; - else if (!Bstrcmp(szLabel,"ROBOTMOUSE")) ROBOTMOUSE = lValue; - else if (!Bstrcmp(szLabel,"ROBOTDOG2")) ROBOTDOG2 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT1")) RESERVEDSLOT1 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT2")) RESERVEDSLOT2 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT3")) RESERVEDSLOT3 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT4")) RESERVEDSLOT4 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT5")) RESERVEDSLOT5 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT6")) RESERVEDSLOT6 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT7")) RESERVEDSLOT7 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT8")) RESERVEDSLOT8 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT9")) RESERVEDSLOT9 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT10")) RESERVEDSLOT10 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT11")) RESERVEDSLOT11 = lValue; - else if (!Bstrcmp(szLabel,"RESERVEDSLOT12")) RESERVEDSLOT12 = lValue; - break; - case 'S': - if (!Bstrcmp(szLabel,"SECTOREFFECTOR")) SECTOREFFECTOR = lValue; - else if (!Bstrcmp(szLabel,"SHRINKERSPRITE")) SHRINKERSPRITE = lValue; - else if (!Bstrcmp(szLabel,"SHOTGUNSPRITE")) SHOTGUNSPRITE = lValue; - else if (!Bstrcmp(szLabel,"SHOTGUNAMMO")) SHOTGUNAMMO = lValue; - else if (!Bstrcmp(szLabel,"SIXPAK")) SIXPAK = lValue; - else if (!Bstrcmp(szLabel,"SHIELD")) SHIELD = lValue; - else if (!Bstrcmp(szLabel,"STEROIDS")) STEROIDS = lValue; - else if (!Bstrcmp(szLabel,"SLOTDOOR")) SLOTDOOR = lValue; - else if (!Bstrcmp(szLabel,"SPACEDOORSWITCH")) SPACEDOORSWITCH = lValue; - else if (!Bstrcmp(szLabel,"SPACELIGHTSWITCH")) SPACELIGHTSWITCH = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK1")) SCREENBREAK1 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK2")) SCREENBREAK2 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK3")) SCREENBREAK3 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK4")) SCREENBREAK4 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK5")) SCREENBREAK5 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK6")) SCREENBREAK6 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK7")) SCREENBREAK7 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK8")) SCREENBREAK8 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK9")) SCREENBREAK9 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK10")) SCREENBREAK10 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK11")) SCREENBREAK11 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK12")) SCREENBREAK12 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK13")) SCREENBREAK13 = lValue; - else if (!Bstrcmp(szLabel,"STATIC")) STATIC = lValue; - else if (!Bstrcmp(szLabel,"SATELLITE")) SATELLITE = lValue; - else if (!Bstrcmp(szLabel,"STAINGLASS1")) STAINGLASS1 = lValue; - else if (!Bstrcmp(szLabel,"SATELITE")) SATELITE = lValue; - else if (!Bstrcmp(szLabel,"SLIMEPIPE")) SLIMEPIPE = lValue; - else if (!Bstrcmp(szLabel,"STALL")) STALL = lValue; - else if (!Bstrcmp(szLabel,"STALLBROKE")) STALLBROKE = lValue; - else if (!Bstrcmp(szLabel,"SOLARPANNEL")) SOLARPANNEL = lValue; - else if (!Bstrcmp(szLabel,"SPLINTERWOOD")) SPLINTERWOOD = lValue; - else if (!Bstrcmp(szLabel,"SCALE")) SCALE = lValue; - else if (!Bstrcmp(szLabel,"STATUE")) STATUE = lValue; - else if (!Bstrcmp(szLabel,"SUSHIPLATE1")) SUSHIPLATE1 = lValue; - else if (!Bstrcmp(szLabel,"SUSHIPLATE2")) SUSHIPLATE2 = lValue; - else if (!Bstrcmp(szLabel,"SUSHIPLATE3")) SUSHIPLATE3 = lValue; - else if (!Bstrcmp(szLabel,"SUSHIPLATE4")) SUSHIPLATE4 = lValue; - else if (!Bstrcmp(szLabel,"SUSHIPLATE5")) SUSHIPLATE5 = lValue; - else if (!Bstrcmp(szLabel,"STATUEFLASH")) STATUEFLASH = lValue; - else if (!Bstrcmp(szLabel,"STRIPEBALL")) STRIPEBALL = lValue; - else if (!Bstrcmp(szLabel,"SPOTLITE")) SPOTLITE = lValue; - else if (!Bstrcmp(szLabel,"SEENINE")) SEENINE = lValue; - else if (!Bstrcmp(szLabel,"SEENINEDEAD")) SEENINEDEAD = lValue; - else if (!Bstrcmp(szLabel,"STEAM")) STEAM = lValue; - else if (!Bstrcmp(szLabel,"SPACEMARINE")) SPACEMARINE = lValue; - else if (!Bstrcmp(szLabel,"SCRATCH")) SCRATCH = lValue; - else if (!Bstrcmp(szLabel,"SHARK")) SHARK = lValue; - else if (!Bstrcmp(szLabel,"SPIT")) SPIT = lValue; - else if (!Bstrcmp(szLabel,"SHRINKSPARK")) SHRINKSPARK = lValue; - else if (!Bstrcmp(szLabel,"SHRINKEREXPLOSION")) SHRINKEREXPLOSION = lValue; - else if (!Bstrcmp(szLabel,"SMALLSMOKE")) SMALLSMOKE = lValue; - else if (!Bstrcmp(szLabel,"SMALLSMOKEMAKER")) SMALLSMOKEMAKER = lValue; - else if (!Bstrcmp(szLabel,"SCRAP6")) SCRAP6 = lValue; - else if (!Bstrcmp(szLabel,"SCRAP1")) SCRAP1 = lValue; - else if (!Bstrcmp(szLabel,"SCRAP2")) SCRAP2 = lValue; - else if (!Bstrcmp(szLabel,"SCRAP3")) SCRAP3 = lValue; - else if (!Bstrcmp(szLabel,"SCRAP4")) SCRAP4 = lValue; - else if (!Bstrcmp(szLabel,"SCRAP5")) SCRAP5 = lValue; - else if (!Bstrcmp(szLabel,"SELECTDIR")) SELECTDIR = lValue; - else if (!Bstrcmp(szLabel,"STEROIDS_ICON")) STEROIDS_ICON = lValue; - else if (!Bstrcmp(szLabel,"SLIDEBAR")) SLIDEBAR = lValue; - else if (!Bstrcmp(szLabel,"SHELL")) SHELL = lValue; - else if (!Bstrcmp(szLabel,"SHOTGUNSHELL")) SHOTGUNSHELL = lValue; - else if (!Bstrcmp(szLabel,"SHRINKER")) SHRINKER = lValue; - else if (!Bstrcmp(szLabel,"SCUBAMASK")) SCUBAMASK = lValue; - else if (!Bstrcmp(szLabel,"SPACEMASK")) SPACEMASK = lValue; - else if (!Bstrcmp(szLabel,"SHOTSPARK1")) SHOTSPARK1 = lValue; - else if (!Bstrcmp(szLabel,"SHOTGUN")) SHOTGUN = lValue; - else if (!Bstrcmp(szLabel,"SPINNINGNUKEICON")) SPINNINGNUKEICON = lValue; - else if (!Bstrcmp(szLabel,"SMALLFNTCURSOR")) SMALLFNTCURSOR = lValue; - else if (!Bstrcmp(szLabel,"STARTALPHANUM")) STARTALPHANUM = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK14")) SCREENBREAK14 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK15")) SCREENBREAK15 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK19")) SCREENBREAK19 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK16")) SCREENBREAK16 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK17")) SCREENBREAK17 = lValue; - else if (!Bstrcmp(szLabel,"SCREENBREAK18")) SCREENBREAK18 = lValue; - else if (!Bstrcmp(szLabel,"SPEAKER")) SPEAKER = lValue; - else if (!Bstrcmp(szLabel,"SIDEBOLT1")) SIDEBOLT1 = lValue; - else if (!Bstrcmp(szLabel,"SKINNEDCHICKEN")) SKINNEDCHICKEN = lValue; - else if (!Bstrcmp(szLabel,"SHOPPINGCART")) SHOPPINGCART = lValue; - else if (!Bstrcmp(szLabel,"SNAKEP")) SNAKEP = lValue; - else if (!Bstrcmp(szLabel,"SIGN1")) SIGN1 = lValue; - else if (!Bstrcmp(szLabel,"SIGN2")) SIGN2 = lValue; - break; - case 'T': - if (!Bstrcmp(szLabel,"TOUCHPLATE")) TOUCHPLATE = lValue; - else if (!Bstrcmp(szLabel,"TRIPBOMBSPRITE")) TRIPBOMBSPRITE = lValue; - else if (!Bstrcmp(szLabel,"TECHLIGHT2")) TECHLIGHT2 = lValue; - else if (!Bstrcmp(szLabel,"TECHLIGHTBUST2")) TECHLIGHTBUST2 = lValue; - else if (!Bstrcmp(szLabel,"TECHLIGHT4")) TECHLIGHT4 = lValue; - else if (!Bstrcmp(szLabel,"TECHLIGHTBUST4")) TECHLIGHTBUST4 = lValue; - else if (!Bstrcmp(szLabel,"TECHSWITCH")) TECHSWITCH = lValue; - else if (!Bstrcmp(szLabel,"TOILET")) TOILET = lValue; - else if (!Bstrcmp(szLabel,"TOILETBROKE")) TOILETBROKE = lValue; - else if (!Bstrcmp(szLabel,"TREE1")) TREE1 = lValue; - else if (!Bstrcmp(szLabel,"TREE2")) TREE2 = lValue; - else if (!Bstrcmp(szLabel,"TOILETWATER")) TOILETWATER = lValue; - else if (!Bstrcmp(szLabel,"TIRE")) TIRE = lValue; - else if (!Bstrcmp(szLabel,"TRANSPORTERBEAM")) TRANSPORTERBEAM = lValue; - else if (!Bstrcmp(szLabel,"TRASH")) TRASH = lValue; - else if (!Bstrcmp(szLabel,"TRANSPORTERSTAR")) TRANSPORTERSTAR = lValue; - else if (!Bstrcmp(szLabel,"TONGUE")) TONGUE = lValue; - else if (!Bstrcmp(szLabel,"TANK")) TANK = lValue; - else if (!Bstrcmp(szLabel,"TITLE")) TITLE = lValue; - else if (!Bstrcmp(szLabel,"TEXTBOX")) TEXTBOX = lValue; - else if (!Bstrcmp(szLabel,"THREEDEE")) THREEDEE = lValue; - else if (!Bstrcmp(szLabel,"TENSCREEN")) TENSCREEN = lValue; - else if (!Bstrcmp(szLabel,"TRIPBOMB")) TRIPBOMB = lValue; - else if (!Bstrcmp(szLabel,"TIP")) TIP = lValue; - else if (!Bstrcmp(szLabel,"THREEBYFIVE")) THREEBYFIVE = lValue; - else if (!Bstrcmp(szLabel,"TEXTSTORY")) TEXTSTORY = lValue; - else if (!Bstrcmp(szLabel,"TARGET")) TARGET = lValue; - else if (!Bstrcmp(szLabel,"TOPSECRET")) TOPSECRET = lValue; - else if (!Bstrcmp(szLabel,"TEDDYBEAR")) TEDDYBEAR = lValue; - else if (!Bstrcmp(szLabel,"TRIPODCAMERA")) TRIPODCAMERA = lValue; - else if (!Bstrcmp(szLabel,"TAMPON")) TAMPON = lValue; - else if (!Bstrcmp(szLabel,"TOUGHGAL")) TOUGHGAL = lValue; - break; - case 'U': - if (!Bstrcmp(szLabel,"USERWEAPON")) USERWEAPON = lValue; - break; - case 'V': - if (!Bstrcmp(szLabel,"VIEWSCREEN2")) VIEWSCREEN2 = lValue; - else if (!Bstrcmp(szLabel,"VIEWSCREENBROKE")) VIEWSCREENBROKE = lValue; - else if (!Bstrcmp(szLabel,"VIEWSCREEN")) VIEWSCREEN = lValue; - else if (!Bstrcmp(szLabel,"VACUUM")) VACUUM = lValue; - else if (!Bstrcmp(szLabel,"VASE")) VASE = lValue; - else if (!Bstrcmp(szLabel,"VENDMACHINE")) VENDMACHINE = lValue; - else if (!Bstrcmp(szLabel,"VENDMACHINEBROKE")) VENDMACHINEBROKE = lValue; - else if (!Bstrcmp(szLabel,"VIEWBORDER")) VIEWBORDER = lValue; - else if (!Bstrcmp(szLabel,"VICTORY1")) VICTORY1 = lValue; - break; - case 'W': - if (!Bstrcmp(szLabel,"WALLLIGHT4")) WALLLIGHT4 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHTBUST4")) WALLLIGHTBUST4 = lValue; - else if (!Bstrcmp(szLabel,"W_LIGHT")) W_LIGHT = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL1")) W_TECHWALL1 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL2")) W_TECHWALL2 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL15")) W_TECHWALL15 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL3")) W_TECHWALL3 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL4")) W_TECHWALL4 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL10")) W_TECHWALL10 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL16")) W_TECHWALL16 = lValue; - else if (!Bstrcmp(szLabel,"WATERTILE2")) WATERTILE2 = lValue; - else if (!Bstrcmp(szLabel,"WATERTILE")) WATERTILE = lValue; - else if (!Bstrcmp(szLabel,"W_SCREENBREAK")) W_SCREENBREAK = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL3")) W_HITTECHWALL3 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL4")) W_HITTECHWALL4 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL2")) W_HITTECHWALL2 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL1")) W_HITTECHWALL1 = lValue; - else if (!Bstrcmp(szLabel,"WATERFOUNTAIN")) WATERFOUNTAIN = lValue; - else if (!Bstrcmp(szLabel,"WATERFOUNTAINBROKE")) WATERFOUNTAINBROKE = lValue; - else if (!Bstrcmp(szLabel,"W_NUMBERS")) W_NUMBERS = lValue; - else if (!Bstrcmp(szLabel,"WATERDRIP")) WATERDRIP = lValue; - else if (!Bstrcmp(szLabel,"WATERBUBBLE")) WATERBUBBLE = lValue; - else if (!Bstrcmp(szLabel,"WATERBUBBLEMAKER")) WATERBUBBLEMAKER = lValue; - else if (!Bstrcmp(szLabel,"W_FORCEFIELD")) W_FORCEFIELD = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHT3")) WALLLIGHT3 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHTBUST3")) WALLLIGHTBUST3 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHT1")) WALLLIGHT1 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHTBUST1")) WALLLIGHTBUST1 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHT2")) WALLLIGHT2 = lValue; - else if (!Bstrcmp(szLabel,"WALLLIGHTBUST2")) WALLLIGHTBUST2 = lValue; - else if (!Bstrcmp(szLabel,"WAITTOBESEATED")) WAITTOBESEATED = lValue; - else if (!Bstrcmp(szLabel,"WOODENHORSE")) WOODENHORSE = lValue; - else if (!Bstrcmp(szLabel,"WATERSPLASH2")) WATERSPLASH2 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD1")) WALLBLOOD1 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD2")) WALLBLOOD2 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD3")) WALLBLOOD3 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD4")) WALLBLOOD4 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD5")) WALLBLOOD5 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD6")) WALLBLOOD6 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD7")) WALLBLOOD7 = lValue; - else if (!Bstrcmp(szLabel,"WALLBLOOD8")) WALLBLOOD8 = lValue; - else if (!Bstrcmp(szLabel,"WATERDRIPSPLASH")) WATERDRIPSPLASH = lValue; - else if (!Bstrcmp(szLabel,"WINDOWBORDER1")) WINDOWBORDER1 = lValue; - else if (!Bstrcmp(szLabel,"WINDOWBORDER2")) WINDOWBORDER2 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL11")) W_TECHWALL11 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL12")) W_TECHWALL12 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL13")) W_TECHWALL13 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL14")) W_TECHWALL14 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL5")) W_TECHWALL5 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL6")) W_TECHWALL6 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL7")) W_TECHWALL7 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL8")) W_TECHWALL8 = lValue; - else if (!Bstrcmp(szLabel,"W_TECHWALL9")) W_TECHWALL9 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL16")) W_HITTECHWALL16 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL10")) W_HITTECHWALL10 = lValue; - else if (!Bstrcmp(szLabel,"W_HITTECHWALL15")) W_HITTECHWALL15 = lValue; - else if (!Bstrcmp(szLabel,"W_MILKSHELF")) W_MILKSHELF = lValue; - else if (!Bstrcmp(szLabel,"W_MILKSHELFBROKE")) W_MILKSHELFBROKE = lValue; - else if (!Bstrcmp(szLabel,"WETFLOOR")) WETFLOOR = lValue; - else if (!Bstrcmp(szLabel,"WOMAN")) WOMAN = lValue; - else if (!Bstrcmp(szLabel,"WEATHERWARN")) WEATHERWARN = lValue; - break; - case 'X': - if (!Bstrcmp(szLabel,"XXXSTACY")) XXXSTACY = lValue; - break; + case 'A': + if (!Bstrcmp(szLabel,"ACTIVATOR")) ACTIVATOR = lValue; + else if (!Bstrcmp(szLabel,"ACTIVATORLOCKED")) ACTIVATORLOCKED = lValue; + else if (!Bstrcmp(szLabel,"ARROW")) ARROW = lValue; + else if (!Bstrcmp(szLabel,"AMMOBOX")) AMMOBOX = lValue; + else if (!Bstrcmp(szLabel,"AMMO")) AMMO = lValue; + else if (!Bstrcmp(szLabel,"AMMOLOTS")) AMMOLOTS = lValue; + else if (!Bstrcmp(szLabel,"AIRTANK")) AIRTANK = lValue; + else if (!Bstrcmp(szLabel,"ACCESSCARD")) ACCESSCARD = lValue; + else if (!Bstrcmp(szLabel,"ATOMICHEALTH")) ATOMICHEALTH = lValue; + else if (!Bstrcmp(szLabel,"ACCESSSWITCH")) ACCESSSWITCH = lValue; + else if (!Bstrcmp(szLabel,"ACCESSSWITCH2")) ACCESSSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"ANTENNA")) ANTENNA = lValue; + else if (!Bstrcmp(szLabel,"ATM")) ATM = lValue; + else if (!Bstrcmp(szLabel,"ATMBROKE")) ATMBROKE = lValue; + else if (!Bstrcmp(szLabel,"ALIENSWITCH")) ALIENSWITCH = lValue; + else if (!Bstrcmp(szLabel,"APLAYERTOP")) APLAYERTOP = lValue; + else if (!Bstrcmp(szLabel,"APLAYER")) APLAYER = lValue; + else if (!Bstrcmp(szLabel,"ARMJIB1")) ARMJIB1 = lValue; + else if (!Bstrcmp(szLabel,"AIRTANK_ICON")) AIRTANK_ICON = lValue; + else if (!Bstrcmp(szLabel,"ACCESS_ICON")) ACCESS_ICON = lValue; + break; + case 'B': + if (!Bstrcmp(szLabel,"BATTERYAMMO")) BATTERYAMMO = lValue; + else if (!Bstrcmp(szLabel,"BOOTS")) BOOTS = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT1")) BIGORBIT1 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT2")) BIGORBIT2 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT3")) BIGORBIT3 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT4")) BIGORBIT4 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT5")) BIGORBIT5 = lValue; + else if (!Bstrcmp(szLabel,"BIGFORCE")) BIGFORCE = lValue; + else if (!Bstrcmp(szLabel,"BPANNEL1")) BPANNEL1 = lValue; + else if (!Bstrcmp(szLabel,"BROKENCHAIR")) BROKENCHAIR = lValue; + else if (!Bstrcmp(szLabel,"BGRATE1")) BGRATE1 = lValue; + else if (!Bstrcmp(szLabel,"BRICK")) BRICK = lValue; + else if (!Bstrcmp(szLabel,"BOLT1")) BOLT1 = lValue; + else if (!Bstrcmp(szLabel,"BIGHOLE2")) BIGHOLE2 = lValue; + else if (!Bstrcmp(szLabel,"BOUNCEMINE")) BOUNCEMINE = lValue; + else if (!Bstrcmp(szLabel,"BROKEFIREHYDRENT")) BROKEFIREHYDRENT = lValue; + else if (!Bstrcmp(szLabel,"BOX")) BOX = lValue; + else if (!Bstrcmp(szLabel,"BULLETHOLE")) BULLETHOLE = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE1")) BOTTLE1 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE2")) BOTTLE2 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE3")) BOTTLE3 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE4")) BOTTLE4 = lValue; + else if (!Bstrcmp(szLabel,"BROKEHYDROPLANT")) BROKEHYDROPLANT = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE5")) BOTTLE5 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE6")) BOTTLE6 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE8")) BOTTLE8 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE7")) BOTTLE7 = lValue; + else if (!Bstrcmp(szLabel,"BROKENCLOCK")) BROKENCLOCK = lValue; + else if (!Bstrcmp(szLabel,"BIGHOLE")) BIGHOLE = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE10")) BOTTLE10 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE11")) BOTTLE11 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE12")) BOTTLE12 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE13")) BOTTLE13 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE14")) BOTTLE14 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE15")) BOTTLE15 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE16")) BOTTLE16 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE17")) BOTTLE17 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE18")) BOTTLE18 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE19")) BOTTLE19 = lValue; + else if (!Bstrcmp(szLabel,"BARBROKE")) BARBROKE = lValue; + else if (!Bstrcmp(szLabel,"BLOODPOOL")) BLOODPOOL = lValue; + else if (!Bstrcmp(szLabel,"BANNER")) BANNER = lValue; + else if (!Bstrcmp(szLabel,"BLANKSCREEN")) BLANKSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BLOODYPOLE")) BLOODYPOLE = lValue; + else if (!Bstrcmp(szLabel,"BLOOD")) BLOOD = lValue; + else if (!Bstrcmp(szLabel,"BURNING")) BURNING = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT1")) BLOODSPLAT1 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT3")) BLOODSPLAT3 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT2")) BLOODSPLAT2 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT4")) BLOODSPLAT4 = lValue; + else if (!Bstrcmp(szLabel,"BURNING2")) BURNING2 = lValue; + else if (!Bstrcmp(szLabel,"BETAVERSION")) BETAVERSION = lValue; + else if (!Bstrcmp(szLabel,"BADGUYICON")) BADGUYICON = lValue; + else if (!Bstrcmp(szLabel,"BOTTOMSTATUSBAR")) BOTTOMSTATUSBAR = lValue; + else if (!Bstrcmp(szLabel,"BOOT_ICON")) BOOT_ICON = lValue; + else if (!Bstrcmp(szLabel,"BETASCREEN")) BETASCREEN = lValue; + else if (!Bstrcmp(szLabel,"BOSS1")) BOSS1 = lValue; + else if (!Bstrcmp(szLabel,"BOSS1STAYPUT")) BOSS1STAYPUT = lValue; + else if (!Bstrcmp(szLabel,"BOSS1SHOOT")) BOSS1SHOOT = lValue; + else if (!Bstrcmp(szLabel,"BOSS1LOB")) BOSS1LOB = lValue; + else if (!Bstrcmp(szLabel,"BOSSTOP")) BOSSTOP = lValue; + else if (!Bstrcmp(szLabel,"BOSS2")) BOSS2 = lValue; + else if (!Bstrcmp(szLabel,"BOSS3")) BOSS3 = lValue; + else if (!Bstrcmp(szLabel,"BIGFNTCURSOR")) BIGFNTCURSOR = lValue; + else if (!Bstrcmp(szLabel,"BIGALPHANUM")) BIGALPHANUM = lValue; + else if (!Bstrcmp(szLabel,"BIGPERIOD")) BIGPERIOD = lValue; + else if (!Bstrcmp(szLabel,"BIGCOMMA")) BIGCOMMA = lValue; + else if (!Bstrcmp(szLabel,"BIGX")) BIGX = lValue; + else if (!Bstrcmp(szLabel,"BIGQ")) BIGQ = lValue; + else if (!Bstrcmp(szLabel,"BIGSEMI")) BIGSEMI = lValue; + else if (!Bstrcmp(szLabel,"BIGCOLIN")) BIGCOLIN = lValue; + else if (!Bstrcmp(szLabel,"BIGAPPOS")) BIGAPPOS = lValue; + else if (!Bstrcmp(szLabel,"BLANK")) BLANK = lValue; + else if (!Bstrcmp(szLabel,"BUTTON1")) BUTTON1 = lValue; + else if (!Bstrcmp(szLabel,"BONUSSCREEN")) BONUSSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BORNTOBEWILDSCREEN")) BORNTOBEWILDSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BLIMP")) BLIMP = lValue; + else if (!Bstrcmp(szLabel,"BPANNEL3")) BPANNEL3 = lValue; + else if (!Bstrcmp(szLabel,"BROOM")) BROOM = lValue; + else if (!Bstrcmp(szLabel,"BOSS4")) BOSS4 = lValue; + else if (!Bstrcmp(szLabel,"BOSS4STAYPUT")) BOSS4STAYPUT = lValue; + break; + case 'C': + if (!Bstrcmp(szLabel,"CYCLER")) CYCLER = lValue; + else if (!Bstrcmp(szLabel,"CHAINGUNSPRITE")) CHAINGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"CRYSTALAMMO")) CRYSTALAMMO = lValue; + else if (!Bstrcmp(szLabel,"COLA")) COLA = lValue; + else if (!Bstrcmp(szLabel,"CLOUDYOCEAN")) CLOUDYOCEAN = lValue; + else if (!Bstrcmp(szLabel,"CLOUDYSKIES")) CLOUDYSKIES = lValue; + else if (!Bstrcmp(szLabel,"CRACK1")) CRACK1 = lValue; + else if (!Bstrcmp(szLabel,"CRACK2")) CRACK2 = lValue; + else if (!Bstrcmp(szLabel,"CRACK3")) CRACK3 = lValue; + else if (!Bstrcmp(szLabel,"CRACK4")) CRACK4 = lValue; + else if (!Bstrcmp(szLabel,"CAMERAPOLE")) CAMERAPOLE = lValue; + else if (!Bstrcmp(szLabel,"CHAIR1")) CHAIR1 = lValue; + else if (!Bstrcmp(szLabel,"CHAIR2")) CHAIR2 = lValue; + else if (!Bstrcmp(szLabel,"CAMERA1")) CAMERA1 = lValue; + else if (!Bstrcmp(szLabel,"CHAIR3")) CHAIR3 = lValue; + else if (!Bstrcmp(szLabel,"CAMERALIGHT")) CAMERALIGHT = lValue; + else if (!Bstrcmp(szLabel,"CACTUS")) CACTUS = lValue; + else if (!Bstrcmp(szLabel,"CACTUSBROKE")) CACTUSBROKE = lValue; + else if (!Bstrcmp(szLabel,"CONE")) CONE = lValue; + else if (!Bstrcmp(szLabel,"CLOCK")) CLOCK = lValue; + else if (!Bstrcmp(szLabel,"CIRCLEPANNEL")) CIRCLEPANNEL = lValue; + else if (!Bstrcmp(szLabel,"CIRCLEPANNELBROKE")) CIRCLEPANNELBROKE = lValue; + else if (!Bstrcmp(szLabel,"COLAMACHINE")) COLAMACHINE = lValue; + else if (!Bstrcmp(szLabel,"COLAMACHINEBROKE")) COLAMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"CRANEPOLE")) CRANEPOLE = lValue; + else if (!Bstrcmp(szLabel,"CRANE")) CRANE = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING")) CANWITHSOMETHING = lValue; + else if (!Bstrcmp(szLabel,"CEILINGSTEAM")) CEILINGSTEAM = lValue; + else if (!Bstrcmp(szLabel,"COOLEXPLOSION1")) COOLEXPLOSION1 = lValue; + else if (!Bstrcmp(szLabel,"CANNONBALL")) CANNONBALL = lValue; + else if (!Bstrcmp(szLabel,"COMMANDER")) COMMANDER = lValue; + else if (!Bstrcmp(szLabel,"COMMANDERSTAYPUT")) COMMANDERSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"CRACKKNUCKLES")) CRACKKNUCKLES = lValue; + else if (!Bstrcmp(szLabel,"CAMCORNER")) CAMCORNER = lValue; + else if (!Bstrcmp(szLabel,"CAMLIGHT")) CAMLIGHT = lValue; + else if (!Bstrcmp(szLabel,"CROSSHAIR")) CROSSHAIR = lValue; + else if (!Bstrcmp(szLabel,"CLIPINHAND")) CLIPINHAND = lValue; + else if (!Bstrcmp(szLabel,"CHAINGUN")) CHAINGUN = lValue; + else if (!Bstrcmp(szLabel,"CATLITE")) CATLITE = lValue; + else if (!Bstrcmp(szLabel,"COFFEEMACHINE")) COFFEEMACHINE = lValue; + else if (!Bstrcmp(szLabel,"CUPS")) CUPS = lValue; + else if (!Bstrcmp(szLabel,"COFFEEMUG")) COFFEEMUG = lValue; + else if (!Bstrcmp(szLabel,"CHESTOFGOLD")) CHESTOFGOLD = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING2")) CANWITHSOMETHING2 = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING3")) CANWITHSOMETHING3 = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING4")) CANWITHSOMETHING4 = lValue; + break; + case 'D': + if (!Bstrcmp(szLabel,"DEVISTATORSPRITE")) DEVISTATORSPRITE = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATORAMMO")) DEVISTATORAMMO = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE5")) DOORTILE5 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE6")) DOORTILE6 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE1")) DOORTILE1 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE2")) DOORTILE2 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE3")) DOORTILE3 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE4")) DOORTILE4 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE7")) DOORTILE7 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE8")) DOORTILE8 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE9")) DOORTILE9 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE10")) DOORTILE10 = lValue; + else if (!Bstrcmp(szLabel,"DOORSHOCK")) DOORSHOCK = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH")) DIPSWITCH = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH2")) DIPSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH3")) DIPSWITCH3 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE22")) DOORTILE22 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE18")) DOORTILE18 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE19")) DOORTILE19 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE20")) DOORTILE20 = lValue; + else if (!Bstrcmp(szLabel,"DOMELITE")) DOMELITE = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE14")) DOORTILE14 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE16")) DOORTILE16 = lValue; + else if (!Bstrcmp(szLabel,"DONUTS")) DONUTS = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE15")) DOORTILE15 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE21")) DOORTILE21 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE17")) DOORTILE17 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE11")) DOORTILE11 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE12")) DOORTILE12 = lValue; + else if (!Bstrcmp(szLabel,"DUKELYINGDEAD")) DUKELYINGDEAD = lValue; + else if (!Bstrcmp(szLabel,"DUKETORSO")) DUKETORSO = lValue; + else if (!Bstrcmp(szLabel,"DUKEGUN")) DUKEGUN = lValue; + else if (!Bstrcmp(szLabel,"DUKELEG")) DUKELEG = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATORBLAST")) DEVISTATORBLAST = lValue; + else if (!Bstrcmp(szLabel,"DRONE")) DRONE = lValue; + else if (!Bstrcmp(szLabel,"DUKEICON")) DUKEICON = lValue; + else if (!Bstrcmp(szLabel,"DIGITALNUM")) DIGITALNUM = lValue; + else if (!Bstrcmp(szLabel,"DUKECAR")) DUKECAR = lValue; + else if (!Bstrcmp(szLabel,"DREALMS")) DREALMS = lValue; + else if (!Bstrcmp(szLabel,"DUKENUKEM")) DUKENUKEM = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATOR")) DEVISTATOR = lValue; + else if (!Bstrcmp(szLabel,"DUKECUTOUT")) DUKECUTOUT = lValue; + else if (!Bstrcmp(szLabel,"DUCK")) DUCK = lValue; + else if (!Bstrcmp(szLabel,"DESKLAMP")) DESKLAMP = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE23")) DOORTILE23 = lValue; + else if (!Bstrcmp(szLabel,"DONUTS2")) DONUTS2 = lValue; + else if (!Bstrcmp(szLabel,"DESKPHONE")) DESKPHONE = lValue; + else if (!Bstrcmp(szLabel,"DUKEBURGER")) DUKEBURGER = lValue; + else if (!Bstrcmp(szLabel,"DOLPHIN1")) DOLPHIN1 = lValue; + else if (!Bstrcmp(szLabel,"DOLPHIN2")) DOLPHIN2 = lValue; + else if (!Bstrcmp(szLabel,"DUKETAG")) DUKETAG = lValue; + break; + case 'E': + if (!Bstrcmp(szLabel,"EPISODE")) EPISODE = lValue; + else if (!Bstrcmp(szLabel,"EGG")) EGG = lValue; + else if (!Bstrcmp(szLabel,"EXPLODINGBARREL")) EXPLODINGBARREL = lValue; + else if (!Bstrcmp(szLabel,"EXPLODINGBARREL2")) EXPLODINGBARREL2 = lValue; + else if (!Bstrcmp(szLabel,"EXPLOSION2")) EXPLOSION2 = lValue; + else if (!Bstrcmp(szLabel,"EXPLOSION2BOT")) EXPLOSION2BOT = lValue; + else if (!Bstrcmp(szLabel,"ENDALPHANUM")) ENDALPHANUM = lValue; + break; + case 'F': + if (!Bstrcmp(szLabel,"FOF")) FOF = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUNSPRITE")) FIRSTGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"FREEZESPRITE")) FREEZESPRITE = lValue; + else if (!Bstrcmp(szLabel,"FREEZEAMMO")) FREEZEAMMO = lValue; + else if (!Bstrcmp(szLabel,"FIRSTAID")) FIRSTAID = lValue; + else if (!Bstrcmp(szLabel,"FRANKENSTINESWITCH")) FRANKENSTINESWITCH = lValue; + else if (!Bstrcmp(szLabel,"FLOORSLIME")) FLOORSLIME = lValue; + else if (!Bstrcmp(szLabel,"FANSPRITE")) FANSPRITE = lValue; + else if (!Bstrcmp(szLabel,"FANSPRITEBROKE")) FANSPRITEBROKE = lValue; + else if (!Bstrcmp(szLabel,"FANSHADOW")) FANSHADOW = lValue; + else if (!Bstrcmp(szLabel,"FANSHADOWBROKE")) FANSHADOWBROKE = lValue; + else if (!Bstrcmp(szLabel,"FUELPOD")) FUELPOD = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS")) FOOTPRINTS = lValue; + else if (!Bstrcmp(szLabel,"FEMMAG1")) FEMMAG1 = lValue; + else if (!Bstrcmp(szLabel,"FEMMAG2")) FEMMAG2 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS2")) FOOTPRINTS2 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS3")) FOOTPRINTS3 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS4")) FOOTPRINTS4 = lValue; + else if (!Bstrcmp(szLabel,"FIREEXT")) FIREEXT = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC5")) FEMPIC5 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC6")) FEMPIC6 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC7")) FEMPIC7 = lValue; + else if (!Bstrcmp(szLabel,"FLOORPLASMA")) FLOORPLASMA = lValue; + else if (!Bstrcmp(szLabel,"FIREBARREL")) FIREBARREL = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC1")) FEMPIC1 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC2")) FEMPIC2 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC3")) FEMPIC3 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC4")) FEMPIC4 = lValue; + else if (!Bstrcmp(szLabel,"FEM1")) FEM1 = lValue; + else if (!Bstrcmp(szLabel,"FEM2")) FEM2 = lValue; + else if (!Bstrcmp(szLabel,"FEM3")) FEM3 = lValue; + else if (!Bstrcmp(szLabel,"FEM5")) FEM5 = lValue; + else if (!Bstrcmp(szLabel,"FEM4")) FEM4 = lValue; + else if (!Bstrcmp(szLabel,"FEM6")) FEM6 = lValue; + else if (!Bstrcmp(szLabel,"FEM6PAD")) FEM6PAD = lValue; + else if (!Bstrcmp(szLabel,"FEM8")) FEM8 = lValue; + else if (!Bstrcmp(szLabel,"FETUSJIB")) FETUSJIB = lValue; + else if (!Bstrcmp(szLabel,"FETUS")) FETUS = lValue; + else if (!Bstrcmp(szLabel,"FETUSBROKE")) FETUSBROKE = lValue; + else if (!Bstrcmp(szLabel,"FIREVASE")) FIREVASE = lValue; + else if (!Bstrcmp(szLabel,"FEM7")) FEM7 = lValue; + else if (!Bstrcmp(szLabel,"FIRELASER")) FIRELASER = lValue; + else if (!Bstrcmp(szLabel,"FIST")) FIST = lValue; + else if (!Bstrcmp(szLabel,"FREEZEBLAST")) FREEZEBLAST = lValue; + else if (!Bstrcmp(szLabel,"FORCERIPPLE")) FORCERIPPLE = lValue; + else if (!Bstrcmp(szLabel,"FECES")) FECES = lValue; + else if (!Bstrcmp(szLabel,"FIRE")) FIRE = lValue; + else if (!Bstrcmp(szLabel,"FIRE2")) FIRE2 = lValue; + else if (!Bstrcmp(szLabel,"FLOORFLAME")) FLOORFLAME = lValue; + else if (!Bstrcmp(szLabel,"F1HELP")) F1HELP = lValue; + else if (!Bstrcmp(szLabel,"FOODICON")) FOODICON = lValue; + else if (!Bstrcmp(szLabel,"FIRSTAID_ICON")) FIRSTAID_ICON = lValue; + else if (!Bstrcmp(szLabel,"FRAGBAR")) FRAGBAR = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUN")) FIRSTGUN = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUNRELOAD")) FIRSTGUNRELOAD = lValue; + else if (!Bstrcmp(szLabel,"FALLINGCLIP")) FALLINGCLIP = lValue; + else if (!Bstrcmp(szLabel,"FREEZE")) FREEZE = lValue; + else if (!Bstrcmp(szLabel,"FORCESPHERE")) FORCESPHERE = lValue; + else if (!Bstrcmp(szLabel,"FEM9")) FEM9 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINT")) FOOTPRINT = lValue; + else if (!Bstrcmp(szLabel,"FRAMEEFFECT1")) FRAMEEFFECT1 = lValue; + else if (!Bstrcmp(szLabel,"FRAMEEFFECT1_13")) FRAMEEFFECT1_13 = lValue; + else if (!Bstrcmp(szLabel,"FLOORBASKET")) FLOORBASKET = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT1")) FOODOBJECT1 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT2")) FOODOBJECT2 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT3")) FOODOBJECT3 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT4")) FOODOBJECT4 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT5")) FOODOBJECT5 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT6")) FOODOBJECT6 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT7")) FOODOBJECT7 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT8")) FOODOBJECT8 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT9")) FOODOBJECT9 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT10")) FOODOBJECT10 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT11")) FOODOBJECT11 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT12")) FOODOBJECT12 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT13")) FOODOBJECT13 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT14")) FOODOBJECT14 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT15")) FOODOBJECT15 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT16")) FOODOBJECT16 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT17")) FOODOBJECT17 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT18")) FOODOBJECT18 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT19")) FOODOBJECT19 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT20")) FOODOBJECT20 = lValue; + else if (!Bstrcmp(szLabel,"FEATHEREDCHICKEN")) FEATHEREDCHICKEN = lValue; + else if (!Bstrcmp(szLabel,"FEM10")) FEM10 = lValue; + break; + case 'G': + if (!Bstrcmp(szLabel,"GPSPEED")) GPSPEED = lValue; + else if (!Bstrcmp(szLabel,"GROWSPRITEICON")) GROWSPRITEICON = lValue; + else if (!Bstrcmp(szLabel,"GROWAMMO")) GROWAMMO = lValue; + else if (!Bstrcmp(szLabel,"GLASS")) GLASS = lValue; + else if (!Bstrcmp(szLabel,"GLASS2")) GLASS2 = lValue; + else if (!Bstrcmp(szLabel,"GRATE1")) GRATE1 = lValue; + else if (!Bstrcmp(szLabel,"GENERICPOLE")) GENERICPOLE = lValue; + else if (!Bstrcmp(szLabel,"GLASSPIECES")) GLASSPIECES = lValue; + else if (!Bstrcmp(szLabel,"GREENSLIME")) GREENSLIME = lValue; + else if (!Bstrcmp(szLabel,"GROWSPARK")) GROWSPARK = lValue; + else if (!Bstrcmp(szLabel,"GETICON")) GETICON = lValue; + else if (!Bstrcmp(szLabel,"GLAIR")) GLAIR = lValue; + else if (!Bstrcmp(szLabel,"GLASS3")) GLASS3 = lValue; + else if (!Bstrcmp(szLabel,"GUNPOWDERBARREL")) GUNPOWDERBARREL = lValue; + else if (!Bstrcmp(szLabel,"GAVALS")) GAVALS = lValue; + else if (!Bstrcmp(szLabel,"GAVALS2")) GAVALS2 = lValue; + else if (!Bstrcmp(szLabel,"GUMBALLMACHINE")) GUMBALLMACHINE = lValue; + else if (!Bstrcmp(szLabel,"GUMBALLMACHINEBROKE")) GUMBALLMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"GENERICPOLE2")) GENERICPOLE2 = lValue; + break; + case 'H': + if (!Bstrcmp(szLabel,"HEAVYHBOMB")) HEAVYHBOMB = lValue; + else if (!Bstrcmp(szLabel,"HEALTHBOX")) HEALTHBOX = lValue; + else if (!Bstrcmp(szLabel,"HBOMBAMMO")) HBOMBAMMO = lValue; + else if (!Bstrcmp(szLabel,"HEATSENSOR")) HEATSENSOR = lValue; + else if (!Bstrcmp(szLabel,"HURTRAIL")) HURTRAIL = lValue; + else if (!Bstrcmp(szLabel,"HYDROPLANT")) HYDROPLANT = lValue; + else if (!Bstrcmp(szLabel,"HANGLIGHT")) HANGLIGHT = lValue; + else if (!Bstrcmp(szLabel,"HYDRENT")) HYDRENT = lValue; + else if (!Bstrcmp(szLabel,"HANGOOZ")) HANGOOZ = lValue; + else if (!Bstrcmp(szLabel,"HORSEONSIDE")) HORSEONSIDE = lValue; + else if (!Bstrcmp(szLabel,"HORSELITE")) HORSELITE = lValue; + else if (!Bstrcmp(szLabel,"HANDSWITCH")) HANDSWITCH = lValue; + else if (!Bstrcmp(szLabel,"HANDPRINTSWITCH")) HANDPRINTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"HELECOPT")) HELECOPT = lValue; + else if (!Bstrcmp(szLabel,"HOLODUKE")) HOLODUKE = lValue; + else if (!Bstrcmp(szLabel,"HEADJIB1")) HEADJIB1 = lValue; + else if (!Bstrcmp(szLabel,"HEADERBAR")) HEADERBAR = lValue; + else if (!Bstrcmp(szLabel,"HEAT_ICON")) HEAT_ICON = lValue; + else if (!Bstrcmp(szLabel,"HOLODUKE_ICON")) HOLODUKE_ICON = lValue; + else if (!Bstrcmp(szLabel,"HAND")) HAND = lValue; + else if (!Bstrcmp(szLabel,"HANDHOLDINGLASER")) HANDHOLDINGLASER = lValue; + else if (!Bstrcmp(szLabel,"HANDHOLDINGACCESS")) HANDHOLDINGACCESS = lValue; + else if (!Bstrcmp(szLabel,"HANDREMOTE")) HANDREMOTE = lValue; + else if (!Bstrcmp(szLabel,"HANDTHROW")) HANDTHROW = lValue; + else if (!Bstrcmp(szLabel,"HATRACK")) HATRACK = lValue; + else if (!Bstrcmp(szLabel,"HOTMEAT")) HOTMEAT = lValue; + else if (!Bstrcmp(szLabel,"HEADLAMP")) HEADLAMP = lValue; + break; + case 'I': + if (!Bstrcmp(szLabel,"INVENTORYBOX")) INVENTORYBOX = lValue; + else if (!Bstrcmp(szLabel,"IVUNIT")) IVUNIT = lValue; + else if (!Bstrcmp(szLabel,"INDY")) INDY = lValue; + else if (!Bstrcmp(szLabel,"INNERJAW")) INNERJAW = lValue; + else if (!Bstrcmp(szLabel,"INGAMEDUKETHREEDEE")) INGAMEDUKETHREEDEE = lValue; + break; + case 'J': + if (!Bstrcmp(szLabel,"JETPACK")) JETPACK = lValue; + else if (!Bstrcmp(szLabel,"JAILBARBREAK")) JAILBARBREAK = lValue; + else if (!Bstrcmp(szLabel,"JIBS1")) JIBS1 = lValue; + else if (!Bstrcmp(szLabel,"JIBS2")) JIBS2 = lValue; + else if (!Bstrcmp(szLabel,"JIBS3")) JIBS3 = lValue; + else if (!Bstrcmp(szLabel,"JIBS4")) JIBS4 = lValue; + else if (!Bstrcmp(szLabel,"JIBS5")) JIBS5 = lValue; + else if (!Bstrcmp(szLabel,"JIBS6")) JIBS6 = lValue; + else if (!Bstrcmp(szLabel,"JETPACK_ICON")) JETPACK_ICON = lValue; + else if (!Bstrcmp(szLabel,"JOLLYMEAL")) JOLLYMEAL = lValue; + else if (!Bstrcmp(szLabel,"JURYGUY")) JURYGUY = lValue; + break; + case 'K': + if (!Bstrcmp(szLabel,"KILLSICON")) KILLSICON = lValue; + else if (!Bstrcmp(szLabel,"KNEE")) KNEE = lValue; + break; + case 'L': + if (!Bstrcmp(szLabel,"LOCATORS")) LOCATORS = lValue; + else if (!Bstrcmp(szLabel,"LA")) LA = lValue; + else if (!Bstrcmp(szLabel,"LIGHTSWITCH")) LIGHTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"LIGHTSWITCH2")) LIGHTSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"LOCKSWITCH1")) LOCKSWITCH1 = lValue; + else if (!Bstrcmp(szLabel,"LUKE")) LUKE = lValue; + else if (!Bstrcmp(szLabel,"LOOGIE")) LOOGIE = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOP")) LIZTROOP = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPRUNNING")) LIZTROOPRUNNING = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPSTAYPUT")) LIZTROOPSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"LIZTOP")) LIZTOP = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPSHOOT")) LIZTROOPSHOOT = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPJETPACK")) LIZTROOPJETPACK = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPDSPRITE")) LIZTROOPDSPRITE = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPONTOILET")) LIZTROOPONTOILET = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPJUSTSIT")) LIZTROOPJUSTSIT = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPDUCKING")) LIZTROOPDUCKING = lValue; + else if (!Bstrcmp(szLabel,"LEGJIB1")) LEGJIB1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMAN")) LIZMAN = lValue; + else if (!Bstrcmp(szLabel,"LIZMANSTAYPUT")) LIZMANSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"LIZMANSPITTING")) LIZMANSPITTING = lValue; + else if (!Bstrcmp(szLabel,"LIZMANFEEDING")) LIZMANFEEDING = lValue; + else if (!Bstrcmp(szLabel,"LIZMANJUMP")) LIZMANJUMP = lValue; + else if (!Bstrcmp(szLabel,"LIZMANDEADSPRITE")) LIZMANDEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"LIZMANHEAD1")) LIZMANHEAD1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMANARM1")) LIZMANARM1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMANLEG1")) LIZMANLEG1 = lValue; + else if (!Bstrcmp(szLabel,"LOGO")) LOGO = lValue; + else if (!Bstrcmp(szLabel,"LASERLINE")) LASERLINE = lValue; + else if (!Bstrcmp(szLabel,"LASERSITE")) LASERSITE = lValue; + else if (!Bstrcmp(szLabel,"LOADSCREEN")) LOADSCREEN = lValue; + else if (!Bstrcmp(szLabel,"LAVABUBBLE")) LAVABUBBLE = lValue; + else if (!Bstrcmp(szLabel,"LETTER")) LETTER = lValue; + break; + case 'M': + if (!Bstrcmp(szLabel,"MUSICANDSFX")) MUSICANDSFX = lValue; + else if (!Bstrcmp(szLabel,"MASTERSWITCH")) MASTERSWITCH = lValue; + else if (!Bstrcmp(szLabel,"MIRRORBROKE")) MIRRORBROKE = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY1")) MOONSKY1 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY2")) MOONSKY2 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY3")) MOONSKY3 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY4")) MOONSKY4 = lValue; + else if (!Bstrcmp(szLabel,"MULTISWITCH")) MULTISWITCH = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL9")) MASKWALL9 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL1")) MASKWALL1 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL10")) MASKWALL10 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL11")) MASKWALL11 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL5")) MASKWALL5 = lValue; + else if (!Bstrcmp(szLabel,"MIRROR")) MIRROR = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL12")) MASKWALL12 = lValue; + else if (!Bstrcmp(szLabel,"MOVIECAMERA")) MOVIECAMERA = lValue; + else if (!Bstrcmp(szLabel,"MIKE")) MIKE = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL13")) MASKWALL13 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL2")) MASKWALL2 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL3")) MASKWALL3 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL4")) MASKWALL4 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL14")) MASKWALL14 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL15")) MASKWALL15 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL6")) MASKWALL6 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL8")) MASKWALL8 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL7")) MASKWALL7 = lValue; + else if (!Bstrcmp(szLabel,"MONEY")) MONEY = lValue; + else if (!Bstrcmp(szLabel,"MONK")) MONK = lValue; + else if (!Bstrcmp(szLabel,"MORTER")) MORTER = lValue; + else if (!Bstrcmp(szLabel,"MENUSCREEN")) MENUSCREEN = lValue; + else if (!Bstrcmp(szLabel,"MENUBAR")) MENUBAR = lValue; + else if (!Bstrcmp(szLabel,"MOUSECURSOR")) MOUSECURSOR = lValue; + else if (!Bstrcmp(szLabel,"MINIFONT")) MINIFONT = lValue; + else if (!Bstrcmp(szLabel,"MAIL")) MAIL = lValue; + else if (!Bstrcmp(szLabel,"MAILBAG")) MAILBAG = lValue; + else if (!Bstrcmp(szLabel,"METER")) METER = lValue; + else if (!Bstrcmp(szLabel,"MACE")) MACE = lValue; + else if (!Bstrcmp(szLabel,"MOP")) MOP = lValue; + else if (!Bstrcmp(szLabel,"MAN")) MAN = lValue; + else if (!Bstrcmp(szLabel,"MAN2")) MAN2 = lValue; + break; + case 'N': + if (!Bstrcmp(szLabel,"NUKEBUTTON")) NUKEBUTTON = lValue; + else if (!Bstrcmp(szLabel,"NAKED1")) NAKED1 = lValue; + else if (!Bstrcmp(szLabel,"NEON1")) NEON1 = lValue; + else if (!Bstrcmp(szLabel,"NEON2")) NEON2 = lValue; + else if (!Bstrcmp(szLabel,"NEON3")) NEON3 = lValue; + else if (!Bstrcmp(szLabel,"NEON4")) NEON4 = lValue; + else if (!Bstrcmp(szLabel,"NEON5")) NEON5 = lValue; + else if (!Bstrcmp(szLabel,"NEON6")) NEON6 = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARREL")) NUKEBARREL = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARRELDENTED")) NUKEBARRELDENTED = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARRELLEAKED")) NUKEBARRELLEAKED = lValue; + else if (!Bstrcmp(szLabel,"NOTCHON")) NOTCHON = lValue; + else if (!Bstrcmp(szLabel,"NOTCHOFF")) NOTCHOFF = lValue; + else if (!Bstrcmp(szLabel,"NUKEWARNINGICON")) NUKEWARNINGICON = lValue; + else if (!Bstrcmp(szLabel,"NEWBEAST")) NEWBEAST = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTSTAYPUT")) NEWBEASTSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTJUMP")) NEWBEASTJUMP = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTHANG")) NEWBEASTHANG = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTHANGDEAD")) NEWBEASTHANGDEAD = lValue; + else if (!Bstrcmp(szLabel,"NATURALLIGHTNING")) NATURALLIGHTNING = lValue; + break; + case 'O': + if (!Bstrcmp(szLabel,"OJ")) OJ = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE1")) OCEANSPRITE1 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE2")) OCEANSPRITE2 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE3")) OCEANSPRITE3 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE4")) OCEANSPRITE4 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE5")) OCEANSPRITE5 = lValue; + else if (!Bstrcmp(szLabel,"OOZFILTER")) OOZFILTER = lValue; + else if (!Bstrcmp(szLabel,"OCTABRAIN")) OCTABRAIN = lValue; + else if (!Bstrcmp(szLabel,"OCTABRAINSTAYPUT")) OCTABRAINSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"OCTATOP")) OCTATOP = lValue; + else if (!Bstrcmp(szLabel,"OCTADEADSPRITE")) OCTADEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"OOZ")) OOZ = lValue; + else if (!Bstrcmp(szLabel,"OOZ2")) OOZ2 = lValue; + else if (!Bstrcmp(szLabel,"ORGANTIC")) ORGANTIC = lValue; + else if (!Bstrcmp(szLabel,"ORDERING")) ORDERING = lValue; + break; + case 'P': + if (!Bstrcmp(szLabel,"PANNEL1")) PANNEL1 = lValue; + else if (!Bstrcmp(szLabel,"PANNEL2")) PANNEL2 = lValue; + else if (!Bstrcmp(szLabel,"PIPE2")) PIPE2 = lValue; + else if (!Bstrcmp(szLabel,"PIPE1B")) PIPE1B = lValue; + else if (!Bstrcmp(szLabel,"PIPE3")) PIPE3 = lValue; + else if (!Bstrcmp(szLabel,"PIPE1")) PIPE1 = lValue; + else if (!Bstrcmp(szLabel,"PIPE2B")) PIPE2B = lValue; + else if (!Bstrcmp(szLabel,"POT1")) POT1 = lValue; + else if (!Bstrcmp(szLabel,"POT2")) POT2 = lValue; + else if (!Bstrcmp(szLabel,"POT3")) POT3 = lValue; + else if (!Bstrcmp(szLabel,"PIPE3B")) PIPE3B = lValue; + else if (!Bstrcmp(szLabel,"POWERSWITCH1")) POWERSWITCH1 = lValue; + else if (!Bstrcmp(szLabel,"POWERSWITCH2")) POWERSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"POCKET")) POCKET = lValue; + else if (!Bstrcmp(szLabel,"PIPE5")) PIPE5 = lValue; + else if (!Bstrcmp(szLabel,"PIPE6")) PIPE6 = lValue; + else if (!Bstrcmp(szLabel,"PIPE4")) PIPE4 = lValue; + else if (!Bstrcmp(szLabel,"PIPE4B")) PIPE4B = lValue; + else if (!Bstrcmp(szLabel,"PIPE5B")) PIPE5B = lValue; + else if (!Bstrcmp(szLabel,"PLUG")) PLUG = lValue; + else if (!Bstrcmp(szLabel,"PULLSWITCH")) PULLSWITCH = lValue; + else if (!Bstrcmp(szLabel,"PIPE6B")) PIPE6B = lValue; + else if (!Bstrcmp(szLabel,"PODFEM1")) PODFEM1 = lValue; + else if (!Bstrcmp(szLabel,"PLAYERONWATER")) PLAYERONWATER = lValue; + else if (!Bstrcmp(szLabel,"PIGCOP")) PIGCOP = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPSTAYPUT")) PIGCOPSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPDIVE")) PIGCOPDIVE = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPDEADSPRITE")) PIGCOPDEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"PIGTOP")) PIGTOP = lValue; + else if (!Bstrcmp(szLabel,"PLAYERISHERE")) PLAYERISHERE = lValue; + else if (!Bstrcmp(szLabel,"PLAYERWASHERE")) PLAYERWASHERE = lValue; + else if (!Bstrcmp(szLabel,"PLUTOPAKSPRITE")) PLUTOPAKSPRITE = lValue; + else if (!Bstrcmp(szLabel,"POOP")) POOP = lValue; + else if (!Bstrcmp(szLabel,"PANNEL3")) PANNEL3 = lValue; + else if (!Bstrcmp(szLabel,"PURPLELAVA")) PURPLELAVA = lValue; + else if (!Bstrcmp(szLabel,"POLICELIGHTPOLE")) POLICELIGHTPOLE = lValue; + else if (!Bstrcmp(szLabel,"PUKE")) PUKE = lValue; + else if (!Bstrcmp(szLabel,"PAPER")) PAPER = lValue; + else if (!Bstrcmp(szLabel,"PIRATE1A")) PIRATE1A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE4A")) PIRATE4A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE2A")) PIRATE2A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE5A")) PIRATE5A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE3A")) PIRATE3A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE6A")) PIRATE6A = lValue; + else if (!Bstrcmp(szLabel,"PIRATEHALF")) PIRATEHALF = lValue; + else if (!Bstrcmp(szLabel,"PLEASEWAIT")) PLEASEWAIT = lValue; + break; + case 'Q': + if (!Bstrcmp(szLabel,"QUEBALL")) QUEBALL = lValue; + break; + case 'R': + if (!Bstrcmp(szLabel,"RESPAWN")) RESPAWN = lValue; + else if (!Bstrcmp(szLabel,"RPGSPRITE")) RPGSPRITE = lValue; + else if (!Bstrcmp(szLabel,"RPGAMMO")) RPGAMMO = lValue; + else if (!Bstrcmp(szLabel,"REDSKY1")) REDSKY1 = lValue; + else if (!Bstrcmp(szLabel,"REDSKY2")) REDSKY2 = lValue; + else if (!Bstrcmp(szLabel,"REFLECTWATERTILE")) REFLECTWATERTILE = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2")) REACTOR2 = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2BURNT")) REACTOR2BURNT = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2SPARK")) REACTOR2SPARK = lValue; + else if (!Bstrcmp(szLabel,"RUBBERCAN")) RUBBERCAN = lValue; + else if (!Bstrcmp(szLabel,"REACTOR")) REACTOR = lValue; + else if (!Bstrcmp(szLabel,"REACTORSPARK")) REACTORSPARK = lValue; + else if (!Bstrcmp(szLabel,"REACTORBURNT")) REACTORBURNT = lValue; + else if (!Bstrcmp(szLabel,"RAT")) RAT = lValue; + else if (!Bstrcmp(szLabel,"RADIUSEXPLOSION")) RADIUSEXPLOSION = lValue; + else if (!Bstrcmp(szLabel,"RECON")) RECON = lValue; + else if (!Bstrcmp(szLabel,"ROTATEGUN")) ROTATEGUN = lValue; + else if (!Bstrcmp(szLabel,"RPGGUN")) RPGGUN = lValue; + else if (!Bstrcmp(szLabel,"RPGMUZZLEFLASH")) RPGMUZZLEFLASH = lValue; + else if (!Bstrcmp(szLabel,"RPG")) RPG = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERRED")) RESPAWNMARKERRED = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERYELLOW")) RESPAWNMARKERYELLOW = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERGREEN")) RESPAWNMARKERGREEN = lValue; + else if (!Bstrcmp(szLabel,"ROBOTDOG")) ROBOTDOG = lValue; + else if (!Bstrcmp(szLabel,"ROBOTPIRATE")) ROBOTPIRATE = lValue; + else if (!Bstrcmp(szLabel,"ROBOTMOUSE")) ROBOTMOUSE = lValue; + else if (!Bstrcmp(szLabel,"ROBOTDOG2")) ROBOTDOG2 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT1")) RESERVEDSLOT1 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT2")) RESERVEDSLOT2 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT3")) RESERVEDSLOT3 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT4")) RESERVEDSLOT4 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT5")) RESERVEDSLOT5 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT6")) RESERVEDSLOT6 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT7")) RESERVEDSLOT7 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT8")) RESERVEDSLOT8 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT9")) RESERVEDSLOT9 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT10")) RESERVEDSLOT10 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT11")) RESERVEDSLOT11 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT12")) RESERVEDSLOT12 = lValue; + break; + case 'S': + if (!Bstrcmp(szLabel,"SECTOREFFECTOR")) SECTOREFFECTOR = lValue; + else if (!Bstrcmp(szLabel,"SHRINKERSPRITE")) SHRINKERSPRITE = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNSPRITE")) SHOTGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNAMMO")) SHOTGUNAMMO = lValue; + else if (!Bstrcmp(szLabel,"SIXPAK")) SIXPAK = lValue; + else if (!Bstrcmp(szLabel,"SHIELD")) SHIELD = lValue; + else if (!Bstrcmp(szLabel,"STEROIDS")) STEROIDS = lValue; + else if (!Bstrcmp(szLabel,"SLOTDOOR")) SLOTDOOR = lValue; + else if (!Bstrcmp(szLabel,"SPACEDOORSWITCH")) SPACEDOORSWITCH = lValue; + else if (!Bstrcmp(szLabel,"SPACELIGHTSWITCH")) SPACELIGHTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK1")) SCREENBREAK1 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK2")) SCREENBREAK2 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK3")) SCREENBREAK3 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK4")) SCREENBREAK4 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK5")) SCREENBREAK5 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK6")) SCREENBREAK6 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK7")) SCREENBREAK7 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK8")) SCREENBREAK8 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK9")) SCREENBREAK9 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK10")) SCREENBREAK10 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK11")) SCREENBREAK11 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK12")) SCREENBREAK12 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK13")) SCREENBREAK13 = lValue; + else if (!Bstrcmp(szLabel,"STATIC")) STATIC = lValue; + else if (!Bstrcmp(szLabel,"SATELLITE")) SATELLITE = lValue; + else if (!Bstrcmp(szLabel,"STAINGLASS1")) STAINGLASS1 = lValue; + else if (!Bstrcmp(szLabel,"SATELITE")) SATELITE = lValue; + else if (!Bstrcmp(szLabel,"SLIMEPIPE")) SLIMEPIPE = lValue; + else if (!Bstrcmp(szLabel,"STALL")) STALL = lValue; + else if (!Bstrcmp(szLabel,"STALLBROKE")) STALLBROKE = lValue; + else if (!Bstrcmp(szLabel,"SOLARPANNEL")) SOLARPANNEL = lValue; + else if (!Bstrcmp(szLabel,"SPLINTERWOOD")) SPLINTERWOOD = lValue; + else if (!Bstrcmp(szLabel,"SCALE")) SCALE = lValue; + else if (!Bstrcmp(szLabel,"STATUE")) STATUE = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE1")) SUSHIPLATE1 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE2")) SUSHIPLATE2 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE3")) SUSHIPLATE3 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE4")) SUSHIPLATE4 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE5")) SUSHIPLATE5 = lValue; + else if (!Bstrcmp(szLabel,"STATUEFLASH")) STATUEFLASH = lValue; + else if (!Bstrcmp(szLabel,"STRIPEBALL")) STRIPEBALL = lValue; + else if (!Bstrcmp(szLabel,"SPOTLITE")) SPOTLITE = lValue; + else if (!Bstrcmp(szLabel,"SEENINE")) SEENINE = lValue; + else if (!Bstrcmp(szLabel,"SEENINEDEAD")) SEENINEDEAD = lValue; + else if (!Bstrcmp(szLabel,"STEAM")) STEAM = lValue; + else if (!Bstrcmp(szLabel,"SPACEMARINE")) SPACEMARINE = lValue; + else if (!Bstrcmp(szLabel,"SCRATCH")) SCRATCH = lValue; + else if (!Bstrcmp(szLabel,"SHARK")) SHARK = lValue; + else if (!Bstrcmp(szLabel,"SPIT")) SPIT = lValue; + else if (!Bstrcmp(szLabel,"SHRINKSPARK")) SHRINKSPARK = lValue; + else if (!Bstrcmp(szLabel,"SHRINKEREXPLOSION")) SHRINKEREXPLOSION = lValue; + else if (!Bstrcmp(szLabel,"SMALLSMOKE")) SMALLSMOKE = lValue; + else if (!Bstrcmp(szLabel,"SMALLSMOKEMAKER")) SMALLSMOKEMAKER = lValue; + else if (!Bstrcmp(szLabel,"SCRAP6")) SCRAP6 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP1")) SCRAP1 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP2")) SCRAP2 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP3")) SCRAP3 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP4")) SCRAP4 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP5")) SCRAP5 = lValue; + else if (!Bstrcmp(szLabel,"SELECTDIR")) SELECTDIR = lValue; + else if (!Bstrcmp(szLabel,"STEROIDS_ICON")) STEROIDS_ICON = lValue; + else if (!Bstrcmp(szLabel,"SLIDEBAR")) SLIDEBAR = lValue; + else if (!Bstrcmp(szLabel,"SHELL")) SHELL = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNSHELL")) SHOTGUNSHELL = lValue; + else if (!Bstrcmp(szLabel,"SHRINKER")) SHRINKER = lValue; + else if (!Bstrcmp(szLabel,"SCUBAMASK")) SCUBAMASK = lValue; + else if (!Bstrcmp(szLabel,"SPACEMASK")) SPACEMASK = lValue; + else if (!Bstrcmp(szLabel,"SHOTSPARK1")) SHOTSPARK1 = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUN")) SHOTGUN = lValue; + else if (!Bstrcmp(szLabel,"SPINNINGNUKEICON")) SPINNINGNUKEICON = lValue; + else if (!Bstrcmp(szLabel,"SMALLFNTCURSOR")) SMALLFNTCURSOR = lValue; + else if (!Bstrcmp(szLabel,"STARTALPHANUM")) STARTALPHANUM = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK14")) SCREENBREAK14 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK15")) SCREENBREAK15 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK19")) SCREENBREAK19 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK16")) SCREENBREAK16 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK17")) SCREENBREAK17 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK18")) SCREENBREAK18 = lValue; + else if (!Bstrcmp(szLabel,"SPEAKER")) SPEAKER = lValue; + else if (!Bstrcmp(szLabel,"SIDEBOLT1")) SIDEBOLT1 = lValue; + else if (!Bstrcmp(szLabel,"SKINNEDCHICKEN")) SKINNEDCHICKEN = lValue; + else if (!Bstrcmp(szLabel,"SHOPPINGCART")) SHOPPINGCART = lValue; + else if (!Bstrcmp(szLabel,"SNAKEP")) SNAKEP = lValue; + else if (!Bstrcmp(szLabel,"SIGN1")) SIGN1 = lValue; + else if (!Bstrcmp(szLabel,"SIGN2")) SIGN2 = lValue; + break; + case 'T': + if (!Bstrcmp(szLabel,"TOUCHPLATE")) TOUCHPLATE = lValue; + else if (!Bstrcmp(szLabel,"TRIPBOMBSPRITE")) TRIPBOMBSPRITE = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHT2")) TECHLIGHT2 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHTBUST2")) TECHLIGHTBUST2 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHT4")) TECHLIGHT4 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHTBUST4")) TECHLIGHTBUST4 = lValue; + else if (!Bstrcmp(szLabel,"TECHSWITCH")) TECHSWITCH = lValue; + else if (!Bstrcmp(szLabel,"TOILET")) TOILET = lValue; + else if (!Bstrcmp(szLabel,"TOILETBROKE")) TOILETBROKE = lValue; + else if (!Bstrcmp(szLabel,"TREE1")) TREE1 = lValue; + else if (!Bstrcmp(szLabel,"TREE2")) TREE2 = lValue; + else if (!Bstrcmp(szLabel,"TOILETWATER")) TOILETWATER = lValue; + else if (!Bstrcmp(szLabel,"TIRE")) TIRE = lValue; + else if (!Bstrcmp(szLabel,"TRANSPORTERBEAM")) TRANSPORTERBEAM = lValue; + else if (!Bstrcmp(szLabel,"TRASH")) TRASH = lValue; + else if (!Bstrcmp(szLabel,"TRANSPORTERSTAR")) TRANSPORTERSTAR = lValue; + else if (!Bstrcmp(szLabel,"TONGUE")) TONGUE = lValue; + else if (!Bstrcmp(szLabel,"TANK")) TANK = lValue; + else if (!Bstrcmp(szLabel,"TITLE")) TITLE = lValue; + else if (!Bstrcmp(szLabel,"TEXTBOX")) TEXTBOX = lValue; + else if (!Bstrcmp(szLabel,"THREEDEE")) THREEDEE = lValue; + else if (!Bstrcmp(szLabel,"TENSCREEN")) TENSCREEN = lValue; + else if (!Bstrcmp(szLabel,"TRIPBOMB")) TRIPBOMB = lValue; + else if (!Bstrcmp(szLabel,"TIP")) TIP = lValue; + else if (!Bstrcmp(szLabel,"THREEBYFIVE")) THREEBYFIVE = lValue; + else if (!Bstrcmp(szLabel,"TEXTSTORY")) TEXTSTORY = lValue; + else if (!Bstrcmp(szLabel,"TARGET")) TARGET = lValue; + else if (!Bstrcmp(szLabel,"TOPSECRET")) TOPSECRET = lValue; + else if (!Bstrcmp(szLabel,"TEDDYBEAR")) TEDDYBEAR = lValue; + else if (!Bstrcmp(szLabel,"TRIPODCAMERA")) TRIPODCAMERA = lValue; + else if (!Bstrcmp(szLabel,"TAMPON")) TAMPON = lValue; + else if (!Bstrcmp(szLabel,"TOUGHGAL")) TOUGHGAL = lValue; + break; + case 'U': + if (!Bstrcmp(szLabel,"USERWEAPON")) USERWEAPON = lValue; + break; + case 'V': + if (!Bstrcmp(szLabel,"VIEWSCREEN2")) VIEWSCREEN2 = lValue; + else if (!Bstrcmp(szLabel,"VIEWSCREENBROKE")) VIEWSCREENBROKE = lValue; + else if (!Bstrcmp(szLabel,"VIEWSCREEN")) VIEWSCREEN = lValue; + else if (!Bstrcmp(szLabel,"VACUUM")) VACUUM = lValue; + else if (!Bstrcmp(szLabel,"VASE")) VASE = lValue; + else if (!Bstrcmp(szLabel,"VENDMACHINE")) VENDMACHINE = lValue; + else if (!Bstrcmp(szLabel,"VENDMACHINEBROKE")) VENDMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"VIEWBORDER")) VIEWBORDER = lValue; + else if (!Bstrcmp(szLabel,"VICTORY1")) VICTORY1 = lValue; + break; + case 'W': + if (!Bstrcmp(szLabel,"WALLLIGHT4")) WALLLIGHT4 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST4")) WALLLIGHTBUST4 = lValue; + else if (!Bstrcmp(szLabel,"W_LIGHT")) W_LIGHT = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL1")) W_TECHWALL1 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL2")) W_TECHWALL2 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL15")) W_TECHWALL15 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL3")) W_TECHWALL3 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL4")) W_TECHWALL4 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL10")) W_TECHWALL10 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL16")) W_TECHWALL16 = lValue; + else if (!Bstrcmp(szLabel,"WATERTILE2")) WATERTILE2 = lValue; + else if (!Bstrcmp(szLabel,"WATERTILE")) WATERTILE = lValue; + else if (!Bstrcmp(szLabel,"W_SCREENBREAK")) W_SCREENBREAK = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL3")) W_HITTECHWALL3 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL4")) W_HITTECHWALL4 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL2")) W_HITTECHWALL2 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL1")) W_HITTECHWALL1 = lValue; + else if (!Bstrcmp(szLabel,"WATERFOUNTAIN")) WATERFOUNTAIN = lValue; + else if (!Bstrcmp(szLabel,"WATERFOUNTAINBROKE")) WATERFOUNTAINBROKE = lValue; + else if (!Bstrcmp(szLabel,"W_NUMBERS")) W_NUMBERS = lValue; + else if (!Bstrcmp(szLabel,"WATERDRIP")) WATERDRIP = lValue; + else if (!Bstrcmp(szLabel,"WATERBUBBLE")) WATERBUBBLE = lValue; + else if (!Bstrcmp(szLabel,"WATERBUBBLEMAKER")) WATERBUBBLEMAKER = lValue; + else if (!Bstrcmp(szLabel,"W_FORCEFIELD")) W_FORCEFIELD = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT3")) WALLLIGHT3 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST3")) WALLLIGHTBUST3 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT1")) WALLLIGHT1 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST1")) WALLLIGHTBUST1 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT2")) WALLLIGHT2 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST2")) WALLLIGHTBUST2 = lValue; + else if (!Bstrcmp(szLabel,"WAITTOBESEATED")) WAITTOBESEATED = lValue; + else if (!Bstrcmp(szLabel,"WOODENHORSE")) WOODENHORSE = lValue; + else if (!Bstrcmp(szLabel,"WATERSPLASH2")) WATERSPLASH2 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD1")) WALLBLOOD1 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD2")) WALLBLOOD2 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD3")) WALLBLOOD3 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD4")) WALLBLOOD4 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD5")) WALLBLOOD5 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD6")) WALLBLOOD6 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD7")) WALLBLOOD7 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD8")) WALLBLOOD8 = lValue; + else if (!Bstrcmp(szLabel,"WATERDRIPSPLASH")) WATERDRIPSPLASH = lValue; + else if (!Bstrcmp(szLabel,"WINDOWBORDER1")) WINDOWBORDER1 = lValue; + else if (!Bstrcmp(szLabel,"WINDOWBORDER2")) WINDOWBORDER2 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL11")) W_TECHWALL11 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL12")) W_TECHWALL12 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL13")) W_TECHWALL13 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL14")) W_TECHWALL14 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL5")) W_TECHWALL5 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL6")) W_TECHWALL6 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL7")) W_TECHWALL7 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL8")) W_TECHWALL8 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL9")) W_TECHWALL9 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL16")) W_HITTECHWALL16 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL10")) W_HITTECHWALL10 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL15")) W_HITTECHWALL15 = lValue; + else if (!Bstrcmp(szLabel,"W_MILKSHELF")) W_MILKSHELF = lValue; + else if (!Bstrcmp(szLabel,"W_MILKSHELFBROKE")) W_MILKSHELFBROKE = lValue; + else if (!Bstrcmp(szLabel,"WETFLOOR")) WETFLOOR = lValue; + else if (!Bstrcmp(szLabel,"WOMAN")) WOMAN = lValue; + else if (!Bstrcmp(szLabel,"WEATHERWARN")) WEATHERWARN = lValue; + break; + case 'X': + if (!Bstrcmp(szLabel,"XXXSTACY")) XXXSTACY = lValue; + break; } } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 9019de4bf..93987e2be 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -257,21 +257,21 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm) switch (parm->numparms) { - case 1: // bpp switch - newbpp = Batol(parm->parms[0]); - break; - case 2: // res switch - newwidth = Batol(parm->parms[0]); - newheight = Batol(parm->parms[1]); - break; - case 3: // res & bpp switch - case 4: - newwidth = Batol(parm->parms[0]); - newheight = Batol(parm->parms[1]); - newbpp = Batol(parm->parms[2]); - if (parm->numparms == 4) - newfs = (Batol(parm->parms[3]) != 0); - break; + case 1: // bpp switch + newbpp = Batol(parm->parms[0]); + break; + case 2: // res switch + newwidth = Batol(parm->parms[0]); + newheight = Batol(parm->parms[1]); + break; + case 3: // res & bpp switch + case 4: + newwidth = Batol(parm->parms[0]); + newheight = Batol(parm->parms[1]); + newbpp = Batol(parm->parms[2]); + if (parm->numparms == 4) + newfs = (Batol(parm->parms[3]) != 0); + break; } if (setgamemode(newfs,newwidth,newheight,newbpp)) @@ -334,58 +334,58 @@ static int osdcmd_spawn(const osdfuncparm_t *parm) switch (parm->numparms) { - case 7: // x,y,z - x = Batol(parm->parms[4]); - y = Batol(parm->parms[5]); - z = Batol(parm->parms[6]); - set |= 8; - case 4: // ang - ang = Batol(parm->parms[3]) & 2047; - set |= 4; - case 3: // cstat - cstat = (unsigned short)Batol(parm->parms[2]); - set |= 2; - case 2: // pal - pal = (unsigned char)Batol(parm->parms[1]); - set |= 1; - case 1: // tile number - if (isdigit(parm->parms[0][0])) + case 7: // x,y,z + x = Batol(parm->parms[4]); + y = Batol(parm->parms[5]); + z = Batol(parm->parms[6]); + set |= 8; + case 4: // ang + ang = Batol(parm->parms[3]) & 2047; + set |= 4; + case 3: // cstat + cstat = (unsigned short)Batol(parm->parms[2]); + set |= 2; + case 2: // pal + pal = (unsigned char)Batol(parm->parms[1]); + set |= 1; + case 1: // tile number + if (isdigit(parm->parms[0][0])) + { + picnum = (unsigned short)Batol(parm->parms[0]); + } + else + { + int i,j; + for (j=0; j<2; j++) { - picnum = (unsigned short)Batol(parm->parms[0]); - } - else - { - int i,j; - for (j=0; j<2; j++) + for (i=0; iparms[0])) || + (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])) + ) { - if ( - (j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) || - (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])) - ) - { - picnum = (unsigned short)labelcode[i]; - break; - } + picnum = (unsigned short)labelcode[i]; + break; } - if (i= MAXTILES) + if (i==labelcnt) { - OSD_Printf("spawn: Invalid tile number\n"); + OSD_Printf("spawn: Invalid tile label given\n"); return OSDCMD_OK; } - break; - default: - return OSDCMD_SHOWHELP; + } + + if (picnum >= MAXTILES) + { + OSD_Printf("spawn: Invalid tile number\n"); + return OSDCMD_OK; + } + break; + default: + return OSDCMD_SHOWHELP; } idx = spawn(ps[myconnectindex].i, (short)picnum); @@ -552,46 +552,46 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm) else switch (cvar[i].type&0x7f) { - case CVAR_INT: - case CVAR_UNSIGNEDINT: - case CVAR_BOOL: + case CVAR_INT: + case CVAR_UNSIGNEDINT: + case CVAR_BOOL: + { + int val; + if (showval) { - int val; - if (showval) - { - OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr); - return OSDCMD_OK; - } - - val = atoi(parm->parms[0]); - if (cvar[i].type == CVAR_BOOL) val = val != 0; - - if (val < cvar[i].min || val > cvar[i].max) - { - OSD_Printf("%s value out of range\n",cvar[i].name); - return OSDCMD_OK; - } - *(int*)cvar[i].var = val; - OSD_Printf("%s %d",cvar[i].name,val); + OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr); + return OSDCMD_OK; } - break; - case CVAR_STRING: + + val = atoi(parm->parms[0]); + if (cvar[i].type == CVAR_BOOL) val = val != 0; + + if (val < cvar[i].min || val > cvar[i].max) { - if (showval) - { - OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr); - return OSDCMD_OK; - } - else - { - Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1); - ((char*)cvar[i].var)[cvar[i].extra-1] = 0; - OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var); - } + OSD_Printf("%s value out of range\n",cvar[i].name); + return OSDCMD_OK; } + *(int*)cvar[i].var = val; + OSD_Printf("%s %d",cvar[i].name,val); + } + break; + case CVAR_STRING: + { + if (showval) + { + OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr); + return OSDCMD_OK; + } + else + { + Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1); + ((char*)cvar[i].var)[cvar[i].extra-1] = 0; + OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var); + } + } + break; + default: break; - default: - break; } if (cvar[i].type&256) updatenames(); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index facf1e6b0..cf31c1d02 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -275,17 +275,17 @@ short aim(spritetype *s,short aang,short atwith) return -1; else switch (dynamictostatic[atwith]) { - case TONGUE__STATIC: - case FREEZEBLAST__STATIC: - case SHRINKSPARK__STATIC: - case SHRINKER__STATIC: - case RPG__STATIC: - case FIRELASER__STATIC: - case SPIT__STATIC: - case COOLEXPLOSION1__STATIC: - return -1; - default: - break; + case TONGUE__STATIC: + case FREEZEBLAST__STATIC: + case SHRINKSPARK__STATIC: + case SHRINKER__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + return -1; + default: + break; } } } @@ -1027,461 +1027,455 @@ DOSKIPBULLETHOLE: { switch (dynamictostatic[atwith]) { - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - - if (p >= 0) - sa += 64 - (TRAND&127); - else sa += 1024 + 64 - (TRAND&127); - zvel = 1024-(TRAND&2047); - case KNEE__STATIC: - if (atwith == KNEE) - { - if (p >= 0) - { - zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; - sz += (6<<8); - sa += 15; - } - else - { - j = ps[findplayer(s,&x)].i; - zvel = ((sprite[j].z-sz)<<8) / (x+1); - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); - } - } - - // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - hitscan(sx,sy,sz,sect, - sintable[(sa+512)&2047], - sintable[sa&2047],zvel<<6, - &hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - - if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) - { - if (FindDistance2D(sx-hitx,sy-hity) < 1024) - if (hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && hitsect >= 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - sector[hitsect].lotag == 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (16<<8)) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) - { - if (wall[hitwall].nextsector >= 0) - { - k = headspritesect[wall[hitwall].nextsector]; - while (k >= 0) - { - if (sprite[k].statnum == 3 && sprite[k].lotag == 13) - return -1; - k = nextspritesect[k]; - } - } - - if (wall[hitwall].nextwall >= 0 && - wall[wall[hitwall].nextwall].hitag != 0) - return -1; - - if (wall[hitwall].hitag == 0) - { - k = spawn(i,atwith); - sprite[k].xvel = -12; - sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - sprite[k].x = hitx; - sprite[k].y = hity; - sprite[k].z = hitz; - sprite[k].cstat |= (TRAND&4); - ssp(k,CLIPMASK0); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - if (PN == OOZFILTER || PN == NEWBEAST) - sprite[k].pal = 6; - } - } - return -1; - } - - if (hitsect < 0) break; - - if ((klabs(sx-hitx)+klabs(sy-hity)) < 1024) - { - if (hitwall >= 0 || hitspr >= 0) - { - j = EGS(hitsect,hitx,hity,hitz,KNEE,-15,0,0,sa,32,0,i,4); - sprite[j].extra += (TRAND&7); - if (p >= 0) - { - k = spawn(j,SMALLSMOKE); - sprite[k].z -= (8<<8); - spritesound(KICK_HIT,j); - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; - } - - if (p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400) - sprite[j].extra += (max_player_health>>2); - - if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) - { - checkhitsprite(hitspr,j); - if (p >= 0) checkhitswitch(p,hitspr,1); - } - - else if (hitwall >= 0) - { - if (wall[hitwall].cstat&2) - if (wall[hitwall].nextsector >= 0) - if (hitz >= (sector[wall[hitwall].nextsector].floorz)) - hitwall = wall[hitwall].nextwall; - - if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) - { - checkhitwall(j,hitwall,hitx,hity,hitz,atwith); - if (p >= 0) checkhitswitch(p,hitwall,0); - } - } - } - else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) - { - j = spawn(ps[p].i,WATERSPLASH2); - sprite[j].x = hitx; - sprite[j].y = hity; - sprite[j].ang = ps[p].ang; // Total tweek - sprite[j].xvel = 32; - ssp(i,CLIPMASK0); - sprite[j].xvel = 0; - - } - } - - break; - - case SHOTSPARK1__STATIC: - case SHOTGUN__STATIC: - case CHAINGUN__STATIC: - - if (s->extra >= 0) s->shade = -96; + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + if (p >= 0) + sa += 64 - (TRAND&127); + else sa += 1024 + 64 - (TRAND&127); + zvel = 1024-(TRAND&2047); + case KNEE__STATIC: + if (atwith == KNEE) + { if (p >= 0) { - int angRange; - int zRange; - - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) - { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); - } - if (j >= 0) - { - dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) - { - - dal -= (8<<8); - - } - zvel = ((sprite[j].z-sz-dal)<<8) / ldist(&sprite[ps[p].i], &sprite[j]) ; - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); - } - - angRange=32; - zRange=256; - SetGameVarID(g_iAngRangeVarID,32, i,p); - SetGameVarID(g_iZRangeVarID,256,i,p); - OnEvent(EVENT_GETSHOTRANGE, i,p, -1); - angRange=GetGameVarID(g_iAngRangeVarID,i,p); - zRange=GetGameVarID(g_iZRangeVarID,i,p); - - sa += (angRange/2)-(TRAND&(angRange-1)); - if (j == -1) - { - // no target - zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; - } - zvel += (zRange/2)-(TRAND&(zRange-1)); - sz -= (2<<8); + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + sz += (6<<8); + sa += 15; } else { - j = findplayer(s,&x); - sz -= (4<<8); - zvel = ((ps[j].posz-sz) <<8) / (ldist(&sprite[ps[j].i], s)); - if (s->picnum != BOSS1) - { - zvel += 128-(TRAND&255); - sa += 32-(TRAND&63); - } - else - { - zvel += 128-(TRAND&255); - sa = getangle(ps[j].posx-sx,ps[j].posy-sy)+64-(TRAND&127); - } + j = ps[findplayer(s,&x)].i; + zvel = ((sprite[j].z-sz)<<8) / (x+1); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } + } - s->cstat &= ~257; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - hitscan(sx,sy,sz,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - s->cstat |= 257; + // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047],zvel<<6, + &hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - if (hitsect < 0) return -1; - - if ((TRAND&15) == 0 && sector[hitsect].lotag == 2) - tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); - - if (p >= 0) - { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].extra += (TRAND%6); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; - - - if (hitwall == -1 && hitspr == -1) - { - if (zvel < 0) - { - if (sector[hitsect].ceilingstat&1) + if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) + { + if (FindDistance2D(sx-hitx,sy-hity) < 1024) + if (hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE) + if ((wall[hitwall].nextsector >= 0 && hitsect >= 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + sector[hitsect].lotag == 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (16<<8)) || + (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) + if ((wall[hitwall].cstat&16) == 0) { - sprite[k].xrepeat = 0; - sprite[k].yrepeat = 0; - return -1; + if (wall[hitwall].nextsector >= 0) + { + k = headspritesect[wall[hitwall].nextsector]; + while (k >= 0) + { + if (sprite[k].statnum == 3 && sprite[k].lotag == 13) + return -1; + k = nextspritesect[k]; + } + } + + if (wall[hitwall].nextwall >= 0 && + wall[wall[hitwall].nextwall].hitag != 0) + return -1; + + if (wall[hitwall].hitag == 0) + { + k = spawn(i,atwith); + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + sprite[k].x = hitx; + sprite[k].y = hity; + sprite[k].z = hitz; + sprite[k].cstat |= (TRAND&4); + ssp(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + if (PN == OOZFILTER || PN == NEWBEAST) + sprite[k].pal = 6; + } } - else - checkhitceiling(hitsect); - } - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; - } + return -1; + } - if (hitspr >= 0) + if (hitsect < 0) break; + + if ((klabs(sx-hitx)+klabs(sy-hity)) < 1024) + { + if (hitwall >= 0 || hitspr >= 0) + { + j = EGS(hitsect,hitx,hity,hitz,KNEE,-15,0,0,sa,32,0,i,4); + sprite[j].extra += (TRAND&7); + if (p >= 0) { - checkhitsprite(hitspr,k); - if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_FLAG_TDM) && ps[sprite[hitspr].yvel].team != ps[sprite[i].yvel].team))) - { - l = spawn(k,JIBS6); - sprite[k].xrepeat = sprite[k].yrepeat = 0; - sprite[l].z += (4<<8); - sprite[l].xvel = 16; - sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(TRAND&127); - } - else - { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; - } - - if (p >= 0 && ( - sprite[hitspr].picnum == DIPSWITCH || - sprite[hitspr].picnum == DIPSWITCH+1 || - sprite[hitspr].picnum == DIPSWITCH2 || - sprite[hitspr].picnum == DIPSWITCH2+1 || - sprite[hitspr].picnum == DIPSWITCH3 || - sprite[hitspr].picnum == DIPSWITCH3+1 || - sprite[hitspr].picnum == HANDSWITCH || - sprite[hitspr].picnum == HANDSWITCH+1)) - { - checkhitswitch(p,hitspr,1); - return -1; - } + k = spawn(j,SMALLSMOKE); + sprite[k].z -= (8<<8); + spritesound(KICK_HIT,j); + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; } + + if (p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400) + sprite[j].extra += (max_player_health>>2); + + if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) + { + checkhitsprite(hitspr,j); + if (p >= 0) checkhitswitch(p,hitspr,1); + } + else if (hitwall >= 0) { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; - - if (isadoorwall(wall[hitwall].picnum) == 1) - goto SKIPBULLETHOLE; - if (p >= 0 && ( - wall[hitwall].picnum == DIPSWITCH || - wall[hitwall].picnum == DIPSWITCH+1 || - wall[hitwall].picnum == DIPSWITCH2 || - wall[hitwall].picnum == DIPSWITCH2+1 || - wall[hitwall].picnum == DIPSWITCH3 || - wall[hitwall].picnum == DIPSWITCH3+1 || - wall[hitwall].picnum == HANDSWITCH || - wall[hitwall].picnum == HANDSWITCH+1)) - { - checkhitswitch(p,hitwall,0); - return -1; - } - - if (wall[hitwall].hitag != 0 || (wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0)) - goto SKIPBULLETHOLE; - - if (hitsect >= 0 && sector[hitsect].lotag == 0) - if (wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) - { - if (wall[hitwall].nextsector >= 0) - { - l = headspritesect[wall[hitwall].nextsector]; - while (l >= 0) - { - if (sprite[l].statnum == 3 && sprite[l].lotag == 13) - goto SKIPBULLETHOLE; - l = nextspritesect[l]; - } - } - - l = headspritestat[5]; - while (l >= 0) - { - if (sprite[l].picnum == BULLETHOLE) - if (dist(&sprite[l],&sprite[k]) < (12+(TRAND&7))) - goto SKIPBULLETHOLE; - l = nextspritestat[l]; - } - l = spawn(k,BULLETHOLE); - sprite[l].xvel = -1; - sprite[l].x = hitx; - sprite[l].y = hity; - sprite[l].z = hitz; - - sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - - sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); - sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - ssp(l,CLIPMASK0); - } - -SKIPBULLETHOLE: - if (wall[hitwall].cstat&2) if (wall[hitwall].nextsector >= 0) if (hitz >= (sector[wall[hitwall].nextsector].floorz)) hitwall = wall[hitwall].nextwall; - checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); - } - } - else - { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; - - if (hitspr >= 0) - { - checkhitsprite(hitspr,k); - if (sprite[hitspr].picnum != APLAYER) + if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; + checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + if (p >= 0) checkhitswitch(p,hitwall,0); } - else sprite[k].xrepeat = sprite[k].yrepeat = 0; - } - else if (hitwall >= 0) - checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); - } - - if ((TRAND&255) < 4) - xyzsound(PISTOL_RICOCHET,k,hitx,hity,hitz); - - return -1; - - case FIRELASER__STATIC: - case SPIT__STATIC: - case COOLEXPLOSION1__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - if (atwith == SPIT) vel = 292; - else - { - if (atwith == COOLEXPLOSION1) - { - if (s->picnum == BOSS2) vel = 644; - else vel = 348; - sz -= (4<<7); - } - else - { - vel = 840; - sz -= (4<<7); } } - - if (p >= 0) + else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) - { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); - } + j = spawn(ps[p].i,WATERSPLASH2); + sprite[j].x = hitx; + sprite[j].y = hity; + sprite[j].ang = ps[p].ang; // Total tweek + sprite[j].xvel = 32; + ssp(i,CLIPMASK0); + sprite[j].xvel = 0; - if (j >= 0) + } + } + + break; + + case SHOTSPARK1__STATIC: + case SHOTGUN__STATIC: + case CHAINGUN__STATIC: + + if (s->extra >= 0) s->shade = -96; + + if (p >= 0) + { + int angRange; + int zRange; + + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + { + j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + } + if (j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) { - dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); - zvel = ((sprite[j].z-sz-dal)*vel) / ldist(&sprite[ps[p].i], &sprite[j]) ; - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + + dal -= (8<<8); + } - else - zvel = (100-ps[p].horiz-ps[p].horizoff)*98; + zvel = ((sprite[j].z-sz-dal)<<8) / ldist(&sprite[ps[p].i], &sprite[j]) ; + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + + angRange=32; + zRange=256; + SetGameVarID(g_iAngRangeVarID,32, i,p); + SetGameVarID(g_iZRangeVarID,256,i,p); + OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + angRange=GetGameVarID(g_iAngRangeVarID,i,p); + zRange=GetGameVarID(g_iZRangeVarID,i,p); + + sa += (angRange/2)-(TRAND&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + } + zvel += (zRange/2)-(TRAND&(zRange-1)); + sz -= (2<<8); + } + else + { + j = findplayer(s,&x); + sz -= (4<<8); + zvel = ((ps[j].posz-sz) <<8) / (ldist(&sprite[ps[j].i], s)); + if (s->picnum != BOSS1) + { + zvel += 128-(TRAND&255); + sa += 32-(TRAND&63); } else { - j = findplayer(s,&x); - // sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); - sa += 16-(TRAND&31); - zvel = (((ps[j].oposz - sz + (3<<8)))*vel) / ldist(&sprite[ps[j].i],s); + zvel += 128-(TRAND&255); + sa = getangle(ps[j].posx-sx,ps[j].posy-sy)+64-(TRAND&127); } - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - oldzvel = zvel; + } - if (atwith == SPIT) + s->cstat &= ~257; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + s->cstat |= 257; + + if (hitsect < 0) return -1; + + if ((TRAND&15) == 0 && sector[hitsect].lotag == 2) + tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); + + if (p >= 0) + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].extra += (TRAND%6); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + + if (hitwall == -1 && hitspr == -1) { - sizx = 18; - sizy = 18,sz -= (10<<8); - } - else - { - if (atwith == FIRELASER) + if (zvel < 0) { - if (p >= 0) + if (sector[hitsect].ceilingstat&1) { - - sizx = 34; - sizy = 34; + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return -1; } else - { - sizx = 18; - sizy = 18; - } + checkhitceiling(hitsect); + } + l = spawn(k,SMALLSMOKE); + hittype[l].temp_data[6] = hitwall; + hittype[l].temp_data[7] = hitsect; + hittype[l].temp_data[8] = hitspr; + } + + if (hitspr >= 0) + { + checkhitsprite(hitspr,k); + if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_FLAG_TDM) && ps[sprite[hitspr].yvel].team != ps[sprite[i].yvel].team))) + { + l = spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(TRAND&127); + } + else + { + l = spawn(k,SMALLSMOKE); + hittype[l].temp_data[6] = hitwall; + hittype[l].temp_data[7] = hitsect; + hittype[l].temp_data[8] = hitspr; + } + + if (p >= 0 && ( + sprite[hitspr].picnum == DIPSWITCH || + sprite[hitspr].picnum == DIPSWITCH+1 || + sprite[hitspr].picnum == DIPSWITCH2 || + sprite[hitspr].picnum == DIPSWITCH2+1 || + sprite[hitspr].picnum == DIPSWITCH3 || + sprite[hitspr].picnum == DIPSWITCH3+1 || + sprite[hitspr].picnum == HANDSWITCH || + sprite[hitspr].picnum == HANDSWITCH+1)) + { + checkhitswitch(p,hitspr,1); + return -1; + } + } + else if (hitwall >= 0) + { + l = spawn(k,SMALLSMOKE); + hittype[l].temp_data[6] = hitwall; + hittype[l].temp_data[7] = hitsect; + hittype[l].temp_data[8] = hitspr; + + if (isadoorwall(wall[hitwall].picnum) == 1) + goto SKIPBULLETHOLE; + if (p >= 0 && ( + wall[hitwall].picnum == DIPSWITCH || + wall[hitwall].picnum == DIPSWITCH+1 || + wall[hitwall].picnum == DIPSWITCH2 || + wall[hitwall].picnum == DIPSWITCH2+1 || + wall[hitwall].picnum == DIPSWITCH3 || + wall[hitwall].picnum == DIPSWITCH3+1 || + wall[hitwall].picnum == HANDSWITCH || + wall[hitwall].picnum == HANDSWITCH+1)) + { + checkhitswitch(p,hitwall,0); + return -1; + } + + if (wall[hitwall].hitag != 0 || (wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0)) + goto SKIPBULLETHOLE; + + if (hitsect >= 0 && sector[hitsect].lotag == 0) + if (wall[hitwall].overpicnum != BIGFORCE) + if ((wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0) || + (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) + if ((wall[hitwall].cstat&16) == 0) + { + if (wall[hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitwall].nextsector]; + while (l >= 0) + { + if (sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto SKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[5]; + while (l >= 0) + { + if (sprite[l].picnum == BULLETHOLE) + if (dist(&sprite[l],&sprite[k]) < (12+(TRAND&7))) + goto SKIPBULLETHOLE; + l = nextspritestat[l]; + } + l = spawn(k,BULLETHOLE); + sprite[l].xvel = -1; + sprite[l].x = hitx; + sprite[l].y = hity; + sprite[l].z = hitz; + + sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + ssp(l,CLIPMASK0); + } + +SKIPBULLETHOLE: + + if (wall[hitwall].cstat&2) + if (wall[hitwall].nextsector >= 0) + if (hitz >= (sector[wall[hitwall].nextsector].floorz)) + hitwall = wall[hitwall].nextwall; + + checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + } + } + else + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + if (hitspr >= 0) + { + checkhitsprite(hitspr,k); + if (sprite[hitspr].picnum != APLAYER) + { + l = spawn(k,SMALLSMOKE); + hittype[l].temp_data[6] = hitwall; + hittype[l].temp_data[7] = hitsect; + hittype[l].temp_data[8] = hitspr; + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if (hitwall >= 0) + checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + } + + if ((TRAND&255) < 4) + xyzsound(PISTOL_RICOCHET,k,hitx,hity,hitz); + + return -1; + + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + if (atwith == SPIT) vel = 292; + else + { + if (atwith == COOLEXPLOSION1) + { + if (s->picnum == BOSS2) vel = 644; + else vel = 348; + sz -= (4<<7); + } + else + { + vel = 840; + sz -= (4<<7); + } + } + + if (p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + { + j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); + zvel = ((sprite[j].z-sz-dal)*vel) / ldist(&sprite[ps[p].i], &sprite[j]) ; + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else + zvel = (100-ps[p].horiz-ps[p].horizoff)*98; + } + else + { + j = findplayer(s,&x); + // sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); + sa += 16-(TRAND&31); + zvel = (((ps[j].oposz - sz + (3<<8)))*vel) / ldist(&sprite[ps[j].i],s); + } + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + oldzvel = zvel; + + if (atwith == SPIT) + { + sizx = 18; + sizy = 18,sz -= (10<<8); + } + else + { + if (atwith == FIRELASER) + { + if (p >= 0) + { + + sizx = 34; + sizy = 34; } else { @@ -1489,378 +1483,384 @@ SKIPBULLETHOLE: sizy = 18; } } - - if (p >= 0) sizx = 7,sizy = 7; - - while (scount > 0) - { - j = EGS(sect,sx,sy,sz,atwith,-127,sizx,sizy,sa,vel,zvel,i,4); - sprite[j].extra += (TRAND&7); - - if (atwith == COOLEXPLOSION1) - { - sprite[j].shade = 0; - if (PN == BOSS2) - { - l = sprite[j].xvel; - sprite[j].xvel = 1024; - ssp(j,CLIPMASK0); - sprite[j].xvel = l; - sprite[j].ang += 128-(TRAND&255); - } - } - - sprite[j].cstat = 128; - sprite[j].clipdist = 4; - - sa = s->ang+32-(TRAND&63); - zvel = oldzvel+512-(TRAND&1023); - - scount--; - } - - return j; - - case FREEZEBLAST__STATIC: - sz += (3<<8); - case RPG__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - vel = 644; - - j = -1; - - if (p >= 0) - { - // j = aim( s, AUTO_AIM_ANGLE ); // 48 - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) - { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); - zvel = ((sprite[j].z-sz-dal)*vel) / ldist(&sprite[ps[p].i], &sprite[j]); - if (sprite[j].picnum != RECON) - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); - } - else zvel = (100-ps[p].horiz-ps[p].horizoff)*81; - if (atwith == RPG) - spritesound(RPG_SHOOT,i); - - } else { - j = findplayer(s,&x); - sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); - if (PN == BOSS3) - sz -= (32<<8); - else if (PN == BOSS2) - { - vel += 128; - sz += 24<<8; - } - - l = ldist(&sprite[ps[j].i],s); - zvel = ((ps[j].oposz-sz)*vel) / l; - - if (badguy(s) && (s->hitag&face_player_smart)) - sa = s->ang+(TRAND&31)-16; + sizx = 18; + sizy = 18; } + } - if (p >= 0 && j >= 0) - l = j; - else l = -1; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - j = EGS(sect, - sx+(sintable[(348+sa+512)&2047]/448), - sy+(sintable[(sa+348)&2047]/448), - sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + if (p >= 0) sizx = 7,sizy = 7; + while (scount > 0) + { + j = EGS(sect,sx,sy,sz,atwith,-127,sizx,sizy,sa,vel,zvel,i,4); sprite[j].extra += (TRAND&7); - if (atwith != FREEZEBLAST) - sprite[j].yvel = l; - else - { - sprite[j].yvel = numfreezebounces; - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; - sprite[j].zvel -= (2<<4); - } - if (p == -1) + if (atwith == COOLEXPLOSION1) { - if (PN == BOSS3) + sprite[j].shade = 0; + if (PN == BOSS2) { - if (TRAND&1) - { - sprite[j].x -= sintable[sa&2047]>>6; - sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang -= 8; - } - else - { - sprite[j].x += sintable[sa&2047]>>6; - sprite[j].y += sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang += 4; - } - sprite[j].xrepeat = 42; - sprite[j].yrepeat = 42; + l = sprite[j].xvel; + sprite[j].xvel = 1024; + ssp(j,CLIPMASK0); + sprite[j].xvel = l; + sprite[j].ang += 128-(TRAND&255); } - else if (PN == BOSS2) - { - sprite[j].x -= sintable[sa&2047]/56; - sprite[j].y -= sintable[(sa+1024+512)&2047]/56; - sprite[j].ang -= 8+(TRAND&255)-128; - sprite[j].xrepeat = 24; - sprite[j].yrepeat = 24; - } - else if (atwith != FREEZEBLAST) - { - sprite[j].xrepeat = 30; - sprite[j].yrepeat = 30; - sprite[j].extra >>= 2; - } - } - - else if (*aplWeaponWorksLike[ps[p].curr_weapon] == DEVISTATOR_WEAPON) - { - sprite[j].extra >>= 2; - sprite[j].ang += 16-(TRAND&31); - sprite[j].zvel += 256-(TRAND&511); - - if (ps[p].hbomb_hold_delay) - { - sprite[j].x -= sintable[sa&2047]/644; - sprite[j].y -= sintable[(sa+1024+512)&2047]/644; - } - else - { - sprite[j].x += sintable[sa&2047]>>8; - sprite[j].y += sintable[(sa+1024+512)&2047]>>8; - } - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; } sprite[j].cstat = 128; + sprite[j].clipdist = 4; + + sa = s->ang+32-(TRAND&63); + zvel = oldzvel+512-(TRAND&1023); + + scount--; + } + + return j; + + case FREEZEBLAST__STATIC: + sz += (3<<8); + case RPG__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + vel = 644; + + j = -1; + + if (p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); // 48 + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + { + j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + zvel = ((sprite[j].z-sz-dal)*vel) / ldist(&sprite[ps[p].i], &sprite[j]); + if (sprite[j].picnum != RECON) + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else zvel = (100-ps[p].horiz-ps[p].horizoff)*81; if (atwith == RPG) - sprite[j].clipdist = 4; - else - sprite[j].clipdist = 40; + spritesound(RPG_SHOOT,i); - break; + } + else + { + j = findplayer(s,&x); + sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); + if (PN == BOSS3) + sz -= (32<<8); + else if (PN == BOSS2) + { + vel += 128; + sz += 24<<8; + } - case HANDHOLDINGLASER__STATIC: + l = ldist(&sprite[ps[j].i],s); + zvel = ((ps[j].oposz-sz)*vel) / l; - if (p >= 0) - zvel = (100-ps[p].horiz-ps[p].horizoff)*32; - else zvel = 0; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - hitscan(sx,sy,sz-ps[p].pyoff,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + if (badguy(s) && (s->hitag&face_player_smart)) + sa = s->ang+(TRAND&31)-16; + } - j = 0; - if (hitspr >= 0) break; + if (p >= 0 && j >= 0) + l = j; + else l = -1; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + j = EGS(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - if (hitwall >= 0 && hitsect >= 0) - if (((hitx-sx)*(hitx-sx)+(hity-sy)*(hity-sy)) < (290*290)) + sprite[j].extra += (TRAND&7); + if (atwith != FREEZEBLAST) + sprite[j].yvel = l; + else + { + sprite[j].yvel = numfreezebounces; + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + + if (p == -1) + { + if (PN == BOSS3) + { + if (TRAND&1) { - if (wall[hitwall].nextsector >= 0) - { - if (sector[wall[hitwall].nextsector].lotag <= 2 && sector[hitsect].lotag <= 2) - j = 1; - } - else if (sector[hitsect].lotag <= 2) + sprite[j].x -= sintable[sa&2047]>>6; + sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang -= 8; + } + else + { + sprite[j].x += sintable[sa&2047]>>6; + sprite[j].y += sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang += 4; + } + sprite[j].xrepeat = 42; + sprite[j].yrepeat = 42; + } + else if (PN == BOSS2) + { + sprite[j].x -= sintable[sa&2047]/56; + sprite[j].y -= sintable[(sa+1024+512)&2047]/56; + sprite[j].ang -= 8+(TRAND&255)-128; + sprite[j].xrepeat = 24; + sprite[j].yrepeat = 24; + } + else if (atwith != FREEZEBLAST) + { + sprite[j].xrepeat = 30; + sprite[j].yrepeat = 30; + sprite[j].extra >>= 2; + } + } + + else if (*aplWeaponWorksLike[ps[p].curr_weapon] == DEVISTATOR_WEAPON) + { + sprite[j].extra >>= 2; + sprite[j].ang += 16-(TRAND&31); + sprite[j].zvel += 256-(TRAND&511); + + if (ps[p].hbomb_hold_delay) + { + sprite[j].x -= sintable[sa&2047]/644; + sprite[j].y -= sintable[(sa+1024+512)&2047]/644; + } + else + { + sprite[j].x += sintable[sa&2047]>>8; + sprite[j].y += sintable[(sa+1024+512)&2047]>>8; + } + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + } + + sprite[j].cstat = 128; + if (atwith == RPG) + sprite[j].clipdist = 4; + else + sprite[j].clipdist = 40; + + break; + + case HANDHOLDINGLASER__STATIC: + + if (p >= 0) + zvel = (100-ps[p].horiz-ps[p].horizoff)*32; + else zvel = 0; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz-ps[p].pyoff,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + j = 0; + if (hitspr >= 0) break; + + if (hitwall >= 0 && hitsect >= 0) + if (((hitx-sx)*(hitx-sx)+(hity-sy)*(hity-sy)) < (290*290)) + { + if (wall[hitwall].nextsector >= 0) + { + if (sector[wall[hitwall].nextsector].lotag <= 2 && sector[hitsect].lotag <= 2) j = 1; } - - if (j == 1) - { - long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, ps[p].i, p); - k = EGS(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); - if (lTripBombControl & TRIPBOMB_TIMER) - { - long lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, ps[p].i, p); - long lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, ps[p].i, p); - // set timer. blows up when at zero.... - hittype[k].temp_data[7]=lLifetime - + mulscale(krand(),lLifetimeVar, 14) - - lLifetimeVar; - hittype[k].temp_data[6]=1; - } - else - - sprite[k].hitag = k; - spritesound(LASERTRIP_ONWALL,k); - sprite[k].xvel = -20; - ssp(k,CLIPMASK0); - sprite[k].cstat = 16; - hittype[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; - - + else if (sector[hitsect].lotag <= 2) + j = 1; } - return j?k:-1; - case BOUNCEMINE__STATIC: - case MORTER__STATIC: - - if (s->extra >= 0) s->shade = -96; - - j = ps[findplayer(s,&x)].i; - x = ldist(&sprite[j],s); - - zvel = -x>>1; - - if (zvel < -4096) - zvel = -2048; - vel = x>>4; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - EGS(sect, - sx+(sintable[(512+sa+512)&2047]>>8), - sy+(sintable[(sa+512)&2047]>>8), - sz+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); - break; - - case GROWSPARK__STATIC: - - if (p >= 0) + if (j == 1) + { + long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, ps[p].i, p); + k = EGS(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); + if (lTripBombControl & TRIPBOMB_TIMER) { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) - { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); - } + long lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, ps[p].i, p); + long lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, ps[p].i, p); + // set timer. blows up when at zero.... + hittype[k].temp_data[7]=lLifetime + + mulscale(krand(),lLifetimeVar, 14) + - lLifetimeVar; + hittype[k].temp_data[6]=1; + } + else - if (j >= 0) - { - dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) - { - dal -= (8<<8); + sprite[k].hitag = k; + spritesound(LASERTRIP_ONWALL,k); + sprite[k].xvel = -20; + ssp(k,CLIPMASK0); + sprite[k].cstat = 16; + hittype[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; - } - zvel = ((sprite[j].z-sz-dal)<<8) / (ldist(&sprite[ps[p].i], &sprite[j])); - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); - } - else - { - sa += 16-(TRAND&31); - zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; - zvel += 128-(TRAND&255); - } - sz -= (2<<8); + } + return j?k:-1; + + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + + if (s->extra >= 0) s->shade = -96; + + j = ps[findplayer(s,&x)].i; + x = ldist(&sprite[j],s); + + zvel = -x>>1; + + if (zvel < -4096) + zvel = -2048; + vel = x>>4; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + EGS(sect, + sx+(sintable[(512+sa+512)&2047]>>8), + sy+(sintable[(sa+512)&2047]>>8), + sz+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); + break; + + case GROWSPARK__STATIC: + + if (p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + { + j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) + { + dal -= (8<<8); + + } + zvel = ((sprite[j].z-sz-dal)<<8) / (ldist(&sprite[ps[p].i], &sprite[j])); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } else { - j = findplayer(s,&x); - sz -= (4<<8); - zvel = ((ps[j].posz-sz) <<8) / (ldist(&sprite[ps[j].i], s)); + sa += 16-(TRAND&31); + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; zvel += 128-(TRAND&255); - sa += 32-(TRAND&63); } - k = 0; + sz -= (2<<8); + } + else + { + j = findplayer(s,&x); + sz -= (4<<8); + zvel = ((ps[j].posz-sz) <<8) / (ldist(&sprite[ps[j].i], s)); + zvel += 128-(TRAND&255); + sa += 32-(TRAND&63); + } - // RESHOOTGROW: + k = 0; - s->cstat &= ~257; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - hitscan(sx,sy,sz,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + // RESHOOTGROW: - s->cstat |= 257; + s->cstat &= ~257; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - j = EGS(sect,hitx,hity,hitz,GROWSPARK,-16,28,28,sa,0,0,i,1); + s->cstat |= 257; - sprite[j].pal = 2; - sprite[j].cstat |= 130; - sprite[j].xrepeat = sprite[j].yrepeat = 1; + j = EGS(sect,hitx,hity,hitz,GROWSPARK,-16,28,28,sa,0,0,i,1); - if (hitwall == -1 && hitspr == -1 && hitsect >= 0) - { - if (zvel < 0 && (sector[hitsect].ceilingstat&1) == 0) - checkhitceiling(hitsect); - } - else if (hitspr >= 0) checkhitsprite(hitspr,j); - else if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) - { - /* if(wall[hitwall].overpicnum == MIRROR && k == 0) - { - l = getangle( - wall[wall[hitwall].point2].x-wall[hitwall].x, - wall[wall[hitwall].point2].y-wall[hitwall].y); + sprite[j].pal = 2; + sprite[j].cstat |= 130; + sprite[j].xrepeat = sprite[j].yrepeat = 1; - sx = hitx; - sy = hity; - sz = hitz; - sect = hitsect; - sa = ((l<<1) - sa)&2047; - sx += sintable[(sa+512)&2047]>>12; - sy += sintable[sa&2047]>>12; - - k++; - goto RESHOOTGROW; - } - else */ - checkhitwall(j,hitwall,hitx,hity,hitz,atwith); - } - - break; - - case SHRINKER__STATIC: - if (s->extra >= 0) s->shade = -96; - if (p >= 0) - { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (hitwall == -1 && hitspr == -1 && hitsect >= 0) + { + if (zvel < 0 && (sector[hitsect].ceilingstat&1) == 0) + checkhitceiling(hitsect); + } + else if (hitspr >= 0) checkhitsprite(hitspr,j); + else if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) + { + /* if(wall[hitwall].overpicnum == MIRROR && k == 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); - } + l = getangle( + wall[wall[hitwall].point2].x-wall[hitwall].x, + wall[wall[hitwall].point2].y-wall[hitwall].y); - if (j >= 0) - { - dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1); - zvel = ((sprite[j].z-sz-dal-(4<<8))*768) / (ldist(&sprite[ps[p].i], &sprite[j])); - sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + sx = hitx; + sy = hity; + sz = hitz; + sect = hitsect; + sa = ((l<<1) - sa)&2047; + sx += sintable[(sa+512)&2047]>>12; + sy += sintable[sa&2047]>>12; + + k++; + goto RESHOOTGROW; } - else zvel = (100-ps[p].horiz-ps[p].horizoff)*98; - } - else if (s->statnum != 3) + else */ + checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + } + + break; + + case SHRINKER__STATIC: + if (s->extra >= 0) s->shade = -96; + if (p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) { - j = findplayer(s,&x); - l = ldist(&sprite[ps[j].i],s); - zvel = ((ps[j].oposz-sz)*512) / l ; + j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); } - else zvel = 0; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - j = EGS(sect, - sx+(sintable[(512+sa+512)&2047]>>12), - sy+(sintable[(sa+512)&2047]>>12), - sz+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); - sprite[j].cstat = 128; - sprite[j].clipdist = 32; + if (j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1); + zvel = ((sprite[j].z-sz-dal-(4<<8))*768) / (ldist(&sprite[ps[p].i], &sprite[j])); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else zvel = (100-ps[p].horiz-ps[p].horizoff)*98; + } + else if (s->statnum != 3) + { + j = findplayer(s,&x); + l = ldist(&sprite[ps[j].i],s); + zvel = ((ps[j].oposz-sz)*512) / l ; + } + else zvel = 0; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + j = EGS(sect, + sx+(sintable[(512+sa+512)&2047]>>12), + sy+(sintable[(sa+512)&2047]>>12), + sz+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); + + sprite[j].cstat = 128; + sprite[j].clipdist = 32; - return j; + return j; } } return -1; @@ -2120,19 +2120,19 @@ void myospalw(long x, long y, short tilenum, signed char shade, char orientation { switch (g_currentweapon) { - case PISTOL_WEAPON: - case CHAINGUN_WEAPON: - case RPG_WEAPON: - case FREEZE_WEAPON: - case SHRINKER_WEAPON: - case GROW_WEAPON: - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - case SHOTGUN_WEAPON: - rotatesprite(160<<16,(180+(ps[screenpeek].weapon_pos*ps[screenpeek].weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); - break; + case PISTOL_WEAPON: + case CHAINGUN_WEAPON: + case RPG_WEAPON: + case FREEZE_WEAPON: + case SHRINKER_WEAPON: + case GROW_WEAPON: + case DEVISTATOR_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: + case SHOTGUN_WEAPON: + rotatesprite(160<<16,(180+(ps[screenpeek].weapon_pos*ps[screenpeek].weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); + break; } } } @@ -2237,454 +2237,413 @@ void displayweapon(short snum) { - case KNEE_WEAPON: + case KNEE_WEAPON: - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if ((*kb) > 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - { - pal = sector[p->cursectnum].floorpal; - if (pal == 0) - pal = p->palookup; - } - - if ((*kb) < 5 || (*kb) > 9) - myospal(weapon_xoffset+220-(p->look_ang>>1), - looking_arc+250-gun_pos,KNEE,gs,o,pal); - else - myospal(weapon_xoffset+160-(p->look_ang>>1), - looking_arc+214-gun_pos,KNEE+1,gs,o,pal); - } - } - break; - - case TRIPBOMB_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - - weapon_xoffset += 8; - gun_pos -= 10; - - if ((*kb) > 6) - looking_arc += ((*kb)<<3); - else if ((*kb) < 4) - myospalw(weapon_xoffset+142-(p->look_ang>>1), - looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); - - myospalw(weapon_xoffset+130-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); - myospalw(weapon_xoffset+152-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); - } - break; - - case RPG_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else pal = sector[p->cursectnum].floorpal; - - weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; - gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; - - if (*kb > 0) - { - if (*kb < 8) - { - myospalw(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN+((*kb)>>1),gs,o,pal); - } - } - - myospalw(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN,gs,o,pal); - } - break; - - case SHOTGUN_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - - - weapon_xoffset -= 8; - - switch (*kb) - { - case 1: - case 2: - myospalw(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, - SHOTGUN+2,-128,o,pal); - case 0: - case 6: - case 7: - case 8: - myospalw(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, - SHOTGUN,gs,o,pal); - break; - case 3: - case 4: - case 5: - case 9: - case 10: - case 11: - case 12: - if (*kb > 1 && *kb < 5) - { - gun_pos -= 40; - weapon_xoffset += 20; - - myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, - SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); - } - - myospalw(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, - SHOTGUN+3,gs,o,pal); - - break; - case 13: - case 14: - case 15: - myospalw(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, - SHOTGUN+4,gs,o,pal); - break; - case 16: - case 17: - case 18: - case 19: - myospalw(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - break; - case 20: - case 21: - case 22: - case 23: - myospalw(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+6,gs,o,pal); - break; - case 24: - case 25: - case 26: - case 27: - myospalw(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - break; - case 28: - case 29: - case 30: - myospalw(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, - SHOTGUN+4,gs,o,pal); - break; - } - } - break; - - - case CHAINGUN_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - - if (*kb > 0) - gun_pos -= sintable[(*kb)<<7]>>12; - - if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); - - myospalw(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, - CHAINGUN,gs,o,pal); - switch (*kb) - { - case 0: - myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - default: - if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) - { - i = 0; - if (sprite[p->i].pal != 1) i = rand()&7; - myospalw(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - if (sprite[p->i].pal != 1) i = rand()&7; - myospalw(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - } - if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) - { - i = rand()&7; - myospalw(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-2)/5),gs,o,pal); - myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1+((*kb)>>1),gs,o,pal); - } - else myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - } - } - break; - - case PISTOL_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - - if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) - { - short kb_frames[] = {0,1,2},l; - - l = 195-12+weapon_xoffset; - - if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) - l -= 3; - - myospalw((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); - } - else - { - - if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) - myospalw(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) - { - myospalw(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); - myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) - { - myospalw(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); - myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - } - - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) - { - myospalw(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); - myospalw(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) - { - myospalw(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); - myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) - myospalw(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); - - } - } - - break; - case HANDBOMB_WEAPON: + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) { - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + if ((*kb) > 0) { if (sprite[p->i].pal == 1) pal = 1; else - pal = sector[p->cursectnum].floorpal; - - if ((*kb)) { - if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) - { - - char throw_frames[] - = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; - - if ((*kb) < 7) - gun_pos -= 10*(*kb); //D - else if ((*kb) < 12) - gun_pos += 20*((*kb)-10); //U - else if ((*kb) < 20) - gun_pos -= 9*((*kb)-14); //D - - myospalw(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); - } + pal = sector[p->cursectnum].floorpal; + if (pal == 0) + pal = p->palookup; } + + if ((*kb) < 5 || (*kb) > 9) + myospal(weapon_xoffset+220-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o,pal); else - myospalw(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + myospal(weapon_xoffset+160-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o,pal); } } break; - case HANDREMOTE_WEAPON: - { - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - signed char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; + case TRIPBOMB_WEAPON: - weapon_xoffset = -48; - if ((*kb)) - myospalw(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); - else - myospalw(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + weapon_xoffset += 8; + gun_pos -= 10; + + if ((*kb) > 6) + looking_arc += ((*kb)<<3); + else if ((*kb) < 4) + myospalw(weapon_xoffset+142-(p->look_ang>>1), + looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); + + myospalw(weapon_xoffset+130-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); + myospalw(weapon_xoffset+152-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); + } + break; + + case RPG_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else pal = sector[p->cursectnum].floorpal; + + weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; + gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; + + if (*kb > 0) + { + if (*kb < 8) + { + myospalw(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN+((*kb)>>1),gs,o,pal); + } + } + + myospalw(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN,gs,o,pal); + } + break; + + case SHOTGUN_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + + weapon_xoffset -= 8; + + switch (*kb) + { + case 1: + case 2: + myospalw(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, + SHOTGUN+2,-128,o,pal); + case 0: + case 6: + case 7: + case 8: + myospalw(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, + SHOTGUN,gs,o,pal); + break; + case 3: + case 4: + case 5: + case 9: + case 10: + case 11: + case 12: + if (*kb > 1 && *kb < 5) + { + gun_pos -= 40; + weapon_xoffset += 20; + + myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, + SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); + } + + myospalw(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, + SHOTGUN+3,gs,o,pal); + + break; + case 13: + case 14: + case 15: + myospalw(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, + SHOTGUN+4,gs,o,pal); + break; + case 16: + case 17: + case 18: + case 19: + myospalw(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 20: + case 21: + case 22: + case 23: + myospalw(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+6,gs,o,pal); + break; + case 24: + case 25: + case 26: + case 27: + myospalw(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 28: + case 29: + case 30: + myospalw(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, + SHOTGUN+4,gs,o,pal); + break; } } break; - case DEVISTATOR_WEAPON: - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + case CHAINGUN_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if (*kb > 0) + gun_pos -= sintable[(*kb)<<7]>>12; + + if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); + + myospalw(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal); + switch (*kb) { - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - - if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + case 0: + myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + default: + if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) { - char cycloidy[] = {0,4,12,24,12,4,0}; - - i = ksgn((*kb)>>2); - - if (p->hbomb_hold_delay) - { - myospalw((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); - myospalw(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); - } - else - { - myospalw(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); - myospalw(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); - } + i = 0; + if (sprite[p->i].pal != 1) i = rand()&7; + myospalw(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + if (sprite[p->i].pal != 1) i = rand()&7; + myospalw(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); } - else + if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) { - myospalw(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + i = rand()&7; + myospalw(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-2)/5),gs,o,pal); + myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1+((*kb)>>1),gs,o,pal); + } + else myospalw(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + } + } + break; + + case PISTOL_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) + { + short kb_frames[] = {0,1,2},l; + + l = 195-12+weapon_xoffset; + + if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) + l -= 3; + + myospalw((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); + } + else + { + + if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) + myospalw(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) + { + myospalw(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); + myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) + { + myospalw(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); + myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) + { + myospalw(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); + myospalw(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) + { + myospalw(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); + myospalw(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) + myospalw(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); + + } + } + + break; + case HANDBOMB_WEAPON: + { + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if ((*kb)) + { + if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) + { + + char throw_frames[] + = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; + + if ((*kb) < 7) + gun_pos -= 10*(*kb); //D + else if ((*kb) < 12) + gun_pos += 20*((*kb)-10); //U + else if ((*kb) < 20) + gun_pos -= 9*((*kb)-14); //D + + myospalw(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); + } + } + else + myospalw(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + } + } + break; + + case HANDREMOTE_WEAPON: + { + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + signed char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + weapon_xoffset = -48; + if ((*kb)) + myospalw(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); + else + myospalw(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + } + } + break; + + case DEVISTATOR_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + { + char cycloidy[] = {0,4,12,24,12,4,0}; + + i = ksgn((*kb)>>2); + + if (p->hbomb_hold_delay) + { + myospalw((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); myospalw(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); } - } - break; - - case FREEZE_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; else - pal = sector[p->cursectnum].floorpal; - - if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) { - char cat_frames[] = { 0,0,1,1,2,2 }; - - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - looking_arc += rand()&3; - } - gun_pos -= 16; - myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); - myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); - } - else myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); - } - break; - - case GROW_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) - { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - { - if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) - { - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - gun_pos += (rand()&3); - } - - myospalw(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,2); - - myospalw(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); - } - else - { - myospalw(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+2, - 16-(sintable[p->random_club_frame&2047]>>10), - o,2); - - myospalw(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); - } + myospalw(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); + myospalw(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); } } - break; - - case SHRINKER_WEAPON: - - SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + else { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else - pal = sector[p->cursectnum].floorpal; - if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + myospalw(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + myospalw(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + } + } + break; + + case FREEZE_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) + { + char cat_frames[] = { 0,0,1,1,2,2 }; + + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + looking_arc += rand()&3; + } + gun_pos -= 16; + myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); + myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); + } + else myospalw(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); + } + break; + + case GROW_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + { + if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) { if (sprite[p->i].pal != 1) { @@ -2694,24 +2653,65 @@ void displayweapon(short snum) myospalw(weapon_xoffset+184-(p->look_ang>>1), looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,0); + o,2); myospalw(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); - + looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); } else { myospalw(weapon_xoffset+184-(p->look_ang>>1), looking_arc+240-gun_pos,SHRINKER+2, 16-(sintable[p->random_club_frame&2047]>>10), - o,0); + o,2); myospalw(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); } } - break; + } + break; + + case SHRINKER_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if (GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + { + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + myospalw(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,0); + + myospalw(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); + + } + else + { + myospalw(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,0); + + myospalw(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + } + } + break; } } @@ -3162,15 +3162,15 @@ char doincrements(struct player_struct *p) checkhitswitch(snum,p->access_spritenum,1); switch (sprite[p->access_spritenum].pal) { - case 0: - p->got_access &= (0xffff-0x1); - break; - case 21: - p->got_access &= (0xffff-0x2); - break; - case 23: - p->got_access &= (0xffff-0x4); - break; + case 0: + p->got_access &= (0xffff-0x1); + break; + case 21: + p->got_access &= (0xffff-0x2); + break; + case 23: + p->got_access &= (0xffff-0x4); + break; } p->access_spritenum = -1; } @@ -3179,15 +3179,15 @@ char doincrements(struct player_struct *p) checkhitswitch(snum,p->access_wallnum,0); switch (wall[p->access_wallnum].pal) { - case 0: - p->got_access &= (0xffff-0x1); - break; - case 21: - p->got_access &= (0xffff-0x2); - break; - case 23: - p->got_access &= (0xffff-0x4); - break; + case 0: + p->got_access &= (0xffff-0x1); + break; + case 21: + p->got_access &= (0xffff-0x2); + break; + case 23: + p->got_access &= (0xffff-0x4); + break; } } } @@ -3275,10 +3275,10 @@ void checkweapons(struct player_struct *p) spawn(p->i,weapon_sprites[cw]); else switch (cw) { - case RPG_WEAPON: - case HANDBOMB_WEAPON: - spawn(p->i,EXPLOSION2); - break; + case RPG_WEAPON: + case HANDBOMB_WEAPON: + spawn(p->i,EXPLOSION2); + break; } } } @@ -3592,41 +3592,41 @@ void processinput(short snum) { switch (dynamictostatic[hittype[p->i].picnum]) { - case KNEE__STATIC: - if (hittype[p->i].temp_data[1] == 1) - i = 7; - else i = 0; - break; - case SHOTSPARK1__STATIC: - switch (ps[p->frag_ps].curr_weapon) - { - default: - case PISTOL_WEAPON: - i = 1; - break; - case SHOTGUN_WEAPON: - i = 2; - break; - case CHAINGUN_WEAPON: - i = 3; - break; - } - break; - case RPG__STATIC: - i = 4; - break; - case RADIUSEXPLOSION__STATIC: - i = 5; - break; - case SHRINKSPARK__STATIC: - i = 6; - break; - case GROWSPARK__STATIC: - i = 8; - break; + case KNEE__STATIC: + if (hittype[p->i].temp_data[1] == 1) + i = 7; + else i = 0; + break; + case SHOTSPARK1__STATIC: + switch (ps[p->frag_ps].curr_weapon) + { default: - i = 0; + case PISTOL_WEAPON: + i = 1; break; + case SHOTGUN_WEAPON: + i = 2; + break; + case CHAINGUN_WEAPON: + i = 3; + break; + } + break; + case RPG__STATIC: + i = 4; + break; + case RADIUSEXPLOSION__STATIC: + i = 5; + break; + case SHRINKSPARK__STATIC: + i = 6; + break; + case GROWSPARK__STATIC: + i = 8; + break; + default: + i = 0; + break; } } Bstrcpy(name1,&ud.user_name[snum][0]); @@ -4014,18 +4014,18 @@ void processinput(short snum) { switch (TRAND&3) { - case 0: - j = spawn(pi,FOOTPRINTS); - break; - case 1: - j = spawn(pi,FOOTPRINTS2); - break; - case 2: - j = spawn(pi,FOOTPRINTS3); - break; - default: - j = spawn(pi,FOOTPRINTS4); - break; + case 0: + j = spawn(pi,FOOTPRINTS); + break; + case 1: + j = spawn(pi,FOOTPRINTS2); + break; + case 2: + j = spawn(pi,FOOTPRINTS3); + break; + default: + j = spawn(pi,FOOTPRINTS4); + break; } sprite[j].pal = p->footprintpal; sprite[j].shade = p->footprintshade; @@ -4254,59 +4254,59 @@ void processinput(short snum) { switch (dynamictostatic[j]) { - case HURTRAIL__STATIC: - if (rnd(32)) + case HURTRAIL__STATIC: + if (rnd(32)) + { + if (p->boot_amount > 0) + k = 1; + else { - if (p->boot_amount > 0) - k = 1; - else - { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); - p->pals[0] = 64; - p->pals[1] = 64; - p->pals[2] = 64; - p->pals_time = 32; - s->extra -= 1+(TRAND&3); - if (!isspritemakingsound(pi,SHORT_CIRCUIT)) - spritesound(SHORT_CIRCUIT,pi); - } + if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 64; + p->pals[1] = 64; + p->pals[2] = 64; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); + if (!isspritemakingsound(pi,SHORT_CIRCUIT)) + spritesound(SHORT_CIRCUIT,pi); } - break; - case FLOORSLIME__STATIC: - if (rnd(16)) + } + break; + case FLOORSLIME__STATIC: + if (rnd(16)) + { + if (p->boot_amount > 0) + k = 1; + else { - if (p->boot_amount > 0) - k = 1; - else - { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); - p->pals[0] = 0; - p->pals[1] = 8; - p->pals[2] = 0; - p->pals_time = 32; - s->extra -= 1+(TRAND&3); - } + if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 0; + p->pals[1] = 8; + p->pals[2] = 0; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); } - break; - case FLOORPLASMA__STATIC: - if (rnd(32)) + } + break; + case FLOORPLASMA__STATIC: + if (rnd(32)) + { + if (p->boot_amount > 0) + k = 1; + else { - if (p->boot_amount > 0) - k = 1; - else - { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); - p->pals[0] = 8; - p->pals[1] = 0; - p->pals[2] = 0; - p->pals_time = 32; - s->extra -= 1+(TRAND&3); - } + if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 8; + p->pals[1] = 0; + p->pals[2] = 0; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); } - break; + } + break; } } @@ -4331,26 +4331,26 @@ void processinput(short snum) { switch (psectlotag) { - case 0: + case 0: - if (lz >= 0 && (lz&(MAXSPRITES-1))==49152) - j = sprite[lz&(MAXSPRITES-1)].picnum; - else j = sector[psect].floorpicnum; + if (lz >= 0 && (lz&(MAXSPRITES-1))==49152) + j = sprite[lz&(MAXSPRITES-1)].picnum; + else j = sector[psect].floorpicnum; - switch (dynamictostatic[j]) - { - case PANNEL1__STATIC: - case PANNEL2__STATIC: - spritesound(DUKE_WALKINDUCTS,pi); - p->walking_snd_toggle = 1; - break; - } - break; - case 1: - if ((TRAND&1) == 0) - spritesound(DUKE_ONWATER,pi); + switch (dynamictostatic[j]) + { + case PANNEL1__STATIC: + case PANNEL2__STATIC: + spritesound(DUKE_WALKINDUCTS,pi); p->walking_snd_toggle = 1; break; + } + break; + case 1: + if ((TRAND&1) == 0) + spritesound(DUKE_ONWATER,pi); + p->walking_snd_toggle = 1; + break; } } } @@ -4630,22 +4630,22 @@ HORIZONLY: spritesound(SQUISHED,p->actorsqu); switch (dynamictostatic[sprite[p->actorsqu].picnum]) { - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case PODFEM1__STATIC: - case NAKED1__STATIC: - case STATUE__STATIC: - if (sprite[p->actorsqu].yvel) - operaterespawns(sprite[p->actorsqu].yvel); - break; + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + if (sprite[p->actorsqu].yvel) + operaterespawns(sprite[p->actorsqu].yvel); + break; } if (sprite[p->actorsqu].picnum == APLAYER) @@ -4744,128 +4744,128 @@ SHOOTINCODE: { switch (aplWeaponWorksLike[p->curr_weapon][snum]) { - case HANDBOMB_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + case HANDBOMB_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - p->hbomb_hold_delay = 0; - if (p->ammo_amount[p->curr_weapon] > 0) + p->hbomb_hold_delay = 0; + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb)=1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) { - (*kb)=1; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } - break; + } + break; - case HANDREMOTE_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - p->hbomb_hold_delay = 0; + case HANDREMOTE_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + p->hbomb_hold_delay = 0; + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + break; + + case SHOTGUN_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0) + { + (*kb)=1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case TRIPBOMB_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + long sx,sy,sz; + short sect,hw,hitsp; + + hitscan(p->posx, p->posy, p->posz, + p->cursectnum, sintable[(p->ang+512)&2047], + sintable[p->ang&2047], (100-p->horiz-p->horizoff)*32, + §, &hw, &hitsp, &sx, &sy, &sz,CLIPMASK1); + + if (sect < 0 || hitsp >= 0) + break; + + if (hw >= 0 && sector[sect].lotag > 2) + break; + + if (hw >= 0 && wall[hw].overpicnum >= 0) + if (wall[hw].overpicnum == BIGFORCE) + break; + + j = headspritesect[sect]; + while (j >= 0) + { + if (sprite[j].picnum == TRIPBOMB && + klabs(sprite[j].z-sz) < (12<<8) && ((sprite[j].x-sx)*(sprite[j].x-sx)+(sprite[j].y-sy)*(sprite[j].y-sy)) < (290*290)) + break; + j = nextspritesect[j]; + } + + if (j == -1 && hw >= 0 && (wall[hw].cstat&16) == 0) + if ((wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2) || (wall[hw].nextsector == -1 && sector[sect].lotag <= 2)) + if (((sx-p->posx)*(sx-p->posx) + (sy-p->posy)*(sy-p->posy)) < (290*290)) + { + p->posz = p->oposz; + p->poszv = 0; + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + } + break; + + case PISTOL_WEAPON: + case CHAINGUN_WEAPON: + case SHRINKER_WEAPON: + case GROW_WEAPON: + case FREEZE_WEAPON: + case RPG_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if (p->ammo_amount[p->curr_weapon] > 0) + { (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } - break; + } + break; - case SHOTGUN_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0) + case DEVISTATOR_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + if (aplWeaponInitialSound[p->curr_weapon][snum]) { - (*kb)=1; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } - break; + } + break; - case TRIPBOMB_WEAPON: - if (p->ammo_amount[p->curr_weapon] > 0) + case KNEE_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if (p->quick_kick == 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) { - long sx,sy,sz; - short sect,hw,hitsp; - - hitscan(p->posx, p->posy, p->posz, - p->cursectnum, sintable[(p->ang+512)&2047], - sintable[p->ang&2047], (100-p->horiz-p->horizoff)*32, - §, &hw, &hitsp, &sx, &sy, &sz,CLIPMASK1); - - if (sect < 0 || hitsp >= 0) - break; - - if (hw >= 0 && sector[sect].lotag > 2) - break; - - if (hw >= 0 && wall[hw].overpicnum >= 0) - if (wall[hw].overpicnum == BIGFORCE) - break; - - j = headspritesect[sect]; - while (j >= 0) - { - if (sprite[j].picnum == TRIPBOMB && - klabs(sprite[j].z-sz) < (12<<8) && ((sprite[j].x-sx)*(sprite[j].x-sx)+(sprite[j].y-sy)*(sprite[j].y-sy)) < (290*290)) - break; - j = nextspritesect[j]; - } - - if (j == -1 && hw >= 0 && (wall[hw].cstat&16) == 0) - if ((wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2) || (wall[hw].nextsector == -1 && sector[sect].lotag <= 2)) - if (((sx-p->posx)*(sx-p->posx) + (sy-p->posy)*(sy-p->posy)) < (290*290)) - { - p->posz = p->oposz; - p->poszv = 0; - (*kb) = 1; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } - } + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } - break; - - case PISTOL_WEAPON: - case CHAINGUN_WEAPON: - case SHRINKER_WEAPON: - case GROW_WEAPON: - case FREEZE_WEAPON: - case RPG_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - if (p->ammo_amount[p->curr_weapon] > 0) - { - (*kb) = 1; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } - } - break; - - case DEVISTATOR_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - if (p->ammo_amount[p->curr_weapon] > 0) - { - (*kb) = 1; - p->hbomb_hold_delay = !p->hbomb_hold_delay; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } - } - break; - - case KNEE_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); - if (p->quick_kick == 0) - { - (*kb) = 1; - if (aplWeaponInitialSound[p->curr_weapon][snum]) - { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); - } - } - break; + } + break; } } } @@ -5143,92 +5143,92 @@ int getspritescore(long snum, long dapicnum) { switch (dynamictostatic[dapicnum]) { - case FIRSTGUNSPRITE__STATIC: - return(20); - case CHAINGUNSPRITE__STATIC: - return(50); - case RPGSPRITE__STATIC: - return(200); - case FREEZESPRITE__STATIC: - return(25); - case SHRINKERSPRITE__STATIC: - return(80); - case HEAVYHBOMB__STATIC: - return(60); - case TRIPBOMBSPRITE__STATIC: - return(50); - case SHOTGUNSPRITE__STATIC: - return(120); - case DEVISTATORSPRITE__STATIC: - return(120); + case FIRSTGUNSPRITE__STATIC: + return(20); + case CHAINGUNSPRITE__STATIC: + return(50); + case RPGSPRITE__STATIC: + return(200); + case FREEZESPRITE__STATIC: + return(25); + case SHRINKERSPRITE__STATIC: + return(80); + case HEAVYHBOMB__STATIC: + return(60); + case TRIPBOMBSPRITE__STATIC: + return(50); + case SHOTGUNSPRITE__STATIC: + return(120); + case DEVISTATORSPRITE__STATIC: + return(120); - case FREEZEAMMO__STATIC: - if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10); - else return(0); - case AMMO__STATIC: - if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10); - else return(0); - case BATTERYAMMO__STATIC: - if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20); - else return(0); - case DEVISTATORAMMO__STATIC: - if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25); - else return(0); - case RPGAMMO__STATIC: - if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50); - else return(0); - case CRYSTALAMMO__STATIC: - if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10); - else return(0); - case HBOMBAMMO__STATIC: - if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30); - else return(0); - case SHOTGUNAMMO__STATIC: - if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25); - else return(0); + case FREEZEAMMO__STATIC: + if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10); + else return(0); + case AMMO__STATIC: + if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10); + else return(0); + case BATTERYAMMO__STATIC: + if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20); + else return(0); + case DEVISTATORAMMO__STATIC: + if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25); + else return(0); + case RPGAMMO__STATIC: + if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50); + else return(0); + case CRYSTALAMMO__STATIC: + if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10); + else return(0); + case HBOMBAMMO__STATIC: + if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30); + else return(0); + case SHOTGUNAMMO__STATIC: + if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25); + else return(0); - case COLA__STATIC: - if (sprite[ps[snum].i].extra < 100) return(10); - else return(0); - case SIXPAK__STATIC: - if (sprite[ps[snum].i].extra < 100) return(30); - else return(0); - case FIRSTAID__STATIC: - if (ps[snum].firstaid_amount < 100) return(100); - else return(0); - case SHIELD__STATIC: - if (ps[snum].shield_amount < 100) return(50); - else return(0); - case STEROIDS__STATIC: - if (ps[snum].steroids_amount < 400) return(30); - else return(0); - case AIRTANK__STATIC: - if (ps[snum].scuba_amount < 6400) return(30); - else return(0); - case JETPACK__STATIC: - if (ps[snum].jetpack_amount < 1600) return(100); - else return(0); - case HEATSENSOR__STATIC: - if (ps[snum].heat_amount < 1200) return(5); - else return(0); - case ACCESSCARD__STATIC: - return(1); - case BOOTS__STATIC: - if (ps[snum].boot_amount < 200) return(15); - else return(0); - case ATOMICHEALTH__STATIC: - if (sprite[ps[snum].i].extra < max_player_health<<1) return(50); - else return(0); - case HOLODUKE__STATIC: - if (ps[snum].holoduke_amount < 2400) return(5); - else return(0); + case COLA__STATIC: + if (sprite[ps[snum].i].extra < 100) return(10); + else return(0); + case SIXPAK__STATIC: + if (sprite[ps[snum].i].extra < 100) return(30); + else return(0); + case FIRSTAID__STATIC: + if (ps[snum].firstaid_amount < 100) return(100); + else return(0); + case SHIELD__STATIC: + if (ps[snum].shield_amount < 100) return(50); + else return(0); + case STEROIDS__STATIC: + if (ps[snum].steroids_amount < 400) return(30); + else return(0); + case AIRTANK__STATIC: + if (ps[snum].scuba_amount < 6400) return(30); + else return(0); + case JETPACK__STATIC: + if (ps[snum].jetpack_amount < 1600) return(100); + else return(0); + case HEATSENSOR__STATIC: + if (ps[snum].heat_amount < 1200) return(5); + else return(0); + case ACCESSCARD__STATIC: + return(1); + case BOOTS__STATIC: + if (ps[snum].boot_amount < 200) return(15); + else return(0); + case ATOMICHEALTH__STATIC: + if (sprite[ps[snum].i].extra < max_player_health<<1) return(50); + else return(0); + case HOLODUKE__STATIC: + if (ps[snum].holoduke_amount < 2400) return(5); + else return(0); - case SECTOREFFECTOR__STATIC: - return(1); - case TOUCHPLATE__STATIC: - return(1); - case MUSICANDSFX__STATIC: - return(1); + case SECTOREFFECTOR__STATIC: + return(1); + case TOUCHPLATE__STATIC: + return(1); + case MUSICANDSFX__STATIC: + return(1); } return(0); } @@ -5331,21 +5331,21 @@ void computergetinput(long snum, input *syn) { switch (dynamictostatic[sprite[j].picnum]) { - case TONGUE__STATIC: - k = 4; - break; - case FREEZEBLAST__STATIC: - k = 4; - break; - case SHRINKSPARK__STATIC: - k = 16; - break; - case RPG__STATIC: - k = 16; - break; - default: - k = 0; - break; + case TONGUE__STATIC: + k = 4; + break; + case FREEZEBLAST__STATIC: + k = 4; + break; + case SHRINKSPARK__STATIC: + k = 16; + break; + case RPG__STATIC: + k = 16; + break; + default: + k = 0; + break; } if (k) { diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 975fd0fbc..a9bb0702a 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -79,124 +79,124 @@ void cachespritenum(short i) switch (dynamictostatic[PN]) { - case HYDRENT__STATIC: - tloadtile(BROKEFIREHYDRENT,1); - for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); - break; - case TOILET__STATIC: - tloadtile(TOILETBROKE,1); - for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); - break; - case STALL__STATIC: - tloadtile(STALLBROKE,1); - for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); - break; - case RUBBERCAN__STATIC: - maxc = 2; - break; - case TOILETWATER__STATIC: - maxc = 4; - break; - case FEMPIC1__STATIC: - maxc = 44; - break; - case LIZTROOP__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPONTOILET__STATIC: - case LIZTROOPDUCKING__STATIC: - for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1); - for (j=HEADJIB1;j 1) + { maxc = 5; - for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1); - break; - case NEWBEAST__STATIC: - case NEWBEASTSTAYPUT__STATIC: - maxc = 90; - break; - case BOSS1__STATIC: - case BOSS2__STATIC: - case BOSS3__STATIC: - maxc = 30; - break; - case OCTABRAIN__STATIC: - case OCTABRAINSTAYPUT__STATIC: - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - maxc = 38; - break; - case RECON__STATIC: - maxc = 13; - break; - case PIGCOP__STATIC: - case PIGCOPDIVE__STATIC: - maxc = 61; - break; - case SHARK__STATIC: - maxc = 30; - break; - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - for (j=LIZMANHEAD1;j 1) - { - maxc = 5; - for (j = 1420;j < 1420+106; j++) tloadtile(j,1); - } - break; - case ATOMICHEALTH__STATIC: - maxc = 14; - break; - case DRONE__STATIC: - maxc = 10; - break; - case EXPLODINGBARREL__STATIC: - case SEENINE__STATIC: - case OOZFILTER__STATIC: - maxc = 3; - break; - case NUKEBARREL__STATIC: - case CAMERA1__STATIC: - maxc = 5; - break; - // caching of HUD sprites for weapons that may be in the level - case CHAINGUNSPRITE__STATIC: - for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1); - break; - case RPGSPRITE__STATIC: - for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1); - break; - case FREEZESPRITE__STATIC: - for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1); - break; - case GROWSPRITEICON__STATIC: - case SHRINKERSPRITE__STATIC: - for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1); - break; - case HBOMBAMMO__STATIC: - case HEAVYHBOMB__STATIC: - for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1); - break; - case TRIPBOMBSPRITE__STATIC: - for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1); - break; - case SHOTGUNSPRITE__STATIC: - tloadtile(SHOTGUNSHELL,1); - for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1); - break; - case DEVISTATORSPRITE__STATIC: - for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1); - break; + for (j = 1420;j < 1420+106; j++) tloadtile(j,1); + } + break; + case ATOMICHEALTH__STATIC: + maxc = 14; + break; + case DRONE__STATIC: + maxc = 10; + break; + case EXPLODINGBARREL__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + maxc = 3; + break; + case NUKEBARREL__STATIC: + case CAMERA1__STATIC: + maxc = 5; + break; + // caching of HUD sprites for weapons that may be in the level + case CHAINGUNSPRITE__STATIC: + for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1); + break; + case RPGSPRITE__STATIC: + for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1); + break; + case FREEZESPRITE__STATIC: + for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1); + break; + case GROWSPRITEICON__STATIC: + case SHRINKERSPRITE__STATIC: + for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1); + break; + case HBOMBAMMO__STATIC: + case HEAVYHBOMB__STATIC: + for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1); + break; + case TRIPBOMBSPRITE__STATIC: + for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1); + break; + case SHOTGUNSPRITE__STATIC: + tloadtile(SHOTGUNSHELL,1); + for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1); + break; + case DEVISTATORSPRITE__STATIC: + for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1); + break; } @@ -719,32 +719,32 @@ void setupbackdrop(short sky) switch (dynamictostatic[sky]) { - case CLOUDYOCEAN__STATIC: - parallaxyscale = 65536L; - break; - case MOONSKY1__STATIC : - pskyoff[6]=1; - pskyoff[1]=2; - pskyoff[4]=2; - pskyoff[2]=3; - break; - case BIGORBIT1__STATIC: // orbit - pskyoff[5]=1; - pskyoff[6]=2; - pskyoff[7]=3; - pskyoff[2]=4; - break; - case LA__STATIC: - parallaxyscale = 16384+1024; - pskyoff[0]=1; - pskyoff[1]=2; - pskyoff[2]=1; - pskyoff[3]=3; - pskyoff[4]=4; - pskyoff[5]=0; - pskyoff[6]=2; - pskyoff[7]=3; - break; + case CLOUDYOCEAN__STATIC: + parallaxyscale = 65536L; + break; + case MOONSKY1__STATIC : + pskyoff[6]=1; + pskyoff[1]=2; + pskyoff[4]=2; + pskyoff[2]=3; + break; + case BIGORBIT1__STATIC: // orbit + pskyoff[5]=1; + pskyoff[6]=2; + pskyoff[7]=3; + pskyoff[2]=4; + break; + case LA__STATIC: + parallaxyscale = 16384+1024; + pskyoff[0]=1; + pskyoff[1]=2; + pskyoff[2]=1; + pskyoff[3]=3; + pskyoff[4]=4; + pskyoff[5]=0; + pskyoff[6]=2; + pskyoff[7]=3; + break; } pskybits=3; @@ -770,11 +770,11 @@ void prelevel(char g) switch (sector[i].lotag) { - case 20: - case 22: - if (sector[i].floorz > sector[i].ceilingz) - sector[i].lotag |= 32768; - continue; + case 20: + case 22: + if (sector[i].floorz > sector[i].ceilingz) + sector[i].lotag |= 32768; + continue; } if (sector[i].ceilingstat&1) @@ -821,37 +821,37 @@ void prelevel(char g) } else switch (dynamictostatic[PN]) { - case GPSPEED__STATIC: - sector[SECT].extra = SLT; - deletesprite(i); - break; + case GPSPEED__STATIC: + sector[SECT].extra = SLT; + deletesprite(i); + break; - case CYCLER__STATIC: - if (numcyclers >= MAXCYCLERS) - { - Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); - gameexit(tempbuf); - } - cyclers[numcyclers][0] = SECT; - cyclers[numcyclers][1] = SLT; - cyclers[numcyclers][2] = SS; - cyclers[numcyclers][3] = sector[SECT].floorshade; - cyclers[numcyclers][4] = SHT; - cyclers[numcyclers][5] = (SA == 1536); - numcyclers++; - deletesprite(i); - break; + case CYCLER__STATIC: + if (numcyclers >= MAXCYCLERS) + { + Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); + gameexit(tempbuf); + } + cyclers[numcyclers][0] = SECT; + cyclers[numcyclers][1] = SLT; + cyclers[numcyclers][2] = SS; + cyclers[numcyclers][3] = sector[SECT].floorshade; + cyclers[numcyclers][4] = SHT; + cyclers[numcyclers][5] = (SA == 1536); + numcyclers++; + deletesprite(i); + break; - case SECTOREFFECTOR__STATIC: - case ACTIVATOR__STATIC: - case TOUCHPLATE__STATIC: - case ACTIVATORLOCKED__STATIC: - case MUSICANDSFX__STATIC: - case LOCATORS__STATIC: - case MASTERSWITCH__STATIC: - case RESPAWN__STATIC: - sprite[i].cstat = 0; - break; + case SECTOREFFECTOR__STATIC: + case ACTIVATOR__STATIC: + case TOUCHPLATE__STATIC: + case ACTIVATORLOCKED__STATIC: + case MUSICANDSFX__STATIC: + case LOCATORS__STATIC: + case MASTERSWITCH__STATIC: + case RESPAWN__STATIC: + sprite[i].cstat = 0; + break; } i = nexti; } @@ -880,39 +880,39 @@ void prelevel(char g) { switch (dynamictostatic[PN-1]) { - case DIPSWITCH__STATIC: - case DIPSWITCH2__STATIC: - case PULLSWITCH__STATIC: - case HANDSWITCH__STATIC: - case SLOTDOOR__STATIC: - case LIGHTSWITCH__STATIC: - case SPACELIGHTSWITCH__STATIC: - case SPACEDOORSWITCH__STATIC: - case FRANKENSTINESWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - for (j=0;j 64) + gameexit("\nToo many switches (64 max)."); + + j = headspritestat[3]; + while (j >= 0) { - lotags[lotaglist] = SLT; - lotaglist++; - if (lotaglist > 64) - gameexit("\nToo many switches (64 max)."); - - j = headspritestat[3]; - while (j >= 0) - { - if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) - hittype[j].temp_data[0] = 1; - j = nextspritestat[j]; - } + if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) + hittype[j].temp_data[0] = 1; + j = nextspritestat[j]; } - break; + } + break; } i = nextspritestat[i]; } @@ -956,105 +956,105 @@ void prelevel(char g) } switch (dynamictostatic[switchpicnum]) { - case FANSHADOW__STATIC: - case FANSPRITE__STATIC: - wall->cstat |= 65; - animwall[numanimwalls].wallnum = i; - numanimwalls++; - break; + case FANSHADOW__STATIC: + case FANSPRITE__STATIC: + wall->cstat |= 65; + animwall[numanimwalls].wallnum = i; + numanimwalls++; + break; - case W_FORCEFIELD__STATIC: - if (wal->overpicnum==W_FORCEFIELD__STATIC) - for (j=0;j<3;j++) - tloadtile(W_FORCEFIELD+j, 0); - if (wal->shade > 31) - wal->cstat = 0; - else wal->cstat |= 85+256; + case W_FORCEFIELD__STATIC: + if (wal->overpicnum==W_FORCEFIELD__STATIC) + for (j=0;j<3;j++) + tloadtile(W_FORCEFIELD+j, 0); + if (wal->shade > 31) + wal->cstat = 0; + else wal->cstat |= 85+256; - if (wal->lotag && wal->nextwall >= 0) - wall[wal->nextwall].lotag = - wal->lotag; + if (wal->lotag && wal->nextwall >= 0) + wall[wal->nextwall].lotag = + wal->lotag; - case BIGFORCE__STATIC: + case BIGFORCE__STATIC: - animwall[numanimwalls].wallnum = i; - numanimwalls++; + animwall[numanimwalls].wallnum = i; + numanimwalls++; - continue; + continue; } wal->extra = -1; switch (dynamictostatic[wal->picnum]) { - case WATERTILE2__STATIC: - for (j=0;j<3;j++) - tloadtile(wal->picnum+j, 0); - break; + case WATERTILE2__STATIC: + for (j=0;j<3;j++) + tloadtile(wal->picnum+j, 0); + break; - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: - tloadtile(wal->picnum, 0); - break; - case W_TECHWALL1__STATIC: - case W_TECHWALL2__STATIC: - case W_TECHWALL3__STATIC: - case W_TECHWALL4__STATIC: - animwall[numanimwalls].wallnum = i; - // animwall[numanimwalls].tag = -1; - numanimwalls++; - break; - case SCREENBREAK6__STATIC: - case SCREENBREAK7__STATIC: - case SCREENBREAK8__STATIC: - for (j=SCREENBREAK6;jpicnum, 0); + break; + case W_TECHWALL1__STATIC: + case W_TECHWALL2__STATIC: + case W_TECHWALL3__STATIC: + case W_TECHWALL4__STATIC: + animwall[numanimwalls].wallnum = i; + // animwall[numanimwalls].tag = -1; + numanimwalls++; + break; + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + for (j=SCREENBREAK6;jextra = wal->picnum; - animwall[numanimwalls].tag = -1; - if (ud.lockout) - { - if (wal->picnum == FEMPIC1) - wal->picnum = BLANKSCREEN; - else wal->picnum = SCREENBREAK6; - } + wal->extra = wal->picnum; + animwall[numanimwalls].tag = -1; + if (ud.lockout) + { + if (wal->picnum == FEMPIC1) + wal->picnum = BLANKSCREEN; + else wal->picnum = SCREENBREAK6; + } - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; - break; + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; - case SCREENBREAK1__STATIC: - case SCREENBREAK2__STATIC: - case SCREENBREAK3__STATIC: - case SCREENBREAK4__STATIC: - case SCREENBREAK5__STATIC: + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: - case SCREENBREAK9__STATIC: - case SCREENBREAK10__STATIC: - case SCREENBREAK11__STATIC: - case SCREENBREAK12__STATIC: - case SCREENBREAK13__STATIC: - case SCREENBREAK14__STATIC: - case SCREENBREAK15__STATIC: - case SCREENBREAK16__STATIC: - case SCREENBREAK17__STATIC: - case SCREENBREAK18__STATIC: - case SCREENBREAK19__STATIC: + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; - break; + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; } } @@ -1320,12 +1320,12 @@ void resetpspritevars(char g) { switch (ud.pteam[j]) { - case 0: - k = 3; - break; - case 1: - k = 21; - break; + case 0: + k = 3; + break; + case 1: + k = 21; + break; } ps[j].team = ud.pteam[j]; } @@ -1738,16 +1738,16 @@ int enterlevel(char g) for (i=connecthead;i>=0;i=connectpoint2[i]) switch (dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum]) { - case HURTRAIL__STATIC: - case FLOORSLIME__STATIC: - case FLOORPLASMA__STATIC: - resetweapons(i); - resetinventory(i); - ps[i].gotweapon[PISTOL_WEAPON] = 0; - ps[i].ammo_amount[PISTOL_WEAPON] = 0; - ps[i].curr_weapon = KNEE_WEAPON; - ps[i].kickback_pic = 0; - break; + case HURTRAIL__STATIC: + case FLOORSLIME__STATIC: + case FLOORPLASMA__STATIC: + resetweapons(i); + resetinventory(i); + ps[i].gotweapon[PISTOL_WEAPON] = 0; + ps[i].ammo_amount[PISTOL_WEAPON] = 0; + ps[i].curr_weapon = KNEE_WEAPON; + ps[i].kickback_pic = 0; + break; } //PREMAP.C - replace near the my's at the end of the file diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index c4122b4f8..dfd1cfeae 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -379,13 +379,13 @@ int loadplayer(signed char spot) for (x=0;xsectnum == sprite[j].sectnum) switch (sprite[j].lotag) { - case 11: - case 30: - if (hittype[j].temp_data[4]) - return(1); - break; - case 20: - case 31: - case 32: - case 18: - if (hittype[j].temp_data[0]) - return(1); - break; + case 11: + case 30: + if (hittype[j].temp_data[4]) + return(1); + break; + case 20: + case 31: + case 32: + case 18: + if (hittype[j].temp_data[0]) + return(1); + break; } j = nextspritestat[j]; @@ -120,29 +120,29 @@ char isadoorwall(short dapic) { switch (dynamictostatic[dapic]) { - case DOORTILE1__STATIC: - case DOORTILE2__STATIC: - case DOORTILE3__STATIC: - case DOORTILE4__STATIC: - case DOORTILE5__STATIC: - case DOORTILE6__STATIC: - case DOORTILE7__STATIC: - case DOORTILE8__STATIC: - case DOORTILE9__STATIC: - case DOORTILE10__STATIC: - case DOORTILE11__STATIC: - case DOORTILE12__STATIC: - case DOORTILE14__STATIC: - case DOORTILE15__STATIC: - case DOORTILE16__STATIC: - case DOORTILE17__STATIC: - case DOORTILE18__STATIC: - case DOORTILE19__STATIC: - case DOORTILE20__STATIC: - case DOORTILE21__STATIC: - case DOORTILE22__STATIC: - case DOORTILE23__STATIC: - return 1; + case DOORTILE1__STATIC: + case DOORTILE2__STATIC: + case DOORTILE3__STATIC: + case DOORTILE4__STATIC: + case DOORTILE5__STATIC: + case DOORTILE6__STATIC: + case DOORTILE7__STATIC: + case DOORTILE8__STATIC: + case DOORTILE9__STATIC: + case DOORTILE10__STATIC: + case DOORTILE11__STATIC: + case DOORTILE12__STATIC: + case DOORTILE14__STATIC: + case DOORTILE15__STATIC: + case DOORTILE16__STATIC: + case DOORTILE17__STATIC: + case DOORTILE18__STATIC: + case DOORTILE19__STATIC: + case DOORTILE20__STATIC: + case DOORTILE21__STATIC: + case DOORTILE22__STATIC: + case DOORTILE23__STATIC: + return 1; } return 0; } @@ -151,14 +151,14 @@ char isanunderoperator(short lotag) { switch (lotag&0xff) { - case 15: - case 16: - case 17: - case 18: - case 19: - case 22: - case 26: - return 1; + case 15: + case 16: + case 17: + case 18: + case 19: + case 22: + case 26: + return 1; } return 0; } @@ -167,20 +167,20 @@ char isanearoperator(short lotag) { switch (lotag&0xff) { - case 9: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 25: - case 26: - case 29://Toothed door - return 1; + case 9: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 25: + case 26: + case 29://Toothed door + return 1; } return 0; } @@ -412,45 +412,45 @@ void animatewalls(void) switch (dynamictostatic[j]) { - case SCREENBREAK1__STATIC: - case SCREENBREAK2__STATIC: - case SCREENBREAK3__STATIC: - case SCREENBREAK4__STATIC: - case SCREENBREAK5__STATIC: + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: - case SCREENBREAK9__STATIC: - case SCREENBREAK10__STATIC: - case SCREENBREAK11__STATIC: - case SCREENBREAK12__STATIC: - case SCREENBREAK13__STATIC: - case SCREENBREAK14__STATIC: - case SCREENBREAK15__STATIC: - case SCREENBREAK16__STATIC: - case SCREENBREAK17__STATIC: - case SCREENBREAK18__STATIC: - case SCREENBREAK19__STATIC: + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: - if ((TRAND&255) < 16) - { - animwall[p].tag = wall[i].picnum; + if ((TRAND&255) < 16) + { + animwall[p].tag = wall[i].picnum; + wall[i].picnum = SCREENBREAK6; + } + + continue; + + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + + if (animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3) + wall[i].picnum = animwall[p].tag; + else + { + wall[i].picnum++; + if (wall[i].picnum == (SCREENBREAK6+3)) wall[i].picnum = SCREENBREAK6; - } - - continue; - - case SCREENBREAK6__STATIC: - case SCREENBREAK7__STATIC: - case SCREENBREAK8__STATIC: - - if (animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3) - wall[i].picnum = animwall[p].tag; - else - { - wall[i].picnum++; - if (wall[i].picnum == (SCREENBREAK6+3)) - wall[i].picnum = SCREENBREAK6; - } - continue; + } + continue; } @@ -550,435 +550,435 @@ void operatesectors(short sn,short ii) switch (sptr->lotag&(0xffff-49152)) { - case 30: - j = sector[sn].hitag; - if (hittype[j].tempang == 0 || - hittype[j].tempang == 256) - callsound(sn,ii); - if (sprite[j].extra == 1) - sprite[j].extra = 3; - else sprite[j].extra = 1; - break; - - case 31: - - j = sector[sn].hitag; - if (hittype[j].temp_data[4] == 0) - hittype[j].temp_data[4] = 1; - + case 30: + j = sector[sn].hitag; + if (hittype[j].tempang == 0 || + hittype[j].tempang == 256) callsound(sn,ii); - break; + if (sprite[j].extra == 1) + sprite[j].extra = 3; + else sprite[j].extra = 1; + break; - case 26: //The split doors - i = getanimationgoal(&sptr->ceilingz); - if (i == -1) //if the door has stopped - { - haltsoundhack = 1; - sptr->lotag &= 0xff00; - sptr->lotag |= 22; - operatesectors(sn,ii); - sptr->lotag &= 0xff00; - sptr->lotag |= 9; - operatesectors(sn,ii); - sptr->lotag &= 0xff00; - sptr->lotag |= 26; - } - return; + case 31: - case 9: + j = sector[sn].hitag; + if (hittype[j].temp_data[4] == 0) + hittype[j].temp_data[4] = 1; + + callsound(sn,ii); + break; + + case 26: //The split doors + i = getanimationgoal(&sptr->ceilingz); + if (i == -1) //if the door has stopped { - long dax,day,dax2,day2,sp; - long wallfind[2]; - - startwall = sptr->wallptr; - endwall = startwall+sptr->wallnum-1; - - sp = sptr->extra>>4; - - //first find center point by averaging all points - dax = 0L, day = 0L; - for (i=startwall;i<=endwall;i++) - { - dax += wall[i].x; - day += wall[i].y; - } - dax /= (endwall-startwall+1); - day /= (endwall-startwall+1); - - //find any points with either same x or same y coordinate - // as center (dax, day) - should be 2 points found. - wallfind[0] = -1; - wallfind[1] = -1; - for (i=startwall;i<=endwall;i++) - if ((wall[i].x == dax) || (wall[i].y == day)) - { - if (wallfind[0] == -1) - wallfind[0] = i; - else wallfind[1] = i; - } - - for (j=0;j<2;j++) - { - if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day)) - { - //find what direction door should open by averaging the - // 2 neighboring points of wallfind[0] & wallfind[1]. - i = wallfind[j]-1; - if (i < startwall) i = endwall; - dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; - day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; - if (dax2 != 0) - { - dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; - dax2 -= wall[wall[wallfind[j]].point2].x; - setanimation(sn,&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,sp); - setanimation(sn,&wall[i].x,wall[i].x+dax2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,sp); - callsound(sn,ii); - } - else if (day2 != 0) - { - day2 = wall[wall[wall[wallfind[j]].point2].point2].y; - day2 -= wall[wall[wallfind[j]].point2].y; - setanimation(sn,&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,sp); - setanimation(sn,&wall[i].y,wall[i].y+day2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,sp); - callsound(sn,ii); - } - } - else - { - i = wallfind[j]-1; - if (i < startwall) i = endwall; - dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; - day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; - if (dax2 != 0) - { - setanimation(sn,&wall[wallfind[j]].x,dax,sp); - setanimation(sn,&wall[i].x,dax+dax2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].x,dax+dax2,sp); - callsound(sn,ii); - } - else if (day2 != 0) - { - setanimation(sn,&wall[wallfind[j]].y,day,sp); - setanimation(sn,&wall[i].y,day+day2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].y,day+day2,sp); - callsound(sn,ii); - } - } - } - + haltsoundhack = 1; + sptr->lotag &= 0xff00; + sptr->lotag |= 22; + operatesectors(sn,ii); + sptr->lotag &= 0xff00; + sptr->lotag |= 9; + operatesectors(sn,ii); + sptr->lotag &= 0xff00; + sptr->lotag |= 26; } return; - case 15://Warping elevators + case 9: + { + long dax,day,dax2,day2,sp; + long wallfind[2]; - if (sprite[ii].picnum != APLAYER) return; - // if(ps[sprite[ii].yvel].select_dir == 1) return; + startwall = sptr->wallptr; + endwall = startwall+sptr->wallnum-1; - i = headspritesect[sn]; - while (i >= 0) + sp = sptr->extra>>4; + + //first find center point by averaging all points + dax = 0L, day = 0L; + for (i=startwall;i<=endwall;i++) + { + dax += wall[i].x; + day += wall[i].y; + } + dax /= (endwall-startwall+1); + day /= (endwall-startwall+1); + + //find any points with either same x or same y coordinate + // as center (dax, day) - should be 2 points found. + wallfind[0] = -1; + wallfind[1] = -1; + for (i=startwall;i<=endwall;i++) + if ((wall[i].x == dax) || (wall[i].y == day)) { - if (PN==SECTOREFFECTOR && SLT == 17) break; - i = nextspritesect[i]; + if (wallfind[0] == -1) + wallfind[0] = i; + else wallfind[1] = i; } - if (sprite[ii].sectnum == sn) + for (j=0;j<2;j++) + { + if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day)) { - if (activatewarpelevators(i,-1)) - activatewarpelevators(i,1); - else if (activatewarpelevators(i,1)) - activatewarpelevators(i,-1); - return; + //find what direction door should open by averaging the + // 2 neighboring points of wallfind[0] & wallfind[1]. + i = wallfind[j]-1; + if (i < startwall) i = endwall; + dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; + dax2 -= wall[wall[wallfind[j]].point2].x; + setanimation(sn,&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,sp); + setanimation(sn,&wall[i].x,wall[i].x+dax2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,sp); + callsound(sn,ii); + } + else if (day2 != 0) + { + day2 = wall[wall[wall[wallfind[j]].point2].point2].y; + day2 -= wall[wall[wallfind[j]].point2].y; + setanimation(sn,&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,sp); + setanimation(sn,&wall[i].y,wall[i].y+day2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,sp); + callsound(sn,ii); + } } else { - if (sptr->floorz > SZ) - activatewarpelevators(i,-1); - else - activatewarpelevators(i,1); + i = wallfind[j]-1; + if (i < startwall) i = endwall; + dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + setanimation(sn,&wall[wallfind[j]].x,dax,sp); + setanimation(sn,&wall[i].x,dax+dax2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].x,dax+dax2,sp); + callsound(sn,ii); + } + else if (day2 != 0) + { + setanimation(sn,&wall[wallfind[j]].y,day,sp); + setanimation(sn,&wall[i].y,day+day2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].y,day+day2,sp); + callsound(sn,ii); + } } + } + } + return; + + case 15://Warping elevators + + if (sprite[ii].picnum != APLAYER) return; + // if(ps[sprite[ii].yvel].select_dir == 1) return; + + i = headspritesect[sn]; + while (i >= 0) + { + if (PN==SECTOREFFECTOR && SLT == 17) break; + i = nextspritesect[i]; + } + + if (sprite[ii].sectnum == sn) + { + if (activatewarpelevators(i,-1)) + activatewarpelevators(i,1); + else if (activatewarpelevators(i,1)) + activatewarpelevators(i,-1); return; + } + else + { + if (sptr->floorz > SZ) + activatewarpelevators(i,-1); + else + activatewarpelevators(i,1); + } - case 16: - case 17: + return; - i = getanimationgoal(&sptr->floorz); + case 16: + case 17: + i = getanimationgoal(&sptr->floorz); + + if (i == -1) + { + i = nextsectorneighborz(sn,sptr->floorz,1,1); if (i == -1) - { - i = nextsectorneighborz(sn,sptr->floorz,1,1); - if (i == -1) - { - i = nextsectorneighborz(sn,sptr->floorz,1,-1); - if (i == -1) return; - j = sector[i].floorz; - setanimation(sn,&sptr->floorz,j,sptr->extra); - } - else - { - j = sector[i].floorz; - setanimation(sn,&sptr->floorz,j,sptr->extra); - } - callsound(sn,ii); - } - - return; - - case 18: - case 19: - - i = getanimationgoal(&sptr->floorz); - - if (i==-1) { i = nextsectorneighborz(sn,sptr->floorz,1,-1); - if (i==-1) i = nextsectorneighborz(sn,sptr->floorz,1,1); - if (i==-1) return; + if (i == -1) return; j = sector[i].floorz; - q = sptr->extra; - l = sptr->ceilingz-sptr->floorz; - setanimation(sn,&sptr->floorz,j,q); - setanimation(sn,&sptr->ceilingz,j+l,q); - callsound(sn,ii); + setanimation(sn,&sptr->floorz,j,sptr->extra); } - return; - - case 29: - - if (sptr->lotag&0x8000) - j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; else - j = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; - - i = headspritestat[3]; //Effectors - while (i >= 0) { - if ((SLT == 22) && - (SHT == sptr->hitag)) - { - sector[SECT].extra = -sector[SECT].extra; - - T1 = sn; - T2 = 1; - } - i = nextspritestat[i]; + j = sector[i].floorz; + setanimation(sn,&sptr->floorz,j,sptr->extra); } - - sptr->lotag ^= 0x8000; - - setanimation(sn,&sptr->ceilingz,j,sptr->extra); - callsound(sn,ii); + } - return; + return; - case 20: + case 18: + case 19: + + i = getanimationgoal(&sptr->floorz); + + if (i==-1) + { + i = nextsectorneighborz(sn,sptr->floorz,1,-1); + if (i==-1) i = nextsectorneighborz(sn,sptr->floorz,1,1); + if (i==-1) return; + j = sector[i].floorz; + q = sptr->extra; + l = sptr->ceilingz-sptr->floorz; + setanimation(sn,&sptr->floorz,j,q); + setanimation(sn,&sptr->ceilingz,j+l,q); + callsound(sn,ii); + } + return; + + case 29: + + if (sptr->lotag&0x8000) + j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else + j = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; + + i = headspritestat[3]; //Effectors + while (i >= 0) + { + if ((SLT == 22) && + (SHT == sptr->hitag)) + { + sector[SECT].extra = -sector[SECT].extra; + + T1 = sn; + T2 = 1; + } + i = nextspritestat[i]; + } + + sptr->lotag ^= 0x8000; + + setanimation(sn,&sptr->ceilingz,j,sptr->extra); + + callsound(sn,ii); + + return; + + case 20: REDODOOR: - if (sptr->lotag&0x8000) - { - i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].statnum == 3 && SLT==9) - { - j = SZ; - break; - } - i = nextspritesect[i]; - } - if (i==-1) - j = sptr->floorz; - } - else - { - j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); - - if (j >= 0) j = sector[j].ceilingz; - else - { - sptr->lotag |= 32768; - goto REDODOOR; - } - } - - sptr->lotag ^= 0x8000; - - setanimation(sn,&sptr->ceilingz,j,sptr->extra); - callsound(sn,ii); - - return; - - case 21: - i = getanimationgoal(&sptr->floorz); - if (i >= 0) - { - if (animategoal[sn] == sptr->ceilingz) - animategoal[i] = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; - else animategoal[i] = sptr->ceilingz; - j = animategoal[i]; - } - else - { - if (sptr->ceilingz == sptr->floorz) - j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; - else j = sptr->ceilingz; - - sptr->lotag ^= 0x8000; - - if (setanimation(sn,&sptr->floorz,j,sptr->extra) >= 0) - callsound(sn,ii); - } - return; - - case 22: - - // REDODOOR22: - - if ((sptr->lotag&0x8000)) - { - q = (sptr->ceilingz+sptr->floorz)>>1; - j = setanimation(sn,&sptr->floorz,q,sptr->extra); - j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); - } - else - { - q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz; - j = setanimation(sn,&sptr->floorz,q,sptr->extra); - q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; - j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); - } - - sptr->lotag ^= 0x8000; - - callsound(sn,ii); - - return; - - case 23: //Swingdoor - - j = -1; - q = 0; - - i = headspritestat[3]; + if (sptr->lotag&0x8000) + { + i = headspritesect[sn]; while (i >= 0) { - if (SLT == 11 && SECT == sn && !T5) + if (sprite[i].statnum == 3 && SLT==9) { - j = i; + j = SZ; break; } - i = nextspritestat[i]; + i = nextspritesect[i]; } - if (i<0) - { - OSD_Printf("WARNING: SE23 i<0!\n"); - return; - } // JBF - l = sector[SECT].lotag&0x8000; + if (i==-1) + j = sptr->floorz; + } + else + { + j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); - if (j >= 0) + if (j >= 0) j = sector[j].ceilingz; + else { - i = headspritestat[3]; - while (i >= 0) - { - if (l == (sector[SECT].lotag&0x8000) && SLT == 11 && sprite[j].hitag == SHT && !T5) - { - if (sector[SECT].lotag&0x8000) sector[SECT].lotag &= 0x7fff; - else sector[SECT].lotag |= 0x8000; - T5 = 1; - T4 = -T4; - if (q == 0) - { - callsound(sn,i); - q = 1; - } - } - i = nextspritestat[i]; - } + sptr->lotag |= 32768; + goto REDODOOR; } + } + + sptr->lotag ^= 0x8000; + + setanimation(sn,&sptr->ceilingz,j,sptr->extra); + callsound(sn,ii); + + return; + + case 21: + i = getanimationgoal(&sptr->floorz); + if (i >= 0) + { + if (animategoal[sn] == sptr->ceilingz) + animategoal[i] = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else animategoal[i] = sptr->ceilingz; + j = animategoal[i]; + } + else + { + if (sptr->ceilingz == sptr->floorz) + j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else j = sptr->ceilingz; + + sptr->lotag ^= 0x8000; + + if (setanimation(sn,&sptr->floorz,j,sptr->extra) >= 0) + callsound(sn,ii); + } + return; + + case 22: + + // REDODOOR22: + + if ((sptr->lotag&0x8000)) + { + q = (sptr->ceilingz+sptr->floorz)>>1; + j = setanimation(sn,&sptr->floorz,q,sptr->extra); + j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + } + else + { + q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz; + j = setanimation(sn,&sptr->floorz,q,sptr->extra); + q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; + j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + } + + sptr->lotag ^= 0x8000; + + callsound(sn,ii); + + return; + + case 23: //Swingdoor + + j = -1; + q = 0; + + i = headspritestat[3]; + while (i >= 0) + { + if (SLT == 11 && SECT == sn && !T5) + { + j = i; + break; + } + i = nextspritestat[i]; + } + if (i<0) + { + OSD_Printf("WARNING: SE23 i<0!\n"); return; + } // JBF + l = sector[SECT].lotag&0x8000; - case 25: //Subway type sliding doors - - j = headspritestat[3]; - while (j >= 0)//Find the sprite - { - if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn) - break; //Found the sectoreffector. - j = nextspritestat[j]; - } - - if (j < 0) - return; - + if (j >= 0) + { i = headspritestat[3]; while (i >= 0) { - if (SHT==sprite[j].hitag) + if (l == (sector[SECT].lotag&0x8000) && SLT == 11 && sprite[j].hitag == SHT && !T5) { - if (SLT == 15) + if (sector[SECT].lotag&0x8000) sector[SECT].lotag &= 0x7fff; + else sector[SECT].lotag |= 0x8000; + T5 = 1; + T4 = -T4; + if (q == 0) { - sector[SECT].lotag ^= 0x8000; // Toggle the open or close - SA += 1024; - if (T5) callsound(SECT,i); - callsound(SECT,i); - if (sector[SECT].lotag&0x8000) T5 = 1; - else T5 = 2; + callsound(sn,i); + q = 1; } } i = nextspritestat[i]; } + } + return; + + case 25: //Subway type sliding doors + + j = headspritestat[3]; + while (j >= 0)//Find the sprite + { + if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn) + break; //Found the sectoreffector. + j = nextspritestat[j]; + } + + if (j < 0) return; - case 27: //Extended bridge - - j = headspritestat[3]; - while (j >= 0) + i = headspritestat[3]; + while (i >= 0) + { + if (SHT==sprite[j].hitag) { - if ((sprite[j].lotag&0xff)==20 && sprite[j].sectnum == sn) //Bridge + if (SLT == 15) { - - sector[sn].lotag ^= 0x8000; - if (sector[sn].lotag&0x8000) //OPENING - hittype[j].temp_data[0] = 1; - else hittype[j].temp_data[0] = 2; - callsound(sn,ii); - break; + sector[SECT].lotag ^= 0x8000; // Toggle the open or close + SA += 1024; + if (T5) callsound(SECT,i); + callsound(SECT,i); + if (sector[SECT].lotag&0x8000) T5 = 1; + else T5 = 2; } - j = nextspritestat[j]; } - return; + i = nextspritestat[i]; + } + return; + case 27: //Extended bridge - case 28: - //activate the rest of them - - j = headspritesect[sn]; - while (j >= 0) + j = headspritestat[3]; + while (j >= 0) + { + if ((sprite[j].lotag&0xff)==20 && sprite[j].sectnum == sn) //Bridge { - if (sprite[j].statnum==3 && (sprite[j].lotag&0xff)==21) - break; //Found it - j = nextspritesect[j]; + + sector[sn].lotag ^= 0x8000; + if (sector[sn].lotag&0x8000) //OPENING + hittype[j].temp_data[0] = 1; + else hittype[j].temp_data[0] = 2; + callsound(sn,ii); + break; } + j = nextspritestat[j]; + } + return; - j = sprite[j].hitag; - l = headspritestat[3]; - while (l >= 0) - { - if ((sprite[l].lotag&0xff)==21 && !hittype[l].temp_data[0] && - (sprite[l].hitag) == j) - hittype[l].temp_data[0] = 1; - l = nextspritestat[l]; - } - callsound(sn,ii); + case 28: + //activate the rest of them - return; + j = headspritesect[sn]; + while (j >= 0) + { + if (sprite[j].statnum==3 && (sprite[j].lotag&0xff)==21) + break; //Found it + j = nextspritesect[j]; + } + + j = sprite[j].hitag; + + l = headspritestat[3]; + while (l >= 0) + { + if ((sprite[l].lotag&0xff)==21 && !hittype[l].temp_data[0] && + (sprite[l].hitag) == j) + hittype[l].temp_data[0] = 1; + l = nextspritestat[l]; + } + callsound(sn,ii); + + return; } } @@ -1047,22 +1047,22 @@ void operateactivators(short low,short snum) { switch (SHT) { - case 0: - break; - case 1: - if (sector[SECT].floorz != sector[SECT].ceilingz) - { - i = nextspritestat[i]; - continue; - } - break; - case 2: - if (sector[SECT].floorz == sector[SECT].ceilingz) - { - i = nextspritestat[i]; - continue; - } - break; + case 0: + break; + case 1: + if (sector[SECT].floorz != sector[SECT].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; + case 2: + if (sector[SECT].floorz == sector[SECT].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; } if (sector[sprite[i].sectnum].lotag < 3) @@ -1072,13 +1072,13 @@ void operateactivators(short low,short snum) { if (sprite[j].statnum == 3) switch (sprite[j].lotag) { - case 36: - case 31: - case 32: - case 18: - hittype[j].temp_data[0] = 1-hittype[j].temp_data[0]; - callsound(SECT,j); - break; + case 36: + case 31: + case 32: + case 18: + hittype[j].temp_data[0] = 1-hittype[j].temp_data[0]; + callsound(SECT,j); + break; } j = nextspritesect[j]; } @@ -1199,83 +1199,83 @@ char checkhitswitch(short snum,long w,char switchtype) switch (dynamictostatic[switchpicnum]) { - case DIPSWITCH__STATIC: - // case DIPSWITCH+1: - case TECHSWITCH__STATIC: - // case TECHSWITCH+1: - case ALIENSWITCH__STATIC: - // case ALIENSWITCH+1: - break; - case ACCESSSWITCH__STATIC: - case ACCESSSWITCH2__STATIC: - if (ps[snum].access_incs == 0) + case DIPSWITCH__STATIC: + // case DIPSWITCH+1: + case TECHSWITCH__STATIC: + // case TECHSWITCH+1: + case ALIENSWITCH__STATIC: + // case ALIENSWITCH+1: + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + if (ps[snum].access_incs == 0) + { + if (switchpal == 0) { - if (switchpal == 0) - { - if ((ps[snum].got_access&1)) - ps[snum].access_incs = 1; - else FTA(70,&ps[snum]); - } - - else if (switchpal == 21) - { - if (ps[snum].got_access&2) - ps[snum].access_incs = 1; - else FTA(71,&ps[snum]); - } - - else if (switchpal == 23) - { - if (ps[snum].got_access&4) - ps[snum].access_incs = 1; - else FTA(72,&ps[snum]); - } - - if (ps[snum].access_incs == 1) - { - if (switchtype == 0) - ps[snum].access_wallnum = w; - else - ps[snum].access_spritenum = w; - } - - return 0; + if ((ps[snum].got_access&1)) + ps[snum].access_incs = 1; + else FTA(70,&ps[snum]); } - case DIPSWITCH2__STATIC: - //case DIPSWITCH2+1: - case DIPSWITCH3__STATIC: - //case DIPSWITCH3+1: - case MULTISWITCH__STATIC: - //case MULTISWITCH+1: - //case MULTISWITCH+2: - //case MULTISWITCH+3: - case PULLSWITCH__STATIC: - //case PULLSWITCH+1: - case HANDSWITCH__STATIC: - //case HANDSWITCH+1: - case SLOTDOOR__STATIC: - //case SLOTDOOR+1: - case LIGHTSWITCH__STATIC: - //case LIGHTSWITCH+1: - case SPACELIGHTSWITCH__STATIC: - //case SPACELIGHTSWITCH+1: - case SPACEDOORSWITCH__STATIC: - //case SPACEDOORSWITCH+1: - case FRANKENSTINESWITCH__STATIC: - //case FRANKENSTINESWITCH+1: - case LIGHTSWITCH2__STATIC: - //case LIGHTSWITCH2+1: - case POWERSWITCH1__STATIC: - //case POWERSWITCH1+1: - case LOCKSWITCH1__STATIC: - //case LOCKSWITCH1+1: - case POWERSWITCH2__STATIC: - //case POWERSWITCH2+1: - if (check_activator_motion(lotag)) return 0; - break; - default: - if (isadoorwall(picnum) == 0) return 0; - break; + + else if (switchpal == 21) + { + if (ps[snum].got_access&2) + ps[snum].access_incs = 1; + else FTA(71,&ps[snum]); + } + + else if (switchpal == 23) + { + if (ps[snum].got_access&4) + ps[snum].access_incs = 1; + else FTA(72,&ps[snum]); + } + + if (ps[snum].access_incs == 1) + { + if (switchtype == 0) + ps[snum].access_wallnum = w; + else + ps[snum].access_spritenum = w; + } + + return 0; + } + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + if (check_activator_motion(lotag)) return 0; + break; + default: + if (isadoorwall(picnum) == 0) return 0; + break; } i = headspritestat[0]; @@ -1295,58 +1295,58 @@ char checkhitswitch(short snum,long w,char switchtype) switch (dynamictostatic[switchpicnum]) { - case DIPSWITCH__STATIC: + case DIPSWITCH__STATIC: + case TECHSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if (switchtype == 1 && w == i) PN++; + else if (SHT == 0) correctdips++; + numdips++; + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case HANDSWITCH__STATIC: + case PULLSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + sprite[i].picnum++; + break; + default: + switch (dynamictostatic[switchpicnum-1]) + { + case TECHSWITCH__STATIC: + case DIPSWITCH__STATIC: case ALIENSWITCH__STATIC: - if (switchtype == 1 && w == i) PN++; - else if (SHT == 0) correctdips++; + if (switchtype == 1 && w == i) PN--; + else if (SHT == 1) correctdips++; numdips++; break; - case ACCESSSWITCH__STATIC: - case ACCESSSWITCH2__STATIC: + case PULLSWITCH__STATIC: + case HANDSWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: case SLOTDOOR__STATIC: case LIGHTSWITCH__STATIC: case SPACELIGHTSWITCH__STATIC: case SPACEDOORSWITCH__STATIC: case FRANKENSTINESWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case HANDSWITCH__STATIC: - case PULLSWITCH__STATIC: case DIPSWITCH2__STATIC: case DIPSWITCH3__STATIC: - sprite[i].picnum++; - break; - default: - switch (dynamictostatic[switchpicnum-1]) - { - - case TECHSWITCH__STATIC: - case DIPSWITCH__STATIC: - case ALIENSWITCH__STATIC: - if (switchtype == 1 && w == i) PN--; - else if (SHT == 1) correctdips++; - numdips++; - break; - case PULLSWITCH__STATIC: - case HANDSWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case SLOTDOOR__STATIC: - case LIGHTSWITCH__STATIC: - case SPACELIGHTSWITCH__STATIC: - case SPACEDOORSWITCH__STATIC: - case FRANKENSTINESWITCH__STATIC: - case DIPSWITCH2__STATIC: - case DIPSWITCH3__STATIC: - sprite[i].picnum--; - break; - } + sprite[i].picnum--; break; + } + break; } } i = nextspritestat[i]; @@ -1367,58 +1367,58 @@ char checkhitswitch(short snum,long w,char switchtype) switch (dynamictostatic[wall[x].picnum]) { - case DIPSWITCH__STATIC: + case DIPSWITCH__STATIC: + case TECHSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if (switchtype == 0 && i == w) wall[x].picnum++; + else if (wall[x].hitag == 0) correctdips++; + numdips++; + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case HANDSWITCH__STATIC: + case PULLSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + wall[x].picnum++; + break; + default: + switch (dynamictostatic[wall[x].picnum-1]) + { + case TECHSWITCH__STATIC: + case DIPSWITCH__STATIC: case ALIENSWITCH__STATIC: - if (switchtype == 0 && i == w) wall[x].picnum++; - else if (wall[x].hitag == 0) correctdips++; + if (switchtype == 0 && i == w) wall[x].picnum--; + else if (wall[x].hitag == 1) correctdips++; numdips++; break; - case ACCESSSWITCH__STATIC: - case ACCESSSWITCH2__STATIC: + case PULLSWITCH__STATIC: + case HANDSWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: case SLOTDOOR__STATIC: case LIGHTSWITCH__STATIC: case SPACELIGHTSWITCH__STATIC: case SPACEDOORSWITCH__STATIC: case FRANKENSTINESWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case HANDSWITCH__STATIC: - case PULLSWITCH__STATIC: case DIPSWITCH2__STATIC: case DIPSWITCH3__STATIC: - wall[x].picnum++; - break; - default: - switch (dynamictostatic[wall[x].picnum-1]) - { - - case TECHSWITCH__STATIC: - case DIPSWITCH__STATIC: - case ALIENSWITCH__STATIC: - if (switchtype == 0 && i == w) wall[x].picnum--; - else if (wall[x].hitag == 1) correctdips++; - numdips++; - break; - case PULLSWITCH__STATIC: - case HANDSWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case SLOTDOOR__STATIC: - case LIGHTSWITCH__STATIC: - case SPACELIGHTSWITCH__STATIC: - case SPACEDOORSWITCH__STATIC: - case FRANKENSTINESWITCH__STATIC: - case DIPSWITCH2__STATIC: - case DIPSWITCH3__STATIC: - wall[x].picnum--; - break; - } + wall[x].picnum--; break; + } + break; } } } @@ -1474,122 +1474,122 @@ char checkhitswitch(short snum,long w,char switchtype) switch (dynamictostatic[switchpicnum]) { - default: - if (isadoorwall(picnum) == 0) break; - case DIPSWITCH__STATIC: - //case DIPSWITCH+1: - case TECHSWITCH__STATIC: - //case TECHSWITCH+1: - case ALIENSWITCH__STATIC: - //case ALIENSWITCH+1: - if (picnum == DIPSWITCH || picnum == DIPSWITCH+1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || - picnum == TECHSWITCH || picnum == TECHSWITCH+1) + default: + if (isadoorwall(picnum) == 0) break; + case DIPSWITCH__STATIC: + //case DIPSWITCH+1: + case TECHSWITCH__STATIC: + //case TECHSWITCH+1: + case ALIENSWITCH__STATIC: + //case ALIENSWITCH+1: + if (picnum == DIPSWITCH || picnum == DIPSWITCH+1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || + picnum == TECHSWITCH || picnum == TECHSWITCH+1) + { + if (picnum == ALIENSWITCH || picnum == ALIENSWITCH+1) { - if (picnum == ALIENSWITCH || picnum == ALIENSWITCH+1) - { - if (switchtype == 1) - xyzsound(ALIEN_SWITCH1,w,sx,sy,ps[snum].posz); - else xyzsound(ALIEN_SWITCH1,ps[snum].i,sx,sy,ps[snum].posz); - } - else - { - if (switchtype == 1) - xyzsound(SWITCH_ON,w,sx,sy,ps[snum].posz); - else xyzsound(SWITCH_ON,ps[snum].i,sx,sy,ps[snum].posz); - } - if (numdips != correctdips) break; - xyzsound(END_OF_LEVEL_WARN,ps[snum].i,sx,sy,ps[snum].posz); + if (switchtype == 1) + xyzsound(ALIEN_SWITCH1,w,sx,sy,ps[snum].posz); + else xyzsound(ALIEN_SWITCH1,ps[snum].i,sx,sy,ps[snum].posz); } - case DIPSWITCH2__STATIC: - //case DIPSWITCH2+1: - case DIPSWITCH3__STATIC: - //case DIPSWITCH3+1: - case MULTISWITCH__STATIC: - //case MULTISWITCH+1: - //case MULTISWITCH+2: - //case MULTISWITCH+3: - case ACCESSSWITCH__STATIC: - case ACCESSSWITCH2__STATIC: - case SLOTDOOR__STATIC: - //case SLOTDOOR+1: - case LIGHTSWITCH__STATIC: - //case LIGHTSWITCH+1: - case SPACELIGHTSWITCH__STATIC: - //case SPACELIGHTSWITCH+1: - case SPACEDOORSWITCH__STATIC: - //case SPACEDOORSWITCH+1: - case FRANKENSTINESWITCH__STATIC: - //case FRANKENSTINESWITCH+1: - case LIGHTSWITCH2__STATIC: - //case LIGHTSWITCH2+1: - case POWERSWITCH1__STATIC: - //case POWERSWITCH1+1: - case LOCKSWITCH1__STATIC: - //case LOCKSWITCH1+1: - case POWERSWITCH2__STATIC: - //case POWERSWITCH2+1: - case HANDSWITCH__STATIC: - //case HANDSWITCH+1: - case PULLSWITCH__STATIC: - //case PULLSWITCH+1: - - if (picnum == MULTISWITCH || picnum == (MULTISWITCH+1) || - picnum == (MULTISWITCH+2) || picnum == (MULTISWITCH+3)) - lotag += picnum-MULTISWITCH; - - x = headspritestat[3]; - while (x >= 0) - { - if (((sprite[x].hitag) == lotag)) - { - switch (sprite[x].lotag) - { - case 12: - sector[sprite[x].sectnum].floorpal = 0; - hittype[x].temp_data[0]++; - if (hittype[x].temp_data[0] == 2) - hittype[x].temp_data[0]++; - - break; - case 24: - case 34: - case 25: - hittype[x].temp_data[4] = !hittype[x].temp_data[4]; - if (hittype[x].temp_data[4]) - FTA(15,&ps[snum]); - else FTA(2,&ps[snum]); - break; - case 21: - FTA(2,&ps[screenpeek]); - break; - } - } - x = nextspritestat[x]; - } - - operateactivators(lotag,snum); - operateforcefields(ps[snum].i,lotag); - operatemasterswitches(lotag); - - if (picnum == DIPSWITCH || picnum == DIPSWITCH+1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || - picnum == TECHSWITCH || picnum == TECHSWITCH+1) return 1; - - if (hitag == 0 && isadoorwall(picnum) == 0) + else { if (switchtype == 1) xyzsound(SWITCH_ON,w,sx,sy,ps[snum].posz); else xyzsound(SWITCH_ON,ps[snum].i,sx,sy,ps[snum].posz); } - else if (hitag != 0) - { - if (switchtype == 1 && (soundm[hitag]&4) == 0) - xyzsound(hitag,w,sx,sy,ps[snum].posz); - else spritesound(hitag,ps[snum].i); - } + if (numdips != correctdips) break; + xyzsound(END_OF_LEVEL_WARN,ps[snum].i,sx,sy,ps[snum].posz); + } + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: - return 1; + if (picnum == MULTISWITCH || picnum == (MULTISWITCH+1) || + picnum == (MULTISWITCH+2) || picnum == (MULTISWITCH+3)) + lotag += picnum-MULTISWITCH; + + x = headspritestat[3]; + while (x >= 0) + { + if (((sprite[x].hitag) == lotag)) + { + switch (sprite[x].lotag) + { + case 12: + sector[sprite[x].sectnum].floorpal = 0; + hittype[x].temp_data[0]++; + if (hittype[x].temp_data[0] == 2) + hittype[x].temp_data[0]++; + + break; + case 24: + case 34: + case 25: + hittype[x].temp_data[4] = !hittype[x].temp_data[4]; + if (hittype[x].temp_data[4]) + FTA(15,&ps[snum]); + else FTA(2,&ps[snum]); + break; + case 21: + FTA(2,&ps[screenpeek]); + break; + } + } + x = nextspritestat[x]; + } + + operateactivators(lotag,snum); + operateforcefields(ps[snum].i,lotag); + operatemasterswitches(lotag); + + if (picnum == DIPSWITCH || picnum == DIPSWITCH+1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || + picnum == TECHSWITCH || picnum == TECHSWITCH+1) return 1; + + if (hitag == 0 && isadoorwall(picnum) == 0) + { + if (switchtype == 1) + xyzsound(SWITCH_ON,w,sx,sy,ps[snum].posz); + else xyzsound(SWITCH_ON,ps[snum].i,sx,sy,ps[snum].posz); + } + else if (hitag != 0) + { + if (switchtype == 1 && (soundm[hitag]&4) == 0) + xyzsound(hitag,w,sx,sy,ps[snum].posz); + else spritesound(hitag,ps[snum].i); + } + + return 1; } return 0; @@ -1644,18 +1644,18 @@ void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith) { switch (dynamictostatic[atwith]) { - case HEAVYHBOMB__STATIC: - case RADIUSEXPLOSION__STATIC: - case RPG__STATIC: - case HYDRENT__STATIC: - case SEENINE__STATIC: - case OOZFILTER__STATIC: - case EXPLODINGBARREL__STATIC: - lotsofglass(spr,dawallnum,70); - wal->cstat &= ~16; - wal->overpicnum = MIRRORBROKE; - spritesound(GLASS_HEAVYBREAK,spr); - return; + case HEAVYHBOMB__STATIC: + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case HYDRENT__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + case EXPLODINGBARREL__STATIC: + lotsofglass(spr,dawallnum,70); + wal->cstat &= ~16; + wal->overpicnum = MIRRORBROKE; + spritesound(GLASS_HEAVYBREAK,spr); + return; } } @@ -1668,215 +1668,215 @@ void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith) switchpicnum = W_FORCEFIELD; switch (dynamictostatic[switchpicnum]) { - case W_FORCEFIELD__STATIC: - //case W_FORCEFIELD+1: - //case W_FORCEFIELD+2: - wal->extra = 1; // tell the forces to animate - case BIGFORCE__STATIC: - updatesector(x,y,&sn); - if (sn < 0) return; + case W_FORCEFIELD__STATIC: + //case W_FORCEFIELD+1: + //case W_FORCEFIELD+2: + wal->extra = 1; // tell the forces to animate + case BIGFORCE__STATIC: + updatesector(x,y,&sn); + if (sn < 0) return; - if (atwith == -1) - i = EGS(sn,x,y,z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); - else - { - if (atwith == CHAINGUN) - i = EGS(sn,x,y,z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); - else i = EGS(sn,x,y,z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); - } + if (atwith == -1) + i = EGS(sn,x,y,z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); + else + { + if (atwith == CHAINGUN) + i = EGS(sn,x,y,z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); + else i = EGS(sn,x,y,z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); + } - CS |= 18+128; - SA = getangle(wal->x-wall[wal->point2].x, - wal->y-wall[wal->point2].y)-512; + CS |= 18+128; + SA = getangle(wal->x-wall[wal->point2].x, + wal->y-wall[wal->point2].y)-512; - spritesound(SOMETHINGHITFORCE,i); + spritesound(SOMETHINGHITFORCE,i); - return; + return; - case FANSPRITE__STATIC: - wal->overpicnum = FANSPRITEBROKE; - wal->cstat &= 65535-65; - if (wal->nextwall >= 0) - { - wall[wal->nextwall].overpicnum = FANSPRITEBROKE; - wall[wal->nextwall].cstat &= 65535-65; - } - spritesound(VENT_BUST,spr); - spritesound(GLASS_BREAKING,spr); - return; + case FANSPRITE__STATIC: + wal->overpicnum = FANSPRITEBROKE; + wal->cstat &= 65535-65; + if (wal->nextwall >= 0) + { + wall[wal->nextwall].overpicnum = FANSPRITEBROKE; + wall[wal->nextwall].cstat &= 65535-65; + } + spritesound(VENT_BUST,spr); + spritesound(GLASS_BREAKING,spr); + return; - case GLASS__STATIC: - updatesector(x,y,&sn); - if (sn < 0) return; - wal->overpicnum=GLASS2; - lotsofglass(spr,dawallnum,10); - wal->cstat = 0; + case GLASS__STATIC: + updatesector(x,y,&sn); + if (sn < 0) return; + wal->overpicnum=GLASS2; + lotsofglass(spr,dawallnum,10); + wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; - i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,ps[0].ang,0,0,spr,3); - SLT = 128; - T2 = 5; - T3 = dawallnum; - spritesound(GLASS_BREAKING,i); - return; - case STAINGLASS1__STATIC: - updatesector(x,y,&sn); - if (sn < 0) return; - lotsofcolourglass(spr,dawallnum,80); - wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; - spritesound(VENT_BUST,spr); - spritesound(GLASS_BREAKING,spr); - return; + i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,ps[0].ang,0,0,spr,3); + SLT = 128; + T2 = 5; + T3 = dawallnum; + spritesound(GLASS_BREAKING,i); + return; + case STAINGLASS1__STATIC: + updatesector(x,y,&sn); + if (sn < 0) return; + lotsofcolourglass(spr,dawallnum,80); + wal->cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; + spritesound(VENT_BUST,spr); + spritesound(GLASS_BREAKING,spr); + return; } } switch (dynamictostatic[wal->picnum]) { - case COLAMACHINE__STATIC: - case VENDMACHINE__STATIC: - breakwall(wal->picnum+2,spr,dawallnum); - spritesound(VENT_BUST,spr); - return; + case COLAMACHINE__STATIC: + case VENDMACHINE__STATIC: + breakwall(wal->picnum+2,spr,dawallnum); + spritesound(VENT_BUST,spr); + return; - case OJ__STATIC: - case FEMPIC2__STATIC: - case FEMPIC3__STATIC: + case OJ__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: - case SCREENBREAK6__STATIC: - case SCREENBREAK7__STATIC: - case SCREENBREAK8__STATIC: + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: - case SCREENBREAK1__STATIC: - case SCREENBREAK2__STATIC: - case SCREENBREAK3__STATIC: - case SCREENBREAK4__STATIC: - case SCREENBREAK5__STATIC: + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: - case SCREENBREAK9__STATIC: - case SCREENBREAK10__STATIC: - case SCREENBREAK11__STATIC: - case SCREENBREAK12__STATIC: - case SCREENBREAK13__STATIC: - case SCREENBREAK14__STATIC: - case SCREENBREAK15__STATIC: - case SCREENBREAK16__STATIC: - case SCREENBREAK17__STATIC: - case SCREENBREAK18__STATIC: - case SCREENBREAK19__STATIC: - case BORNTOBEWILDSCREEN__STATIC: + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + case BORNTOBEWILDSCREEN__STATIC: - lotsofglass(spr,dawallnum,30); - wal->picnum=W_SCREENBREAK+(TRAND%3); + lotsofglass(spr,dawallnum,30); + wal->picnum=W_SCREENBREAK+(TRAND%3); + spritesound(GLASS_HEAVYBREAK,spr); + return; + + case W_TECHWALL5__STATIC: + case W_TECHWALL6__STATIC: + case W_TECHWALL7__STATIC: + case W_TECHWALL8__STATIC: + case W_TECHWALL9__STATIC: + breakwall(wal->picnum+1,spr,dawallnum); + return; + case W_MILKSHELF__STATIC: + breakwall(W_MILKSHELFBROKE,spr,dawallnum); + return; + + case W_TECHWALL10__STATIC: + breakwall(W_HITTECHWALL10,spr,dawallnum); + return; + + case W_TECHWALL1__STATIC: + case W_TECHWALL11__STATIC: + case W_TECHWALL12__STATIC: + case W_TECHWALL13__STATIC: + case W_TECHWALL14__STATIC: + breakwall(W_HITTECHWALL1,spr,dawallnum); + return; + + case W_TECHWALL15__STATIC: + breakwall(W_HITTECHWALL15,spr,dawallnum); + return; + + case W_TECHWALL16__STATIC: + breakwall(W_HITTECHWALL16,spr,dawallnum); + return; + + case W_TECHWALL2__STATIC: + breakwall(W_HITTECHWALL2,spr,dawallnum); + return; + + case W_TECHWALL3__STATIC: + breakwall(W_HITTECHWALL3,spr,dawallnum); + return; + + case W_TECHWALL4__STATIC: + breakwall(W_HITTECHWALL4,spr,dawallnum); + return; + + case ATM__STATIC: + wal->picnum = ATMBROKE; + lotsofmoney(&sprite[spr],1+(TRAND&7)); + spritesound(GLASS_HEAVYBREAK,spr); + break; + + case WALLLIGHT1__STATIC: + case WALLLIGHT2__STATIC: + case WALLLIGHT3__STATIC: + case WALLLIGHT4__STATIC: + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: + + if (rnd(128)) spritesound(GLASS_HEAVYBREAK,spr); - return; + else spritesound(GLASS_BREAKING,spr); + lotsofglass(spr,dawallnum,30); - case W_TECHWALL5__STATIC: - case W_TECHWALL6__STATIC: - case W_TECHWALL7__STATIC: - case W_TECHWALL8__STATIC: - case W_TECHWALL9__STATIC: - breakwall(wal->picnum+1,spr,dawallnum); - return; - case W_MILKSHELF__STATIC: - breakwall(W_MILKSHELFBROKE,spr,dawallnum); - return; + if (wal->picnum == WALLLIGHT1) + wal->picnum = WALLLIGHTBUST1; - case W_TECHWALL10__STATIC: - breakwall(W_HITTECHWALL10,spr,dawallnum); - return; + if (wal->picnum == WALLLIGHT2) + wal->picnum = WALLLIGHTBUST2; - case W_TECHWALL1__STATIC: - case W_TECHWALL11__STATIC: - case W_TECHWALL12__STATIC: - case W_TECHWALL13__STATIC: - case W_TECHWALL14__STATIC: - breakwall(W_HITTECHWALL1,spr,dawallnum); - return; + if (wal->picnum == WALLLIGHT3) + wal->picnum = WALLLIGHTBUST3; - case W_TECHWALL15__STATIC: - breakwall(W_HITTECHWALL15,spr,dawallnum); - return; + if (wal->picnum == WALLLIGHT4) + wal->picnum = WALLLIGHTBUST4; - case W_TECHWALL16__STATIC: - breakwall(W_HITTECHWALL16,spr,dawallnum); - return; + if (wal->picnum == TECHLIGHT2) + wal->picnum = TECHLIGHTBUST2; - case W_TECHWALL2__STATIC: - breakwall(W_HITTECHWALL2,spr,dawallnum); - return; + if (wal->picnum == TECHLIGHT4) + wal->picnum = TECHLIGHTBUST4; - case W_TECHWALL3__STATIC: - breakwall(W_HITTECHWALL3,spr,dawallnum); - return; + if (!wal->lotag) return; - case W_TECHWALL4__STATIC: - breakwall(W_HITTECHWALL4,spr,dawallnum); - return; + sn = wal->nextsector; + if (sn < 0) return; + darkestwall = 0; - case ATM__STATIC: - wal->picnum = ATMBROKE; - lotsofmoney(&sprite[spr],1+(TRAND&7)); - spritesound(GLASS_HEAVYBREAK,spr); - break; + wal = &wall[sector[sn].wallptr]; + for (i=sector[sn].wallnum;i > 0;i--,wal++) + if (wal->shade > darkestwall) + darkestwall=wal->shade; - case WALLLIGHT1__STATIC: - case WALLLIGHT2__STATIC: - case WALLLIGHT3__STATIC: - case WALLLIGHT4__STATIC: - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: - - if (rnd(128)) - spritesound(GLASS_HEAVYBREAK,spr); - else spritesound(GLASS_BREAKING,spr); - lotsofglass(spr,dawallnum,30); - - if (wal->picnum == WALLLIGHT1) - wal->picnum = WALLLIGHTBUST1; - - if (wal->picnum == WALLLIGHT2) - wal->picnum = WALLLIGHTBUST2; - - if (wal->picnum == WALLLIGHT3) - wal->picnum = WALLLIGHTBUST3; - - if (wal->picnum == WALLLIGHT4) - wal->picnum = WALLLIGHTBUST4; - - if (wal->picnum == TECHLIGHT2) - wal->picnum = TECHLIGHTBUST2; - - if (wal->picnum == TECHLIGHT4) - wal->picnum = TECHLIGHTBUST4; - - if (!wal->lotag) return; - - sn = wal->nextsector; - if (sn < 0) return; - darkestwall = 0; - - wal = &wall[sector[sn].wallptr]; - for (i=sector[sn].wallnum;i > 0;i--,wal++) - if (wal->shade > darkestwall) - darkestwall=wal->shade; - - j = TRAND&1; - i= headspritestat[3]; - while (i >= 0) + j = TRAND&1; + i= headspritestat[3]; + while (i >= 0) + { + if (SHT == wall[dawallnum].lotag && SLT == 3) { - if (SHT == wall[dawallnum].lotag && SLT == 3) - { - T3 = j; - T4 = darkestwall; - T5 = 1; - } - i = nextspritestat[i]; + T3 = j; + T4 = darkestwall; + T5 = 1; } - break; + i = nextspritestat[i]; + } + break; } } @@ -1917,35 +1917,35 @@ void checkplayerhurt(struct player_struct *p,short j) switch (dynamictostatic[switchpicnum]) { - case W_FORCEFIELD__STATIC: - // case W_FORCEFIELD+1: - // case W_FORCEFIELD+2: - sprite[p->i].extra -= 5; + case W_FORCEFIELD__STATIC: + // case W_FORCEFIELD+1: + // case W_FORCEFIELD+2: + sprite[p->i].extra -= 5; - p->hurt_delay = 16; - p->pals_time = 32; - p->pals[0] = 32; - p->pals[1] = 0; - p->pals[2] = 0; + p->hurt_delay = 16; + p->pals_time = 32; + p->pals[0] = 32; + p->pals[1] = 0; + p->pals[2] = 0; - p->posxv = -(sintable[(p->ang+512)&2047]<<8); - p->posyv = -(sintable[(p->ang)&2047]<<8); - spritesound(DUKE_LONGTERM_PAIN,p->i); + p->posxv = -(sintable[(p->ang+512)&2047]<<8); + p->posyv = -(sintable[(p->ang)&2047]<<8); + spritesound(DUKE_LONGTERM_PAIN,p->i); - checkhitwall(p->i,j, - p->posx+(sintable[(p->ang+512)&2047]>>9), - p->posy+(sintable[p->ang&2047]>>9), - p->posz,-1); + checkhitwall(p->i,j, + p->posx+(sintable[(p->ang+512)&2047]>>9), + p->posy+(sintable[p->ang&2047]>>9), + p->posz,-1); - break; + break; - case BIGFORCE__STATIC: - p->hurt_delay = 26; - checkhitwall(p->i,j, - p->posx+(sintable[(p->ang+512)&2047]>>9), - p->posy+(sintable[p->ang&2047]>>9), - p->posz,-1); - break; + case BIGFORCE__STATIC: + p->hurt_delay = 26; + checkhitwall(p->i,j, + p->posx+(sintable[(p->ang+512)&2047]>>9), + p->posy+(sintable[p->ang&2047]>>9), + p->posz,-1); + break; } } @@ -1957,68 +1957,68 @@ char checkhitceiling(short sn) switch (dynamictostatic[sector[sn].ceilingpicnum]) { - case WALLLIGHT1__STATIC: - case WALLLIGHT2__STATIC: - case WALLLIGHT3__STATIC: - case WALLLIGHT4__STATIC: - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: + case WALLLIGHT1__STATIC: + case WALLLIGHT2__STATIC: + case WALLLIGHT3__STATIC: + case WALLLIGHT4__STATIC: + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: - ceilingglass(ps[myconnectindex].i,sn,10); - spritesound(GLASS_BREAKING,ps[screenpeek].i); + ceilingglass(ps[myconnectindex].i,sn,10); + spritesound(GLASS_BREAKING,ps[screenpeek].i); - if (sector[sn].ceilingpicnum == WALLLIGHT1) - sector[sn].ceilingpicnum = WALLLIGHTBUST1; + if (sector[sn].ceilingpicnum == WALLLIGHT1) + sector[sn].ceilingpicnum = WALLLIGHTBUST1; - if (sector[sn].ceilingpicnum == WALLLIGHT2) - sector[sn].ceilingpicnum = WALLLIGHTBUST2; + if (sector[sn].ceilingpicnum == WALLLIGHT2) + sector[sn].ceilingpicnum = WALLLIGHTBUST2; - if (sector[sn].ceilingpicnum == WALLLIGHT3) - sector[sn].ceilingpicnum = WALLLIGHTBUST3; + if (sector[sn].ceilingpicnum == WALLLIGHT3) + sector[sn].ceilingpicnum = WALLLIGHTBUST3; - if (sector[sn].ceilingpicnum == WALLLIGHT4) - sector[sn].ceilingpicnum = WALLLIGHTBUST4; + if (sector[sn].ceilingpicnum == WALLLIGHT4) + sector[sn].ceilingpicnum = WALLLIGHTBUST4; - if (sector[sn].ceilingpicnum == TECHLIGHT2) - sector[sn].ceilingpicnum = TECHLIGHTBUST2; + if (sector[sn].ceilingpicnum == TECHLIGHT2) + sector[sn].ceilingpicnum = TECHLIGHTBUST2; - if (sector[sn].ceilingpicnum == TECHLIGHT4) - sector[sn].ceilingpicnum = TECHLIGHTBUST4; + if (sector[sn].ceilingpicnum == TECHLIGHT4) + sector[sn].ceilingpicnum = TECHLIGHTBUST4; - if (!sector[sn].hitag) - { - i = headspritesect[sn]; - while (i >= 0) - { - if (PN == SECTOREFFECTOR && SLT == 12) - { - j = headspritestat[3]; - while (j >= 0) - { - if (sprite[j].hitag == SHT) - hittype[j].temp_data[3] = 1; - j = nextspritestat[j]; - } - break; - } - i = nextspritesect[i]; - } - } - - i = headspritestat[3]; - j = TRAND&1; + if (!sector[sn].hitag) + { + i = headspritesect[sn]; while (i >= 0) { - if (SHT == (sector[sn].hitag) && SLT == 3) + if (PN == SECTOREFFECTOR && SLT == 12) { - T3 = j; - T5 = 1; + j = headspritestat[3]; + while (j >= 0) + { + if (sprite[j].hitag == SHT) + hittype[j].temp_data[3] = 1; + j = nextspritestat[j]; + } + break; } - i = nextspritestat[i]; + i = nextspritesect[i]; } + } - return 1; + i = headspritestat[3]; + j = TRAND&1; + while (i >= 0) + { + if (SHT == (sector[sn].hitag) && SLT == 3) + { + T3 = j; + T5 = 1; + } + i = nextspritestat[i]; + } + + return 1; } return 0; @@ -2042,457 +2042,457 @@ void checkhitsprite(short i,short sn) } switch (dynamictostatic[PN]) { - case OCEANSPRITE1__STATIC: - case OCEANSPRITE2__STATIC: - case OCEANSPRITE3__STATIC: - case OCEANSPRITE4__STATIC: - case OCEANSPRITE5__STATIC: - spawn(i,SMALLSMOKE); - deletesprite(i); - break; - case QUEBALL__STATIC: - case STRIPEBALL__STATIC: - if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) + case OCEANSPRITE1__STATIC: + case OCEANSPRITE2__STATIC: + case OCEANSPRITE3__STATIC: + case OCEANSPRITE4__STATIC: + case OCEANSPRITE5__STATIC: + spawn(i,SMALLSMOKE); + deletesprite(i); + break; + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) + { + sprite[sn].xvel = (sprite[i].xvel>>1)+(sprite[i].xvel>>2); + sprite[sn].ang -= (SA<<1)+1024; + SA = getangle(SX-sprite[sn].x,SY-sprite[sn].y)-512; + if (issoundplaying(i,POOLBALLHIT) < 2) + spritesound(POOLBALLHIT,i); + } + else + { + if (TRAND&3) { - sprite[sn].xvel = (sprite[i].xvel>>1)+(sprite[i].xvel>>2); - sprite[sn].ang -= (SA<<1)+1024; - SA = getangle(SX-sprite[sn].x,SY-sprite[sn].y)-512; - if (issoundplaying(i,POOLBALLHIT) < 2) - spritesound(POOLBALLHIT,i); + sprite[i].xvel = 164; + sprite[i].ang = sprite[sn].ang; } else { - if (TRAND&3) - { - sprite[i].xvel = 164; - sprite[i].ang = sprite[sn].ang; - } - else - { - lotsofglass(i,-1,3); - deletesprite(i); - } - } - break; - case TREE1__STATIC: - case TREE2__STATIC: - case TIRE__STATIC: - case CONE__STATIC: - case BOX__STATIC: - { - if (rpg == 1) - if (T1 == 0) - { - CS &= ~257; - T1 = 1; - spawn(i,BURNING); - } - switch (dynamictostatic[sprite[sn].picnum]) - { - case RADIUSEXPLOSION__STATIC: - case RPG__STATIC: - case FIRELASER__STATIC: - case HYDRENT__STATIC: - case HEAVYHBOMB__STATIC: - if (T1 == 0) - { - CS &= ~257; - T1 = 1; - spawn(i,BURNING); - } - break; - } - break; - } - case CACTUS__STATIC: - { - if (rpg == 1) - for (k=0;k<64;k++) - { - j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); - sprite[j].pal = 8; - } - // case CACTUSBROKE: - switch (dynamictostatic[sprite[sn].picnum]) - { - case RADIUSEXPLOSION__STATIC: - case RPG__STATIC: - case FIRELASER__STATIC: - case HYDRENT__STATIC: - case HEAVYHBOMB__STATIC: - for (k=0;k<64;k++) - { - j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); - sprite[j].pal = 8; - } - - if (PN == CACTUS) - PN = CACTUSBROKE; - CS &= ~257; - // else deletesprite(i); - break; - } - break; - } - case HANGLIGHT__STATIC: - case GENERICPOLE2__STATIC: - for (k=0;k<6;k++) - EGS(SECT,SX,SY,SZ-(8<<8),SCRAP1+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); - spritesound(GLASS_HEAVYBREAK,i); - deletesprite(i); - break; - - - case FANSPRITE__STATIC: - PN = FANSPRITEBROKE; - CS &= (65535-257); - if (sector[SECT].floorpicnum == FANSHADOW) - sector[SECT].floorpicnum = FANSHADOWBROKE; - - spritesound(GLASS_HEAVYBREAK,i); - s = &sprite[i]; - for (j=0;j<16;j++) RANDOMSCRAP; - - break; - case WATERFOUNTAIN__STATIC: - // case WATERFOUNTAIN+1: - // case WATERFOUNTAIN+2: - // case __STATIC: - PN = WATERFOUNTAINBROKE; - spawn(i,TOILETWATER); - break; - case SATELITE__STATIC: - case FUELPOD__STATIC: - case SOLARPANNEL__STATIC: - case ANTENNA__STATIC: - if (sprite[sn].extra != *actorscrptr[SHOTSPARK1]) - { - for (j=0;j<15;j++) - EGS(SECT,SX,SY,sector[SECT].floorz-(12<<8)-(j<<9),SCRAP1+(TRAND&15),-8,64,64, - TRAND&2047,(TRAND&127)+64,-(TRAND&511)-256,i,5); - spawn(i,EXPLOSION2); + lotsofglass(i,-1,3); deletesprite(i); } - break; - case BOTTLE1__STATIC: - case BOTTLE2__STATIC: - case BOTTLE3__STATIC: - case BOTTLE4__STATIC: - case BOTTLE5__STATIC: - case BOTTLE6__STATIC: - case BOTTLE8__STATIC: - case BOTTLE10__STATIC: - case BOTTLE11__STATIC: - case BOTTLE12__STATIC: - case BOTTLE13__STATIC: - case BOTTLE14__STATIC: - case BOTTLE15__STATIC: - case BOTTLE16__STATIC: - case BOTTLE17__STATIC: - case BOTTLE18__STATIC: - case BOTTLE19__STATIC: - case WATERFOUNTAINBROKE__STATIC: - case DOMELITE__STATIC: - case SUSHIPLATE1__STATIC: - case SUSHIPLATE2__STATIC: - case SUSHIPLATE3__STATIC: - case SUSHIPLATE4__STATIC: - case SUSHIPLATE5__STATIC: - case WAITTOBESEATED__STATIC: - case VASE__STATIC: - case STATUEFLASH__STATIC: - case STATUE__STATIC: - if (PN == BOTTLE10) - lotsofmoney(&sprite[i],4+(TRAND&3)); - else if (PN == STATUE || PN == STATUEFLASH) + } + break; + case TREE1__STATIC: + case TREE2__STATIC: + case TIRE__STATIC: + case CONE__STATIC: + case BOX__STATIC: + { + if (rpg == 1) + if (T1 == 0) { - lotsofcolourglass(i,-1,40); - spritesound(GLASS_HEAVYBREAK,i); + CS &= ~257; + T1 = 1; + spawn(i,BURNING); } - else if (PN == VASE) - lotsofglass(i,-1,40); - - spritesound(GLASS_BREAKING,i); - SA = TRAND&2047; - lotsofglass(i,-1,8); - deletesprite(i); - break; - case FETUS__STATIC: - PN = FETUSBROKE; - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); - break; - case FETUSBROKE__STATIC: - for (j=0;j<48;j++) - { - shoot(i,BLOODSPLAT1); - SA += 333; - } - spritesound(GLASS_HEAVYBREAK,i); - spritesound(SQUISHED,i); - case BOTTLE7__STATIC: - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); - deletesprite(i); - break; - case HYDROPLANT__STATIC: - PN = BROKEHYDROPLANT; - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); - break; - - case FORCESPHERE__STATIC: - sprite[i].xrepeat = 0; - hittype[OW].temp_data[0] = 32; - hittype[OW].temp_data[1] = !hittype[OW].temp_data[1]; - hittype[OW].temp_data[2] ++; - spawn(i,EXPLOSION2); - break; - - case BROKEHYDROPLANT__STATIC: - if (CS&1) - { - spritesound(GLASS_BREAKING,i); - SZ += 16<<8; - CS = 0; - lotsofglass(i,-1,5); - } - break; - - case TOILET__STATIC: - PN = TOILETBROKE; - CS |= (TRAND&1)<<2; - CS &= ~257; - spawn(i,TOILETWATER); - spritesound(GLASS_BREAKING,i); - break; - - case STALL__STATIC: - PN = STALLBROKE; - CS |= (TRAND&1)<<2; - CS &= ~257; - spawn(i,TOILETWATER); - spritesound(GLASS_HEAVYBREAK,i); - break; - + switch (dynamictostatic[sprite[sn].picnum]) + { + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: case HYDRENT__STATIC: - PN = BROKEFIREHYDRENT; - spawn(i,TOILETWATER); - - // for(k=0;k<5;k++) - // { - // j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); - // sprite[j].pal = 2; - // } - spritesound(GLASS_HEAVYBREAK,i); - break; - - case GRATE1__STATIC: - PN = BGRATE1; - CS &= (65535-256-1); - spritesound(VENT_BUST,i); - break; - - case CIRCLEPANNEL__STATIC: - PN = CIRCLEPANNELBROKE; - CS &= (65535-256-1); - spritesound(VENT_BUST,i); - break; - case PANNEL1__STATIC: - case PANNEL2__STATIC: - PN = BPANNEL1; - CS &= (65535-256-1); - spritesound(VENT_BUST,i); - break; - case PANNEL3__STATIC: - PN = BPANNEL3; - CS &= (65535-256-1); - spritesound(VENT_BUST,i); - break; - case PIPE1__STATIC: - case PIPE2__STATIC: - case PIPE3__STATIC: - case PIPE4__STATIC: - case PIPE5__STATIC: - case PIPE6__STATIC: - switch (dynamictostatic[PN]) + case HEAVYHBOMB__STATIC: + if (T1 == 0) { - case PIPE1__STATIC: - PN=PIPE1B; - break; - case PIPE2__STATIC: - PN=PIPE2B; - break; - case PIPE3__STATIC: - PN=PIPE3B; - break; - case PIPE4__STATIC: - PN=PIPE4B; - break; - case PIPE5__STATIC: - PN=PIPE5B; - break; - case PIPE6__STATIC: - PN=PIPE6B; - break; + CS &= ~257; + T1 = 1; + spawn(i,BURNING); + } + break; + } + break; + } + case CACTUS__STATIC: + { + if (rpg == 1) + for (k=0;k<64;k++) + { + j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + sprite[j].pal = 8; + } + // case CACTUSBROKE: + switch (dynamictostatic[sprite[sn].picnum]) + { + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case HYDRENT__STATIC: + case HEAVYHBOMB__STATIC: + for (k=0;k<64;k++) + { + j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + sprite[j].pal = 8; } - j = spawn(i,STEAM); - sprite[j].z = sector[SECT].floorz-(32<<8); + if (PN == CACTUS) + PN = CACTUSBROKE; + CS &= ~257; + // else deletesprite(i); break; + } + break; + } + case HANGLIGHT__STATIC: + case GENERICPOLE2__STATIC: + for (k=0;k<6;k++) + EGS(SECT,SX,SY,SZ-(8<<8),SCRAP1+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + spritesound(GLASS_HEAVYBREAK,i); + deletesprite(i); + break; - case MONK__STATIC: - case LUKE__STATIC: - case INDY__STATIC: - case JURYGUY__STATIC: - spritesound(SLT,i); - spawn(i,SHT); - case SPACEMARINE__STATIC: - sprite[i].extra -= sprite[sn].extra; - if (sprite[i].extra > 0) break; - SA = TRAND&2047; - shoot(i,BLOODSPLAT1); - SA = TRAND&2047; - shoot(i,BLOODSPLAT2); - SA = TRAND&2047; - shoot(i,BLOODSPLAT3); - SA = TRAND&2047; - shoot(i,BLOODSPLAT4); - SA = TRAND&2047; - shoot(i,BLOODSPLAT1); - SA = TRAND&2047; - shoot(i,BLOODSPLAT2); - SA = TRAND&2047; - shoot(i,BLOODSPLAT3); - SA = TRAND&2047; - shoot(i,BLOODSPLAT4); - guts(&sprite[i],JIBS1,1,myconnectindex); - guts(&sprite[i],JIBS2,2,myconnectindex); - guts(&sprite[i],JIBS3,3,myconnectindex); - guts(&sprite[i],JIBS4,4,myconnectindex); - guts(&sprite[i],JIBS5,1,myconnectindex); - guts(&sprite[i],JIBS3,6,myconnectindex); - sound(SQUISHED); + + case FANSPRITE__STATIC: + PN = FANSPRITEBROKE; + CS &= (65535-257); + if (sector[SECT].floorpicnum == FANSHADOW) + sector[SECT].floorpicnum = FANSHADOWBROKE; + + spritesound(GLASS_HEAVYBREAK,i); + s = &sprite[i]; + for (j=0;j<16;j++) RANDOMSCRAP; + + break; + case WATERFOUNTAIN__STATIC: + // case WATERFOUNTAIN+1: + // case WATERFOUNTAIN+2: + // case __STATIC: + PN = WATERFOUNTAINBROKE; + spawn(i,TOILETWATER); + break; + case SATELITE__STATIC: + case FUELPOD__STATIC: + case SOLARPANNEL__STATIC: + case ANTENNA__STATIC: + if (sprite[sn].extra != *actorscrptr[SHOTSPARK1]) + { + for (j=0;j<15;j++) + EGS(SECT,SX,SY,sector[SECT].floorz-(12<<8)-(j<<9),SCRAP1+(TRAND&15),-8,64,64, + TRAND&2047,(TRAND&127)+64,-(TRAND&511)-256,i,5); + spawn(i,EXPLOSION2); deletesprite(i); - break; - case CHAIR1__STATIC: - case CHAIR2__STATIC: - PN = BROKENCHAIR; + } + break; + case BOTTLE1__STATIC: + case BOTTLE2__STATIC: + case BOTTLE3__STATIC: + case BOTTLE4__STATIC: + case BOTTLE5__STATIC: + case BOTTLE6__STATIC: + case BOTTLE8__STATIC: + case BOTTLE10__STATIC: + case BOTTLE11__STATIC: + case BOTTLE12__STATIC: + case BOTTLE13__STATIC: + case BOTTLE14__STATIC: + case BOTTLE15__STATIC: + case BOTTLE16__STATIC: + case BOTTLE17__STATIC: + case BOTTLE18__STATIC: + case BOTTLE19__STATIC: + case WATERFOUNTAINBROKE__STATIC: + case DOMELITE__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case SUSHIPLATE5__STATIC: + case WAITTOBESEATED__STATIC: + case VASE__STATIC: + case STATUEFLASH__STATIC: + case STATUE__STATIC: + if (PN == BOTTLE10) + lotsofmoney(&sprite[i],4+(TRAND&3)); + else if (PN == STATUE || PN == STATUEFLASH) + { + lotsofcolourglass(i,-1,40); + spritesound(GLASS_HEAVYBREAK,i); + } + else if (PN == VASE) + lotsofglass(i,-1,40); + + spritesound(GLASS_BREAKING,i); + SA = TRAND&2047; + lotsofglass(i,-1,8); + deletesprite(i); + break; + case FETUS__STATIC: + PN = FETUSBROKE; + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + break; + case FETUSBROKE__STATIC: + for (j=0;j<48;j++) + { + shoot(i,BLOODSPLAT1); + SA += 333; + } + spritesound(GLASS_HEAVYBREAK,i); + spritesound(SQUISHED,i); + case BOTTLE7__STATIC: + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + deletesprite(i); + break; + case HYDROPLANT__STATIC: + PN = BROKEHYDROPLANT; + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + break; + + case FORCESPHERE__STATIC: + sprite[i].xrepeat = 0; + hittype[OW].temp_data[0] = 32; + hittype[OW].temp_data[1] = !hittype[OW].temp_data[1]; + hittype[OW].temp_data[2] ++; + spawn(i,EXPLOSION2); + break; + + case BROKEHYDROPLANT__STATIC: + if (CS&1) + { + spritesound(GLASS_BREAKING,i); + SZ += 16<<8; CS = 0; - break; - case CHAIR3__STATIC: - case MOVIECAMERA__STATIC: - case SCALE__STATIC: - case VACUUM__STATIC: - case CAMERALIGHT__STATIC: - case IVUNIT__STATIC: - case POT1__STATIC: - case POT2__STATIC: - case POT3__STATIC: - case TRIPODCAMERA__STATIC: - spritesound(GLASS_HEAVYBREAK,i); - s = &sprite[i]; - for (j=0;j<16;j++) RANDOMSCRAP; - deletesprite(i); - break; - case PLAYERONWATER__STATIC: - i = OW; - default: - if ((sprite[i].cstat&16) && SHT == 0 && SLT == 0 && sprite[i].statnum == 0) - break; + lotsofglass(i,-1,5); + } + break; - if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) + case TOILET__STATIC: + PN = TOILETBROKE; + CS |= (TRAND&1)<<2; + CS &= ~257; + spawn(i,TOILETWATER); + spritesound(GLASS_BREAKING,i); + break; + + case STALL__STATIC: + PN = STALLBROKE; + CS |= (TRAND&1)<<2; + CS &= ~257; + spawn(i,TOILETWATER); + spritesound(GLASS_HEAVYBREAK,i); + break; + + case HYDRENT__STATIC: + PN = BROKEFIREHYDRENT; + spawn(i,TOILETWATER); + + // for(k=0;k<5;k++) + // { + // j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + // sprite[j].pal = 2; + // } + spritesound(GLASS_HEAVYBREAK,i); + break; + + case GRATE1__STATIC: + PN = BGRATE1; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + + case CIRCLEPANNEL__STATIC: + PN = CIRCLEPANNELBROKE; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PANNEL1__STATIC: + case PANNEL2__STATIC: + PN = BPANNEL1; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PANNEL3__STATIC: + PN = BPANNEL3; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PIPE1__STATIC: + case PIPE2__STATIC: + case PIPE3__STATIC: + case PIPE4__STATIC: + case PIPE5__STATIC: + case PIPE6__STATIC: + switch (dynamictostatic[PN]) + { + case PIPE1__STATIC: + PN=PIPE1B; + break; + case PIPE2__STATIC: + PN=PIPE2B; + break; + case PIPE3__STATIC: + PN=PIPE3B; + break; + case PIPE4__STATIC: + PN=PIPE4B; + break; + case PIPE5__STATIC: + PN=PIPE5B; + break; + case PIPE6__STATIC: + PN=PIPE6B; + break; + } + + j = spawn(i,STEAM); + sprite[j].z = sector[SECT].floorz-(32<<8); + break; + + case MONK__STATIC: + case LUKE__STATIC: + case INDY__STATIC: + case JURYGUY__STATIC: + spritesound(SLT,i); + spawn(i,SHT); + case SPACEMARINE__STATIC: + sprite[i].extra -= sprite[sn].extra; + if (sprite[i].extra > 0) break; + SA = TRAND&2047; + shoot(i,BLOODSPLAT1); + SA = TRAND&2047; + shoot(i,BLOODSPLAT2); + SA = TRAND&2047; + shoot(i,BLOODSPLAT3); + SA = TRAND&2047; + shoot(i,BLOODSPLAT4); + SA = TRAND&2047; + shoot(i,BLOODSPLAT1); + SA = TRAND&2047; + shoot(i,BLOODSPLAT2); + SA = TRAND&2047; + shoot(i,BLOODSPLAT3); + SA = TRAND&2047; + shoot(i,BLOODSPLAT4); + guts(&sprite[i],JIBS1,1,myconnectindex); + guts(&sprite[i],JIBS2,2,myconnectindex); + guts(&sprite[i],JIBS3,3,myconnectindex); + guts(&sprite[i],JIBS4,4,myconnectindex); + guts(&sprite[i],JIBS5,1,myconnectindex); + guts(&sprite[i],JIBS3,6,myconnectindex); + sound(SQUISHED); + deletesprite(i); + break; + case CHAIR1__STATIC: + case CHAIR2__STATIC: + PN = BROKENCHAIR; + CS = 0; + break; + case CHAIR3__STATIC: + case MOVIECAMERA__STATIC: + case SCALE__STATIC: + case VACUUM__STATIC: + case CAMERALIGHT__STATIC: + case IVUNIT__STATIC: + case POT1__STATIC: + case POT2__STATIC: + case POT3__STATIC: + case TRIPODCAMERA__STATIC: + spritesound(GLASS_HEAVYBREAK,i); + s = &sprite[i]; + for (j=0;j<16;j++) RANDOMSCRAP; + deletesprite(i); + break; + case PLAYERONWATER__STATIC: + i = OW; + default: + if ((sprite[i].cstat&16) && SHT == 0 && SLT == 0 && sprite[i].statnum == 0) + break; + + if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) + { + if (badguy(&sprite[i]) == 1) { - if (badguy(&sprite[i]) == 1) - { - if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; + if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; - if ((PN != DRONE) && (PN != ROTATEGUN) && (PN != COMMANDER) && (PN < GREENSLIME || PN > GREENSLIME+7)) - if (sprite[sn].picnum != FREEZEBLAST) - if (actortype[PN] == 0) - { - j = spawn(sn,JIBS6); - if (sprite[sn].pal == 6) - sprite[j].pal = 6; - sprite[j].z += (4<<8); - sprite[j].xvel = 16; - sprite[j].xrepeat = sprite[j].yrepeat = 24; - sprite[j].ang += 32-(TRAND&63); - } - - j = sprite[sn].owner; - - if (j >= 0 && sprite[j].picnum == APLAYER && PN != ROTATEGUN && PN != DRONE) - if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) + if ((PN != DRONE) && (PN != ROTATEGUN) && (PN != COMMANDER) && (PN < GREENSLIME || PN > GREENSLIME+7)) + if (sprite[sn].picnum != FREEZEBLAST) + if (actortype[PN] == 0) { - shoot(i,BLOODSPLAT3); - shoot(i,BLOODSPLAT1); - shoot(i,BLOODSPLAT2); - shoot(i,BLOODSPLAT4); + j = spawn(sn,JIBS6); + if (sprite[sn].pal == 6) + sprite[j].pal = 6; + sprite[j].z += (4<<8); + sprite[j].xvel = 16; + sprite[j].xrepeat = sprite[j].yrepeat = 24; + sprite[j].ang += 32-(TRAND&63); } - if (PN != TANK && PN != BOSS1 && PN != BOSS4 && PN != BOSS2 && PN != BOSS3 && PN != RECON && PN != ROTATEGUN) + j = sprite[sn].owner; + + if (j >= 0 && sprite[j].picnum == APLAYER && PN != ROTATEGUN && PN != DRONE) + if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) { - if ((sprite[i].cstat&48) == 0) - SA = (sprite[sn].ang+1024)&2047; - sprite[i].xvel = -(sprite[sn].extra<<2); - j = SECT; - pushmove(&SX,&SY,&SZ,&j,128L,(4L<<8),(4L<<8),CLIPMASK0); - if (j != SECT && j >= 0 && j < MAXSECTORS) - changespritesect(i,j); + shoot(i,BLOODSPLAT3); + shoot(i,BLOODSPLAT1); + shoot(i,BLOODSPLAT2); + shoot(i,BLOODSPLAT4); } - if (sprite[i].statnum == 2) - { - changespritestat(i,1); - hittype[i].timetosleep = SLEEPTIME; - } - if ((RX < 24 || PN == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; - } - - if (sprite[i].statnum != 2) + if (PN != TANK && PN != BOSS1 && PN != BOSS4 && PN != BOSS2 && PN != BOSS3 && PN != RECON && PN != ROTATEGUN) { - if (sprite[sn].picnum == FREEZEBLAST && ((PN == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) - return; - - hittype[i].picnum = sprite[sn].picnum; - hittype[i].extra += sprite[sn].extra; - hittype[i].ang = sprite[sn].ang; - hittype[i].owner = sprite[sn].owner; + if ((sprite[i].cstat&48) == 0) + SA = (sprite[sn].ang+1024)&2047; + sprite[i].xvel = -(sprite[sn].extra<<2); + j = SECT; + pushmove(&SX,&SY,&SZ,&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + if (j != SECT && j >= 0 && j < MAXSECTORS) + changespritesect(i,j); } - if (sprite[i].statnum == 10) + if (sprite[i].statnum == 2) { - p = sprite[i].yvel; - if (ps[p].newowner >= 0) - { - ps[p].newowner = -1; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; - ps[p].ang = ps[p].oang; - - updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); - setpal(&ps[p]); - - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; - j = nextspritestat[j]; - } - } - - if (RX < 24 && sprite[sn].picnum == SHRINKSPARK) - return; - - if (sprite[hittype[i].owner].picnum != APLAYER) - if (ud.player_skill >= 3) - sprite[sn].extra += (sprite[sn].extra>>1); + changespritestat(i,1); + hittype[i].timetosleep = SLEEPTIME; } - + if ((RX < 24 || PN == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; } - break; + + if (sprite[i].statnum != 2) + { + if (sprite[sn].picnum == FREEZEBLAST && ((PN == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) + return; + + hittype[i].picnum = sprite[sn].picnum; + hittype[i].extra += sprite[sn].extra; + hittype[i].ang = sprite[sn].ang; + hittype[i].owner = sprite[sn].owner; + } + + if (sprite[i].statnum == 10) + { + p = sprite[i].yvel; + if (ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].ang = ps[p].oang; + + updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); + setpal(&ps[p]); + + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + if (RX < 24 && sprite[sn].picnum == SHRINKSPARK) + return; + + if (sprite[hittype[i].owner].picnum != APLAYER) + if (ud.player_skill >= 3) + sprite[sn].extra += (sprite[sn].extra>>1); + } + + } + break; } } @@ -2622,21 +2622,21 @@ void cheatkeys(short snum) { switch (p->inven_icon) { - case 4: - sb_snum |= (1<<25); - break; - case 3: - sb_snum |= (1<<24); - break; - case 5: - sb_snum |= (1<<15); - break; - case 1: - sb_snum |= (1<<16); - break; - case 2: - sb_snum |= (1<<12); - break; + case 4: + sb_snum |= (1<<25); + break; + case 3: + sb_snum |= (1<<24); + break; + case 5: + sb_snum |= (1<<15); + break; + case 1: + sb_snum |= (1<<16); + break; + case 2: + sb_snum |= (1<<12); + break; } } } @@ -2696,49 +2696,49 @@ CHECKINV1: switch (dainv) { - case 4: - if (p->jetpack_amount > 0 && i > 1) - break; - if (k) dainv = 5; - else dainv = 3; - goto CHECKINV1; - case 6: - if (p->scuba_amount > 0 && i > 1) - break; - if (k) dainv = 7; - else dainv = 5; - goto CHECKINV1; - case 2: - if (p->steroids_amount > 0 && i > 1) - break; - if (k) dainv = 3; - else dainv = 1; - goto CHECKINV1; - case 3: - if (p->holoduke_amount > 0 && i > 1) - break; - if (k) dainv = 4; - else dainv = 2; - goto CHECKINV1; - case 0: - case 1: - if (p->firstaid_amount > 0 && i > 1) - break; - if (k) dainv = 2; - else dainv = 7; - goto CHECKINV1; - case 5: - if (p->heat_amount > 0 && i > 1) - break; - if (k) dainv = 6; - else dainv = 4; - goto CHECKINV1; - case 7: - if (p->boot_amount > 0 && i > 1) - break; - if (k) dainv = 1; - else dainv = 6; - goto CHECKINV1; + case 4: + if (p->jetpack_amount > 0 && i > 1) + break; + if (k) dainv = 5; + else dainv = 3; + goto CHECKINV1; + case 6: + if (p->scuba_amount > 0 && i > 1) + break; + if (k) dainv = 7; + else dainv = 5; + goto CHECKINV1; + case 2: + if (p->steroids_amount > 0 && i > 1) + break; + if (k) dainv = 3; + else dainv = 1; + goto CHECKINV1; + case 3: + if (p->holoduke_amount > 0 && i > 1) + break; + if (k) dainv = 4; + else dainv = 2; + goto CHECKINV1; + case 0: + case 1: + if (p->firstaid_amount > 0 && i > 1) + break; + if (k) dainv = 2; + else dainv = 7; + goto CHECKINV1; + case 5: + if (p->heat_amount > 0 && i > 1) + break; + if (k) dainv = 6; + else dainv = 4; + goto CHECKINV1; + case 7: + if (p->boot_amount > 0 && i > 1) + break; + if (k) dainv = 1; + else dainv = 6; + goto CHECKINV1; } } else dainv = 0; @@ -2760,27 +2760,27 @@ CHECKINV1: switch (dainv) { - case 1: - FTA(3,p); - break; - case 2: - FTA(90,p); - break; - case 3: - FTA(91,p); - break; - case 4: - FTA(88,p); - break; - case 5: - FTA(101,p); - break; - case 6: - FTA(89,p); - break; - case 7: - FTA(6,p); - break; + case 1: + FTA(3,p); + break; + case 2: + FTA(90,p); + break; + case 3: + FTA(91,p); + break; + case 4: + FTA(88,p); + break; + case 5: + FTA(101,p); + break; + case 6: + FTA(89,p); + break; + case 7: + FTA(6,p); + break; } } @@ -2790,42 +2790,42 @@ CHECKINV1: switch (j) { - case 0: - OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); - break; - case 1: - OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); - break; - case 2: - OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); - break; - case 3: - OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); - break; - case 4: - OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); - break; - case 5: - OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); - break; - case 6: - OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); - break; - case 7: - OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); - break; - case 8: - OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); - break; - case 9: - OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); - break; - case 10: - OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); - break; - case 11: - OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); - break; + case 0: + OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); + break; + case 1: + OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); + break; + case 2: + OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); + break; + case 3: + OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); + break; + case 4: + OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); + break; + case 5: + OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); + break; + case 6: + OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); + break; + case 7: + OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); + break; + case 8: + OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); + break; + case 9: + OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); + break; + case 10: + OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); + break; + case 11: + OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); + break; } if ((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) @@ -2958,86 +2958,86 @@ CHECKINV1: else if ((long)j >= 0 && p->gotweapon[j] && (unsigned long)p->curr_weapon != j) switch (j) { - case KNEE_WEAPON: - addweapon(p, KNEE_WEAPON); - break; - case PISTOL_WEAPON: - if (p->ammo_amount[PISTOL_WEAPON] == 0) - if (p->show_empty_weapon == 0) - { - p->last_full_weapon = p->curr_weapon; - p->show_empty_weapon = 32; - } - addweapon(p, PISTOL_WEAPON); - break; - case SHOTGUN_WEAPON: - if (p->ammo_amount[SHOTGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + case KNEE_WEAPON: + addweapon(p, KNEE_WEAPON); + break; + case PISTOL_WEAPON: + if (p->ammo_amount[PISTOL_WEAPON] == 0) + if (p->show_empty_weapon == 0) { p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, SHOTGUN_WEAPON); - break; - case CHAINGUN_WEAPON: - if (p->ammo_amount[CHAINGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + addweapon(p, PISTOL_WEAPON); + break; + case SHOTGUN_WEAPON: + if (p->ammo_amount[SHOTGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon(p, SHOTGUN_WEAPON); + break; + case CHAINGUN_WEAPON: + if (p->ammo_amount[CHAINGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon(p, CHAINGUN_WEAPON); + break; + case RPG_WEAPON: + if (p->ammo_amount[RPG_WEAPON] == 0) + if (p->show_empty_weapon == 0) { p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, CHAINGUN_WEAPON); - break; - case RPG_WEAPON: - if (p->ammo_amount[RPG_WEAPON] == 0) - if (p->show_empty_weapon == 0) - { - p->last_full_weapon = p->curr_weapon; - p->show_empty_weapon = 32; - } - addweapon(p, RPG_WEAPON); - break; - case DEVISTATOR_WEAPON: - if (p->ammo_amount[DEVISTATOR_WEAPON] == 0 && p->show_empty_weapon == 0) - { - p->last_full_weapon = p->curr_weapon; - p->show_empty_weapon = 32; - } - addweapon(p, DEVISTATOR_WEAPON); - break; - case FREEZE_WEAPON: - if (p->ammo_amount[FREEZE_WEAPON] == 0 && p->show_empty_weapon == 0) - { - p->last_full_weapon = p->curr_weapon; - p->show_empty_weapon = 32; - } - addweapon(p, FREEZE_WEAPON); - break; - case GROW_WEAPON: - case SHRINKER_WEAPON: + addweapon(p, RPG_WEAPON); + break; + case DEVISTATOR_WEAPON: + if (p->ammo_amount[DEVISTATOR_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon(p, DEVISTATOR_WEAPON); + break; + case FREEZE_WEAPON: + if (p->ammo_amount[FREEZE_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon(p, FREEZE_WEAPON); + break; + case GROW_WEAPON: + case SHRINKER_WEAPON: - if (p->ammo_amount[j] == 0 && p->show_empty_weapon == 0) - { - p->show_empty_weapon = 32; - p->last_full_weapon = p->curr_weapon; - } + if (p->ammo_amount[j] == 0 && p->show_empty_weapon == 0) + { + p->show_empty_weapon = 32; + p->last_full_weapon = p->curr_weapon; + } - addweapon(p, j); - break; - case HANDREMOTE_WEAPON: - if (k >= 0) // Found in list of [1]'s - { - p->curr_weapon = HANDREMOTE_WEAPON; - p->last_weapon = -1; - p->weapon_pos = 10; - } - break; - case HANDBOMB_WEAPON: - if (p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON]) - addweapon(p, HANDBOMB_WEAPON); - break; - case TRIPBOMB_WEAPON: - if (p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON]) - addweapon(p, TRIPBOMB_WEAPON); - break; + addweapon(p, j); + break; + case HANDREMOTE_WEAPON: + if (k >= 0) // Found in list of [1]'s + { + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; + } + break; + case HANDBOMB_WEAPON: + if (p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON]) + addweapon(p, HANDBOMB_WEAPON); + break; + case TRIPBOMB_WEAPON: + if (p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON]) + addweapon(p, TRIPBOMB_WEAPON); + break; } } @@ -3191,42 +3191,42 @@ void checksectors(short snum) switch (sector[p->cursectnum].lotag) { - case 32767: + case 32767: + sector[p->cursectnum].lotag = 0; + FTA(9,p); + p->secret_rooms++; + return; + case -1: + for (i=connecthead;i>=0;i=connectpoint2[i]) + ps[i].gm = MODE_EOL; + sector[p->cursectnum].lotag = 0; + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + if ((ud.volume_number && ud.level_number > 10) || (ud.volume_number == 0 && ud.level_number > 5)) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + return; + case -2: + sector[p->cursectnum].lotag = 0; + p->timebeforeexit = 26*8; + p->customexitsound = sector[p->cursectnum].hitag; + return; + default: + if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) + { + if (snum == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) + spritesound(sector[p->cursectnum].lotag-10000,p->i); sector[p->cursectnum].lotag = 0; - FTA(9,p); - p->secret_rooms++; - return; - case -1: - for (i=connecthead;i>=0;i=connectpoint2[i]) - ps[i].gm = MODE_EOL; - sector[p->cursectnum].lotag = 0; - if (ud.from_bonus) - { - ud.level_number = ud.from_bonus; - ud.m_level_number = ud.level_number; - ud.from_bonus = 0; - } - else - { - ud.level_number++; - if ((ud.volume_number && ud.level_number > 10) || (ud.volume_number == 0 && ud.level_number > 5)) - ud.level_number = 0; - ud.m_level_number = ud.level_number; - } - return; - case -2: - sector[p->cursectnum].lotag = 0; - p->timebeforeexit = 26*8; - p->customexitsound = sector[p->cursectnum].hitag; - return; - default: - if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) - { - if (snum == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) - spritesound(sector[p->cursectnum].lotag-10000,p->i); - sector[p->cursectnum].lotag = 0; - } - break; + } + break; } @@ -3286,9 +3286,9 @@ void checksectors(short snum) if (hitscanwall >= 0 && (wall[hitscanwall].cstat&16)) switch (wall[hitscanwall].overpicnum) { - default: - if (wall[hitscanwall].lotag) - return; + default: + if (wall[hitscanwall].lotag) + return; } if (p->newowner >= 0) @@ -3307,21 +3307,21 @@ void checksectors(short snum) { switch (dynamictostatic[sprite[neartagsprite].picnum]) { - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case PODFEM1__STATIC: - case NAKED1__STATIC: - case STATUE__STATIC: - case TOUGHGAL__STATIC: - return; + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + case TOUGHGAL__STATIC: + return; } } @@ -3351,131 +3351,131 @@ void checksectors(short snum) switch (dynamictostatic[sprite[neartagsprite].picnum]) { - case TOILET__STATIC: - case STALL__STATIC: - if (p->last_pissed_time == 0) - { - if (ud.lockout == 0) spritesound(DUKE_URINATE,p->i); - - p->last_pissed_time = 26*220; - p->transporter_hold = 29*2; - if (p->holster_weapon == 0) - { - p->holster_weapon = 1; - p->weapon_pos = -1; - } - if (sprite[p->i].extra <= (max_player_health-(max_player_health/10))) - { - sprite[p->i].extra += max_player_health/10; - p->last_extra = sprite[p->i].extra; - } - else if (sprite[p->i].extra < max_player_health) - sprite[p->i].extra = max_player_health; - } - else if (!isspritemakingsound(neartagsprite,FLUSH_TOILET)) - spritesound(FLUSH_TOILET,neartagsprite); - return; - - case NUKEBUTTON__STATIC: - - hitawall(p,&j); - if (j >= 0 && wall[j].overpicnum == 0) - if (hittype[neartagsprite].temp_data[0] == 0) - { - if (ud.noexits && ud.multimode > 1) - { - hittype[p->i].picnum = NUKEBUTTON; - hittype[p->i].extra = 250; - } - else - { - hittype[neartagsprite].temp_data[0] = 1; - sprite[neartagsprite].owner = p->i; - p->buttonpalette = sprite[neartagsprite].pal; - if (p->buttonpalette) - ud.secretlevel = sprite[neartagsprite].lotag; - else ud.secretlevel = 0; - } - } - return; - case WATERFOUNTAIN__STATIC: - if (hittype[neartagsprite].temp_data[0] != 1) - { - hittype[neartagsprite].temp_data[0] = 1; - sprite[neartagsprite].owner = p->i; - - if (sprite[p->i].extra < max_player_health) - { - sprite[p->i].extra++; - spritesound(DUKE_DRINKING,p->i); - } - } - return; - case PLUG__STATIC: - spritesound(SHORT_CIRCUIT,p->i); - sprite[p->i].extra -= 2+(TRAND&3); - p->pals[0] = 48; - p->pals[1] = 48; - p->pals[2] = 64; - p->pals_time = 32; - break; - case VIEWSCREEN__STATIC: - case VIEWSCREEN2__STATIC: + case TOILET__STATIC: + case STALL__STATIC: + if (p->last_pissed_time == 0) { - i = headspritestat[1]; + if (ud.lockout == 0) spritesound(DUKE_URINATE,p->i); - while (i >= 0) + p->last_pissed_time = 26*220; + p->transporter_hold = 29*2; + if (p->holster_weapon == 0) { - if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT) + p->holster_weapon = 1; + p->weapon_pos = -1; + } + if (sprite[p->i].extra <= (max_player_health-(max_player_health/10))) + { + sprite[p->i].extra += max_player_health/10; + p->last_extra = sprite[p->i].extra; + } + else if (sprite[p->i].extra < max_player_health) + sprite[p->i].extra = max_player_health; + } + else if (!isspritemakingsound(neartagsprite,FLUSH_TOILET)) + spritesound(FLUSH_TOILET,neartagsprite); + return; + + case NUKEBUTTON__STATIC: + + hitawall(p,&j); + if (j >= 0 && wall[j].overpicnum == 0) + if (hittype[neartagsprite].temp_data[0] == 0) + { + if (ud.noexits && ud.multimode > 1) { - SP = 1; //Using this camera - spritesound(MONITOR_ACTIVE,neartagsprite); - - sprite[neartagsprite].owner = i; - sprite[neartagsprite].yvel = 1; - - - j = p->cursectnum; - p->cursectnum = SECT; - setpal(p); - p->cursectnum = j; - - // parallaxtype = 2; - p->newowner = i; - return; + hittype[p->i].picnum = NUKEBUTTON; + hittype[p->i].extra = 250; } - i = nextspritestat[i]; + else + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; + p->buttonpalette = sprite[neartagsprite].pal; + if (p->buttonpalette) + ud.secretlevel = sprite[neartagsprite].lotag; + else ud.secretlevel = 0; + } + } + return; + case WATERFOUNTAIN__STATIC: + if (hittype[neartagsprite].temp_data[0] != 1) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; + + if (sprite[p->i].extra < max_player_health) + { + sprite[p->i].extra++; + spritesound(DUKE_DRINKING,p->i); } } + return; + case PLUG__STATIC: + spritesound(SHORT_CIRCUIT,p->i); + sprite[p->i].extra -= 2+(TRAND&3); + p->pals[0] = 48; + p->pals[1] = 48; + p->pals[2] = 64; + p->pals_time = 32; + break; + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + { + i = headspritestat[1]; + + while (i >= 0) + { + if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT) + { + SP = 1; //Using this camera + spritesound(MONITOR_ACTIVE,neartagsprite); + + sprite[neartagsprite].owner = i; + sprite[neartagsprite].yvel = 1; + + + j = p->cursectnum; + p->cursectnum = SECT; + setpal(p); + p->cursectnum = j; + + // parallaxtype = 2; + p->newowner = i; + return; + } + i = nextspritestat[i]; + } + } CLEARCAMERAS: - if (i < 0) + if (i < 0) + { + p->posx = p->oposx; + p->posy = p->oposy; + p->posz = p->oposz; + p->ang = p->oang; + p->newowner = -1; + + updatesector(p->posx,p->posy,&p->cursectnum); + setpal(p); + + + i = headspritestat[1]; + while (i >= 0) { - p->posx = p->oposx; - p->posy = p->oposy; - p->posz = p->oposz; - p->ang = p->oang; - p->newowner = -1; - - updatesector(p->posx,p->posy,&p->cursectnum); - setpal(p); - - - i = headspritestat[1]; - while (i >= 0) - { - if (PN==CAMERA1) SP = 0; - i = nextspritestat[i]; - } + if (PN==CAMERA1) SP = 0; + i = nextspritestat[i]; } - else if (p->newowner >= 0) - p->newowner = -1; + } + else if (p->newowner >= 0) + p->newowner = -1; - if (KB_KeyPressed(sc_Escape)) - KB_ClearKeyDown(sc_Escape); + if (KB_KeyPressed(sc_Escape)) + KB_ClearKeyDown(sc_Escape); - return; + return; } } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 624ec3fe2..99c855116 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -204,6 +204,7 @@ void intomenusounds(void) void playmusic(char *fn) { +#if defined(_WIN32) short fp; long l; @@ -224,6 +225,15 @@ void playmusic(char *fn) kread(fp, MusicPtr, l); kclose(fp); MUSIC_PlaySong(MusicPtr, MUSIC_LoopSong); +#else + void PlayMusic(char *_filename); + if(MusicToggle == 0) return; + if(MusicDevice < 0) return; + + // FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler + MUSIC_SetVolume( MusicVolume ); + PlayMusic(fn); +#endif } char loadsound(unsigned short num) @@ -318,20 +328,20 @@ int xyzsound(short num,short i,long x,long y,long z) switch (num) { - case PIPEBOMB_EXPLODE: - case LASERTRIP_EXPLODE: - case RPG_EXPLODE: - if (sndist > (6144)) - sndist = 6144; - if (sector[ps[screenpeek].cursectnum].lotag == 2) - pitch -= 1024; - break; - default: - if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) - pitch = -768; - if (sndist > 31444 && PN != MUSICANDSFX) - return -1; - break; + case PIPEBOMB_EXPLODE: + case LASERTRIP_EXPLODE: + case RPG_EXPLODE: + if (sndist > (6144)) + sndist = 6144; + if (sector[ps[screenpeek].cursectnum].lotag == 2) + pitch -= 1024; + break; + default: + if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) + pitch = -768; + if (sndist > 31444 && PN != MUSICANDSFX) + return -1; + break; } if (ps[screenpeek].sound_pitch) pitch += ps[screenpeek].sound_pitch; @@ -558,17 +568,17 @@ void pan3dsound(void) switch (j) { - case PIPEBOMB_EXPLODE: - case LASERTRIP_EXPLODE: - case RPG_EXPLODE: - if (sndist > (6144)) sndist = (6144); - break; - default: - if (sndist > 31444 && PN != MUSICANDSFX) - { - stopsound(j); - continue; - } + case PIPEBOMB_EXPLODE: + case LASERTRIP_EXPLODE: + case RPG_EXPLODE: + if (sndist > (6144)) sndist = (6144); + break; + default: + if (sndist > 31444 && PN != MUSICANDSFX) + { + stopsound(j); + continue; + } } if (Sound[j].ptr == 0 && loadsound(j) == 0) continue; diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index f31bc0bfb..b066787d2 100755 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -558,31 +558,31 @@ int startwin_puts(const char *str) { switch (*bptr) { - case '\b': - if (bptr > aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); + case '\b': + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); #if GTK_CHECK_VERSION(2,6,0) - gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); #else - { - GtkTextIter iter2 = enditer; - gtk_text_iter_backward_cursor_position(&iter2); - //FIXME: this seems be deleting one too many chars somewhere! - if (!gtk_text_iter_equal(&iter2, &enditer)) - gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); - } + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } #endif - aptr = ++bptr; - break; - case 0: - if (bptr > aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); - aptr = bptr; - break; - case '\r': // FIXME - default: - bptr++; - break; + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; } } diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index b23eed0f9..b2d5f4b5d 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -153,42 +153,42 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L { switch (uMsg) { - case WM_COMMAND: - switch (LOWORD(wParam)) + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDCFULLSCREEN: + settings.fullscreen = !settings.fullscreen; + PopulateForm(POPULATE_VIDEO); + return TRUE; + case IDCVMODE: + if (HIWORD(wParam) == CBN_SELCHANGE) { - case IDCFULLSCREEN: - settings.fullscreen = !settings.fullscreen; - PopulateForm(POPULATE_VIDEO); - return TRUE; - case IDCVMODE: - if (HIWORD(wParam) == CBN_SELCHANGE) - { - int i; - i = ComboBox_GetCurSel((HWND)lParam); - if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); - if (i != CB_ERR) - { - settings.xdim = validmode[i].xdim; - settings.ydim = validmode[i].ydim; - settings.bpp = validmode[i].bpp; - } - } - return TRUE; - case IDCALWAYSSHOW: - settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; - return TRUE; - case IDCINPUTMOUSE: - settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED; - return TRUE; - case IDCINPUTJOY: - settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED; - return TRUE; - default: - break; + int i; + i = ComboBox_GetCurSel((HWND)lParam); + if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); + if (i != CB_ERR) + { + settings.xdim = validmode[i].xdim; + settings.ydim = validmode[i].ydim; + settings.bpp = validmode[i].bpp; + } } - break; + return TRUE; + case IDCALWAYSSHOW: + settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED; + return TRUE; + case IDCINPUTMOUSE: + settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED; + return TRUE; + case IDCINPUTJOY: + settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED; + return TRUE; default: break; + } + break; + default: + break; } return FALSE; } @@ -197,28 +197,28 @@ static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA { switch (uMsg) { - case WM_COMMAND: - switch (LOWORD(wParam)) + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDGDATA: + { + int i; + if (HIWORD(wParam) != LBN_SELCHANGE) break; + i = ListBox_GetCurSel((HWND)lParam); + if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); + if (i != CB_ERR) { - case IDGDATA: - { - int i; - if (HIWORD(wParam) != LBN_SELCHANGE) break; - i = ListBox_GetCurSel((HWND)lParam); - if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); - if (i != CB_ERR) - { - strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); - settings.game = ((struct grpfile*)i)->game; - } - return TRUE; - } - default: - break; + strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); + settings.game = ((struct grpfile*)i)->game; } - break; + return TRUE; + } default: break; + } + break; + default: + break; } return FALSE; } @@ -258,204 +258,204 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, switch (uMsg) { - case WM_INITDIALOG: + case WM_INITDIALOG: + { + HWND hwnd; + RECT r, rdlg, chrome, rtab, rcancel, rstart; + int xoffset = 0, yoffset = 0; + + // Fetch the positions (in screen coordinates) of all the windows we need to tweak + ZeroMemory(&chrome, sizeof(chrome)); + AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); + GetWindowRect(hwndDlg, &rdlg); + GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); + GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); + GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); + + // Knock off the non-client area of the main dialogue to give just the client area + rdlg.left -= chrome.left; + rdlg.top -= chrome.top; + rdlg.right -= chrome.right; + rdlg.bottom -= chrome.bottom; + + // Translate them to client-relative coordinates wrt the main dialogue window + rtab.right -= rtab.left - 1; + rtab.bottom -= rtab.top - 1; + rtab.left -= rdlg.left; + rtab.top -= rdlg.top; + + rcancel.right -= rcancel.left - 1; + rcancel.bottom -= rcancel.top - 1; + rcancel.left -= rdlg.left; + rcancel.top -= rdlg.top; + + rstart.right -= rstart.left - 1; + rstart.bottom -= rstart.top - 1; + rstart.left -= rdlg.left; + rstart.top -= rdlg.top; + + // And then convert the main dialogue coordinates to just width/length + rdlg.right -= rdlg.left - 1; + rdlg.bottom -= rdlg.top - 1; + rdlg.left = 0; + rdlg.top = 0; + + // Load the bitmap into the bitmap control and fetch its dimensions + hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); + hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); + SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); + GetClientRect(hwnd, &r); + xoffset = r.right; + yoffset = r.bottom - rdlg.bottom; + + // Shift and resize the controls that require it + rtab.left += xoffset; + rtab.bottom += yoffset; + rcancel.left += xoffset; + rcancel.top += yoffset; + rstart.left += xoffset; + rstart.top += yoffset; + rdlg.right += xoffset; + rdlg.bottom += yoffset; + + // Move the controls to their new positions + MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); + MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); + MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); + + // Move the main dialogue to the centre of the screen + hdc = GetDC(NULL); + rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; + rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; + ReleaseDC(NULL, hdc); + MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, + rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); + + // Add tabs to the tab control { - HWND hwnd; - RECT r, rdlg, chrome, rtab, rcancel, rstart; - int xoffset = 0, yoffset = 0; + TCITEM tab; - // Fetch the positions (in screen coordinates) of all the windows we need to tweak - ZeroMemory(&chrome, sizeof(chrome)); - AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); - GetWindowRect(hwndDlg, &rdlg); - GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); - GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); - GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); + hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); - // Knock off the non-client area of the main dialogue to give just the client area - rdlg.left -= chrome.left; - rdlg.top -= chrome.top; - rdlg.right -= chrome.right; - rdlg.bottom -= chrome.bottom; + ZeroMemory(&tab, sizeof(tab)); + tab.mask = TCIF_TEXT; + tab.pszText = TEXT("Configuration"); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); + tab.mask = TCIF_TEXT; + tab.pszText = TEXT("Game"); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); + tab.mask = TCIF_TEXT; + tab.pszText = TEXT("Messages"); + SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); - // Translate them to client-relative coordinates wrt the main dialogue window - rtab.right -= rtab.left - 1; - rtab.bottom -= rtab.top - 1; - rtab.left -= rdlg.left; - rtab.top -= rdlg.top; - - rcancel.right -= rcancel.left - 1; - rcancel.bottom -= rcancel.top - 1; - rcancel.left -= rdlg.left; - rcancel.top -= rdlg.top; - - rstart.right -= rstart.left - 1; - rstart.bottom -= rstart.top - 1; - rstart.left -= rdlg.left; - rstart.top -= rdlg.top; - - // And then convert the main dialogue coordinates to just width/length - rdlg.right -= rdlg.left - 1; - rdlg.bottom -= rdlg.top - 1; - rdlg.left = 0; - rdlg.top = 0; - - // Load the bitmap into the bitmap control and fetch its dimensions - hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); - hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); - SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); + // Work out the position and size of the area inside the tab control for the pages + ZeroMemory(&r, sizeof(r)); GetClientRect(hwnd, &r); - xoffset = r.right; - yoffset = r.bottom - rdlg.bottom; + SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); + r.right -= r.left-1; + r.bottom -= r.top-1; + r.top += rtab.top; + r.left += rtab.left; - // Shift and resize the controls that require it - rtab.left += xoffset; - rtab.bottom += yoffset; - rcancel.left += xoffset; - rcancel.top += yoffset; - rstart.left += xoffset; - rstart.top += yoffset; - rdlg.right += xoffset; - rdlg.bottom += yoffset; + // Create the pages and position them in the tab control, but hide them + pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), + MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); + pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), + MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); + pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); + SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); + SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); + SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); - // Move the controls to their new positions - MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); - MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); - MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); + // Tell the editfield acting as the console to exclude the width of the scrollbar + GetClientRect(pages[TAB_MESSAGES],&r); + r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; + r.left = r.top = 0; + SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); - // Move the main dialogue to the centre of the screen - hdc = GetDC(NULL); - rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; - rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; - ReleaseDC(NULL, hdc); - MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, - rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); - - // Add tabs to the tab control + // Set a tab stop in the game data listbox { - TCITEM tab; - - hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); - - ZeroMemory(&tab, sizeof(tab)); - tab.mask = TCIF_TEXT; - tab.pszText = TEXT("Configuration"); - SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); - tab.mask = TCIF_TEXT; - tab.pszText = TEXT("Game"); - SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); - tab.mask = TCIF_TEXT; - tab.pszText = TEXT("Messages"); - SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); - - // Work out the position and size of the area inside the tab control for the pages - ZeroMemory(&r, sizeof(r)); - GetClientRect(hwnd, &r); - SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); - r.right -= r.left-1; - r.bottom -= r.top-1; - r.top += rtab.top; - r.left += rtab.left; - - // Create the pages and position them in the tab control, but hide them - pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), - MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); - pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), - MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); - pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); - SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); - SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); - SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); - - // Tell the editfield acting as the console to exclude the width of the scrollbar - GetClientRect(pages[TAB_MESSAGES],&r); - r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; - r.left = r.top = 0; - SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); - - // Set a tab stop in the game data listbox - { - DWORD tabs[1] = { 150 }; - ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs); - } - - SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); - SetWindowText(hwndDlg, apptitle); + DWORD tabs[1] = { 150 }; + ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs); } - return FALSE; - } - case WM_NOTIFY: + SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); + SetWindowText(hwndDlg, apptitle); + } + return FALSE; + } + + case WM_NOTIFY: + { + LPNMHDR nmhdr = (LPNMHDR)lParam; + int cur; + if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; + cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); + switch (nmhdr->code) { - LPNMHDR nmhdr = (LPNMHDR)lParam; - int cur; - if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; - cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); - switch (nmhdr->code) - { - case TCN_SELCHANGING: - { - if (cur < 0 || !pages[cur]) break; - ShowWindow(pages[cur],SW_HIDE); - return TRUE; - } - case TCN_SELCHANGE: - { - if (cur < 0 || !pages[cur]) break; - ShowWindow(pages[cur],SW_SHOW); - return TRUE; - } - } - break; + case TCN_SELCHANGING: + { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_HIDE); + return TRUE; + } + case TCN_SELCHANGE: + { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_SHOW); + return TRUE; + } + } + break; + } + + case WM_CLOSE: + if (mode == TAB_CONFIG) done = 0; + else quitevent++; + return TRUE; + + case WM_DESTROY: + if (hbmp) + { + DeleteObject(hbmp); + hbmp = NULL; } - case WM_CLOSE: + if (pages[TAB_GAME]) + { + DestroyWindow(pages[TAB_GAME]); + pages[TAB_GAME] = NULL; + } + + if (pages[TAB_CONFIG]) + { + DestroyWindow(pages[TAB_CONFIG]); + pages[TAB_CONFIG] = NULL; + } + + startupdlg = NULL; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case WIN_STARTWIN_CANCEL: if (mode == TAB_CONFIG) done = 0; else quitevent++; return TRUE; - - case WM_DESTROY: - if (hbmp) - { - DeleteObject(hbmp); - hbmp = NULL; - } - - if (pages[TAB_GAME]) - { - DestroyWindow(pages[TAB_GAME]); - pages[TAB_GAME] = NULL; - } - - if (pages[TAB_CONFIG]) - { - DestroyWindow(pages[TAB_CONFIG]); - pages[TAB_CONFIG] = NULL; - } - - startupdlg = NULL; + case WIN_STARTWIN_START: + done = 1; return TRUE; + } + return FALSE; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case WIN_STARTWIN_CANCEL: - if (mode == TAB_CONFIG) done = 0; - else quitevent++; - return TRUE; - case WIN_STARTWIN_START: - done = 1; - return TRUE; - } - return FALSE; + case WM_CTLCOLORSTATIC: + if ((HWND)lParam == pages[TAB_MESSAGES]) + return (BOOL)GetSysColorBrush(COLOR_WINDOW); + break; - case WM_CTLCOLORSTATIC: - if ((HWND)lParam == pages[TAB_MESSAGES]) - return (BOOL)GetSysColorBrush(COLOR_WINDOW); - break; - - default: - break; + default: + break; } return FALSE; @@ -590,16 +590,16 @@ int startwin_run(void) { switch (GetMessage(&msg, NULL, 0,0)) { - case 0: - done = 1; - break; - case -1: - return -1; - default: - if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; - TranslateMessage(&msg); - DispatchMessage(&msg); - break; + case 0: + done = 1; + break; + case -1: + return -1; + default: + if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; + TranslateMessage(&msg); + DispatchMessage(&msg); + break; } }