- tabified several Blood source files.

This commit is contained in:
Christoph Oelckers 2021-12-29 20:03:42 +01:00
parent e670cf2786
commit 69283bfb0c
17 changed files with 4934 additions and 4538 deletions

View file

@ -44,38 +44,38 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
static inline uint16_t findpage(anim_t *anim, uint16_t framenumber)
{
// curlpnum is initialized to 0xffff, obviously
size_t i = anim->curlpnum & ~0xffff;
size_t const nLps = anim->lpheader->nLps;
bool j = true;
// curlpnum is initialized to 0xffff, obviously
size_t i = anim->curlpnum & ~0xffff;
size_t const nLps = anim->lpheader->nLps;
bool j = true;
if (framenumber < anim->currentframe)
i = 0, j = false;
if (framenumber < anim->currentframe)
i = 0, j = false;
// this scans the last used page and higher first and then scans the
// previously accessed pages afterwards if it doesn't find anything
do
{
for (; i < nLps; ++i)
{
lp_descriptor & lp = anim->LpArray[i];
if (lp.baseRecord <= framenumber && framenumber < lp.baseRecord + lp.nRecords)
return (uint16_t)i;
}
// this scans the last used page and higher first and then scans the
// previously accessed pages afterwards if it doesn't find anything
do
{
for (; i < nLps; ++i)
{
lp_descriptor & lp = anim->LpArray[i];
if (lp.baseRecord <= framenumber && framenumber < lp.baseRecord + lp.nRecords)
return (uint16_t)i;
}
if (j && i == nLps)
{
// handle out of order pages... I don't think any Duke .ANM files
// have them, but they're part of the file spec
i = 0, j = false;
continue;
}
if (j && i == nLps)
{
// handle out of order pages... I don't think any Duke .ANM files
// have them, but they're part of the file spec
i = 0, j = false;
continue;
}
break;
}
while (1);
break;
}
while (1);
return (uint16_t)i;
return (uint16_t)i;
}
@ -88,13 +88,13 @@ static inline uint16_t findpage(anim_t *anim, uint16_t framenumber)
static inline void loadpage(anim_t *anim, uint16_t pagenumber, uint16_t **pagepointer)
{
if (anim->curlpnum == pagenumber)
return;
if (anim->curlpnum == pagenumber)
return;
anim->curlpnum = pagenumber;
anim->curlp = &anim->LpArray[pagenumber];
*pagepointer = (uint16_t *)(anim->buffer + 0xb00 + (pagenumber*IMAGEBUFFERSIZE) +
sizeof(lp_descriptor) + sizeof(uint16_t));
anim->curlpnum = pagenumber;
anim->curlp = &anim->LpArray[pagenumber];
*pagepointer = (uint16_t *)(anim->buffer + 0xb00 + (pagenumber*IMAGEBUFFERSIZE) +
sizeof(lp_descriptor) + sizeof(uint16_t));
}
@ -114,63 +114,63 @@ static inline void loadpage(anim_t *anim, uint16_t pagenumber, uint16_t **pagepo
static void decodeframe(uint8_t * srcP, uint8_t * dstP)
{
do
{
{
/* short op */
uint8_t count = *srcP++;
do
{
{
/* short op */
uint8_t count = *srcP++;
if (!count) /* short RLE */
{
uint8_t color = *(srcP+1);
count = *(uint8_t *)srcP;
srcP += sizeof(int16_t);
memset(dstP, color, count);
dstP += count;
continue;
}
else if ((count & 0x80) == 0) /* short copy */
{
memcpy(dstP, srcP, count);
dstP += count;
srcP += count;
continue;
}
else if ((count &= ~0x80) > 0) /* short skip */
{
dstP += count;
continue;
}
}
if (!count) /* short RLE */
{
uint8_t color = *(srcP+1);
count = *(uint8_t *)srcP;
srcP += sizeof(int16_t);
memset(dstP, color, count);
dstP += count;
continue;
}
else if ((count & 0x80) == 0) /* short copy */
{
memcpy(dstP, srcP, count);
dstP += count;
srcP += count;
continue;
}
else if ((count &= ~0x80) > 0) /* short skip */
{
dstP += count;
continue;
}
}
{
/* long op */
uint16_t count = LittleShort((uint16_t)GetShort(srcP));
srcP += sizeof(int16_t);
{
/* long op */
uint16_t count = LittleShort((uint16_t)GetShort(srcP));
srcP += sizeof(int16_t);
if (!count) /* stop sign */
return;
else if ((count & 0x8000) == 0) /* long skip */
{
dstP += count;
continue;
}
else if ((count &= ~0x8000) & 0x4000) /* long RLE */
{
uint8_t color = *srcP++;
count &= ~0x4000;
memset(dstP, color, count);
dstP += count;
continue;
}
if (!count) /* stop sign */
return;
else if ((count & 0x8000) == 0) /* long skip */
{
dstP += count;
continue;
}
else if ((count &= ~0x8000) & 0x4000) /* long RLE */
{
uint8_t color = *srcP++;
count &= ~0x4000;
memset(dstP, color, count);
dstP += count;
continue;
}
/* long copy */
memcpy(dstP, srcP, count);
dstP += count;
srcP += count;
}
}
while (1);
/* long copy */
memcpy(dstP, srcP, count);
dstP += count;
srcP += count;
}
}
while (1);
}
@ -183,23 +183,23 @@ static void decodeframe(uint8_t * srcP, uint8_t * dstP)
static void renderframe(anim_t *anim, uint16_t framenumber, uint16_t *pagepointer)
{
uint16_t offset = 0;
uint16_t frame = framenumber - anim->curlp->baseRecord;
uint16_t offset = 0;
uint16_t frame = framenumber - anim->curlp->baseRecord;
while (frame--) offset += LittleShort(pagepointer[frame]);
while (frame--) offset += LittleShort(pagepointer[frame]);
if (offset >= anim->curlp->nBytes)
return;
uint8_t *ppointer = (uint8_t *)(pagepointer) + anim->curlp->nRecords*2 + offset + 4;
uint8_t *ppointer = (uint8_t *)(pagepointer) + anim->curlp->nRecords*2 + offset + 4;
if ((ppointer-4)[1])
{
uint16_t const temp = LittleShort(((uint16_t *)(ppointer-4))[1]);
ppointer += temp + (temp & 1);
}
if ((ppointer-4)[1])
{
uint16_t const temp = LittleShort(((uint16_t *)(ppointer-4))[1]);
ppointer += temp + (temp & 1);
}
decodeframe((uint8_t *)ppointer, (uint8_t *)anim->imagebuffer);
decodeframe((uint8_t *)ppointer, (uint8_t *)anim->imagebuffer);
}
@ -212,79 +212,79 @@ static void renderframe(anim_t *anim, uint16_t framenumber, uint16_t *pagepointe
static inline void drawframe(anim_t *anim, uint16_t framenumber)
{
loadpage(anim, findpage(anim, framenumber), &anim->thepage);
renderframe(anim, framenumber, anim->thepage);
loadpage(anim, findpage(anim, framenumber), &anim->thepage);
renderframe(anim, framenumber, anim->thepage);
}
// <length> is the file size, for consistency checking.
int32_t ANIM_LoadAnim(anim_t *anim, uint8_t *buffer, int32_t length)
{
if (memcmp(buffer, "LPF ", 4)) return -1;
if (memcmp(buffer, "LPF ", 4)) return -1;
length -= sizeof(lpfileheader)+128+768;
if (length < 0)
return -1;
length -= sizeof(lpfileheader)+128+768;
if (length < 0)
return -1;
anim->curlpnum = 0xffff;
anim->currentframe = -1;
anim->curlpnum = 0xffff;
anim->currentframe = -1;
// this just modifies the data in-place instead of copying it elsewhere now
lpfileheader & lpheader = *(anim->lpheader = (lpfileheader *)(anim->buffer = buffer));
// this just modifies the data in-place instead of copying it elsewhere now
lpfileheader & lpheader = *(anim->lpheader = (lpfileheader *)(anim->buffer = buffer));
lpheader.id = LittleLong(lpheader.id);
lpheader.maxLps = LittleShort(lpheader.maxLps);
lpheader.nLps = LittleShort(lpheader.nLps);
lpheader.nRecords = LittleLong(lpheader.nRecords);
lpheader.maxRecsPerLp = LittleShort(lpheader.maxRecsPerLp);
lpheader.lpfTableOffset = LittleShort(lpheader.lpfTableOffset);
lpheader.contentType = LittleLong(lpheader.contentType);
lpheader.width = LittleShort(lpheader.width);
lpheader.height = LittleShort(lpheader.height);
lpheader.nFrames = LittleLong(lpheader.nFrames);
lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond);
lpheader.id = LittleLong(lpheader.id);
lpheader.maxLps = LittleShort(lpheader.maxLps);
lpheader.nLps = LittleShort(lpheader.nLps);
lpheader.nRecords = LittleLong(lpheader.nRecords);
lpheader.maxRecsPerLp = LittleShort(lpheader.maxRecsPerLp);
lpheader.lpfTableOffset = LittleShort(lpheader.lpfTableOffset);
lpheader.contentType = LittleLong(lpheader.contentType);
lpheader.width = LittleShort(lpheader.width);
lpheader.height = LittleShort(lpheader.height);
lpheader.nFrames = LittleLong(lpheader.nFrames);
lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond);
length -= lpheader.nLps * sizeof(lp_descriptor);
if (length < 0)
return -2;
length -= lpheader.nLps * sizeof(lp_descriptor);
if (length < 0)
return -2;
buffer += sizeof(lpfileheader)+128;
buffer += sizeof(lpfileheader)+128;
// load the color palette
for (uint8_t * pal = anim->pal, * pal_end = pal+768; pal < pal_end; pal += 3, buffer += 4)
{
pal[2] = buffer[0];
pal[1] = buffer[1];
pal[0] = buffer[2];
}
// load the color palette
for (uint8_t * pal = anim->pal, * pal_end = pal+768; pal < pal_end; pal += 3, buffer += 4)
{
pal[2] = buffer[0];
pal[1] = buffer[1];
pal[0] = buffer[2];
}
// set up large page descriptors
anim->LpArray = (lp_descriptor *)buffer;
// set up large page descriptors
anim->LpArray = (lp_descriptor *)buffer;
// theoretically we should be able to play files with more than 256 frames now
// assuming the utilities to create them can make them that way
for (lp_descriptor * lp = anim->LpArray, * lp_end = lp+lpheader.nLps; lp < lp_end; ++lp)
{
lp->baseRecord = LittleShort(lp->baseRecord);
lp->nRecords = LittleShort(lp->nRecords);
lp->nBytes = LittleShort(lp->nBytes);
}
return ANIM_NumFrames(anim) <= 0 ? -1 : 0;
// theoretically we should be able to play files with more than 256 frames now
// assuming the utilities to create them can make them that way
for (lp_descriptor * lp = anim->LpArray, * lp_end = lp+lpheader.nLps; lp < lp_end; ++lp)
{
lp->baseRecord = LittleShort(lp->baseRecord);
lp->nRecords = LittleShort(lp->nRecords);
lp->nBytes = LittleShort(lp->nBytes);
}
return ANIM_NumFrames(anim) <= 0 ? -1 : 0;
}
uint8_t * ANIM_DrawFrame(anim_t *anim, int32_t framenumber)
{
uint32_t cnt = anim->currentframe;
uint32_t cnt = anim->currentframe;
// handle first play and looping or rewinding
if (cnt > (uint32_t)framenumber)
cnt = 0;
// handle first play and looping or rewinding
if (cnt > (uint32_t)framenumber)
cnt = 0;
do drawframe(anim, cnt++);
while (cnt < (uint32_t)framenumber);
do drawframe(anim, cnt++);
while (cnt < (uint32_t)framenumber);
anim->currentframe = framenumber;
return anim->imagebuffer;
anim->currentframe = framenumber;
return anim->imagebuffer;
}

View file

@ -45,37 +45,37 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
struct lpfileheader
{
uint32_t id; /* 4 uint8_tacter ID == "LPF " */
uint16_t maxLps; /* max # largePages allowed. 256 FOR NOW. */
uint16_t nLps; /* # largePages in this file. */
uint32_t nRecords; /* # records in this file. 65534 is current limit + ring */
uint16_t maxRecsPerLp; /* # records permitted in an lp. 256 FOR NOW. */
uint16_t lpfTableOffset; /* Absolute Seek position of lpfTable. 1280 FOR NOW. */
uint32_t contentType; /* 4 character ID == "ANIM" */
uint16_t width; /* Width of screen in pixels. */
uint16_t height; /* Height of screen in pixels. */
uint8_t variant; /* 0==ANIM. */
uint8_t version; /* 0==frame rate in 18/sec, 1= 70/sec */
uint8_t hasLastDelta; /* 1==Last record is a delta from last-to-first frame. */
uint8_t lastDeltaValid; /* 0==Ignore ring frame. */
uint8_t pixelType; /* 0==256 color. */
uint8_t CompressionType; /* 1==(RunSkipDump) Only one used FOR NOW. */
uint8_t otherRecsPerFrm; /* 0 FOR NOW. */
uint8_t bitmaptype; /* 1==320x200, 256-color. Only one implemented so far. */
uint8_t recordTypes[32]; /* Not yet implemented. */
uint32_t nFrames; /* Number of actual frames in the file, includes ring frame. */
uint16_t framesPerSecond; /* Number of frames to play per second. */
uint16_t pad2[29]; /* 58 bytes of filler to round up to 128 bytes total. */
uint32_t id; /* 4 uint8_tacter ID == "LPF " */
uint16_t maxLps; /* max # largePages allowed. 256 FOR NOW. */
uint16_t nLps; /* # largePages in this file. */
uint32_t nRecords; /* # records in this file. 65534 is current limit + ring */
uint16_t maxRecsPerLp; /* # records permitted in an lp. 256 FOR NOW. */
uint16_t lpfTableOffset; /* Absolute Seek position of lpfTable. 1280 FOR NOW. */
uint32_t contentType; /* 4 character ID == "ANIM" */
uint16_t width; /* Width of screen in pixels. */
uint16_t height; /* Height of screen in pixels. */
uint8_t variant; /* 0==ANIM. */
uint8_t version; /* 0==frame rate in 18/sec, 1= 70/sec */
uint8_t hasLastDelta; /* 1==Last record is a delta from last-to-first frame. */
uint8_t lastDeltaValid; /* 0==Ignore ring frame. */
uint8_t pixelType; /* 0==256 color. */
uint8_t CompressionType; /* 1==(RunSkipDump) Only one used FOR NOW. */
uint8_t otherRecsPerFrm; /* 0 FOR NOW. */
uint8_t bitmaptype; /* 1==320x200, 256-color. Only one implemented so far. */
uint8_t recordTypes[32]; /* Not yet implemented. */
uint32_t nFrames; /* Number of actual frames in the file, includes ring frame. */
uint16_t framesPerSecond; /* Number of frames to play per second. */
uint16_t pad2[29]; /* 58 bytes of filler to round up to 128 bytes total. */
};
// this is the format of a large page structure
struct lp_descriptor
{
uint16_t baseRecord; // Number of first record in this large page.
uint16_t nRecords; // Number of records in lp.
// bit 15 of "nRecords" == "has continuation from previous lp".
// bit 14 of "nRecords" == "final record continues on next lp".
uint16_t nBytes; // Total number of bytes of contents, excluding header.
uint16_t baseRecord; // Number of first record in this large page.
uint16_t nRecords; // Number of records in lp.
// bit 15 of "nRecords" == "has continuation from previous lp".
// bit 14 of "nRecords" == "final record continues on next lp".
uint16_t nBytes; // Total number of bytes of contents, excluding header.
};
#pragma pack(pop)
@ -84,16 +84,16 @@ struct lp_descriptor
struct anim_t
{
uint16_t framecount; // current frame of anim
lpfileheader * lpheader; // file header will be loaded into this structure
lp_descriptor * LpArray; // arrays of large page structs used to find frames
uint16_t curlpnum; // initialize to an invalid Large page number
lp_descriptor * curlp; // header of large page currently in memory
uint16_t * thepage; // buffer where current large page is loaded
uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded
uint8_t * buffer;
uint8_t pal[768];
int32_t currentframe;
uint16_t framecount; // current frame of anim
lpfileheader * lpheader; // file header will be loaded into this structure
lp_descriptor * LpArray; // arrays of large page structs used to find frames
uint16_t curlpnum; // initialize to an invalid Large page number
lp_descriptor * curlp; // header of large page currently in memory
uint16_t * thepage; // buffer where current large page is loaded
uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded
uint8_t * buffer;
uint8_t pal[768];
int32_t currentframe;
};
//****************************************************************************
@ -116,7 +116,7 @@ int32_t ANIM_LoadAnim(anim_t *anim, uint8_t *buffer, int32_t length);
inline int32_t ANIM_NumFrames(anim_t* anim)
{
return anim->lpheader->nRecords;
return anim->lpheader->nRecords;
}
//****************************************************************************
@ -138,7 +138,7 @@ uint8_t * ANIM_DrawFrame(anim_t* anim, int32_t framenumber);
inline uint8_t* ANIM_GetPalette(anim_t* anim)
{
return anim->pal;
return anim->pal;
}
#endif

View file

@ -44,42 +44,42 @@
void AnimTexture::SetFrameSize(int format, int width, int height)
{
pixelformat = format;
FTexture::SetSize(width, height);
Image.Resize(width * height * (format == Paletted ? 1 : 3));
memset(Image.Data(), 0, Image.Size());
pixelformat = format;
FTexture::SetSize(width, height);
Image.Resize(width * height * (format == Paletted ? 1 : 3));
memset(Image.Data(), 0, Image.Size());
}
void AnimTexture::SetFrame(const uint8_t* palette, const void* data_)
{
if (palette) memcpy(Palette, palette, 768);
if (data_)
{
if (pixelformat == YUV)
{
auto spix = (const uint8_t*)data_;
auto dpix = Image.Data();
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int q = i * 3;
float y = spix[p] * (1 / 255.f);
float u = spix[p + 1] * (1 / 255.f) - 0.5f;
float v = spix[p + 2] * (1 / 255.f) - 0.5f;
if (palette) memcpy(Palette, palette, 768);
if (data_)
{
if (pixelformat == YUV)
{
auto spix = (const uint8_t*)data_;
auto dpix = Image.Data();
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int q = i * 3;
float y = spix[p] * (1 / 255.f);
float u = spix[p + 1] * (1 / 255.f) - 0.5f;
float v = spix[p + 2] * (1 / 255.f) - 0.5f;
y = 1.1643f * (y - 0.0625f);
y = 1.1643f * (y - 0.0625f);
float r = y + 1.5958f * v;
float g = y - 0.39173f * u - 0.81290f * v;
float b = y + 2.017f * u;
float r = y + 1.5958f * v;
float g = y - 0.39173f * u - 0.81290f * v;
float b = y + 2.017f * u;
dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255);
dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255);
dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255);
}
}
else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3));
}
dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255);
dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255);
dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255);
}
}
else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3));
}
}
//===========================================================================
@ -90,37 +90,37 @@ void AnimTexture::SetFrame(const uint8_t* palette, const void* data_)
FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
{
FBitmap bmp;
FBitmap bmp;
bmp.Create(Width, Height);
bmp.Create(Width, Height);
auto spix = Image.Data();
auto dpix = bmp.GetPixels();
if (pixelformat == Paletted)
{
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int index = spix[i];
dpix[p + 0] = Palette[index * 3 + 2];
dpix[p + 1] = Palette[index * 3 + 1];
dpix[p + 2] = Palette[index * 3];
dpix[p + 3] = 255;
}
}
else if (pixelformat == RGB || pixelformat == YUV)
{
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int q = i * 3;
dpix[p + 0] = spix[q + 2];
dpix[p + 1] = spix[q + 1];
dpix[p + 2] = spix[q];
dpix[p + 3] = 255;
}
}
return bmp;
auto spix = Image.Data();
auto dpix = bmp.GetPixels();
if (pixelformat == Paletted)
{
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int index = spix[i];
dpix[p + 0] = Palette[index * 3 + 2];
dpix[p + 1] = Palette[index * 3 + 1];
dpix[p + 2] = Palette[index * 3];
dpix[p + 3] = 255;
}
}
else if (pixelformat == RGB || pixelformat == YUV)
{
for (int i = 0; i < Width * Height; i++)
{
int p = i * 4;
int q = i * 3;
dpix[p + 0] = spix[q + 2];
dpix[p + 1] = spix[q + 1];
dpix[p + 2] = spix[q];
dpix[p + 3] = 255;
}
}
return bmp;
}
//==========================================================================
@ -131,36 +131,36 @@ FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
AnimTextures::AnimTextures()
{
active = 1;
tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override);
tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override);
active = 1;
tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override);
tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override);
}
AnimTextures::~AnimTextures()
{
Clean();
Clean();
}
void AnimTextures::Clean()
{
if (tex[0]) tex[0]->CleanHardwareData(true);
if (tex[1]) tex[1]->CleanHardwareData(true);
tex[0] = tex[1] = nullptr;
if (tex[0]) tex[0]->CleanHardwareData(true);
if (tex[1]) tex[1]->CleanHardwareData(true);
tex[0] = tex[1] = nullptr;
}
void AnimTextures::SetSize(int format, int width, int height)
{
static_cast<AnimTexture*>(tex[0]->GetTexture())->SetFrameSize(format, width, height);
static_cast<AnimTexture*>(tex[1]->GetTexture())->SetFrameSize(format, width, height);
tex[0]->SetSize(width, height);
tex[1]->SetSize(width, height);
tex[0]->CleanHardwareData();
tex[1]->CleanHardwareData();
static_cast<AnimTexture*>(tex[0]->GetTexture())->SetFrameSize(format, width, height);
static_cast<AnimTexture*>(tex[1]->GetTexture())->SetFrameSize(format, width, height);
tex[0]->SetSize(width, height);
tex[1]->SetSize(width, height);
tex[0]->CleanHardwareData();
tex[1]->CleanHardwareData();
}
void AnimTextures::SetFrame(const uint8_t* palette, const void* data)
{
active ^= 1;
static_cast<AnimTexture*>(tex[active]->GetTexture())->SetFrame(palette, data);
tex[active]->CleanHardwareData();
active ^= 1;
static_cast<AnimTexture*>(tex[active]->GetTexture())->SetFrame(palette, data);
tex[active]->CleanHardwareData();
}

View file

@ -44,379 +44,379 @@ static TArray<usermaphack_t> usermaphacks;
void AddUserMapHack(usermaphack_t& mhk)
{
usermaphacks.Push(mhk);
usermaphacks.Push(mhk);
}
static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites)
{
int currentsprite = -1;
int currentwall = -1;
int currentsector = -1;
int numsprites = sprites.sprites.Size();
int currentsprite = -1;
int currentwall = -1;
int currentsector = -1;
int numsprites = sprites.sprites.Size();
FScanner sc;
int lump = fileSystem.FindFile(filename);
if (lump < 0)
{
return -1;
}
sc.OpenLumpNum(lump);
sprites.sprext.Resize(numsprites);
memset(sprites.sprext.Data(), 0, sizeof(spriteext_t) * sprites.sprext.Size());
FScanner sc;
int lump = fileSystem.FindFile(filename);
if (lump < 0)
{
return -1;
}
sc.OpenLumpNum(lump);
sprites.sprext.Resize(numsprites);
memset(sprites.sprext.Data(), 0, sizeof(spriteext_t) * sprites.sprext.Size());
while (sc.GetString())
{
FString token = sc.String;
auto validateSprite = [&]()
{
if (currentsprite < 0 || currentsprite >= numsprites)
{
sc.ScriptMessage("Using %s without a valid sprite", token.GetChars());
return false;
}
return true;
};
while (sc.GetString())
{
FString token = sc.String;
auto validateSprite = [&]()
{
if (currentsprite < 0 || currentsprite >= numsprites)
{
sc.ScriptMessage("Using %s without a valid sprite", token.GetChars());
return false;
}
return true;
};
auto validateWall = [&]()
{
if (currentwall < 0 || currentwall >= (int)wall.Size())
{
sc.ScriptMessage("Using %s without a valid wall", token.GetChars());
return false;
}
return true;
};
auto validateWall = [&]()
{
if (currentwall < 0 || currentwall >= (int)wall.Size())
{
sc.ScriptMessage("Using %s without a valid wall", token.GetChars());
return false;
}
return true;
};
auto validateSector = [&]()
{
if (currentsector < 0 || currentsector >= (int)sector.Size())
{
sc.ScriptMessage("Using %s without a valid sector", token.GetChars());
return false;
}
return true;
};
auto validateSector = [&]()
{
if (currentsector < 0 || currentsector >= (int)sector.Size())
{
sc.ScriptMessage("Using %s without a valid sector", token.GetChars());
return false;
}
return true;
};
if (sc.Compare("sprite"))
{
currentwall = -1;
currentsector = -1;
if (sc.CheckNumber())
{
currentsprite = sc.Number;
if ((unsigned)currentsprite >= sprites.sprites.Size())
{
sc.ScriptMessage("Invalid sprite number %d", currentsprite);
currentsprite = -1;
}
}
else currentsprite = -1;
}
if (sc.Compare("wall"))
{
currentsprite = -1;
currentsector = -1;
if (sc.CheckNumber())
{
currentwall = sc.Number;
if (!validWallIndex(currentwall))
{
sc.ScriptMessage("Invalid wall number %d", currentwall);
currentwall = -1;
}
}
else currentwall = -1;
}
if (sc.Compare("sector"))
{
currentsprite = -1;
currentwall = -1;
if (sc.CheckNumber())
{
currentsector = sc.Number;
if (!validSectorIndex(currentsector))
{
sc.ScriptMessage("Invalid sector number %d", currentsector);
currentsector = -1;
}
}
else currentsector = -1;
}
else if (sc.Compare("sector"))
{
if (sc.CheckNumber())
{
if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].setsector(sc.Number);
}
}
}
else if (sc.Compare("picnum"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].picnum = sc.Number;
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].picnum = sc.Number;
}
}
}
else if (sc.Compare("overpicnum"))
{
if (sc.CheckNumber() && validateWall())
{
wall[currentwall].overpicnum = sc.Number;
}
}
else if (sc.Compare("overpicnum"))
{
if (sc.CheckNumber() && validateWall())
{
wall[currentwall].overpicnum = sc.Number;
}
}
else if (sc.Compare("split"))
{
int start = -1, end = -1;
if (sc.CheckNumber()) start = sc.Number;
if (sc.CheckNumber()) end = sc.Number;
if (end >= 0 && validateSector())
{
hw_SetSplitSector(currentsector, start, end);
}
}
else if (sc.Compare("clearflags"))
{
if (currentsector != -1 && validateSector())
{
sc.GetString();
if (sc.Compare("floor") && sc.CheckNumber())
{
sector[currentsector].floorstat &= ESectorFlags::FromInt(~sc.Number);
}
else if (sc.Compare("ceiling") && sc.CheckNumber())
{
sector[currentsector].ceilingstat &= ESectorFlags::FromInt(~sc.Number);
}
else sc.ScriptError("Bad token %s", sc.String);
}
else if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].cstat &= EWallFlags::FromInt(~sc.Number);
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].cstat &= ESpriteFlags::FromInt(~sc.Number);
}
}
}
else if (sc.Compare("setflags"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].cstat |= EWallFlags::FromInt(sc.Number);
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].cstat |= ESpriteFlags::FromInt(sc.Number);
}
}
}
else if (sc.Compare("lotag"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].lotag = sc.Number;
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].lotag = sc.Number;
}
}
}
else if (sc.Compare("sw_serp_continue")) // This is a hack for SW's Last Warrior mod to continue from L4 to L5.
{
if (currentLevel) currentLevel->gameflags |= LEVEL_SW_DEATHEXIT_SERPENT_NEXT;
}
if (sc.Compare("sprite"))
{
currentwall = -1;
currentsector = -1;
if (sc.CheckNumber())
{
currentsprite = sc.Number;
if ((unsigned)currentsprite >= sprites.sprites.Size())
{
sc.ScriptMessage("Invalid sprite number %d", currentsprite);
currentsprite = -1;
}
}
else currentsprite = -1;
}
if (sc.Compare("wall"))
{
currentsprite = -1;
currentsector = -1;
if (sc.CheckNumber())
{
currentwall = sc.Number;
if (!validWallIndex(currentwall))
{
sc.ScriptMessage("Invalid wall number %d", currentwall);
currentwall = -1;
}
}
else currentwall = -1;
}
if (sc.Compare("sector"))
{
currentsprite = -1;
currentwall = -1;
if (sc.CheckNumber())
{
currentsector = sc.Number;
if (!validSectorIndex(currentsector))
{
sc.ScriptMessage("Invalid sector number %d", currentsector);
currentsector = -1;
}
}
else currentsector = -1;
}
else if (sc.Compare("sector"))
{
if (sc.CheckNumber())
{
if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].setsector(sc.Number);
}
}
}
else if (sc.Compare("picnum"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].picnum = sc.Number;
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].picnum = sc.Number;
}
}
}
else if (sc.Compare("overpicnum"))
{
if (sc.CheckNumber() && validateWall())
{
wall[currentwall].overpicnum = sc.Number;
}
}
else if (sc.Compare("overpicnum"))
{
if (sc.CheckNumber() && validateWall())
{
wall[currentwall].overpicnum = sc.Number;
}
}
else if (sc.Compare("split"))
{
int start = -1, end = -1;
if (sc.CheckNumber()) start = sc.Number;
if (sc.CheckNumber()) end = sc.Number;
if (end >= 0 && validateSector())
{
hw_SetSplitSector(currentsector, start, end);
}
}
else if (sc.Compare("clearflags"))
{
if (currentsector != -1 && validateSector())
{
sc.GetString();
if (sc.Compare("floor") && sc.CheckNumber())
{
sector[currentsector].floorstat &= ESectorFlags::FromInt(~sc.Number);
}
else if (sc.Compare("ceiling") && sc.CheckNumber())
{
sector[currentsector].ceilingstat &= ESectorFlags::FromInt(~sc.Number);
}
else sc.ScriptError("Bad token %s", sc.String);
}
else if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].cstat &= EWallFlags::FromInt(~sc.Number);
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].cstat &= ESpriteFlags::FromInt(~sc.Number);
}
}
}
else if (sc.Compare("setflags"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].cstat |= EWallFlags::FromInt(sc.Number);
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].cstat |= ESpriteFlags::FromInt(sc.Number);
}
}
}
else if (sc.Compare("lotag"))
{
if (sc.CheckNumber())
{
if (currentwall != -1 && validateWall())
{
wall[currentwall].lotag = sc.Number;
}
else if (currentsprite != -1 && validateSprite())
{
sprites.sprites[currentsprite].lotag = sc.Number;
}
}
}
else if (sc.Compare("sw_serp_continue")) // This is a hack for SW's Last Warrior mod to continue from L4 to L5.
{
if (currentLevel) currentLevel->gameflags |= LEVEL_SW_DEATHEXIT_SERPENT_NEXT;
}
else if (sc.Compare("angleoff") || sc.Compare("angoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].angoff = (int16_t)sc.Number;
}
else if (sc.Compare("notmd") || sc.Compare("notmd2") || sc.Compare("notmd3"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_NOTMD;
}
else if (sc.Compare("nomdanim") || sc.Compare("nomd2anim") || sc.Compare("nomd3anim"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_NOMDANIM;
}
else if (sc.Compare("pitch"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pitch = (int16_t)sc.Number;
}
else if (sc.Compare("roll"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].roll = (int16_t)sc.Number;
}
else if (sc.Compare("mdxoff") || sc.Compare("mdpivxoff") || sc.Compare("mdpivotxoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.X = sc.Number;
}
else if (sc.Compare("mdyoff") || sc.Compare("mdpivyoff") || sc.Compare("mdpivotyoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.Y = sc.Number;
}
else if (sc.Compare("mdzoff") || sc.Compare("mdpivzoff") || sc.Compare("mdpivotzoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.Z = sc.Number;
}
else if (sc.Compare("mdposxoff") || sc.Compare("mdpositionxoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("mdposyoff") || sc.Compare("mdpositionyoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("mdposzoff") || sc.Compare("mdpositionzoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("away1"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_AWAY1;
}
else if (sc.Compare("away2"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_AWAY2;
}
else if (sc.Compare("mhkreset"))
{
if (validateSprite())
{
auto& sx = sprites.sprext[currentsprite];
sx.angoff = 0;
sx.flags &= ~(SPREXT_NOTMD | SPREXT_NOMDANIM | SPREXT_AWAY1 | SPREXT_AWAY2);
sx.pitch = 0;
sx.roll = 0;
sx.pivot_offset = {};
sx.position_offset = {};
}
}
else if (sc.Compare("light"))
{
// skip over it - once lights are working this should be reactivated. Assignments were kept as documentation.
sc.MustGetNumber();
//light.sector= sc.Number;
sc.MustGetNumber();
//light.x= sc.Number;
sc.MustGetNumber();
//light.y= sc.Number;
sc.MustGetNumber();
//light.z= sc.Number;
sc.MustGetNumber();
//light.range= sc.Number;
sc.MustGetNumber();
//light.color[0]= sc.Number;
sc.MustGetNumber();
//light.color[1]= sc.Number;
sc.MustGetNumber();
//light.color[2]= sc.Number;
sc.MustGetNumber();
//light.radius= sc.Number;
sc.MustGetNumber();
//light.faderadius= sc.Number;
sc.MustGetNumber();
//light.angle= sc.Number;
sc.MustGetNumber();
//light.horiz= sc.Number;
sc.MustGetNumber();
//light.minshade= sc.Number;
sc.MustGetNumber();
//light.maxshade= sc.Number;
sc.MustGetNumber();
//light.priority= sc.Number;
sc.MustGetString();
//light.tilenum= sc.Number;
}
}
else if (sc.Compare("angleoff") || sc.Compare("angoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].angoff = (int16_t)sc.Number;
}
else if (sc.Compare("notmd") || sc.Compare("notmd2") || sc.Compare("notmd3"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_NOTMD;
}
else if (sc.Compare("nomdanim") || sc.Compare("nomd2anim") || sc.Compare("nomd3anim"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_NOMDANIM;
}
else if (sc.Compare("pitch"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pitch = (int16_t)sc.Number;
}
else if (sc.Compare("roll"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].roll = (int16_t)sc.Number;
}
else if (sc.Compare("mdxoff") || sc.Compare("mdpivxoff") || sc.Compare("mdpivotxoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.X = sc.Number;
}
else if (sc.Compare("mdyoff") || sc.Compare("mdpivyoff") || sc.Compare("mdpivotyoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.Y = sc.Number;
}
else if (sc.Compare("mdzoff") || sc.Compare("mdpivzoff") || sc.Compare("mdpivotzoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].pivot_offset.Z = sc.Number;
}
else if (sc.Compare("mdposxoff") || sc.Compare("mdpositionxoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("mdposyoff") || sc.Compare("mdpositionyoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("mdposzoff") || sc.Compare("mdpositionzoff"))
{
if (sc.CheckNumber() && validateSprite())
sprites.sprext[currentsprite].position_offset.X = sc.Number;
}
else if (sc.Compare("away1"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_AWAY1;
}
else if (sc.Compare("away2"))
{
if (validateSprite())
sprites.sprext[currentsprite].flags |= SPREXT_AWAY2;
}
else if (sc.Compare("mhkreset"))
{
if (validateSprite())
{
auto& sx = sprites.sprext[currentsprite];
sx.angoff = 0;
sx.flags &= ~(SPREXT_NOTMD | SPREXT_NOMDANIM | SPREXT_AWAY1 | SPREXT_AWAY2);
sx.pitch = 0;
sx.roll = 0;
sx.pivot_offset = {};
sx.position_offset = {};
}
}
else if (sc.Compare("light"))
{
// skip over it - once lights are working this should be reactivated. Assignments were kept as documentation.
sc.MustGetNumber();
//light.sector= sc.Number;
sc.MustGetNumber();
//light.x= sc.Number;
sc.MustGetNumber();
//light.y= sc.Number;
sc.MustGetNumber();
//light.z= sc.Number;
sc.MustGetNumber();
//light.range= sc.Number;
sc.MustGetNumber();
//light.color[0]= sc.Number;
sc.MustGetNumber();
//light.color[1]= sc.Number;
sc.MustGetNumber();
//light.color[2]= sc.Number;
sc.MustGetNumber();
//light.radius= sc.Number;
sc.MustGetNumber();
//light.faderadius= sc.Number;
sc.MustGetNumber();
//light.angle= sc.Number;
sc.MustGetNumber();
//light.horiz= sc.Number;
sc.MustGetNumber();
//light.minshade= sc.Number;
sc.MustGetNumber();
//light.maxshade= sc.Number;
sc.MustGetNumber();
//light.priority= sc.Number;
sc.MustGetString();
//light.tilenum= sc.Number;
}
}
return 0;
}
void loadMapHack(const char* filename, const unsigned char* md4, SpawnSpriteDef& sprites)
{
hw_ClearSplitSector();
hw_ClearSplitSector();
FString internal = "engine/compatibility/";
for (int j = 0; j < 16; ++j)
{
internal.AppendFormat("%02x", md4[j]);
}
LoadMapHack(internal + ".mhk", sprites);
FString hack = StripExtension(filename) + ".mhk";
FString internal = "engine/compatibility/";
for (int j = 0; j < 16; ++j)
{
internal.AppendFormat("%02x", md4[j]);
}
LoadMapHack(internal + ".mhk", sprites);
FString hack = StripExtension(filename) + ".mhk";
if (LoadMapHack(hack, sprites))
{
for (auto& mhk : usermaphacks)
{
if (!memcmp(md4, mhk.md4, 16))
{
LoadMapHack(mhk.mhkfile, sprites);
}
}
}
if (LoadMapHack(hack, sprites))
{
for (auto& mhk : usermaphacks)
{
if (!memcmp(md4, mhk.md4, 16))
{
LoadMapHack(mhk.mhkfile, sprites);
}
}
}
}
// Map hacks use MD4 instead of MD5. Oh, well...
CCMD(md4sum)
{
if (argv.argc() < 2)
{
Printf("Usage: md4sum <file> ...\n");
}
for (int i = 1; i < argv.argc(); ++i)
{
FileReader fr = fileSystem.OpenFileReader(argv[i]);
if (!fr.isOpen())
{
Printf("%s: %s\n", argv[i], strerror(errno));
}
else
{
auto data = fr.Read();
uint8_t digest[16];
md4once(data.Data(), data.Size(), digest);
for (int j = 0; j < 16; ++j)
{
Printf("%02x", digest[j]);
}
Printf(" //*%s\n", argv[i]);
}
}
if (argv.argc() < 2)
{
Printf("Usage: md4sum <file> ...\n");
}
for (int i = 1; i < argv.argc(); ++i)
{
FileReader fr = fileSystem.OpenFileReader(argv[i]);
if (!fr.isOpen())
{
Printf("%s: %s\n", argv[i], strerror(errno));
}
else
{
auto data = fr.Read();
uint8_t digest[16];
md4once(data.Data(), data.Size(), digest);
for (int j = 0; j < 16; ++j)
{
Printf("%02x", digest[j]);
}
Printf(" //*%s\n", argv[i]);
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,12 @@ struct AMB_CHANNEL
AMB_CHANNEL ambChannels[kMaxAmbChannel];
int nAmbChannels = 0;
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ambProcess(void)
{
if (!SoundEnabled())
@ -90,6 +96,12 @@ void ambProcess(void)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ambKillAll(void)
{
AMB_CHANNEL *pChannel = ambChannels;
@ -101,6 +113,12 @@ void ambKillAll(void)
nAmbChannels = 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ambInit(void)
{
ambKillAll();

View file

@ -135,6 +135,12 @@ void AddCmdDefine(char *text, int value)
nCmdDefines++;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void SplitPath(const char *pzPath, char *pzDirectory, char *pzFile, char *pzType)
{
int const nLength = (int)strlen(pzPath);
@ -180,6 +186,12 @@ static void SplitPath(const char *pzPath, char *pzDirectory, char *pzFile, char
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
// 174 bytes
struct RFS
{
@ -207,6 +219,12 @@ public:
void UnsetMark();
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int RFS::Open(int lumpnum)
{
auto hFile = fileSystem.OpenFileReader(lumpnum);
@ -238,6 +256,12 @@ void RFS::Close()
{
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void RFS::Increment()
{
if (_curChar == '\n') {
@ -254,6 +278,12 @@ void RFS::Increment()
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void RFS::SkipBeyondValue(char nVal)
{
while (_curChar && _curChar != nVal) {
@ -276,6 +306,12 @@ void RFS::UnsetMark()
_curLine = _unknown7;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void RFS::ScriptError(const char *message)
{
// TODO
@ -307,6 +343,12 @@ void RFS::ScriptError(const char *message)
Printf("Error in %s line %d: %s\n\n%s", _fileName, _curLine, message, msg.Data());
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
uint8_t RFS::GetNextTag()
{
// skip any space characters
@ -493,6 +535,12 @@ uint8_t RFS::GetNextTag()
// qAssert(1==0); // TODO - what to return here
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ParseScript(int lumpnum)
{
char text[256];
@ -933,6 +981,12 @@ void ParseScript(int lumpnum)
rfs.Close();
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void addMemoryResource(char* filePath, char flags, int ID)
{
char zDirectory[BMAX_PATH];
@ -945,6 +999,12 @@ void addMemoryResource(char* filePath, char flags, int ID)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ReadAllRFS()
{
bool found = false;

View file

@ -71,6 +71,12 @@ IMPLEMENT_POINTER(xspr.burnSource)
IMPLEMENT_POINTER(xspr.target)
IMPLEMENT_POINTERS_END
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
size_t DBloodActor::PropagateMark()
{
condition[0].Mark();
@ -109,6 +115,12 @@ int16_t startang;
sectortype* startsector;
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void QuitGame(void)
{
throw CExitEvent(0);
@ -124,6 +136,12 @@ void EndLevel(void)
seqKillAll();
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
TArray<DBloodActor*> SpawnActors(BloodSpawnSpriteDef& sprites)
{
TArray<DBloodActor*> spawns(sprites.sprites.Size(), true);
@ -153,6 +171,12 @@ TArray<DBloodActor*> SpawnActors(BloodSpawnSpriteDef& sprites)
return spawns;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void PropagateMarkerReferences(void)
{
BloodStatIterator it(kStatMarker);
@ -194,6 +218,12 @@ void PropagateMarkerReferences(void)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void StartLevel(MapRecord* level, bool newgame)
{
if (!level) return;
@ -329,6 +359,12 @@ void StartLevel(MapRecord* level, bool newgame)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void NewLevel(MapRecord *sng, int skill, bool newgame)
{
if (skill != -1) gGameOptions.nDifficulty = skill;
@ -355,6 +391,12 @@ int GameInterface::GetCurrentSkill()
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void GameInterface::Ticker()
{
for (int i = connecthead; i >= 0; i = connectpoint2[i])
@ -436,6 +478,12 @@ void GameInterface::Ticker()
else r_NoInterpolate = true;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void GameInterface::DrawBackground()
{
twod->ClearScreen();
@ -461,6 +509,12 @@ static void SetTileNames()
void ReadAllRFS();
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void GameInterface::loadPalette(void)
{
// in nearly typical Blood fashion it had to use an inverse of the original translucency settings...
@ -529,6 +583,12 @@ void GameInterface::loadPalette(void)
paletteloaded = PALETTE_SHADE | PALETTE_TRANSLUC | PALETTE_MAIN;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void GameInterface::app_init()
{
GC::AddMarkerFunc(markgcroots);
@ -568,6 +628,12 @@ void GameInterface::app_init()
gMe = gView = &gPlayer[myconnectindex];
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void gameInit()
{
gViewIndex = myconnectindex;
@ -607,6 +673,12 @@ void sndPlaySpecialMusicOrNothing(int nMusic)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
extern IniFile* BloodINI;
void GameInterface::FreeGameData()
{
@ -635,6 +707,12 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
return new GameInterface;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
enum
{
kLoadScreenCRC = -2051908571,

View file

@ -60,19 +60,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
struct INIDESCRIPTION {
const char *pzName;
const char *pzFilename;
const char **pzArts;
int nArts;
const char* pzName;
const char* pzFilename;
const char** pzArts;
int nArts;
};
struct INICHAIN {
INICHAIN *pNext;
char zName[BMAX_PATH];
INIDESCRIPTION *pDescription;
INICHAIN* pNext;
char zName[BMAX_PATH];
INIDESCRIPTION* pDescription;
};
extern INICHAIN *pINIChain;
extern INICHAIN* pINIChain;
extern int gNetPlayers;
extern int blood_globalflags;
@ -104,12 +104,12 @@ void PolymostAllocFakeSector();
inline bool DemoRecordStatus(void)
{
return false;
return false;
}
inline bool VanillaMode()
{
return false;
return false;
}
void sndPlaySpecialMusicOrNothing(int nMusic);
@ -136,7 +136,7 @@ struct GameInterface : public ::GameInterface
void Startup() override;
void Render() override;
const char* GenericCheat(int player, int cheat) override;
void NewGame(MapRecord *sng, int skill, bool) override;
void NewGame(MapRecord* sng, int skill, bool) override;
void NextLevel(MapRecord* map, int skill) override;
void LevelCompleted(MapRecord* map, int skill) override;
bool DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a, double const smoothratio) override;

View file

@ -121,12 +121,12 @@ public:
return spr.type >= kItemAmmoBase && spr.type < kItemAmmoMax;
}
bool isActive()
bool isActive()
{
if (!hasX())
return false;
switch (xspr.aiState->stateType)
switch (xspr.aiState->stateType)
{
case kAiStateIdle:
case kAiStateGenIdle:

File diff suppressed because it is too large Load diff

View file

@ -26,36 +26,36 @@ BEGIN_BLD_NS
void sleeveStopBouncing(DBloodActor* pSprite);
enum CALLBACK_ID {
kCallbackNone = -1,
kCallbackFXFlameLick = 0,
kCallbackRemove = 1,
kCallbackFXFlareBurst = 2,
kCallbackFXFlareSpark = 3,
kCallbackFXFlareSparkLite = 4,
kCallbackFXZombieSpurt = 5,
kCallbackFXBloodSpurt = 6,
kCallbackFXArcSpark = 7,
kCallbackFXDynPuff = 8,
kCallbackRespawn = 9,
kCallbackPlayerBubble = 10,
kCallbackEnemeyBubble = 11,
kCallbackCounterCheck = 12,
kCallbackFinishHim = 13,
kCallbackFXBloodBits = 14,
kCallbackFXTeslaAlt = 15,
kCallbackFXBouncingSleeve = 16,
kCallbackReturnFlag = 17,
kCallbackFXPodBloodSpray = 18,
kCallbackFXPodBloodSplat = 19,
kCallbackLeechStateTimer = 20,
kCallbackDropVoodoo = 21, // unused
#ifdef NOONE_EXTENSIONS
kCallbackMissileBurst = 22,
kCallbackMissileSpriteBlock = 23,
kCallbackGenDudeUpdate = 24,
kCallbackCondition = 25,
#endif
kCallbackMax,
kCallbackNone = -1,
kCallbackFXFlameLick = 0,
kCallbackRemove = 1,
kCallbackFXFlareBurst = 2,
kCallbackFXFlareSpark = 3,
kCallbackFXFlareSparkLite = 4,
kCallbackFXZombieSpurt = 5,
kCallbackFXBloodSpurt = 6,
kCallbackFXArcSpark = 7,
kCallbackFXDynPuff = 8,
kCallbackRespawn = 9,
kCallbackPlayerBubble = 10,
kCallbackEnemeyBubble = 11,
kCallbackCounterCheck = 12,
kCallbackFinishHim = 13,
kCallbackFXBloodBits = 14,
kCallbackFXTeslaAlt = 15,
kCallbackFXBouncingSleeve = 16,
kCallbackReturnFlag = 17,
kCallbackFXPodBloodSpray = 18,
kCallbackFXPodBloodSplat = 19,
kCallbackLeechStateTimer = 20,
kCallbackDropVoodoo = 21, // unused
#ifdef NOONE_EXTENSIONS
kCallbackMissileBurst = 22,
kCallbackMissileSpriteBlock = 23,
kCallbackGenDudeUpdate = 24,
kCallbackCondition = 25,
#endif
kCallbackMax,
};
extern void(*gCallback[kCallbackMax])(DBloodActor*, sectortype*);

View file

@ -29,6 +29,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void CChoke::init(int a1, void(*a2)(PLAYER*))
{
callback = a2;
@ -44,6 +50,12 @@ void CChoke::init(int a1, void(*a2)(PLAYER*))
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void CChoke::animateChoke(int x, int y, int smoothratio)
{
if (!qav)
@ -64,6 +76,12 @@ void CChoke::animateChoke(int x, int y, int smoothratio)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void chokeCallback(PLAYER* pPlayer)
{
int t = gGameOptions.nDifficulty + 2;

File diff suppressed because it is too large Load diff

View file

@ -37,40 +37,46 @@ static InputPacket gInput;
void UpdatePlayerSpriteAngle(PLAYER* pPlayer);
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust);
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet)
{
if (paused || M_Active())
{
gInput = {};
return;
}
if (paused || M_Active())
{
gInput = {};
return;
}
PLAYER* pPlayer = &gPlayer[myconnectindex];
InputPacket input {};
PLAYER* pPlayer = &gPlayer[myconnectindex];
InputPacket input{};
ApplyGlobalInput(gInput, hidInput);
processMovement(&input, &gInput, hidInput, scaleAdjust);
ApplyGlobalInput(gInput, hidInput);
processMovement(&input, &gInput, hidInput, scaleAdjust);
if (!SyncInput() && gamestate == GS_LEVEL)
{
// Perform unsynchronised angle/horizon if not dead.
if (gView->actor->xspr.health != 0)
{
pPlayer->angle.applyinput(input.avel, &pPlayer->input.actions, scaleAdjust);
pPlayer->horizon.applyinput(input.horz, &pPlayer->input.actions, scaleAdjust);
doslopetilting(pPlayer, scaleAdjust);
}
if (!SyncInput() && gamestate == GS_LEVEL)
{
// Perform unsynchronised angle/horizon if not dead.
if (gView->actor->xspr.health != 0)
{
pPlayer->angle.applyinput(input.avel, &pPlayer->input.actions, scaleAdjust);
pPlayer->horizon.applyinput(input.horz, &pPlayer->input.actions, scaleAdjust);
doslopetilting(pPlayer, scaleAdjust);
}
pPlayer->angle.processhelpers(scaleAdjust);
pPlayer->horizon.processhelpers(scaleAdjust);
UpdatePlayerSpriteAngle(pPlayer);
}
pPlayer->angle.processhelpers(scaleAdjust);
pPlayer->horizon.processhelpers(scaleAdjust);
UpdatePlayerSpriteAngle(pPlayer);
}
if (packet)
{
*packet = gInput;
gInput = {};
}
if (packet)
{
*packet = gInput;
gInput = {};
}
}
//---------------------------------------------------------------------------
@ -81,7 +87,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
void GameInterface::clearlocalinputstate()
{
gInput = {};
gInput = {};
}
END_BLD_NS

View file

@ -49,6 +49,12 @@ public:
void Draw(void);
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
{
bWideScreen = widescreen;
@ -67,6 +73,12 @@ CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widesc
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void CGameMenuItemQAV::Draw(void)
{
if (bClearBackground)
@ -103,6 +115,12 @@ void CGameMenuItemQAV::Draw(void)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static std::unique_ptr<CGameMenuItemQAV> itemBloodQAV; // This must be global to ensure that the animation remains consistent across menus.
void UpdateNetworkMenus(void)