mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- consolidated RTS code, because there were 3 copies.
Also completely rewritten to get rid of the cache dependency.
This commit is contained in:
parent
bf8a2ee573
commit
1b96861615
22 changed files with 137 additions and 1086 deletions
|
@ -781,6 +781,8 @@ set (PCH_SOURCES
|
|||
build/src/timer.cpp
|
||||
build/src/voxmodel.cpp
|
||||
|
||||
common/rts.cpp
|
||||
|
||||
common/utility/m_argv.cpp
|
||||
common/utility/files.cpp
|
||||
common/utility/files_decompress.cpp
|
||||
|
|
128
source/common/rts.cpp
Normal file
128
source/common/rts.cpp
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
** rts.cpp
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2019 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "zstring.h"
|
||||
#include "tarray.h"
|
||||
#include "cache1d.h"
|
||||
#include "rts.h"
|
||||
#include "m_swap.h"
|
||||
|
||||
|
||||
struct WadInfo
|
||||
{
|
||||
char identification[4];
|
||||
int32_t numlumps;
|
||||
int32_t infotableofs;
|
||||
};
|
||||
|
||||
struct FileLump
|
||||
{
|
||||
int32_t position;
|
||||
int32_t size;
|
||||
char name[8];
|
||||
};
|
||||
|
||||
struct LumpInfoInternal
|
||||
{
|
||||
int32_t position, size;
|
||||
};
|
||||
|
||||
//=============
|
||||
// STATICS
|
||||
//=============
|
||||
|
||||
static FString RTSName;
|
||||
static TArray<uint8_t> RTSFile;
|
||||
static TArray<LumpInfoInternal> LumpInfo;
|
||||
|
||||
|
||||
void RTS_Init(const char *filename)
|
||||
{
|
||||
// Don't do anything before actually requesting some data from it.
|
||||
// In most cases this is never ever used, so just remember the file name for later.
|
||||
RTSName = filename;
|
||||
}
|
||||
|
||||
bool RTS_IsInitialized()
|
||||
{
|
||||
if (LumpInfo.Size() > 0) return true;
|
||||
if (RTSName.IsEmpty()) return false;
|
||||
auto fr = kopenFileReader(RTSName, 0);
|
||||
RTSName = ""; // don't try ever again.
|
||||
if (!fr.isOpen()) return false;
|
||||
RTSFile = fr.Read();
|
||||
if (RTSFile.Size() >= 28) // minimum size for one entry
|
||||
{
|
||||
WadInfo *wi = (WadInfo*)RTSFile.Data();
|
||||
if (!memcmp(wi->identification, "IWAD", 4))
|
||||
{
|
||||
auto numlumps = LittleLong(wi->numlumps);
|
||||
if (numlumps >= 1)
|
||||
{
|
||||
FileLump *li = (FileLump*)(RTSFile.Data() + LittleLong(wi->infotableofs));
|
||||
LumpInfo.Resize(numlumps);
|
||||
for(unsigned i = 0; i < numlumps; i++, li++)
|
||||
{
|
||||
LumpInfo[i] = { LittleLong(li->position), LittleLong(li->size) };
|
||||
if (unsigned(LumpInfo[i].position + LumpInfo[i].size) >= RTSFile.Size())
|
||||
{
|
||||
LumpInfo[i].size = 0; // points to invalid data
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
RTSFile.Reset();
|
||||
LumpInfo.Reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
int RTS_SoundLength(int lump)
|
||||
{
|
||||
if (!RTS_IsInitialized()) return 0;
|
||||
lump++;
|
||||
if ((unsigned)lump >= LumpInfo.Size()) return 0;
|
||||
return LumpInfo[lump].size;
|
||||
}
|
||||
|
||||
void *RTS_GetSound(int lump)
|
||||
{
|
||||
if (!RTS_IsInitialized()) return nullptr;
|
||||
lump++;
|
||||
if ((unsigned)lump >= LumpInfo.Size()) return nullptr;
|
||||
if(LumpInfo[lump].size <= 0) return nullptr;
|
||||
return RTSFile.Data() + LumpInfo[lump].position;
|
||||
}
|
6
source/common/rts.h
Normal file
6
source/common/rts.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
void RTS_Init(const char *filename);
|
||||
bool RTS_IsInitialized();
|
||||
int RTS_SoundLength(int lump);
|
||||
void *RTS_GetSound(int lump);
|
|
@ -64,7 +64,6 @@ set( PCH_SOURCES
|
|||
src/osdfuncs.cpp
|
||||
src/player.cpp
|
||||
src/premap.cpp
|
||||
src/rts.cpp
|
||||
src/savegame.cpp
|
||||
src/sbar.cpp
|
||||
src/screens.cpp
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#ifndef rts_private__
|
||||
#define rts_private__
|
||||
|
||||
#include "cache1d.h"
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
//===============
|
||||
// TYPES
|
||||
//===============
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[8];
|
||||
buildvfs_kfd handle;
|
||||
int32_t position, size;
|
||||
} lumpinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char identification[4]; // should be "IWAD"
|
||||
int32_t numlumps;
|
||||
int32_t infotableofs;
|
||||
} wadinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t filepos;
|
||||
int32_t size;
|
||||
char name[8];
|
||||
} filelump_t;
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
#endif
|
|
@ -108,7 +108,6 @@ EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES);
|
|||
// so that debugging with valgrind --smc-check=none is possible:
|
||||
//#define DEBUG_VALGRIND_NO_SMC
|
||||
|
||||
#include "_rts.h"
|
||||
#include "actors.h"
|
||||
#include "common_game.h"
|
||||
#include "config.h"
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h" // Must come before everything else!
|
||||
|
||||
#include "duke3d.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
static int32_t rts_numlumps;
|
||||
static void **rts_lumpcache;
|
||||
static lumpinfo_t *rts_lumpinfo;
|
||||
static int32_t RTS_Started = FALSE;
|
||||
|
||||
uint8_t rts_lumplockbyte[11];
|
||||
|
||||
|
||||
/*
|
||||
= RTS_AddFile
|
||||
=
|
||||
= All files are optional, but at least one file must be found
|
||||
= Files with a .rts extension are wadlink files with multiple lumps
|
||||
= Other files are single lumps with the base filename for the lump name
|
||||
*/
|
||||
static int32_t RTS_AddFile(const char *filename)
|
||||
{
|
||||
wadinfo_t header;
|
||||
int32_t i, length, startlump;
|
||||
filelump_t *fileinfo, *fileinfoo;
|
||||
|
||||
// read the entire file in
|
||||
// FIXME: shared opens
|
||||
|
||||
buildvfs_kfd handle = kopen4loadfrommod(filename, 0);
|
||||
|
||||
if (handle == buildvfs_kfd_invalid)
|
||||
return -1;
|
||||
else
|
||||
initprintf("RTS file \"%s\" loaded\n", filename);
|
||||
|
||||
startlump = rts_numlumps;
|
||||
|
||||
// WAD file
|
||||
i = kread(handle, &header, sizeof(header));
|
||||
if (i != sizeof(header) || Bmemcmp(header.identification, "IWAD", 4))
|
||||
{
|
||||
initprintf("RTS file \"%s\" too short or doesn't have IWAD id\n", filename);
|
||||
kclose(handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
header.numlumps = B_LITTLE32(header.numlumps);
|
||||
header.infotableofs = B_LITTLE32(header.infotableofs);
|
||||
|
||||
length = header.numlumps*sizeof(filelump_t);
|
||||
fileinfo = fileinfoo = (filelump_t *)Xmalloc(length);
|
||||
|
||||
klseek(handle, header.infotableofs, SEEK_SET);
|
||||
kread(handle, fileinfo, length);
|
||||
|
||||
{
|
||||
lumpinfo_t *lump_p = (lumpinfo_t *)Xrealloc(
|
||||
rts_lumpinfo, (rts_numlumps + header.numlumps)*sizeof(lumpinfo_t));
|
||||
|
||||
rts_lumpinfo = lump_p;
|
||||
}
|
||||
|
||||
rts_numlumps += header.numlumps;
|
||||
|
||||
for (i=startlump; i<rts_numlumps; i++, fileinfo++)
|
||||
{
|
||||
lumpinfo_t *lump = &rts_lumpinfo[i];
|
||||
|
||||
lump->handle = handle; // NOTE: cache1d-file is not closed!
|
||||
lump->position = B_LITTLE32(fileinfo->filepos);
|
||||
lump->size = B_LITTLE32(fileinfo->size);
|
||||
|
||||
Bstrncpy(lump->name, fileinfo->name, 8);
|
||||
}
|
||||
|
||||
Xfree(fileinfoo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void RTS_Init(const char *filename)
|
||||
{
|
||||
// open all the files, load headers, and count lumps
|
||||
|
||||
rts_numlumps = 0;
|
||||
rts_lumpinfo = NULL; // will be realloced as lumps are added
|
||||
|
||||
if (RTS_AddFile(filename))
|
||||
return;
|
||||
|
||||
if (rts_numlumps == 0)
|
||||
return;
|
||||
|
||||
rts_lumpcache = (void **)Xcalloc(rts_numlumps, sizeof(rts_lumpcache[0]));
|
||||
|
||||
RTS_Started = TRUE;
|
||||
}
|
||||
|
||||
|
||||
int32_t RTS_IsInitialized(void)
|
||||
{
|
||||
return rts_numlumps > 0;
|
||||
}
|
||||
|
||||
|
||||
#define RTS_BAD_LUMP(lump) ((uint32_t)lump >= (uint32_t)rts_numlumps)
|
||||
|
||||
int32_t RTS_SoundLength(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
|
||||
return RTS_BAD_LUMP(lump) ? 0 : rts_lumpinfo[lump].size;
|
||||
}
|
||||
|
||||
|
||||
/* Loads the lump into the given buffer, which must be >= RTS_SoundLength() */
|
||||
static void RTS_ReadLump(int32_t lump, void *dest)
|
||||
{
|
||||
lumpinfo_t *l = &rts_lumpinfo[lump];
|
||||
|
||||
klseek(l->handle, l->position, SEEK_SET);
|
||||
kread(l->handle, dest, l->size);
|
||||
}
|
||||
|
||||
|
||||
void *RTS_GetSound(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
|
||||
if (RTS_BAD_LUMP(lump))
|
||||
return NULL;
|
||||
|
||||
if (rts_lumpcache[lump] == NULL)
|
||||
{
|
||||
rts_lumplockbyte[lump] = 200;
|
||||
cacheAllocateBlock((intptr_t *)&rts_lumpcache[lump], RTS_SoundLength(lump-1), &rts_lumplockbyte[lump]); // JBF 20030910: char * => int32_t *
|
||||
RTS_ReadLump(lump, rts_lumpcache[lump]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rts_lumplockbyte[lump] < 200)
|
||||
rts_lumplockbyte[lump] = 200;
|
||||
else
|
||||
rts_lumplockbyte[lump]++;
|
||||
}
|
||||
|
||||
return rts_lumpcache[lump];
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
|
@ -1,49 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//***************************************************************************
|
||||
//
|
||||
// RTS.H
|
||||
//
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef rts_public_
|
||||
#define rts_public_
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
extern uint8_t rts_lumplockbyte[11];
|
||||
|
||||
/* Files with a .rts extension are idlink files with multiple lumps */
|
||||
void RTS_Init(const char *filename);
|
||||
|
||||
int32_t RTS_IsInitialized(void);
|
||||
|
||||
/* Returns the buffer size needed to load the given lump */
|
||||
int32_t RTS_SoundLength(int32_t lump);
|
||||
|
||||
void *RTS_GetSound(int32_t lump);
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
#endif
|
|
@ -690,19 +690,6 @@ static void G_ShowCacheLocks(void)
|
|||
if (k < ydim-12)
|
||||
k += 6;
|
||||
|
||||
for (int i=10; i>=0; i--)
|
||||
{
|
||||
if (rts_lumplockbyte[i] >= 200)
|
||||
{
|
||||
if (k >= ydim-12)
|
||||
break;
|
||||
|
||||
Bsprintf(tempbuf, "RTS Locked %d:", i);
|
||||
printext256(0, k, COLOR_WHITE, -1, tempbuf, 1);
|
||||
k += 6;
|
||||
}
|
||||
}
|
||||
|
||||
if (k >= ydim-12 && k<ydim-6)
|
||||
printext256(0, k, COLOR_WHITE, -1, "(MORE . . .)", 1);
|
||||
|
||||
|
|
|
@ -402,10 +402,6 @@ void S_Cleanup(void)
|
|||
// negative index is RTS playback
|
||||
if ((int32_t)num < 0)
|
||||
{
|
||||
int const rtsindex = klabs((int32_t)num);
|
||||
|
||||
if (rts_lumplockbyte[rtsindex] >= 200)
|
||||
--rts_lumplockbyte[rtsindex];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -993,12 +989,6 @@ void S_ClearSoundLocks(void)
|
|||
int32_t i;
|
||||
int32_t const msp = g_highestSoundIdx;
|
||||
|
||||
for (native_t i = 0; i < 11; ++i)
|
||||
if (rts_lumplockbyte[i] >= 200)
|
||||
rts_lumplockbyte[i] = 199;
|
||||
|
||||
int32_t const msp = g_highestSoundIdx;
|
||||
|
||||
for (native_t i = 0; i <= msp; ++i)
|
||||
if (g_soundlocks[i] >= 200)
|
||||
g_soundlocks[i] = 199;
|
||||
|
|
|
@ -64,7 +64,6 @@ set( PCH_SOURCES
|
|||
src/osdfuncs.cpp
|
||||
src/player.cpp
|
||||
src/premap.cpp
|
||||
src/rts.cpp
|
||||
src/savegame.cpp
|
||||
src/sbar.cpp
|
||||
src/screens.cpp
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#ifndef rts_private__
|
||||
#define rts_private__
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
//===============
|
||||
// TYPES
|
||||
//===============
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[8];
|
||||
int32_t handle, position, size;
|
||||
} lumpinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char identification[4]; // should be "IWAD"
|
||||
int32_t numlumps;
|
||||
int32_t infotableofs;
|
||||
} wadinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t filepos;
|
||||
int32_t size;
|
||||
char name[8];
|
||||
} filelump_t;
|
||||
|
||||
END_RR_NS
|
||||
|
||||
#endif
|
|
@ -111,7 +111,6 @@ EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES);
|
|||
|
||||
END_RR_NS
|
||||
|
||||
#include "_rts.h"
|
||||
#include "actors.h"
|
||||
#include "common_game.h"
|
||||
#include "config.h"
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
#include "ns.h" // Must come before everything else!
|
||||
|
||||
#include "duke3d.h"
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
static int32_t rts_numlumps;
|
||||
static void **rts_lumpcache;
|
||||
static lumpinfo_t *rts_lumpinfo;
|
||||
static int32_t RTS_Started = FALSE;
|
||||
|
||||
uint8_t rts_lumplockbyte[11];
|
||||
|
||||
|
||||
/*
|
||||
= RTS_AddFile
|
||||
=
|
||||
= All files are optional, but at least one file must be found
|
||||
= Files with a .rts extension are wadlink files with multiple lumps
|
||||
= Other files are single lumps with the base filename for the lump name
|
||||
*/
|
||||
static int32_t RTS_AddFile(const char *filename)
|
||||
{
|
||||
wadinfo_t header;
|
||||
int32_t i, handle, length, startlump;
|
||||
filelump_t *fileinfo, *fileinfoo;
|
||||
|
||||
// read the entire file in
|
||||
// FIXME: shared opens
|
||||
|
||||
handle = kopen4loadfrommod(filename, 0);
|
||||
|
||||
if (handle < 0)
|
||||
return -1;
|
||||
else
|
||||
initprintf("RTS file \"%s\" loaded\n", filename);
|
||||
|
||||
startlump = rts_numlumps;
|
||||
|
||||
// WAD file
|
||||
i = kread(handle, &header, sizeof(header));
|
||||
if (i != sizeof(header) || Bmemcmp(header.identification, "IWAD", 4))
|
||||
{
|
||||
initprintf("RTS file \"%s\" too short or doesn't have IWAD id\n", filename);
|
||||
kclose(handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
header.numlumps = B_LITTLE32(header.numlumps);
|
||||
header.infotableofs = B_LITTLE32(header.infotableofs);
|
||||
|
||||
length = header.numlumps*sizeof(filelump_t);
|
||||
fileinfo = fileinfoo = (filelump_t *)Xmalloc(length);
|
||||
|
||||
klseek(handle, header.infotableofs, SEEK_SET);
|
||||
kread(handle, fileinfo, length);
|
||||
|
||||
{
|
||||
lumpinfo_t *lump_p = (lumpinfo_t *)Xrealloc(
|
||||
rts_lumpinfo, (rts_numlumps + header.numlumps)*sizeof(lumpinfo_t));
|
||||
|
||||
rts_lumpinfo = lump_p;
|
||||
}
|
||||
|
||||
rts_numlumps += header.numlumps;
|
||||
|
||||
for (i=startlump; i<rts_numlumps; i++, fileinfo++)
|
||||
{
|
||||
lumpinfo_t *lump = &rts_lumpinfo[i];
|
||||
|
||||
lump->handle = handle; // NOTE: cache1d-file is not closed!
|
||||
lump->position = B_LITTLE32(fileinfo->filepos);
|
||||
lump->size = B_LITTLE32(fileinfo->size);
|
||||
|
||||
Bstrncpy(lump->name, fileinfo->name, 8);
|
||||
}
|
||||
|
||||
Bfree(fileinfoo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void RTS_Init(const char *filename)
|
||||
{
|
||||
// open all the files, load headers, and count lumps
|
||||
|
||||
rts_numlumps = 0;
|
||||
rts_lumpinfo = NULL; // will be realloced as lumps are added
|
||||
|
||||
if (RTS_AddFile(filename))
|
||||
return;
|
||||
|
||||
if (rts_numlumps == 0)
|
||||
return;
|
||||
|
||||
rts_lumpcache = (void **)Xcalloc(rts_numlumps, sizeof(rts_lumpcache[0]));
|
||||
|
||||
RTS_Started = TRUE;
|
||||
}
|
||||
|
||||
|
||||
int32_t RTS_IsInitialized(void)
|
||||
{
|
||||
return rts_numlumps > 0;
|
||||
}
|
||||
|
||||
|
||||
#define RTS_BAD_LUMP(lump) ((uint32_t)lump >= (uint32_t)rts_numlumps)
|
||||
|
||||
int32_t RTS_SoundLength(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
|
||||
return RTS_BAD_LUMP(lump) ? 0 : rts_lumpinfo[lump].size;
|
||||
}
|
||||
|
||||
|
||||
/* Loads the lump into the given buffer, which must be >= RTS_SoundLength() */
|
||||
static void RTS_ReadLump(int32_t lump, void *dest)
|
||||
{
|
||||
lumpinfo_t *l = &rts_lumpinfo[lump];
|
||||
|
||||
klseek(l->handle, l->position, SEEK_SET);
|
||||
kread(l->handle, dest, l->size);
|
||||
}
|
||||
|
||||
|
||||
void *RTS_GetSound(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
|
||||
if (RTS_BAD_LUMP(lump))
|
||||
return NULL;
|
||||
|
||||
if (rts_lumpcache[lump] == NULL)
|
||||
{
|
||||
rts_lumplockbyte[lump] = 200;
|
||||
cacheAllocateBlock((intptr_t *)&rts_lumpcache[lump], RTS_SoundLength(lump-1), &rts_lumplockbyte[lump]); // JBF 20030910: char * => int32_t *
|
||||
RTS_ReadLump(lump, rts_lumpcache[lump]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rts_lumplockbyte[lump] < 200)
|
||||
rts_lumplockbyte[lump] = 200;
|
||||
else
|
||||
rts_lumplockbyte[lump]++;
|
||||
}
|
||||
|
||||
return rts_lumpcache[lump];
|
||||
}
|
||||
END_RR_NS
|
|
@ -1,48 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//***************************************************************************
|
||||
//
|
||||
// RTS.H
|
||||
//
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef rts_public_
|
||||
#define rts_public_
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
extern uint8_t rts_lumplockbyte[11];
|
||||
|
||||
/* Files with a .rts extension are idlink files with multiple lumps */
|
||||
void RTS_Init(const char *filename);
|
||||
|
||||
int32_t RTS_IsInitialized(void);
|
||||
|
||||
/* Returns the buffer size needed to load the given lump */
|
||||
int32_t RTS_SoundLength(int32_t lump);
|
||||
|
||||
void *RTS_GetSound(int32_t lump);
|
||||
|
||||
END_RR_NS
|
||||
|
||||
#endif
|
|
@ -686,17 +686,6 @@ static void G_ShowCacheLocks(void)
|
|||
if (k < ydim-12)
|
||||
k += 6;
|
||||
|
||||
for (i=10; i>=0; i--)
|
||||
if (rts_lumplockbyte[i] >= 200)
|
||||
{
|
||||
if (k >= ydim-12)
|
||||
break;
|
||||
|
||||
Bsprintf(tempbuf, "RTS Locked %d:", i);
|
||||
printext256(0, k, COLOR_WHITE, -1, tempbuf, 1);
|
||||
k += 6;
|
||||
}
|
||||
|
||||
if (k >= ydim-12 && k<ydim-6)
|
||||
printext256(0, k, COLOR_WHITE, -1, "(MORE . . .)", 1);
|
||||
|
||||
|
|
|
@ -71,8 +71,6 @@ void S_SoundStartup(void)
|
|||
voice.dist = UINT16_MAX;
|
||||
voice.clock = 0;
|
||||
}
|
||||
|
||||
g_soundlocks[i] = 199;
|
||||
}
|
||||
|
||||
S_PrecacheSounds();
|
||||
|
@ -391,8 +389,6 @@ void S_Cleanup(void)
|
|||
// negative index is RTS playback
|
||||
if ((int32_t)num < 0)
|
||||
{
|
||||
if (rts_lumplockbyte[-(int32_t)num] >= 200)
|
||||
rts_lumplockbyte[-(int32_t)num]--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -933,12 +929,6 @@ void S_ClearSoundLocks(void)
|
|||
int32_t i;
|
||||
int32_t const msp = g_highestSoundIdx;
|
||||
|
||||
for (native_t i = 0; i < 11; ++i)
|
||||
if (rts_lumplockbyte[i] >= 200)
|
||||
rts_lumplockbyte[i] = 199;
|
||||
|
||||
int32_t const msp = g_highestSoundIdx;
|
||||
|
||||
for (native_t i = 0; i <= msp; ++i)
|
||||
if (g_soundlocks[i] >= 200)
|
||||
g_soundlocks[i] = 199;
|
||||
|
|
|
@ -86,7 +86,6 @@ set( PCH_SOURCES
|
|||
src/ripper2.cpp
|
||||
src/rooms.cpp
|
||||
src/rotator.cpp
|
||||
src/rts.cpp
|
||||
src/save.cpp
|
||||
src/saveable.cpp
|
||||
src/scrip2.cpp
|
||||
|
|
|
@ -1,345 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
||||
|
||||
This file is part of Shadow Warrior version 1.2
|
||||
|
||||
Shadow Warrior 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Original Source: 1997 - Frank Maddin and Jim Norwood
|
||||
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h"
|
||||
// rts.c
|
||||
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
#include "baselayer.h"
|
||||
|
||||
#include "mytypes.h"
|
||||
#include "_rts.h"
|
||||
#include "rts.h"
|
||||
#include "cache.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
char ValidPtr(void *ptr);
|
||||
void *AllocMem(int size);
|
||||
void *CallocMem(int size, int num);
|
||||
void *ReAllocMem(void *ptr, int size);
|
||||
void FreeMem(void *ptr);
|
||||
|
||||
extern char ds[];
|
||||
uint8_t lumplockbyte[11];
|
||||
|
||||
//=============
|
||||
// STATICS
|
||||
//=============
|
||||
|
||||
static int32_t numlumps = 0;
|
||||
static intptr_t *lumpcache = NULL;
|
||||
static lumpinfo_t *lumpinfo = NULL; // location of each lump on disk
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
LUMP BASED ROUTINES
|
||||
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_AddFile
|
||||
=
|
||||
= All files are optional, but at least one file must be found
|
||||
= Files with a .rts extension are wadlink files with multiple lumps
|
||||
= Other files are single lumps with the base filename for the lump name
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
int32_t RTS_AddFile(char *filename)
|
||||
{
|
||||
wadinfo_t header;
|
||||
lumpinfo_t *lump_p;
|
||||
int32_t i;
|
||||
int32_t handle, length;
|
||||
int32_t startlump;
|
||||
filelump_t *fileinfo, *fileinfoo;
|
||||
|
||||
//
|
||||
// read the entire file in
|
||||
// FIXME: shared opens
|
||||
|
||||
handle = kopen4load(filename, 0);
|
||||
if (handle < 0)
|
||||
{
|
||||
buildprintf("RTS file %s was not found\n",filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
startlump = numlumps;
|
||||
|
||||
// WAD file
|
||||
// printf(" Adding %s.\n",filename);
|
||||
kread(handle, &header, sizeof(header));
|
||||
if (strncmp(header.identification,"IWAD",4))
|
||||
{
|
||||
buildprintf("RTS file %s doesn't have IWAD id\n",filename);
|
||||
kclose(handle);
|
||||
return -1;
|
||||
}
|
||||
header.numlumps = B_LITTLE32(header.numlumps);
|
||||
header.infotableofs = B_LITTLE32(header.infotableofs);
|
||||
length = header.numlumps*sizeof(filelump_t);
|
||||
fileinfo = fileinfoo = (filelump_t*)malloc(length);
|
||||
if (!fileinfo)
|
||||
{
|
||||
buildprintf("RTS file could not allocate header info\n");
|
||||
kclose(handle);
|
||||
return -1;
|
||||
}
|
||||
klseek(handle, header.infotableofs, SEEK_SET);
|
||||
kread(handle, fileinfo, length);
|
||||
|
||||
//
|
||||
// Fill in lumpinfo
|
||||
//
|
||||
lump_p = (lumpinfo_t*)realloc(lumpinfo, (numlumps + header.numlumps)*sizeof(lumpinfo_t));
|
||||
if (!lump_p)
|
||||
{
|
||||
kclose(handle);
|
||||
return -1;
|
||||
}
|
||||
lumpinfo = lump_p;
|
||||
|
||||
numlumps += header.numlumps;
|
||||
|
||||
lump_p = &lumpinfo[startlump];
|
||||
|
||||
for (i=startlump; i<numlumps; i++,lump_p++, fileinfo++)
|
||||
{
|
||||
lump_p->handle = handle;
|
||||
lump_p->position = B_LITTLE32(fileinfo->filepos);
|
||||
lump_p->size = B_LITTLE32(fileinfo->size);
|
||||
strncpy(lump_p->name, fileinfo->name, 8);
|
||||
}
|
||||
|
||||
free(fileinfoo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_Init
|
||||
=
|
||||
= Files with a .rts extension are idlink files with multiple lumps
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void RTS_Init(char *filename)
|
||||
{
|
||||
int32_t length;
|
||||
//
|
||||
// open all the files, load headers, and count lumps
|
||||
//
|
||||
numlumps = 0;
|
||||
lumpinfo = NULL; // will be realloced as lumps are added
|
||||
|
||||
// printf("RTS Manager Started\n");
|
||||
if (RTS_AddFile(filename)) return;
|
||||
|
||||
if (!numlumps) return;
|
||||
// buildprintf ("RTS_Init: no files found");
|
||||
|
||||
//
|
||||
// set up caching
|
||||
//
|
||||
length = (numlumps) * sizeof(*lumpcache);
|
||||
lumpcache = (intptr_t*)Xmalloc(length);
|
||||
memset(lumpcache,0,length);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_Shutdown
|
||||
=
|
||||
= shutdown the RTS system
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void RTS_Shutdown(void)
|
||||
{
|
||||
//int32_t i;
|
||||
|
||||
if (lumpcache)
|
||||
{
|
||||
#if 0
|
||||
for (i=0; i<numlumps; i++)
|
||||
{
|
||||
if (lumpcache[i])
|
||||
{
|
||||
Bfree(lumpcache[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Bfree(lumpcache);
|
||||
}
|
||||
if (lumpinfo) Bfree(lumpinfo);
|
||||
|
||||
numlumps = 0;
|
||||
lumpinfo = NULL;
|
||||
lumpcache = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_NumSounds
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
int32_t RTS_NumSounds(void)
|
||||
{
|
||||
return numlumps-1;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_SoundLength
|
||||
=
|
||||
= Returns the buffer size needed to load the given lump
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
int32_t RTS_SoundLength(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
if (lump >= numlumps)
|
||||
buildprintf("RTS_SoundLength: %i >= numlumps",lump);
|
||||
return lumpinfo[lump].size;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_GetSoundName
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
char *RTS_GetSoundName(int32_t i)
|
||||
{
|
||||
i++;
|
||||
if (i>=numlumps)
|
||||
buildprintf("RTS_GetSoundName: %i >= numlumps",i);
|
||||
return &(lumpinfo[i].name[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_ReadLump
|
||||
=
|
||||
= Loads the lump into the given buffer, which must be >= RTS_SoundLength()
|
||||
=
|
||||
====================
|
||||
*/
|
||||
void RTS_ReadLump(int32_t lump, intptr_t dest)
|
||||
{
|
||||
lumpinfo_t *l;
|
||||
|
||||
if (lump >= numlumps)
|
||||
buildprintf("RTS_ReadLump: %i >= numlumps",lump);
|
||||
if (lump < 0)
|
||||
buildprintf("RTS_ReadLump: %i < 0",lump);
|
||||
l = lumpinfo+lump;
|
||||
klseek(l->handle, l->position, SEEK_SET);
|
||||
kread(l->handle,(void *)dest,l->size);
|
||||
}
|
||||
|
||||
#if 1
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_GetSound
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
// allocates off the cache
|
||||
|
||||
void *RTS_GetSound(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
if ((uint16_t)lump >= (uint16_t)numlumps)
|
||||
buildprintf("RTS_GetSound: %i >= %i\n",lump,numlumps);
|
||||
|
||||
if (lumpcache[lump] == (intptr_t)NULL)
|
||||
{
|
||||
lumplockbyte[lump] = CACHE_LOCK_START;
|
||||
cacheAllocateBlock(&lumpcache[lump],(int)RTS_SoundLength(lump-1),&lumplockbyte[lump]);
|
||||
RTS_ReadLump(lump, lumpcache[lump]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lumplockbyte[lump] < CACHE_LOCK_START)
|
||||
lumplockbyte[lump] = CACHE_LOCK_START;
|
||||
else
|
||||
lumplockbyte[lump]++;
|
||||
}
|
||||
return (void *)lumpcache[lump];
|
||||
}
|
||||
#else
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_GetSound
|
||||
=
|
||||
====================
|
||||
*/
|
||||
void *RTS_GetSound(int32_t lump)
|
||||
{
|
||||
lump++;
|
||||
if ((uint16_t)lump >= numlumps)
|
||||
buildprintf("RTS_GetSound: %i >= numlumps",lump);
|
||||
|
||||
else if (lump < 0)
|
||||
buildprintf("RTS_GetSound: %i < 0\n",lump);
|
||||
|
||||
if (lumpcache[lump] == NULL)
|
||||
{
|
||||
// read the lump in
|
||||
lumpcache[lump] = Xmalloc(RTS_SoundLength(lump-1));
|
||||
RTS_ReadLump(lump, lumpcache[lump]);
|
||||
}
|
||||
return (void *)lumpcache[lump];
|
||||
}
|
||||
#endif
|
||||
END_SW_NS
|
|
@ -1,116 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
||||
|
||||
This file is part of Shadow Warrior version 1.2
|
||||
|
||||
Shadow Warrior 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
|
||||
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
||||
|
||||
Duke Nukem 3D 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Original Source: 1996 - Todd Replogle
|
||||
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//***************************************************************************
|
||||
//
|
||||
// RTS.H
|
||||
//
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef rts_public__
|
||||
#define rts_public__
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_Init
|
||||
=
|
||||
= Files with a .rts extension are idlink files with multiple lumps
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void RTS_Init(char *filename);
|
||||
void RTS_Shutdown(void);
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_NumSounds
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
int32_t RTS_NumSounds(void);
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_SoundLength
|
||||
=
|
||||
= Returns the buffer size needed to load the given lump
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
int32_t RTS_SoundLength(int32_t lump);
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_GetSoundName
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
char *RTS_GetSoundName(int32_t i);
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= RTS_GetSound
|
||||
=
|
||||
====================
|
||||
*/
|
||||
void *RTS_GetSound(int32_t lump);
|
||||
|
||||
END_SW_NS
|
||||
|
||||
#endif
|
|
@ -252,8 +252,6 @@ int PlayerYellVocs[] =
|
|||
DIGI_PLAYERYELL3
|
||||
};
|
||||
|
||||
extern uint8_t lumplockbyte[];
|
||||
|
||||
#if 0
|
||||
// DEBUG
|
||||
void CheckSndData(char *file, int line)
|
||||
|
@ -293,8 +291,6 @@ SoundCallBack(intptr_t num)
|
|||
// RTS sounds are negative
|
||||
if ((int)num < 0)
|
||||
{
|
||||
ASSERT(-num < 11);
|
||||
lumplockbyte[-num]--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -317,12 +313,6 @@ ClearSoundLocks(void)
|
|||
if (voc[i].lock >= 200)
|
||||
voc[i].lock = 199;
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
if (lumplockbyte[i] >= 200)
|
||||
lumplockbyte[i] = 199;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1057,7 +1047,7 @@ void PlaySoundRTS(int rts_num)
|
|||
char *rtsptr;
|
||||
int voice=-1;
|
||||
|
||||
if (RTS_NumSounds() <= 0 || !gs.FxOn)
|
||||
if (!RTS_IsInitialized() || !gs.FxOn)
|
||||
return;
|
||||
|
||||
rtsptr = (char *)RTS_GetSound(rts_num - 1);
|
||||
|
@ -1065,11 +1055,6 @@ void PlaySoundRTS(int rts_num)
|
|||
ASSERT(rtsptr);
|
||||
|
||||
voice = FX_Play3D(rtsptr, RTS_SoundLength(rts_num - 1), FX_ONESHOT, 0, 0, 0, 255, 1.f, -rts_num); // [JM] Float volume here too I bet. !CHECKME!
|
||||
|
||||
if (voice <= FX_Ok)
|
||||
{
|
||||
lumplockbyte[rts_num]--;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
|
|
@ -357,6 +357,5 @@ void TermSetup(void)
|
|||
{
|
||||
extern SWBOOL BotMode;
|
||||
CONFIG_WriteSetup();
|
||||
RTS_Shutdown();
|
||||
}
|
||||
END_SW_NS
|
||||
|
|
Loading…
Reference in a new issue