- can be compiled again but crashes.

This commit is contained in:
Christoph Oelckers 2019-09-19 23:02:57 +02:00
parent dd7ce38cbb
commit 8074d8251e
13 changed files with 92 additions and 107 deletions

View file

@ -1162,7 +1162,6 @@ void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * c
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
extern vec2_t hitscangoal;
int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz,
hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6)));
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
@ -1583,7 +1582,6 @@ extern void(*PolymostProcessVoxels_Callback)(void);
extern int32_t automapping;
extern int32_t bloodhack;
extern int32_t blooddemohack;
extern intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
extern int8_t voxreserve[(MAXVOXELS+7)>>3];

View file

@ -18,6 +18,7 @@ extern "C" {
#endif
extern bool playing_rr;
extern bool playing_blood;
//// TYPES
struct strllist

View file

@ -1094,18 +1094,18 @@ int32_t kopen4load(const char *filename, char searchfirst)
char g_modDir[BMAX_PATH] = "/";
int32_t kopen4loadfrommod(const char *fileName, char searchfirst)
buildvfs_kfd kopen4loadfrommod(const char* fileName, char searchfirst)
{
int kFile = -1;
buildvfs_kfd kFile = buildvfs_kfd_invalid;
if (g_modDir[0] != '/' || g_modDir[1] != 0)
{
static char staticFileName[BMAX_PATH];
Bsnprintf(staticFileName, sizeof(staticFileName), "%s/%s", g_modDir, fileName);
kFile = kopen4load(staticFileName, searchfirst);
}
if (g_modDir[0] != '/' || g_modDir[1] != 0)
{
static char staticFileName[BMAX_PATH];
Bsnprintf(staticFileName, sizeof(staticFileName), "%s/%s", g_modDir, fileName);
kFile = kopen4load(staticFileName, searchfirst);
}
return (kFile < 0) ? kopen4load(fileName, searchfirst) : kFile;
return (kFile == buildvfs_kfd_invalid) ? kopen4load(fileName, searchfirst) : kFile;
}
int32_t kread_internal(int32_t handle, void *buffer, int32_t leng, const uint8_t *arraygrp, const intptr_t *arrayhan, int32_t *arraypos)

View file

@ -262,8 +262,10 @@ static int32_t Defs_ImportTileFromTexture(char const * const fn, int32_t const t
if (artstatus < 0)
return artstatus<<8;
Bmemcpy(&picanm[tile], &kpzbuf[20], sizeof(picanm_t));
tileConvertAnimFormat(tile);
int32_t picanmdisk;
Bmemcpy(&picanmdisk, &kpzbuf[20], sizeof(int32_t));
picanmdisk = B_LITTLE32(picanmdisk);
tileConvertAnimFormat(tile, picanmdisk);
int32_t const xsiz = B_LITTLE16(B_UNBUF16(&kpzbuf[16]));
int32_t const ysiz = B_LITTLE16(B_UNBUF16(&kpzbuf[18]));

View file

@ -13,6 +13,7 @@
#include "build.h"
#include "cache1d.h"
#include "colmatch.h"
#include "common.h"
#include "compat.h"
#include "crc32.h"
#include "editor.h"
@ -189,6 +190,11 @@ static void draw_rainbow_background(void);
int16_t editstatus = 0;
static fix16_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms)
int32_t(*getpalookup_replace)(int32_t davis, int32_t dashade) = NULL;
int32_t automapping = 0;
int32_t bloodhack = 0;
// adapted from build.c
static void getclosestpointonwall_internal(vec2_t const &p, int32_t const dawall, vec2_t *const closest)
{
@ -7166,11 +7172,7 @@ static void dosetaspect(void)
radarang2[i] = (int16_t)((radarang[k]+j)>>6);
}
if (xdimen != oxdimen
#ifndef PLAYING_BLOOD
&& voxoff[0][0]
#endif
)
if (xdimen != oxdimen && (playing_blood || voxoff[0][0]))
{
if (distrecip == NULL)
distrecip = (uint32_t *)Xaligned_alloc(16, DISTRECIPSIZ * sizeof(uint32_t));
@ -8125,25 +8127,28 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
dmost[0] = shortptr2[0]-windowxy1.y;
}
for (int i = 0; i < numwalls; ++i)
if (!bloodhack)
{
if (wall[i].cstat & CSTAT_WALL_ROTATE_90)
for (int i = 0; i < numwalls; ++i)
{
auto &w = wall[i];
auto &tile = rottile[w.picnum+animateoffs(w.picnum)];
if (tile.newtile == -1 && tile.owner == -1)
if (wall[i].cstat & CSTAT_WALL_ROTATE_90)
{
tile.newtile = findUnusedTile();
Bassert(tile.newtile != -1);
auto &w = wall[i];
auto &tile = rottile[w.picnum+animateoffs(w.picnum,16384)];
rottile[tile.newtile].owner = w.picnum+animateoffs(w.picnum);
if (tile.newtile == -1 && tile.owner == -1)
{
tile.newtile = findUnusedTile();
Bassert(tile.newtile != -1);
auto &siz = tilesiz[w.picnum+animateoffs(w.picnum)];
tileSetSize(tile.newtile, siz.x, siz.y);
rottile[tile.newtile].owner = w.picnum+animateoffs(w.picnum,16384);
tileLoad(tile.newtile);
// Bassert(waloff[tile.newtile]);
auto &siz = tilesiz[w.picnum+animateoffs(w.picnum,16384)];
tileSetSize(tile.newtile, siz.x, siz.y);
tileLoad(tile.newtile);
// Bassert(waloff[tile.newtile]);
}
}
}
}
@ -8732,11 +8737,7 @@ killsprite:
get_wallspr_points((uspriteptr_t)tspr, &xx[0], &xx[1], &yy[0], &yy[1]);
#ifndef PLAYING_BLOOD
if ((tspr->cstat & 48) == 0)
#else
if ((tspr->cstat & 48) != 16)
#endif
if (!playing_blood? ((tspr->cstat & 48) == 0) : ((tspr->cstat & 48) != 16))
tspriteptr[i]->ang = oang;
}

View file

@ -272,17 +272,26 @@ void set_globalang(fix16_t const ang);
int32_t animateoffs(int tilenum, int fakevar);
extern bool playing_blood;
}
template <class inttype>
inline void DO_TILE_ANIM(inttype &Picnum, int Fakevar)
{
#ifndef PLAYING_BLOOD
if (picanm[Picnum].sf&PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum);
#else
Picnum += animateoffs(Picnum, Fakevar);
#endif
if (!playing_blood)
{
if (picanm[Picnum].sf & PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum, Fakevar);
}
else
{
Picnum += animateoffs(Picnum, Fakevar);
}
if (((Fakevar & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && rottile[Picnum].newtile != -1) Picnum = rottile[Picnum].newtile;
}
extern "C" {
static FORCE_INLINE int32_t bad_tspr(tspriteptr_t tspr)
{
// NOTE: tspr->owner >= MAXSPRITES (could be model) has to be handled by

View file

@ -210,7 +210,7 @@ void paletteLoadFromDisk(void)
}
auto fil = kopen4load("palette.dat", 0);
if (fil) == buildvfs_kfd_invalid)
if (fil == buildvfs_kfd_invalid)
return;

View file

@ -19,6 +19,7 @@ Ken Silverman's official web site: http://www.advsys.net/ken
extern char textfont[2048], smalltextfont[2048];
bool playing_rr;
bool playing_blood;
int32_t rendmode=0;
int32_t usemodels=1;

View file

@ -6,6 +6,7 @@
#include "a.h"
#include "build.h"
#include "cache1d.h"
#include "common.h"
#include "compat.h"
#include "engine_priv.h"
#include "osd.h"
@ -1715,9 +1716,8 @@ void videoShowFrame(int32_t w)
{
if (palfadedelta)
fullscreen_tint_gl(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
#ifdef PLAYING_BLOOD
fullscreen_tint_gl_blood();
#endif
if (playing_blood)
fullscreen_tint_gl_blood();
#ifdef __ANDROID__
AndroidDrawControls();

View file

@ -367,40 +367,41 @@ int32_t artCheckUnitFileHeader(uint8_t const * const buf, int32_t length)
return 0;
}
void tileConvertAnimFormat(int32_t const picnum)
void tileConvertAnimFormat(int32_t const picnum, int32_t const picanmdisk)
{
EDUKE32_STATIC_ASSERT(sizeof(picanm_t) == 4);
EDUKE32_STATIC_ASSERT(PICANM_ANIMTYPE_MASK == 192);
EDUKE32_STATIC_ASSERT(PICANM_ANIMTYPE_MASK == 192);
picanm_t * const thispicanm = &picanm[picnum];
// Old on-disk format: anim type is in the 2 highest bits of the lowest byte.
thispicanm->sf &= ~192;
thispicanm->sf |= thispicanm->num&192;
thispicanm->num &= ~192;
// don't allow setting texhitscan/nofullbright from ART
thispicanm->sf &= ~PICANM_MISC_MASK;
// Unpack a 4 byte packed anim descriptor into the internal 5 byte format.
picanm_t* const thispicanm = &picanm[picnum];
thispicanm->num = picanmdisk & 63;
thispicanm->xofs = (picanmdisk >> 8) & 255;
thispicanm->yofs = (picanmdisk >> 16) & 255;
thispicanm->sf = ((picanmdisk >> 24) & 15) | (picanmdisk & 192);
thispicanm->extra = (picanmdisk >> 28) & 15;
}
void artReadManifest(buildvfs_kfd const fil, artheader_t const * const local)
void artReadManifest(int32_t const fil, artheader_t const* const local)
{
int16_t *tilesizx = (int16_t *) Xmalloc(local->numtiles * sizeof(int16_t));
int16_t *tilesizy = (int16_t *) Xmalloc(local->numtiles * sizeof(int16_t));
kread(fil, tilesizx, local->numtiles*sizeof(int16_t));
kread(fil, tilesizy, local->numtiles*sizeof(int16_t));
kread(fil, &picanm[local->tilestart], local->numtiles*sizeof(picanm_t));
int16_t* tilesizx = (int16_t*)Xmalloc(local->numtiles * sizeof(int16_t));
int16_t* tilesizy = (int16_t*)Xmalloc(local->numtiles * sizeof(int16_t));
kread(fil, tilesizx, local->numtiles * sizeof(int16_t));
kread(fil, tilesizy, local->numtiles * sizeof(int16_t));
for (bssize_t i=local->tilestart; i<=local->tileend; i++)
{
tilesiz[i].x = B_LITTLE16(tilesizx[i-local->tilestart]);
tilesiz[i].y = B_LITTLE16(tilesizy[i-local->tilestart]);
for (bssize_t i = local->tilestart; i <= local->tileend; i++)
{
int32_t picanmdisk;
tileConvertAnimFormat(i);
}
tilesiz[i].x = B_LITTLE16(tilesizx[i - local->tilestart]);
tilesiz[i].y = B_LITTLE16(tilesizy[i - local->tilestart]);
DO_FREE_AND_NULL(tilesizx);
DO_FREE_AND_NULL(tilesizy);
kread(fil, &picanmdisk, sizeof(int32_t));
picanmdisk = B_LITTLE32(picanmdisk);
tileConvertAnimFormat(i, picanmdisk);
}
DO_FREE_AND_NULL(tilesizx);
DO_FREE_AND_NULL(tilesizy);
}
void artPreloadFile(buildvfs_kfd const fil, artheader_t const * const local)
@ -470,11 +471,6 @@ static const char *artGetIndexedFileName(int32_t tilefilei)
}
#ifndef PLAYING_BLOOD
auto kopen4loadfunc = kopen4load;
#else
auto kopen4loadfunc = kopen4loadfrommod;
#endif
// Returns:
// 0: successfully read ART file
@ -487,6 +483,8 @@ static int32_t artReadIndexedFile(int32_t tilefilei)
const int32_t permap = (tilefilei >= MAXARTFILES_BASE); // is it a per-map ART file?
buildvfs_kfd fil;
auto kopen4loadfunc = playing_blood ? kopen4loadfrommod : kopen4load;
if ((fil = kopen4loadfunc(fn, 0)) != buildvfs_kfd_invalid)
{
artheader_t local;
@ -690,7 +688,9 @@ void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer)
char const *fn = artGetIndexedFileName(tfn);
artfil = kopen4loadfunc(fn, 0);
auto kopen4loadfunc = playing_blood ? kopen4loadfrommod : kopen4load;
artfil = kopen4loadfunc(fn, 0);
if (artfil == buildvfs_kfd_invalid)
{

View file

@ -995,7 +995,7 @@ voxmodel_t *loadkvxfrombuf(const char *kvxbuffer, int32_t length)
vm->piv.x = voxpiv.x; vm->piv.y = voxpiv.y; vm->piv.z = voxpiv.z;
vm->is8bit = 1;
vm->texid = (uint32_t *)Xcalloc(MAXPALOOKUPS, sizeof(uint32_t));
vm->texid = (FHardwareTexture **)Xcalloc(MAXPALOOKUPS, sizeof(FHardwareTexture *));
}
DO_FREE_AND_NULL(shcntmal);

View file

@ -239,21 +239,8 @@ void G_SetupGlobalPsky(void)
//////////
static char g_rootDir[BMAX_PATH];
char g_modDir[BMAX_PATH] = "/";
//char g_modDir[BMAX_PATH] = "/";
buildvfs_kfd kopen4loadfrommod(const char *fileName, char searchfirst)
{
buildvfs_kfd kFile = buildvfs_kfd_invalid;
if (g_modDir[0] != '/' || g_modDir[1] != 0)
{
static char staticFileName[BMAX_PATH];
Bsnprintf(staticFileName, sizeof(staticFileName), "%s/%s", g_modDir, fileName);
kFile = kopen4load(staticFileName, searchfirst);
}
return (kFile == buildvfs_kfd_invalid) ? kopen4load(fileName, searchfirst) : kFile;
}
int g_useCwd;
static void G_LoadAddon(void);

View file

@ -211,21 +211,7 @@ void G_SetupGlobalPsky(void)
//////////
static char g_rootDir[BMAX_PATH];
char g_modDir[BMAX_PATH] = "/";
int kopen4loadfrommod(const char *fileName, char searchfirst)
{
int kFile = -1;
if (g_modDir[0] != '/' || g_modDir[1] != 0)
{
static char staticFileName[BMAX_PATH];
Bsnprintf(staticFileName, sizeof(staticFileName), "%s/%s", g_modDir, fileName);
kFile = kopen4load(staticFileName, searchfirst);
}
return (kFile < 0) ? kopen4load(fileName, searchfirst) : kFile;
}
//char g_modDir[BMAX_PATH] = "/";
int g_useCwd;
static void G_LoadAddon(void);