From 98a359f3e13bf8dd9769e3216f452ea25e514823 Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 24 Jul 2009 02:31:34 +0000 Subject: [PATCH] Clean out tree... misc changes git-svn-id: https://svn.eduke32.com/eduke32@1465 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile.deps | 2 - polymer/eduke32/Makefile.msvc | 1 - polymer/eduke32/build/include/build.h | 4 +- polymer/eduke32/build/src/build.c | 8 +- polymer/eduke32/build/src/mmulti_unstable.c | 19 ++- polymer/eduke32/build/src/polymer.c | 14 +- polymer/eduke32/eduke32.vcproj | 8 -- polymer/eduke32/source/anim.c | 2 +- polymer/eduke32/source/duke3d.h | 25 ++-- polymer/eduke32/source/funct.h | 1 - polymer/eduke32/source/game.c | 62 ++++----- polymer/eduke32/source/gamedef.c | 16 +-- polymer/eduke32/source/gameexec.c | 6 +- polymer/eduke32/source/gamevars.c | 12 +- polymer/eduke32/source/jaudiolib/_multivc.h | 2 +- polymer/eduke32/source/jaudiolib/multivoc.c | 6 +- polymer/eduke32/source/player.c | 16 +-- polymer/eduke32/source/sector.c | 126 +++--------------- polymer/eduke32/source/sounds.c | 134 ++++++++++---------- polymer/eduke32/source/sounds_mapster32.c | 10 +- polymer/eduke32/source/sounds_mapster32.h | 1 - 21 files changed, 182 insertions(+), 293 deletions(-) diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index 29a3b9331..a7b49e7f5 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -49,8 +49,6 @@ $(OBJ)/scriplib.$o: $(SRC)/jmact/scriplib.c $(SRC)/jmact/scriplib.h $(SRC)/jmact $(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 -$(OBJ)/audiolib_fx_fmod.$o: $(SRC)/jaudiolib/audiolib_fx_fmod.c $(SRC)/jaudiolib/fx_man_fmod.h $(INC)/duke3d.h - $(OBJ)/mv_mix.$o: $(SRC)/jaudiolib/mv_mix.nasm $(OBJ)/mv_mix16.$o: $(SRC)/jaudiolib/mv_mix16.nasm $(OBJ)/mvreverb.$o: $(SRC)/jaudiolib/mvreverb.nasm diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index cf1fa0d3d..191b14652 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -61,7 +61,6 @@ JMACTOBJ=$(OBJ)\util_lib.$o \ AUDIOLIB_FX_STUB=$(OBJ)\jaudiolib_fxstub.$o AUDIOLIB_MUSIC_STUB=$(OBJ)\jaudiolib_musicstub.$o -#AUDIOLIB_FX=$(OBJ)\jaudiolib_fx_fmod.$o AUDIOLIB_FX=$(OBJ)\mv_mix.$o \ $(OBJ)\mv_mix16.$o \ $(OBJ)\mvreverb.$o \ diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 61a188e28..bed8241bd 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -410,13 +410,13 @@ typedef struct { int32_t x, y, z; } vec3_t; -#pragma pack(pop) - typedef struct { vec3_t pos; int16_t hitsprite, hitwall, hitsect; } hitdata_t; +#pragma pack(pop) + int32_t preinitengine(void); // a partial setup of the engine used for launch windows int32_t initengine(void); void uninitengine(void); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 60a0f53cd..65b7e04a3 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -5155,7 +5155,7 @@ void clearmidstatbar16(void) void clearministatbar16(void) { - int32_t i, col = whitecol - 16; + int32_t i, col = whitecol - 21; char tempbuf[32]; begindrawing(); @@ -6065,7 +6065,7 @@ void showsectordata(int16_t sectnum) row = 2; begindrawing(); - col = whitecol - 16; + col = whitecol - 21; for (i=ydim-(row*96)-STATUS2DSIZ+16; i //#include "buildqueue.h" @@ -28,6 +27,18 @@ #define PLATFORM_WIN32 1 #else #define PLATFORM_UNIX 1 + +#include +static int32_t GetTickCount(void) +{ + struct timeval tv; + int32_t ti; + if (gettimeofday(&tv,NULL) < 0) return 0; + // tv is sec.usec, GTC gives msec + ti = tv.tv_sec * 1000; + ti += tv.tv_usec / 1000; + return ti; +} #endif #define UDP_NETWORKING 1 @@ -1209,10 +1220,8 @@ static int32_t connect_to_server(gcomtype *gcom, int32_t myip) while (my_id == 0) /* player number is based on id, low to high. */ { - /* struct timeval tv; - gettimeofday(&tv, NULL); - my_id = (unsigned short)tv.tv_usec; //HACK */ - my_id = (uint16_t) rand(); + my_id = (unsigned short)GetTickCount(); + // my_id = (uint16_t) rand(); } initprintf("network: Using 0x%X as client ID\n", my_id); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 18639f96a..b58009f1e 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1784,6 +1784,7 @@ static void polymer_freeboard(void) } } +#if 0 static void polymer_editorselect(void) { // int32_t i, n; @@ -1870,6 +1871,7 @@ static void polymer_editorselect(void) searchit = 0; } } +#endif // 0 // vvv --- improved editor aiming @@ -5191,8 +5193,8 @@ static void polymer_initrendertargets(int32_t count) bglTexImage2D(prrts[i].target, 0, GL_RGBA, prrts[i].xdim, prrts[i].ydim, 0, GL_RGBA, GL_SHORT, NULL); bglTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); bglTexParameteri(prrts[i].target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, GL_CLAMP); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); } else { prrts[i].target = GL_TEXTURE_2D; prrts[i].xdim = 128 << pr_shadowdetail; @@ -5206,8 +5208,8 @@ static void polymer_initrendertargets(int32_t count) bglTexImage2D(prrts[i].target, 0, GL_RGBA, prrts[i].xdim, prrts[i].ydim, 0, GL_RGBA, GL_SHORT, NULL); bglTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); bglTexParameteri(prrts[i].target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, GL_CLAMP); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); } } @@ -5217,8 +5219,8 @@ static void polymer_initrendertargets(int32_t count) bglTexImage2D(prrts[i].target, 0, GL_DEPTH_COMPONENT, prrts[i].xdim, prrts[i].ydim, 0, GL_DEPTH_COMPONENT, GL_SHORT, NULL); bglTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, pr_shadowfiltering ? GL_LINEAR : GL_NEAREST); bglTexParameteri(prrts[i].target, GL_TEXTURE_MAG_FILTER, pr_shadowfiltering ? GL_LINEAR : GL_NEAREST); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, GL_CLAMP); - bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(prrts[i].target, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); bglTexParameteri(prrts[i].target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); bglTexParameteri(prrts[i].target, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); bglTexParameteri(prrts[i].target, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); diff --git a/polymer/eduke32/eduke32.vcproj b/polymer/eduke32/eduke32.vcproj index fb019f99d..d0b87c9f5 100644 --- a/polymer/eduke32/eduke32.vcproj +++ b/polymer/eduke32/eduke32.vcproj @@ -596,10 +596,6 @@ RelativePath=".\source\jaudiolib\fx_man.h" > - - @@ -656,10 +652,6 @@ - - diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index e720baaa8..a4df9ef62 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -263,7 +263,7 @@ void G_PlayAnim(const char *fn,char t) for (i=1; i 4) && (totalclock > frametime + 45)) + if ((i > 4) && (totalclock > frametime + 60)) { OSD_Printf("WARNING: slowdown in %s, skipping playback\n",fn); goto ENDOFANIMLOOP; diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 26ec84532..8c47df33d 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -312,12 +312,9 @@ struct savehead { int32_t numplr,volnum,levnum,plrskl; char boardfn[BMAX_PATH]; }; -#pragma pack(pop) -// the following struct is never saved off anywhere -// so we don't need to fuck with its packing typedef struct { - int32_t camerax,cameray,cameraz; + vec3_t camera; int32_t const_visibility,uw_framerate; int32_t camera_time,folfvel,folavel,folx,foly,fola; int32_t reccnt,crosshairscale; @@ -343,15 +340,6 @@ typedef struct { int16_t camerasprite,last_camsprite; int16_t last_level,secretlevel; - char overhead_on,last_overhead,showweapons; - char god,warp_on,cashman,eog,showallmap; - char show_help,scrollmode,clipping; - char ridecule[10][40]; - char savegame[10][22]; - char pwlockout[128],rtsname[128]; - char display_bonus_screen; - char show_level_text; - struct { int32_t UseJoystick; int32_t UseMouse; @@ -414,9 +402,16 @@ typedef struct { int32_t LastUpdateCheck; int32_t useprecache; } config; -} user_defs; -#pragma pack(push,1) + char overhead_on,last_overhead,showweapons; + char god,warp_on,cashman,eog,showallmap; + char show_help,scrollmode,clipping; + char ridecule[10][40]; + char savegame[10][22]; + char pwlockout[128],rtsname[128]; + char display_bonus_screen; + char show_level_text; +} user_defs; typedef struct { int32_t ox,oy,oz; diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index 2690257f8..f1db830da 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -236,7 +236,6 @@ extern void X_OnEvent(register int32_t iEventID, register int32_t sActor, regist extern int32_t A_CheckSoundPlaying(int32_t i, int32_t num); extern int32_t S_CheckSoundPlaying(int32_t i, int32_t num); -extern void A_StopSound(int32_t num, int32_t i); extern void G_UpdatePlayerFromMenu(void); extern void Net_SendPlayerName(void); extern void Net_SendUserMapName(void); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index ba443db4d..effa42c78 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -4086,9 +4086,9 @@ void G_SE40(int32_t smoothratio) if (klabs(sector[sp->sectnum].floorz - sp->z) < klabs(sector[sprite[sprite2].sectnum].floorz - sprite[sprite2].z)) level = 1; - x = ud.camerax - sp->x; - y = ud.cameray - sp->y; - z = ud.cameraz - (level ? sector[sp->sectnum].floorz : sector[sp->sectnum].ceilingz); + x = ud.camera.x - sp->x; + y = ud.camera.y - sp->y; + z = ud.camera.z - (level ? sector[sp->sectnum].floorz : sector[sp->sectnum].ceilingz); sect = sprite[sprite2].sectnum; updatesector(sprite[sprite2].x + x, sprite[sprite2].y + y, §); @@ -4176,7 +4176,7 @@ void G_SE40(int32_t smoothratio) } } - G_DoSpriteAnimations(ud.camerax,ud.cameray,ud.cameraang,smoothratio); + G_DoSpriteAnimations(ud.camera.x,ud.camera.y,ud.cameraang,smoothratio); drawmasks(); if (level) @@ -4325,18 +4325,18 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) if ((snum == myconnectindex) && (numplayers > 1)) { - ud.camerax = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); - ud.cameray = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); - ud.cameraz = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio); + ud.camera.x = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + ud.camera.y = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); + ud.camera.z = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio); ud.cameraang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((int32_t)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); ud.camerasect = mycursectnum; } else { - ud.camerax = p->oposx+mulscale16((int32_t)(p->posx-p->oposx),smoothratio); - ud.cameray = p->oposy+mulscale16((int32_t)(p->posy-p->oposy),smoothratio); - ud.cameraz = p->oposz+mulscale16((int32_t)(p->posz-p->oposz),smoothratio); + ud.camera.x = p->oposx+mulscale16((int32_t)(p->posx-p->oposx),smoothratio); + ud.camera.y = p->oposy+mulscale16((int32_t)(p->posy-p->oposy),smoothratio); + ud.camera.z = p->oposz+mulscale16((int32_t)(p->posz-p->oposz),smoothratio); ud.cameraang = p->oang+mulscale16((int32_t)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); ud.camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((int32_t)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); } @@ -4346,21 +4346,21 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) { ud.cameraang = p->ang+p->look_ang; ud.camerahoriz = p->horiz+p->horizoff; - ud.camerax = p->posx; - ud.cameray = p->posy; - ud.cameraz = p->posz; + ud.camera.x = p->posx; + ud.camera.y = p->posy; + ud.camera.z = p->posz; ud.camerasect = sprite[p->newowner].sectnum; smoothratio = 65536L; } else if (ud.viewbob) // if (p->over_shoulder_on == 0) { if (p->over_shoulder_on) - ud.cameraz += (p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio))>>3; - else ud.cameraz += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); + ud.camera.z += (p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio))>>3; + else ud.camera.z += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); } if (p->over_shoulder_on) { - ud.cameraz -= 3072; + ud.camera.z -= 3072; G_DoThirdPerson(p,(vec3_t *)&ud,&ud.camerasect,ud.cameraang,ud.camerahoriz); } @@ -4369,25 +4369,25 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) if (g_earthquakeTime > 0 && p->on_ground == 1) { - ud.cameraz += 256-(((g_earthquakeTime)&1)<<9); + ud.camera.z += 256-(((g_earthquakeTime)&1)<<9); ud.cameraang += (2-((g_earthquakeTime)&2))<<2; } - if (sprite[p->i].pal == 1) ud.cameraz -= (18<<8); + if (sprite[p->i].pal == 1) ud.camera.z -= (18<<8); if (p->newowner >= 0) ud.camerahoriz = 100+sprite[p->newowner].shade; else if (p->spritebridge == 0) { - if (ud.cameraz < (p->truecz + (4<<8))) ud.cameraz = cz + (4<<8); - else if (ud.cameraz > (p->truefz - (4<<8))) ud.cameraz = fz - (4<<8); + if (ud.camera.z < (p->truecz + (4<<8))) ud.camera.z = cz + (4<<8); + else if (ud.camera.z > (p->truefz - (4<<8))) ud.camera.z = fz - (4<<8); } if (ud.camerasect >= 0) { - getzsofslope(ud.camerasect,ud.camerax,ud.cameray,&cz,&fz); - if (ud.cameraz < cz+(4<<8)) ud.cameraz = cz+(4<<8); - if (ud.cameraz > fz-(4<<8)) ud.cameraz = fz-(4<<8); + getzsofslope(ud.camerasect,ud.camera.x,ud.camera.y,&cz,&fz); + if (ud.camera.z < cz+(4<<8)) ud.camera.z = cz+(4<<8); + if (ud.camera.z > fz-(4<<8)) ud.camera.z = fz-(4<<8); } if (ud.camerahoriz > HORIZ_MAX) ud.camerahoriz = HORIZ_MAX; @@ -4406,19 +4406,19 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) i = 0; for (k=g_mirrorCount-1; k>=0; k--) { - j = klabs(wall[g_mirrorWall[k]].x-ud.camerax); - j += klabs(wall[g_mirrorWall[k]].y-ud.cameray); + j = klabs(wall[g_mirrorWall[k]].x-ud.camera.x); + j += klabs(wall[g_mirrorWall[k]].y-ud.camera.y); if (j < dst) dst = j, i = k; } if (wall[g_mirrorWall[i]].overpicnum == MIRROR) { - preparemirror(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang); + preparemirror(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang); j = visibility; visibility = (j>>1) + (j>>2); - drawrooms(tposx,tposy,ud.cameraz,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); + drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); display_mirror = 1; G_DoSpriteAnimations(tposx,tposy,tang,smoothratio); @@ -4434,12 +4434,12 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) #ifdef POLYMER if (getrendermode() == 4) { - polymer_setanimatesprites(G_DoSpriteAnimations, ud.camerax,ud.cameray,ud.cameraang,smoothratio); + polymer_setanimatesprites(G_DoSpriteAnimations, ud.camera.x,ud.camera.y,ud.cameraang,smoothratio); } #endif G_SE40(smoothratio); - drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect); + drawrooms(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,ud.camerasect); // dupe the sprites touching the portal to the other sector @@ -4472,7 +4472,7 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) } } - G_DoSpriteAnimations(ud.camerax,ud.cameray,ud.cameraang,smoothratio); + G_DoSpriteAnimations(ud.camera.x,ud.camera.y,ud.cameraang,smoothratio); drawing_ror = 0; drawmasks(); @@ -11622,6 +11622,7 @@ MAIN_LOOP_RESTART: if (getrendermode() >= 3) G_DrawBackground(); G_DisplayRest(i); + S_Pan3D(); if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex) { @@ -12785,7 +12786,6 @@ static int32_t G_DoMoveThings(void) { G_AnimateWalls(); A_MoveCyclers(); - S_Pan3D(); } return 0; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index bdf4d8d7b..10fc7b4a2 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -103,6 +103,8 @@ int32_t g_numCompilerErrors,g_numCompilerWarnings; extern char *duke3dgrpstring; extern char *duke3ddef; +extern int32_t g_maxSoundPos; + enum ScriptLabel_t { LABEL_ANY = -1, @@ -1402,14 +1404,8 @@ static int32_t C_CheckEventSync(int32_t iEventID) static inline int32_t ispecial(const char c) { - if (c == 0x0a) - { - g_lineNumber++; - return 1; - } - if (c == ' ' || c == 0x0d || c == '(' || c == ')' || - c == ',' || c == ';') + c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber)) return 1; return 0; @@ -2973,8 +2969,7 @@ static int32_t C_ParseCommand(void) return 0; case CON_QSPRINTF: - C_GetNextValue(LABEL_DEFINE); - C_GetNextValue(LABEL_DEFINE); + C_GetManyVars(2); j = 0; @@ -5585,6 +5580,9 @@ repeatcase: C_GetNextValue(LABEL_DEFINE); g_sounds[k].vo = *(g_scriptPtr-1); g_scriptPtr--; + + if (k > g_maxSoundPos) + g_maxSoundPos = k; return 0; case CON_ENDEVENT: diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 66589e0e1..542d099cd 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -1061,7 +1061,7 @@ skip_check: continue; } if (S_CheckSoundPlaying(vm.g_i,*insptr)) - A_StopSound((int16_t)*insptr,vm.g_i); + S_StopSound((int16_t)*insptr); insptr++; continue; @@ -2193,7 +2193,7 @@ nullquote: case CON_STOPSOUNDVAR: if ((j<0 || j>=MAXSOUNDS) /* && g_scriptSanityChecks */) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j); break;} if (S_CheckSoundPlaying(vm.g_i,j)) - A_StopSound((int16_t)j,vm.g_i); + S_StopSound((int16_t)j); break; case CON_SOUNDVAR: if ((j<0 || j>=MAXSOUNDS) /* && g_scriptSanityChecks */) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j); break;} @@ -3160,7 +3160,7 @@ nullquote: case CON_QSPRINTF: insptr++; { - int32_t dq = *insptr++, sq = *insptr++; + int32_t dq = Gv_GetVarX(*insptr++), sq = Gv_GetVarX(*insptr++); if ((ScriptQuotes[sq] == NULL || ScriptQuotes[dq] == NULL) /* && g_scriptSanityChecks */) { OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],ScriptQuotes[sq] ? dq : sq); diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 1e044aba7..70df9a1a0 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -1449,9 +1449,9 @@ static void Gv_AddSystemVars(void) Gv_NewVar("CLIPMASK0", CLIPMASK0, GAMEVAR_SYSTEM|GAMEVAR_READONLY); Gv_NewVar("CLIPMASK1", CLIPMASK1, GAMEVAR_SYSTEM|GAMEVAR_READONLY); - Gv_NewVar("camerax",(intptr_t)&ud.camerax, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("cameray",(intptr_t)&ud.cameray, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("cameraz",(intptr_t)&ud.cameraz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("camerax",(intptr_t)&ud.camera.x, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("cameray",(intptr_t)&ud.camera.y, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("cameraz",(intptr_t)&ud.camera.z, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("cameraang",(intptr_t)&ud.cameraang, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("camerahoriz",(intptr_t)&ud.camerahoriz, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("camerasect",(intptr_t)&ud.camerasect, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); @@ -1604,9 +1604,9 @@ void Gv_RefreshPointers(void) aGameVars[Gv_GetVarIndex("gametype_flags")].val.lValue = (intptr_t)&GametypeFlags[ud.coop]; aGameVars[Gv_GetVarIndex("framerate")].val.lValue = (intptr_t)&g_currentFrameRate; - aGameVars[Gv_GetVarIndex("camerax")].val.lValue = (intptr_t)&ud.camerax; - aGameVars[Gv_GetVarIndex("cameray")].val.lValue = (intptr_t)&ud.cameray; - aGameVars[Gv_GetVarIndex("cameraz")].val.lValue = (intptr_t)&ud.cameraz; + aGameVars[Gv_GetVarIndex("camerax")].val.lValue = (intptr_t)&ud.camera.x; + aGameVars[Gv_GetVarIndex("cameray")].val.lValue = (intptr_t)&ud.camera.y; + aGameVars[Gv_GetVarIndex("cameraz")].val.lValue = (intptr_t)&ud.camera.z; aGameVars[Gv_GetVarIndex("cameraang")].val.lValue = (intptr_t)&ud.cameraang; aGameVars[Gv_GetVarIndex("camerahoriz")].val.lValue = (intptr_t)&ud.camerahoriz; aGameVars[Gv_GetVarIndex("camerasect")].val.lValue = (intptr_t)&ud.camerasect; diff --git a/polymer/eduke32/source/jaudiolib/_multivc.h b/polymer/eduke32/source/jaudiolib/_multivc.h index 37f886d44..a41ae2c4d 100644 --- a/polymer/eduke32/source/jaudiolib/_multivc.h +++ b/polymer/eduke32/source/jaudiolib/_multivc.h @@ -56,7 +56,7 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) #define T_RIGHTQUIET 16 #define T_DEFAULT T_SIXTEENBIT_STEREO -#define MV_MaxPanPosition 31 +#define MV_MaxPanPosition 127 #define MV_NumPanPositions ( MV_MaxPanPosition + 1 ) #define MV_MaxTotalVolume 255 //#define MV_MaxVolume 63 diff --git a/polymer/eduke32/source/jaudiolib/multivoc.c b/polymer/eduke32/source/jaudiolib/multivoc.c index c5ecd90cf..bfb844eb9 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/multivoc.c @@ -67,10 +67,10 @@ static int32_t MV_ReverbDelay; static VOLUME16 *MV_ReverbTable = NULL; //static signed short MV_VolumeTable[ MV_MaxVolume + 1 ][ 256 ]; -static int16_t MV_VolumeTable[ 63 + 1 ][ 256 ]; +static int16_t MV_VolumeTable[ 255 + 1 ][ 256 ]; //static Pan MV_PanTable[ MV_NumPanPositions ][ MV_MaxVolume + 1 ]; -static Pan MV_PanTable[ MV_NumPanPositions ][ 63 + 1 ]; +static Pan MV_PanTable[ MV_NumPanPositions ][ 255 + 1 ]; static int32_t MV_Installed = FALSE; static int32_t MV_SoundCard = -1; @@ -113,7 +113,7 @@ static void(*MV_CallBackFunc)(uint32_t) = NULL; static void(*MV_RecordFunc)(char *ptr, int32_t length) = NULL; static void(*MV_MixFunction)(VoiceNode *voice, int32_t buffer); -static int32_t MV_MaxVolume = 63; +static int32_t MV_MaxVolume = 255; char *MV_HarshClipTable; char *MV_MixDestination; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 32604bcac..c4a88e775 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -4065,11 +4065,11 @@ void P_ProcessInput(int32_t snum) p->holoduke_on = -1; S_StopEnvSound(DUKE_JETPACK_IDLE,p->i); - if (p->scream_voice > FX_Ok) + if (p->scream_voice >= FX_Ok) { FX_StopSound(p->scream_voice); S_TestSoundCallback(DUKE_SCREAM); - p->scream_voice = FX_Ok; + p->scream_voice = -1; } if (s->pal != 1 && (s->cstat&32768) == 0) s->cstat = 0; @@ -4512,7 +4512,8 @@ void P_ProcessInput(int32_t snum) // not jumping or crouching - if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && !TEST_SYNC_KEY(sb_snum, SK_CROUCH) && p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8))) + if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && !TEST_SYNC_KEY(sb_snum, SK_CROUCH) && + p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8))) p->posz = fz-(i<<8); else { @@ -4522,7 +4523,7 @@ void P_ProcessInput(int32_t snum) if (p->poszv > 2400 && p->falling_counter < 255) { p->falling_counter++; - if (p->falling_counter == 38) + if (p->falling_counter >= 38 && p->scream_voice == -1) p->scream_voice = A_PlaySound(DUKE_SCREAM,pi); } @@ -4533,8 +4534,7 @@ void P_ProcessInput(int32_t snum) else if (p->falling_counter > 9) { - j = p->falling_counter; - s->extra -= j-(krand()&3); + s->extra -= p->falling_counter-(krand()&3); if (s->extra <= 0) { A_PlaySound(SQUISHED,pi); @@ -4562,10 +4562,10 @@ void P_ProcessInput(int32_t snum) else { p->falling_counter = 0; - if (p->scream_voice > FX_Ok) + if (p->scream_voice >= FX_Ok) { FX_StopSound(p->scream_voice); - p->scream_voice = FX_Ok; + p->scream_voice = -1; } if (psectlotag != 1 && psectlotag != 2 && p->on_ground == 0 && p->poszv > (6144>>1)) diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 8f675286d..feaf0ac4c 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2680,29 +2680,9 @@ CHECKINV1: p->inven_icon = dainv; - switch (dainv) { - case 1: - P_DoQuote(3,p); - break; - case 2: - P_DoQuote(90,p); - break; - case 3: - P_DoQuote(91,p); - break; - case 4: - P_DoQuote(88,p); - break; - case 5: - P_DoQuote(101,p); - break; - case 6: - P_DoQuote(89,p); - break; - case 7: - P_DoQuote(6,p); - break; + static const int32_t i[8] = { 3, 90, 91, 88, 101, 89, 6, 0 }; + P_DoQuote(i[dainv], p); } } @@ -2713,34 +2693,16 @@ CHECKINV1: switch (j) { case 0: - X_OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); - break; case 1: - X_OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); - break; case 2: - X_OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); - break; case 3: - X_OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); - break; case 4: - X_OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); - break; case 5: - X_OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); - break; case 6: - X_OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); - break; case 7: - X_OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); - break; case 8: - X_OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); - break; case 9: - X_OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY1+j,p->i,snum, -1); break; case 10: X_OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); @@ -2750,17 +2712,16 @@ CHECKINV1: break; } - if ((uint32_t) aGameVars[g_iReturnVarID].val.lValue != j) - j = (uint32_t) aGameVars[g_iReturnVarID].val.lValue; + j = (uint32_t) aGameVars[g_iReturnVarID].val.lValue; if (p->reloading == 1) j = -1; - else if (j > 0 && p->kickback_pic == 1 && p->weapon_pos == 1) + else if ((int32_t)j != -1 && p->kickback_pic == 1 && p->weapon_pos == 1) { p->wantweaponfire = j; p->kickback_pic = 0; } - if (p->last_pissed_time <= (GAMETICSPERSEC*218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 32 && p->access_incs == 0 && p->knee_incs == 0) + if ((int32_t)j != -1 && p->last_pissed_time <= (GAMETICSPERSEC*218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 32 && p->access_incs == 0 && p->knee_incs == 0) { // if( ( p->weapon_pos == 0 || ( p->holster_weapon && p->weapon_pos == -9 ) )) { @@ -2774,10 +2735,9 @@ CHECKINV1: { if (k == GROW_WEAPON) // JBF: this is handling next/previous with the grower selected { - if (j == (uint32_t)-1) + if ((int32_t)j == -1) k = 5; else k = 7; - } else { @@ -2824,9 +2784,10 @@ CHECKINV1: Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWeaponVarID,j, p->i, snum); - aGameVars[g_iReturnVarID].val.lValue = 0; + aGameVars[g_iReturnVarID].val.lValue = j; X_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1); - if (aGameVars[g_iReturnVarID].val.lValue == 0) + j = aGameVars[g_iReturnVarID].val.lValue; + if ((int32_t)j != -1 && j <= MAX_WEAPONS) { if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0) { @@ -2879,95 +2840,42 @@ CHECKINV1: else if ((int32_t)j >= 0 && p->gotweapon[j] && (uint32_t)p->curr_weapon != j) switch (j) { - case KNEE_WEAPON: - P_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; - } - P_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; - } - P_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; - } - P_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; - } - P_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; - } - P_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; - } - P_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; + p->show_empty_weapon = 32; } - + case KNEE_WEAPON: P_AddWeapon(p, j); break; case HANDREMOTE_WEAPON: if (k >= 0) // Found in list of [1]'s { - p->curr_weapon = HANDREMOTE_WEAPON; + p->curr_weapon = j; p->last_weapon = -1; p->weapon_pos = 10; } break; case HANDBOMB_WEAPON: - if (p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON]) - P_AddWeapon(p, HANDBOMB_WEAPON); - break; case TRIPBOMB_WEAPON: - if (p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON]) - P_AddWeapon(p, TRIPBOMB_WEAPON); + if (p->ammo_amount[j] > 0 && p->gotweapon[j]) + P_AddWeapon(p, j); break; } } - } } if (TEST_SYNC_KEY(sb_snum, SK_HOLODUKE) && p->newowner == -1) { - if (p->holoduke_on == -1) { aGameVars[g_iReturnVarID].val.lValue = 0; @@ -3044,11 +2952,11 @@ CHECKINV1: if (p->jetpack_on) { p->inven_icon = 4; - if (p->scream_voice > FX_Ok) + if (p->scream_voice >= FX_Ok) { FX_StopSound(p->scream_voice); S_TestSoundCallback(DUKE_SCREAM); - p->scream_voice = FX_Ok; + p->scream_voice = -1; } A_PlaySound(DUKE_JETPACK_ON,p->i); diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 6c9348d13..989efeae4 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LOUDESTVOLUME 150 -int32_t backflag,g_numEnvSoundsPlaying; +int32_t backflag,g_numEnvSoundsPlaying,g_maxSoundPos = 0; /* =================== @@ -302,7 +302,8 @@ int32_t S_LoadSound(uint32_t num) int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) { - int32_t sndist, cx, cy, cz, j,k; + vec3_t c; + int32_t sndist,j,k; int32_t pitche,pitchs,cs; int32_t voice, sndang, ca, pitch; @@ -340,40 +341,40 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) } else if (!(ud.config.VoiceToggle&1)) return -1; - for (j=0; j=0; j--) for (k=0; k 0) && (g_sounds[j].m&4)) return -1; } - cx = g_player[screenpeek].ps->oposx; - cy = g_player[screenpeek].ps->oposy; - cz = g_player[screenpeek].ps->oposz; - cs = g_player[screenpeek].ps->cursectnum; - ca = g_player[screenpeek].ps->ang+g_player[screenpeek].ps->look_ang; + Bmemcpy(&c, &ud.camera, sizeof(vec3_t)); + cs = ud.camerasect; + ca = ud.cameraang; - sndist = FindDistance3D((cx-pos->x),(cy-pos->y),(cz-pos->z)>>4); + sndist = FindDistance3D((c.x-pos->x),(c.y-pos->y),(c.z-pos->z)>>4); if (i >= 0 && (g_sounds[num].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9) sndist = divscale14(sndist,(SHT+1)); - pitchs = g_sounds[num].ps; - pitche = g_sounds[num].pe; - cx = klabs(pitche-pitchs); - - if (cx) - { - if (pitchs < pitche) - pitch = pitchs + (rand()%cx); - else pitch = pitche + (rand()%cx); - } - else pitch = pitchs; - sndist += g_sounds[num].vo; if (sndist < 0) sndist = 0; - if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT)) + if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(c.x,c.y,c.z-(24<<8),cs,SX,SY,SZ-(24<<8),SECT)) sndist += sndist>>5; + + pitchs = g_sounds[num].ps; + pitche = g_sounds[num].pe; + + j = klabs(pitche-pitchs); + + if (j) + { + if (pitchs < pitche) + pitch = pitchs + (rand()%j); + else pitch = pitche + (rand()%j); + } + else pitch = pitchs; + switch (num) { case PIPEBOMB_EXPLODE: @@ -387,8 +388,10 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) default: if (g_player[screenpeek].ps->cursectnum > -1 && sector[g_player[screenpeek].ps->cursectnum].lotag == 2 && (g_sounds[num].m&4) == 0) pitch = -768; +/* if (sndist > 31444 && PN != MUSICANDSFX) return -1; +*/ break; } @@ -408,7 +411,7 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) } else { - sndang = 2048 + ca - getangle(cx-pos->x,cy-pos->y); + sndang = 2048 + ca - getangle(c.x-pos->x,c.y-pos->y); sndang &= 2047; } @@ -438,22 +441,22 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) if (*g_sounds[num].ptr == 'C') voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, - pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); + pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num); else if (*g_sounds[num].ptr == 'O') voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, - pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); + pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num); else voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, - pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); + pitch,sndist>>4,sndist>>6,0,g_sounds[num].pr,num); } else { if (*g_sounds[num].ptr == 'C') - voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); + voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num); else if (*g_sounds[num].ptr == 'O') - voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); + voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num); else - voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); + voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num); } if (voice >= FX_Ok) @@ -555,20 +558,13 @@ int32_t A_PlaySound(uint32_t num, int32_t i) return S_PlaySoundXYZ(num, i, (vec3_t *)&sprite[i]); } -void A_StopSound(int32_t num, int32_t i) +inline void S_StopSound(int32_t num) { - UNREFERENCED_PARAMETER(i); - if (num >= 0 && num < MAXSOUNDS) S_StopSound(num); -} - -void S_StopSound(int32_t num) -{ - if (num >= 0 && num < MAXSOUNDS) - if (g_sounds[num].num > 0) - { - FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice); - S_TestSoundCallback(num); - } + if (num >= 0 && num < MAXSOUNDS && g_sounds[num].num > 0) + { + FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice); + S_TestSoundCallback(num); + } } void S_StopEnvSound(int32_t num,int32_t i) @@ -594,35 +590,34 @@ void S_StopEnvSound(int32_t num,int32_t i) void S_Pan3D(void) { - int32_t sndist, sx, sy, sz, cx, cy, cz; + vec3_t s, c; + int32_t sndist; int32_t sndang,ca,j,k,i,cs; g_numEnvSoundsPlaying = 0; if (ud.camerasprite == -1) { - cx = g_player[screenpeek].ps->oposx; - cy = g_player[screenpeek].ps->oposy; - cz = g_player[screenpeek].ps->oposz; - cs = g_player[screenpeek].ps->cursectnum; - ca = g_player[screenpeek].ps->ang+g_player[screenpeek].ps->look_ang; + Bmemcpy(&c, &ud.camera, sizeof(vec3_t)); + cs = ud.camerasect; + ca = ud.cameraang; } else { - cx = sprite[ud.camerasprite].x; - cy = sprite[ud.camerasprite].y; - cz = sprite[ud.camerasprite].z; + Bmemcpy(&c, &sprite[ud.camerasprite], sizeof(vec3_t)); cs = sprite[ud.camerasprite].sectnum; ca = sprite[ud.camerasprite].ang; } - for (j=0; j=0; k--) { i = g_sounds[j].SoundOwner[k].i; - sx = sprite[i].x; - sy = sprite[i].y; - sz = sprite[i].z; + Bmemcpy(&s, &sprite[i], sizeof(vec3_t)); if (PN == APLAYER && sprite[i].yvel == screenpeek) { @@ -631,9 +626,9 @@ void S_Pan3D(void) } else { - sndang = 2048 + ca - getangle(cx-sx,cy-sy); + sndang = 2048 + ca - getangle(c.x-s.x,c.y-s.y); sndang &= 2047; - sndist = FindDistance3D((cx-sx),(cy-sy),(cz-sz)>>4); + sndist = FindDistance3D((c.x-s.x),(c.y-s.y),(c.z-s.z)>>4); if (i >= 0 && (g_sounds[j].m&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9) sndist = divscale14(sndist,(SHT+1)); } @@ -641,7 +636,7 @@ void S_Pan3D(void) sndist += g_sounds[j].vo; if (sndist < 0) sndist = 0; - if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT)) + if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(c.x,c.y,c.z-(24<<8),cs,s.x,s.y,s.z-(24<<8),SECT)) sndist += sndist>>5; if (PN == MUSICANDSFX && SLT < 999) @@ -654,12 +649,14 @@ void S_Pan3D(void) case RPG_EXPLODE: if (sndist > (6144)) sndist = (6144); break; - default: + /* + default: if (sndist > 31444 && PN != MUSICANDSFX) { - S_StopSound(j); - continue; + S_StopSound(j); + continue; } + */ } if (g_sounds[j].ptr == 0 && S_LoadSound(j) == 0) continue; @@ -668,8 +665,9 @@ void S_Pan3D(void) if (sndist < ((255-LOUDESTVOLUME)<<6)) sndist = ((255-LOUDESTVOLUME)<<6); - FX_Pan3D(g_sounds[j].SoundOwner[k].voice,sndang>>6,sndist>>6); + FX_Pan3D(g_sounds[j].SoundOwner[k].voice,sndang>>4,sndist>>6); } + } while (j--); } void S_TestSoundCallback(uint32_t num) @@ -703,8 +701,8 @@ void S_TestSoundCallback(uint32_t num) } } - g_sounds[num].num--; - g_sounds[num].SoundOwner[tempk-1].i = -1; + g_sounds[num].num--; + g_sounds[num].SoundOwner[tempk-1].i = -1; } g_soundlocks[num]--; @@ -727,10 +725,8 @@ int32_t A_CheckSoundPlaying(int32_t i, int32_t num) { int32_t j; - num = clamp(num, 0, MAXSOUNDS); // FIXME - - if (i == -1) - return (g_sounds[num].num > 0); + if (num >= MAXSOUNDS || num < 0) return 0; + if (i == -1) return (g_sounds[num].num > 0); if (g_sounds[num].num > 0) { @@ -746,7 +742,7 @@ int32_t A_CheckSoundPlaying(int32_t i, int32_t num) int32_t S_CheckSoundPlaying(int32_t i, int32_t num) { - num = clamp(num, 0, MAXSOUNDS); // FIXME + if (num >= MAXSOUNDS || num < 0) return 0; if (i == -1) { diff --git a/polymer/eduke32/source/sounds_mapster32.c b/polymer/eduke32/source/sounds_mapster32.c index 2473e34b8..faea5713b 100644 --- a/polymer/eduke32/source/sounds_mapster32.c +++ b/polymer/eduke32/source/sounds_mapster32.c @@ -312,7 +312,7 @@ int32_t S_PlaySoundXYZ(int32_t num, int32_t i, const vec3_t *pos) voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); } - if (voice > FX_Ok) + if (voice >= FX_Ok) { g_sounds[num].SoundOwner[g_sounds[num].num].i = i; g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice; @@ -392,7 +392,7 @@ void S_PlaySound(int32_t num) voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); } - if (voice > FX_Ok)// return; + if (voice >= FX_Ok)// return; { g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice; g_sounds[num].num++; @@ -413,12 +413,6 @@ int32_t A_PlaySound(uint32_t num, int32_t i) return S_PlaySoundXYZ(num,i, (vec3_t *)&sprite[i]); } -void A_StopSound(int32_t num, int32_t i) -{ - UNREFERENCED_PARAMETER(i); - if (num >= 0 && num < MAXSOUNDS) S_StopSound(num); -} - void S_StopSound(int32_t num) { if (num >= 0 && num < MAXSOUNDS) diff --git a/polymer/eduke32/source/sounds_mapster32.h b/polymer/eduke32/source/sounds_mapster32.h index d213f538d..2b89c96e1 100644 --- a/polymer/eduke32/source/sounds_mapster32.h +++ b/polymer/eduke32/source/sounds_mapster32.h @@ -26,7 +26,6 @@ void S_SoundShutdown(void); int32_t S_PlaySoundXYZ(int32_t, int32_t, const vec3_t*); void S_PlaySound(int32_t); int32_t A_PlaySound(uint32_t num, int32_t i); -void A_StopSound(int32_t num, int32_t i); void S_StopSound(int32_t num); void S_StopEnvSound(int32_t num,int32_t i); void S_Pan3D(void);