- misc code changes

This commit is contained in:
Ilya Shurumov 2021-05-11 21:26:26 +06:00 committed by InspirationByte
parent fdc9782530
commit fd5ed926ab
2 changed files with 29 additions and 38 deletions

View File

@ -264,7 +264,7 @@ int CheckUnpackNewRegions(void)
} }
else if (32 - force_load_boundary < current_barrel_region_xcell) else if (32 - force_load_boundary < current_barrel_region_xcell)
{ {
if (region_x < cells_across >> 5) if (region_x < regions_across)
{ {
leftright_unpack = 2; leftright_unpack = 2;
num_regions_to_unpack = 1; num_regions_to_unpack = 1;
@ -295,8 +295,6 @@ int CheckUnpackNewRegions(void)
{ {
if (topbottom_unpack == 1) if (topbottom_unpack == 1)
{ {
num_regions_to_unpack = 3;
if (leftright_unpack == 1) if (leftright_unpack == 1)
{ {
regions_to_unpack[2].xoffset = -1; regions_to_unpack[2].xoffset = -1;
@ -447,7 +445,16 @@ void InitMap(void)
} }
// load regions synchronously // load regions synchronously
if (doSpooling == 0) if (doSpooling)
{
regions_unpacked[0] = -1;
regions_unpacked[1] = -1;
regions_unpacked[2] = -1;
regions_unpacked[3] = -1;
ControlMap();
}
else
{ {
old_region = -1; old_region = -1;
@ -458,8 +465,8 @@ void InitMap(void)
multiplayerregions[3] = multiplayerregions[2] + 1; multiplayerregions[3] = multiplayerregions[2] + 1;
} }
i = 0; for (i = 0; i < 4; i++)
do { {
region_to_unpack = multiplayerregions[i]; region_to_unpack = multiplayerregions[i];
if (spoolinfo_offsets[region_to_unpack] != 0xffff) if (spoolinfo_offsets[region_to_unpack] != 0xffff)
@ -469,13 +476,12 @@ void InitMap(void)
if (spoolptr->super_region != 0xff) if (spoolptr->super_region != 0xff)
initarea = spoolptr->super_region; initarea = spoolptr->super_region;
barrel_region = (region_to_unpack % (cells_across >> 5) & 1U) + (region_to_unpack / (cells_across >> 5) & 1U) * 2; barrel_region = (region_to_unpack % regions_across & 1U) +
(region_to_unpack / regions_across & 1U) * 2;
UnpackRegion(region_to_unpack, barrel_region); UnpackRegion(region_to_unpack, barrel_region);
} }
}
i++;
} while (i < 4);
LoadInAreaTSets(initarea); LoadInAreaTSets(initarea);
LoadInAreaModels(initarea); LoadInAreaModels(initarea);
@ -485,25 +491,13 @@ void InitMap(void)
StartSpooling(); StartSpooling();
} }
else
{
regions_unpacked[0] = -1;
regions_unpacked[1] = -1;
regions_unpacked[2] = -1;
regions_unpacked[3] = -1;
ControlMap();
}
} }
// [D] [T] [A] // [D] [T] [A]
void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz) void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz)
{ {
int cz; int cx, cz;
int cx; int rx, rz;
int rz;
int rx;
cx = (pos->vx + units_across_halved) / MAP_CELL_SIZE; cx = (pos->vx + units_across_halved) / MAP_CELL_SIZE;
cz = (pos->vz + units_down_halved) / MAP_CELL_SIZE; cz = (pos->vz + units_down_halved) / MAP_CELL_SIZE;
@ -524,8 +518,6 @@ void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz)
tgt); tgt);
} }
unsigned char nybblearray[512] = { 0 };
char* PVS_Buffers[4] = { 0 }; char* PVS_Buffers[4] = { 0 };
int pvsSize[4] = { 0, 0, 0, 0 }; int pvsSize[4] = { 0, 0, 0, 0 };
unsigned char *PVSEncodeTable = NULL; unsigned char *PVSEncodeTable = NULL;
@ -533,6 +525,7 @@ unsigned char *PVSEncodeTable = NULL;
// [D] [T] // [D] [T]
void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBodge) void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBodge)
{ {
u_char nybblearray[256];
int pixelIndex; int pixelIndex;
u_char* decodebuf; u_char* decodebuf;
u_char* op; u_char* op;
@ -620,8 +613,8 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
size = pvs_square - 1; size = pvs_square - 1;
op = (decodebuf - 2) + (size * pvs_square + pvs_square); op = (decodebuf - 2) + (size * pvs_square + pvs_square);
i = size;
i = size;
while (i >= 0) while (i >= 0)
{ {
j = pvs_square-2; j = pvs_square-2;
@ -683,20 +676,18 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
PVSEncodeTable = (unsigned char *)(bp + 0x802); PVSEncodeTable = (unsigned char *)(bp + 0x802);
tbp = bp + cell * 2; tbp = bp + cell * 2;
length = M_SHRT_2((unsigned char)tbp[2], (unsigned char)tbp[3]) - M_SHRT_2((unsigned char)tbp[0], (unsigned char)tbp[1]) & 0xffff; length = M_SHRT_2((u_char)tbp[2], (u_char)tbp[3]) - M_SHRT_2((u_char)tbp[0], (u_char)tbp[1]) & 0xffff;
if (length == 0) if (length != 0)
{ {
for (k = 0; k < pvs_square_sq; k++) havanaCorruptCellBodge = (regions_unpacked[source_region] == 158 && cell == 168);
output[k] = 1;
PVSDecode(output, bp + M_SHRT_2((u_char)tbp[0], (u_char)tbp[1]), length, havanaCorruptCellBodge);
} }
else else
{ {
havanaCorruptCellBodge = 0; for (k = 0; k < pvs_square_sq; k++)
if (regions_unpacked[source_region] == 158 && cell == 168) output[k] = 1;
havanaCorruptCellBodge = (GameLevel == 1);
PVSDecode(output, bp + M_SHRT_2((unsigned char)tbp[0], (unsigned char)tbp[1]), length, havanaCorruptCellBodge);
} }
} }
else else

View File

@ -163,7 +163,7 @@ int check_regions_present(void)
{ {
regions_to_unpack[0].xoffset = 1; regions_to_unpack[0].xoffset = 1;
if (region_x < (cells_across >> 5)) if (region_x < regions_across)
{ {
leftright_unpack = 2; leftright_unpack = 2;
num_regions_to_unpack = 1; num_regions_to_unpack = 1;
@ -222,7 +222,7 @@ int check_regions_present(void)
x = regions_to_unpack[retval].xoffset; x = regions_to_unpack[retval].xoffset;
z = regions_to_unpack[retval].zoffset; z = regions_to_unpack[retval].zoffset;
region_to_unpack = current_region + x + z * (cells_across >> 5); region_to_unpack = current_region + x + z * regions_across;
if (loading_region[(region_x + x & 1U) + (region_z + z & 1U) * 2] != -1 && if (loading_region[(region_x + x & 1U) + (region_z + z & 1U) * 2] != -1 &&
spoolinfo_offsets[region_to_unpack] != 0xffff && spoolinfo_offsets[region_to_unpack] != 0xffff &&