Fix a bunch of bugs

This commit is contained in:
Edoardo Morandi 2020-10-30 21:57:25 +01:00
parent d4fc21e641
commit 6612ae497e
6 changed files with 28 additions and 23 deletions

View File

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

View File

@ -875,20 +875,20 @@ idPVS::Shutdown
*/
void idPVS::Shutdown( void ) {
if ( connectedAreas ) {
delete connectedAreas;
delete[] connectedAreas;
connectedAreas = NULL;
}
if ( areaQueue ) {
delete areaQueue;
delete[] areaQueue;
areaQueue = NULL;
}
if ( areaPVS ) {
delete areaPVS;
delete[] areaPVS;
areaPVS = NULL;
}
if ( currentPVS ) {
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
delete currentPVS[i].pvs;
delete[] currentPVS[i].pvs;
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.image_type = *buf_p++;
targa_header.colormap_index = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.colormap_length = LittleShort ( *(short *)buf_p );
buf_p += 2;
auto const get_little_short = [&buf_p]() {
short tmp;
memcpy( &tmp, buf_p, sizeof( short ) );
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.x_origin = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.y_origin = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.width = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.height = LittleShort ( *(short *)buf_p );
buf_p += 2;
targa_header.x_origin = get_little_short();
targa_header.y_origin = get_little_short();
targa_header.width = get_little_short();
targa_header.height = get_little_short();
targa_header.pixel_size = *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 ) );
if ( len == -1 ) {
Sys_Printf("couldn't stat exe path link %s\n", linkpath.c_str());
buf[ len ] = '\0';
buf[ 0 ] = '\0';
}
return buf;
}

View File

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

View File

@ -348,7 +348,9 @@ void Sys_InitNetworking(void)
if ( ifr->ifr_addr.sa_family != AF_INET ) {
common->Printf( "not AF_INET\n" );
} 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 ) {
common->Printf( "loopback\n" );
} else {
@ -361,7 +363,9 @@ void Sys_InitNetworking(void)
if ( ioctl( s, SIOCGIFNETMASK, ifr ) < 0 ) {
common->Printf( " SIOCGIFNETMASK failed: %s\n", strerror( errno ) );
} 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 ) {
common->Printf( "/%d.%d.%d.%d\n",
(unsigned char)ifr->ifr_addr.sa_data[2],