From 94cc88d8f46f70dcd521db3e778009defda95c13 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 27 Sep 2021 16:18:46 +0300 Subject: [PATCH] fix header->ident handling --- tools/quake3/q3map2/bspfile_ibsp.cpp | 6 +++--- tools/quake3/q3map2/bspfile_rbsp.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/quake3/q3map2/bspfile_ibsp.cpp b/tools/quake3/q3map2/bspfile_ibsp.cpp index c4a65b27..fee09ab5 100644 --- a/tools/quake3/q3map2/bspfile_ibsp.cpp +++ b/tools/quake3/q3map2/bspfile_ibsp.cpp @@ -223,7 +223,7 @@ void LoadIBSPFile( const char *filename ){ SwapBlock( (int*) ( (byte*) header + 4 ), sizeof( *header ) - 4 ); /* make sure it matches the format we're trying to load */ - if ( !force && (const int&) header->ident != (const int&) g_game->bspIdent ) { + if ( !force && memcmp( header->ident, g_game->bspIdent, 4 ) ) { Error( "%s is not a %s file", filename, g_game->bspIdent ); } if ( !force && header->version != g_game->bspVersion ) { @@ -277,7 +277,7 @@ void PartialLoadIBSPFile( const char *filename ){ SwapBlock( (int*) ( (byte*) header + 4 ), sizeof( *header ) - 4 ); /* make sure it matches the format we're trying to load */ - if ( !force && (const int&) header->ident != (const int&) g_game->bspIdent ) { + if ( !force && memcmp( header->ident, g_game->bspIdent, 4 ) ) { Error( "%s is not a %s file", filename, g_game->bspIdent ); } if ( !force && header->version != g_game->bspVersion ) { @@ -305,7 +305,7 @@ void WriteIBSPFile( const char *filename ){ //% Swapfile(); /* set up header */ - (int&) header.ident = (const int&) g_game->bspIdent; + memcpy( header.ident, g_game->bspIdent, 4 ); header.version = LittleLong( g_game->bspVersion ); /* write initial header */ diff --git a/tools/quake3/q3map2/bspfile_rbsp.cpp b/tools/quake3/q3map2/bspfile_rbsp.cpp index 39bf3a8e..fc458c27 100644 --- a/tools/quake3/q3map2/bspfile_rbsp.cpp +++ b/tools/quake3/q3map2/bspfile_rbsp.cpp @@ -189,7 +189,7 @@ void LoadRBSPFile( const char *filename ){ SwapBlock( (int*) ( (byte*) header + 4 ), sizeof( *header ) - 4 ); /* make sure it matches the format we're trying to load */ - if ( !force && (const int&) header->ident != (const int&) g_game->bspIdent ) { + if ( !force && memcmp( header->ident, g_game->bspIdent, 4 ) ) { Error( "%s is not a %s file", filename, g_game->bspIdent ); } if ( !force && header->version != g_game->bspVersion ) { @@ -232,7 +232,7 @@ void WriteRBSPFile( const char *filename ){ //% Swapfile(); /* set up header */ - (int&) header.ident = (const int&) g_game->bspIdent; + memcpy( header.ident, g_game->bspIdent, 4 ); header.version = LittleLong( g_game->bspVersion ); /* write initial header */