Skip to content

Commit

Permalink
Valve BSP, WAD, and external texture support
Browse files Browse the repository at this point in the history
  • Loading branch information
Toodles2You committed Dec 7, 2024
1 parent 2c987a4 commit 2f62426
Show file tree
Hide file tree
Showing 10 changed files with 677 additions and 68 deletions.
4 changes: 4 additions & 0 deletions Quake/bspfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#define BSPVERSION 29

#ifdef BSP29_VALVE
#define BSPVERSION_VALVE 30
#endif

/* RMQ support (2PSB). 32bits instead of shorts for all but bbox sizes (which
* still use shorts) */
#define BSP2VERSION_2PSB (('B' << 24) | ('S' << 16) | ('P' << 8) | '2')
Expand Down
10 changes: 9 additions & 1 deletion Quake/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ char *q_strupr (char *str)
return str;
}

char *q_strdup (const char *str)
{
size_t len = strlen (str) + 1;
char *newstr = (char *)malloc (len);
memcpy (newstr, str, len);
return newstr;
}

/* platform dependant (v)snprintf function names: */
#if defined(_WIN32)
#define snprintf_func _snprintf
Expand Down Expand Up @@ -1138,7 +1146,7 @@ void COM_FileBase (const char *in, char *out, size_t outsize)
dot = NULL;
while (*s)
{
if (*s == '/')
if (*s == '/' || *s == '\\')
slash = s + 1;
if (*s == '.')
dot = s;
Expand Down
3 changes: 3 additions & 0 deletions Quake/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ extern char *q_strcasestr(const char *haystack, const char *needle);
extern char *q_strlwr (char *str);
extern char *q_strupr (char *str);

// strdup that calls malloc
extern char *q_strdup (const char *str);

/* snprintf, vsnprintf : always use our versions. */
extern int q_snprintf (char *str, size_t size, const char *format, ...) FUNC_PRINTF(3,4);
extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args) FUNC_PRINTF(3,0);
Expand Down
4 changes: 2 additions & 2 deletions Quake/gl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ qpic_t *Draw_PicFromWad (const char *name)
char texturename[64]; //johnfitz
q_snprintf (texturename, sizeof(texturename), "%s:%s", WADFILENAME, name); //johnfitz

offset = (src_offset_t)p - (src_offset_t)wad_base + sizeof(int)*2; //johnfitz
offset = (src_offset_t)p - (src_offset_t)gfx.base + sizeof(int)*2; //johnfitz

gl.gltexture = TexMgr_LoadImage (NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME,
offset, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
Expand Down Expand Up @@ -357,7 +357,7 @@ void Draw_LoadPics (void)

data = (byte *) W_GetLumpName ("conchars");
if (!data) Sys_Error ("Draw_LoadPics: couldn't load conchars");
offset = (src_offset_t)data - (src_offset_t)wad_base;
offset = (src_offset_t)data - (src_offset_t)gfx.base;
char_texture = TexMgr_LoadImage (NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data,
WADFILENAME, offset, TEXPREF_ALPHA | TEXPREF_NEAREST | TEXPREF_NOPICMIP | TEXPREF_CONCHARS);

Expand Down
Loading

0 comments on commit 2f62426

Please sign in to comment.