Merge pull request #3 from dodomorandi/bugfixing

Just a bunch of fixes
This commit is contained in:
blendogames 2023-07-29 12:14:34 -07:00 committed by GitHub
commit 216ea8b804
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 24 deletions

View file

@ -1,7 +1,7 @@
# CMake File for Quadrilateral Cowboy (Because scons and Xcode are butt) # CMake File for Quadrilateral Cowboy (Because scons and Xcode are butt)
# Written by Ethan "flibitijibibo" Lee # Written by Ethan "flibitijibibo" Lee
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(QuadrilateralCowboy) PROJECT(QuadrilateralCowboy)
# CMake Options # CMake Options
@ -466,6 +466,10 @@ ENDIF()
# Executable information # Executable information
ADD_EXECUTABLE(qc ${QC_SRC}) ADD_EXECUTABLE(qc ${QC_SRC})
set_target_properties(qc PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON)
# SDL2 Dependency (Detection pulled from FAudio) # SDL2 Dependency (Detection pulled from FAudio)
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES) if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES") message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")

View file

@ -1707,7 +1707,7 @@ bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWo
if ( !InhibitEntitySpawn( mapEnt->epairs ) ) { if ( !InhibitEntitySpawn( mapEnt->epairs ) ) {
CacheDictionaryMedia( &mapEnt->epairs ); CacheDictionaryMedia( &mapEnt->epairs );
const char *classname = mapEnt->epairs.GetString( "classname" ); const char *classname = mapEnt->epairs.GetString( "classname" );
if ( classname != '\0' ) { if ( *classname != '\0' ) {
FindEntityDef( classname, false ); FindEntityDef( classname, false );
} }
} }
@ -2148,7 +2148,7 @@ void idGameLocal::GetShakeSounds( const idDict *dict ) {
idStr soundName; idStr soundName;
soundShaderName = dict->GetString( "s_shader" ); soundShaderName = dict->GetString( "s_shader" );
if ( soundShaderName != '\0' && dict->GetFloat( "s_shakes" ) != 0.0f ) { if ( *soundShaderName != '\0' && dict->GetFloat( "s_shakes" ) != 0.0f ) {
soundShader = declManager->FindSound( soundShaderName ); soundShader = declManager->FindSound( soundShaderName );
for ( int i = 0; i < soundShader->GetNumSounds(); i++ ) { for ( int i = 0; i < soundShader->GetNumSounds(); i++ ) {

View file

@ -875,20 +875,20 @@ idPVS::Shutdown
*/ */
void idPVS::Shutdown( void ) { void idPVS::Shutdown( void ) {
if ( connectedAreas ) { if ( connectedAreas ) {
delete connectedAreas; delete[] connectedAreas;
connectedAreas = NULL; connectedAreas = NULL;
} }
if ( areaQueue ) { if ( areaQueue ) {
delete areaQueue; delete[] areaQueue;
areaQueue = NULL; areaQueue = NULL;
} }
if ( areaPVS ) { if ( areaPVS ) {
delete areaPVS; delete[] areaPVS;
areaPVS = NULL; areaPVS = NULL;
} }
if ( currentPVS ) { if ( currentPVS ) {
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
delete currentPVS[i].pvs; delete[] currentPVS[i].pvs;
currentPVS[i].pvs = NULL; currentPVS[i].pvs = NULL;
} }
} }

View file

@ -583,19 +583,20 @@ static void LoadTGA( const char *name, byte **pic, int *width, int *height, ID_T
targa_header.colormap_type = *buf_p++; targa_header.colormap_type = *buf_p++;
targa_header.image_type = *buf_p++; targa_header.image_type = *buf_p++;
targa_header.colormap_index = LittleShort ( *(short *)buf_p ); auto const get_little_short = [&buf_p]() {
buf_p += 2; short tmp;
targa_header.colormap_length = LittleShort ( *(short *)buf_p ); memcpy( &tmp, buf_p, sizeof( short ) );
buf_p += 2; short little_short = LittleShort ( tmp );
buf_p += 2;
return little_short;
};
targa_header.colormap_index = get_little_short();
targa_header.colormap_length = get_little_short();
targa_header.colormap_size = *buf_p++; targa_header.colormap_size = *buf_p++;
targa_header.x_origin = LittleShort ( *(short *)buf_p ); targa_header.x_origin = get_little_short();
buf_p += 2; targa_header.y_origin = get_little_short();
targa_header.y_origin = LittleShort ( *(short *)buf_p ); targa_header.width = get_little_short();
buf_p += 2; targa_header.height = get_little_short();
targa_header.width = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.height = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.pixel_size = *buf_p++; targa_header.pixel_size = *buf_p++;
targa_header.attributes = *buf_p++; targa_header.attributes = *buf_p++;

View file

@ -144,7 +144,7 @@ const char *Sys_EXEPath( void ) {
len = readlink( linkpath.c_str(), buf, sizeof( buf ) ); len = readlink( linkpath.c_str(), buf, sizeof( buf ) );
if ( len == -1 ) { if ( len == -1 ) {
Sys_Printf("couldn't stat exe path link %s\n", linkpath.c_str()); Sys_Printf("couldn't stat exe path link %s\n", linkpath.c_str());
buf[ len ] = '\0'; buf[ 0 ] = '\0';
} }
return buf; return buf;
} }

View file

@ -42,7 +42,7 @@ public:
int GetMixBufferSize( void ) { return 0; } int GetMixBufferSize( void ) { return 0; }
int GetNumberOfSpeakers( void ) { int GetNumberOfSpeakers( void ) {
idSoundSystemLocal::s_numberOfSpeakers.GetInteger(); return idSoundSystemLocal::s_numberOfSpeakers.GetInteger();
} }
// doesn't support write API // doesn't support write API
@ -97,4 +97,4 @@ idAudioHardwareLinux::Initialize
*/ */
bool idAudioHardwareLinux::Initialize( ) { bool idAudioHardwareLinux::Initialize( ) {
return false; return false;
} }

View file

@ -348,7 +348,9 @@ void Sys_InitNetworking(void)
if ( ifr->ifr_addr.sa_family != AF_INET ) { if ( ifr->ifr_addr.sa_family != AF_INET ) {
common->Printf( "not AF_INET\n" ); common->Printf( "not AF_INET\n" );
} else { } else {
ip = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); unsigned long raw_ip;
memcpy( &raw_ip, &ifr->ifr_addr.sa_data[2], sizeof(unsigned long) );
ip = ntohl( raw_ip );
if ( ip == INADDR_LOOPBACK ) { if ( ip == INADDR_LOOPBACK ) {
common->Printf( "loopback\n" ); common->Printf( "loopback\n" );
} else { } else {
@ -361,7 +363,9 @@ void Sys_InitNetworking(void)
if ( ioctl( s, SIOCGIFNETMASK, ifr ) < 0 ) { if ( ioctl( s, SIOCGIFNETMASK, ifr ) < 0 ) {
common->Printf( " SIOCGIFNETMASK failed: %s\n", strerror( errno ) ); common->Printf( " SIOCGIFNETMASK failed: %s\n", strerror( errno ) );
} else { } else {
mask = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); unsigned long raw_mask;
memcpy( &raw_mask, &ifr->ifr_addr.sa_data[2], sizeof(unsigned long) );
mask = ntohl( raw_mask );
if ( ip != INADDR_LOOPBACK ) { if ( ip != INADDR_LOOPBACK ) {
common->Printf( "/%d.%d.%d.%d\n", common->Printf( "/%d.%d.%d.%d\n",
(unsigned char)ifr->ifr_addr.sa_data[2], (unsigned char)ifr->ifr_addr.sa_data[2],