Skip to content

Commit

Permalink
Merge branch 'FWGS:master' into android
Browse files Browse the repository at this point in the history
  • Loading branch information
Velaron committed Nov 22, 2023
2 parents dacff8a + 8d7b9c2 commit eb36905
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 43 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/vgui_support
Submodule vgui_support updated 1 files
+7 −11 vgui_surf.cpp
4 changes: 4 additions & 0 deletions Documentation/gameinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ These strings are specific to Xash3D FWGS.

| Key | Type | Default value | Description |
| ----------------------- | ---------- | ------------------------ | ----------- |
| `animated_title` | boolean | 0 | Use animated title in main menu (WON Half-Life logo.avi imitation from Half-Life 25-th anniversary update)
| `autosave_aged_count` | integer | 2 | Auto saves limit used in saves rotation |
| `gamedll_linux` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 Linux (see LibraryNaming.md for details) |
| `gamedll_osx` | string | Generated from `gamedll` | Game server DLL for 32-bit x86 macOS (see LibraryNaming.md for details) |
| `hd_background` | boolean | 0 | Use HD background for main menu (Half-Life 25-th anniversary update) |
| `internal_vgui_support` | boolean | 0 | Only for programmers! Required to be set as 1 for PrimeXT!<br>When set to 1, the engine will not load vgui_support DLL, as VGUI support is done (or intentionally ignored) on the game side. |
| `render_picbutton_text` | boolean | 0 | When set to 1, the UI will not use prerendered `btns_main.bmp` and dynamically render them instead |
| `quicksave_aged_count` | integer | 2 | Quick saves limit used in saves rotation |
Expand All @@ -88,13 +90,15 @@ The table below defines conversion rules from liblist.gam to gameinfo.txt. Some

| `liblist.gam` key | `gameinfo.txt` key | Note |
| ----------------- | ------------------ | ---- |
| `animated_title` | `animated_title` | |
| `edicts` | `max_edicts` | |
| `fallback_dir` | `fallback_dir` | |
| `game` | `title` | |
| `gamedir` | `gamedir` | |
| `gamedll` | `gamedll` | |
| `gamedll_linux` | `gamedll_linux` | |
| `gamedll_osx` | `gamedll_osx` | |
| `hd_background` | `hd_background` | |
| `icon` | `icon` | |
| `mpentity` | `mp_entity` | |
| `mpfilter` | `mp_filter` | |
Expand Down
2 changes: 2 additions & 0 deletions common/gameinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ GNU General Public License for more details.
#define GFL_NOMODELS (1<<0)
#define GFL_NOSKILLS (1<<1)
#define GFL_RENDER_PICBUTTON_TEXT (1<<2)
#define GFL_HD_BACKGROUND (1<<3)
#define GFL_ANIMATED_TITLE (1<<4)

/*
========================================================================
Expand Down
10 changes: 7 additions & 3 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,15 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
out->gamemode = in->gamemode;

if( in->nomodels )
out->flags |= GFL_NOMODELS;
SetBits( out->flags, GFL_NOMODELS );
if( in->noskills )
out->flags |= GFL_NOSKILLS;
SetBits( out->flags, GFL_NOSKILLS );
if( in->render_picbutton_text )
out->flags |= GFL_RENDER_PICBUTTON_TEXT;
SetBits( out->flags, GFL_RENDER_PICBUTTON_TEXT );
if( in->hd_background )
SetBits( out->flags, GFL_HD_BACKGROUND );
if( in->animated_title )
SetBits( out->flags, GFL_ANIMATED_TITLE );
}

/*
Expand Down
7 changes: 7 additions & 0 deletions filesystem/VFileSystem009.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ class CXashFS : public IVFileSystem009
return FS_FileTime( p, false );
}

long int GetFileModificationTime( const char *path )
{
// TODO: properly reverse-engineer this
FixupPath( p, path );
return FS_FileTime( p, false );
}

void FileTimeToString( char *p, int size, long int time ) override
{
const time_t curtime = time;
Expand Down
5 changes: 3 additions & 2 deletions filesystem/VFileSystem009.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class IBaseInterface
virtual ~IBaseInterface() {}
};

class IVFileSystem009 : public IBaseInterface
{
class IVFileSystem009 : public IBaseInterface {
public:
virtual void Mount() = 0; /* linkage=_ZN11IFileSystem5MountEv */

Expand Down Expand Up @@ -148,6 +147,8 @@ class IVFileSystem009 : public IBaseInterface
virtual FileHandle_t OpenFromCacheForRead(const char *, const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20OpenFromCacheForReadEPKcS1_S1_ */

virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */

virtual long int GetFileModificationTime(const char *) = 0; /* linkage=_ZN11IFileSystem23GetFileModificationTimeEPKc */
};

#endif // VFILESYSTEM009_H
20 changes: 19 additions & 1 deletion filesystem/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
}

if( GameInfo->noskills )
FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->nomodels );
FS_Printf( f, "noskills\t\t\"%i\"\n", GameInfo->noskills );

#define SAVE_AGED_COUNT 2 // the default count of quick and auto saves
if( GameInfo->quicksave_aged_count != SAVE_AGED_COUNT )
Expand All @@ -613,6 +613,13 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
FS_Printf( f, "autosave_aged_count\t\t%d\n", GameInfo->autosave_aged_count );
#undef SAVE_AGED_COUNT

// HL25 compatibility
if( GameInfo->animated_title )
FS_Printf( f, "animated_title\t\t%i\n", GameInfo->animated_title );

if( GameInfo->hd_background )
FS_Printf( f, "hd_background\t\t%i\n", GameInfo->hd_background );

// always expose our extensions :)
FS_Printf( f, "internal_vgui_support\t\t%s\n", GameInfo->internal_vgui_support ? "1" : "0" );
FS_Printf( f, "render_picbutton_text\t\t%s\n", GameInfo->render_picbutton_text ? "1" : "0" );
Expand Down Expand Up @@ -790,6 +797,17 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->max_edicts = bound( MIN_EDICTS, Q_atoi( token ), MAX_EDICTS );
}
// valid for both
else if( !Q_stricmp( token, "hd_background" ))
{
pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->hd_background = Q_atoi( token ) ? true : false;
}
else if( !Q_stricmp( token, "animated_title" ))
{
pfile = COM_ParseFile( pfile, token, sizeof( token ));
GameInfo->animated_title = Q_atoi( token ) ? true : false;
}
// only for gameinfo
else if( isGameInfo )
{
Expand Down
4 changes: 4 additions & 0 deletions filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ typedef struct gameinfo_s

int quicksave_aged_count; // min is 1, max is 99
int autosave_aged_count; // min is 1, max is 99

// HL25 compatibility keys
qboolean hd_background;
qboolean animated_title;
} gameinfo_t;

typedef enum
Expand Down
11 changes: 6 additions & 5 deletions utils/mdldec/mdldec.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static qboolean IsValidName( char *name )
if( !( isalpha( *name ) || isdigit( *name )))
return false;

while( *( ++name))
while( *( ++name ))
{
if( isalpha( *name ) || isdigit( *name )
|| *name == '.' || *name == '-' || *name == '_'
Expand Down Expand Up @@ -305,7 +305,7 @@ static qboolean LoadMDL( const char *modelname )
return false;
}

if( Q_strcmp( ext, "mdl" ) )
if( Q_stricmp( ext, "mdl" ) )
{
fprintf( stderr, "ERROR: Only .mdl-files is supported.\n" );
return false;
Expand Down Expand Up @@ -349,17 +349,18 @@ static qboolean LoadMDL( const char *modelname )

if( destdir[0] != '\0' )
{
if( !MakeDirectory( destdir ) )
if( !MakeDirectory( destdir ))
{
fprintf( stderr, "ERROR: Couldn't create directory %s\n", destdir );
return false;
}

COM_PathSlashFix( destdir );
}
else
COM_ExtractFilePath( modelname, destdir );

if( destdir[0] != '\0' )
COM_PathSlashFix( destdir );

len -= ( sizeof( ".mdl" ) - 1 ); // path length without extension

if( !model_hdr->numtextures )
Expand Down
112 changes: 81 additions & 31 deletions utils/mdldec/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GNU General Public License for more details.
#include "crtlib.h"
#include "studio.h"
#include "img_bmp.h"
#include "img_tga.h"
#include "mdldec.h"
#include "texture.h"

Expand All @@ -28,50 +29,30 @@ GNU General Public License for more details.
WriteBMP
============
*/
static void WriteBMP( mstudiotexture_t *texture )
static void WriteBMP( FILE *fp, mstudiotexture_t *texture )
{
int i, len;
FILE *fp;
int i;
const byte *p;
byte *palette, *pic;
char filename[MAX_SYSPATH];
rgba_t rgba_palette[256];
bmp_t bmp_hdr = {0,};
size_t texture_size;

len = Q_snprintf( filename, MAX_SYSPATH, "%s%s", destdir, texture->name );

if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s\n", texture->name );
return;
}

fp = fopen( filename, "wb" );

if( !fp )
{
fprintf( stderr, "ERROR: Can't write texture file %s\n", filename );
return;
}

texture_size = texture->height * texture->width;
pic = (byte *)texture_hdr + texture->index;
palette = pic + texture_size;

bmp_hdr.id[0] = 'B';
bmp_hdr.id[1] = 'M';
bmp_hdr.width = texture->width;
bmp_hdr.height = texture->height;
bmp_hdr.planes = 1;
bmp_hdr.bitsPerPixel = 8;
bmp_hdr.bitmapDataSize = texture_size;
bmp_hdr.bitmapDataSize = bmp_hdr.width * bmp_hdr.height;
bmp_hdr.colors = 256;

bmp_hdr.fileSize = sizeof( bmp_hdr ) + texture_size + sizeof( rgba_palette );
bmp_hdr.fileSize = sizeof( bmp_hdr ) + bmp_hdr.bitmapDataSize + sizeof( rgba_palette );
bmp_hdr.bitmapDataOffset = sizeof( bmp_hdr ) + sizeof( rgba_palette );
bmp_hdr.bitmapHeaderSize = BI_SIZE;

pic = (byte *)texture_hdr + texture->index;
palette = pic + bmp_hdr.bitmapDataSize;

fwrite( &bmp_hdr, sizeof( bmp_hdr ), 1, fp );

p = palette;
Expand All @@ -94,10 +75,52 @@ static void WriteBMP( mstudiotexture_t *texture )
fwrite( p, bmp_hdr.width, 1, fp );
p -= bmp_hdr.width;
}
}

/*
============
WriteTGA
============
*/
static void WriteTGA( FILE *fp, mstudiotexture_t *texture )
{
int i;
const byte *p;
byte *palette, *pic;
rgb_t rgb_palette[256];
tga_t tga_hdr = {0,};

tga_hdr.colormap_type = tga_hdr.image_type = 1;
tga_hdr.colormap_length = 256;
tga_hdr.colormap_size = 24;
tga_hdr.pixel_size = 8;
tga_hdr.width = texture->width;
tga_hdr.height = texture->height;

fclose( fp );
pic = (byte *)texture_hdr + texture->index;
palette = pic + tga_hdr.width * tga_hdr.height;

printf( "Texture: %s\n", filename );
fwrite( &tga_hdr, sizeof( tga_hdr ), 1, fp );

p = palette;

for( i = 0; i < (int)tga_hdr.colormap_length; i++ )
{
rgb_palette[i][2] = *p++;
rgb_palette[i][1] = *p++;
rgb_palette[i][0] = *p++;
}

fwrite( rgb_palette, sizeof( rgb_palette ), 1, fp );

p = pic;
p += ( tga_hdr.height - 1 ) * tga_hdr.width;

for( i = 0; i < tga_hdr.height; i++ )
{
fwrite( p, tga_hdr.width, 1, fp );
p -= tga_hdr.width;
}
}

/*
Expand All @@ -107,10 +130,37 @@ WriteTextures
*/
void WriteTextures( void )
{
int i;
int i, len;
FILE *fp;
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
char filename[MAX_SYSPATH];

for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
WriteBMP( texture );
{
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s", destdir, texture->name );

if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s\n", texture->name );
continue;
}

fp = fopen( filename, "wb" );

if( !fp )
{
fprintf( stderr, "ERROR: Can't write texture file %s\n", filename );
continue;
}

if( !Q_stricmp( COM_FileExtension( texture->name ), "tga" ))
WriteTGA( fp, texture );
else
WriteBMP( fp, texture );

fclose( fp );

printf( "Texture: %s\n", filename );
}
}

0 comments on commit eb36905

Please sign in to comment.