Working solution that i built and tested.
it works for level commands:
hole 1900 (bor legacy)
hole 2300 244 11 0 199 287 45 (current build, invisible hole)
hole data/sprites/hole2 490 244 11 0 199 287 45 (upgrade i did to load any custom sprite hole anywhere in the level instead of using panels with holes)
in openbor.h change the s_terrain struct to accept a sprite identifier (to be optionally drawn later)
typedef struct
{
/*
Hole/Wall structure.
2013-12-07
Damon Caskey
*/
float depth;
float height;
float lowerleft;
float lowerright;
float upperleft;
float upperright;
float x;
float z;
int type;
int sprite; // store a sprite to be drawn if != -1
// Meta data.
s_meta_data* meta_data; // User defiend data.
int meta_tag; // User defined int.
} s_terrain;
in openbor.c change the addhole function to store a sprite identifier
static void addhole(float x, float z, float x1, float x2, float x3, float x4, float depth, float alt, int type, int sprite)
{
__realloc(level->holes, level->numholes);
level->holes[level->numholes].x = x;
level->holes[level->numholes].z = z;
level->holes[level->numholes].upperleft = x1;
level->holes[level->numholes].lowerleft = x2;
level->holes[level->numholes].upperright = x3;
level->holes[level->numholes].lowerright = x4;
level->holes[level->numholes].depth = depth;
level->holes[level->numholes].height = alt;
level->holes[level->numholes].type = type;
level->holes[level->numholes].sprite = sprite;
level->numholes++;
}
in openbor.c change the handling of "hole" command case to handle: legacy bor.pak + loading of any new hole sprite + invisible hole (current build)
case CMD_LEVEL_HOLE:
if (arglist.count == 2) //bor legacy with default hole sprite
{
float wall_x = GET_FLOAT_ARG(1);
int default_hole_sprite = loadsprite("data/sprites/hole", 0, 0, pixelformat);
addhole(wall_x, 244.0f, 11, 0, 199, 287, 45, 0, 0, default_hole_sprite);
}
else if (!isdigit((unsigned char)GET_ARG(1)[0])) //upgrade use any hole sprite
{
const char* sprite_path = GET_ARG(1);
int custom_hole_sprite = loadsprite((char *)sprite_path, 0, 0, pixelformat); // Cast to char *
addhole(GET_FLOAT_ARG(2), GET_FLOAT_ARG(3), GET_FLOAT_ARG(4), GET_FLOAT_ARG(5), GET_FLOAT_ARG(6), GET_FLOAT_ARG(7), GET_FLOAT_ARG(8), GET_FLOAT_ARG(9), GET_FLOAT_ARG(10), custom_hole_sprite);
}
else // invisible hole
{
addhole(GET_FLOAT_ARG(1), GET_FLOAT_ARG(2), GET_FLOAT_ARG(3), GET_FLOAT_ARG(4), GET_FLOAT_ARG(5), GET_FLOAT_ARG(6), GET_FLOAT_ARG(7), GET_FLOAT_ARG(8), GET_FLOAT_ARG(9), -1);
}
break;
in openbor.c change the exit_hole condition to add -1 at the end of the addhole function call :
if(exit_hole)
{
addhole(level->width, PLAYER_MAX_Z, -panel_height, 0, 1000, 1000, panel_height, 0, 0, -1);
}
in openbor.c and the void draw_scrolled_bg, replace the commented code with :
s_drawmethod *pscreenmethod = &screenmethod;
for (i = 0; i < level->numholes; i++)
{
if (level->holes.sprite >= 0)
{
spriteq_add_sprite((int)(level->holes.x - screenx + gfx_x_offset), (int)(level->holes.z - level->holes.depth - screeny + gfx_y_offset), HOLE_Z, level->holes.sprite, pscreenmethod, 0);
}
}