From 88a7e24d44695f49e1250a9314f03bf4c6e1cff8 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Sun, 24 Jun 2012 18:55:14 +0000 Subject: A few PVS studio things --- Stars45/FighterAI.cpp | 24 +++++++++++++----------- Stars45/HUDView.cpp | 4 ++++ Stars45/Main.cpp | 2 +- Stars45/ShipAI.cpp | 2 ++ Stars45/ShipDesign.cpp | 3 +++ Stars45/Starshatter.cpp | 1 + 6 files changed, 24 insertions(+), 12 deletions(-) (limited to 'Stars45') diff --git a/Stars45/FighterAI.cpp b/Stars45/FighterAI.cpp index 0102f21..835bd00 100644 --- a/Stars45/FighterAI.cpp +++ b/Stars45/FighterAI.cpp @@ -1604,20 +1604,22 @@ FighterAI::EvadeThreat() else { evading = true; - - if (target == threat) { - if (target->Type() == SimObject::SIM_SHIP) { - Ship* tgt_ship = (Ship*) target; - if (tgt_ship->GetTrigger(0)) { - SetTarget(0); - drop_time = 3; + + if (target != nullptr) { + if (target == threat) { + if (target->Type() == SimObject::SIM_SHIP) { + Ship* tgt_ship = (Ship*) target; + if (tgt_ship->GetTrigger(0)) { + SetTarget(0); + drop_time = 3; + } } } - } - else if (target && threat_dist < threat_range / 2) { - SetTarget(0); - drop_time = 3; + else if (target && threat_dist < threat_range / 2) { + SetTarget(0); + drop_time = 3; + } } if (target) diff --git a/Stars45/HUDView.cpp b/Stars45/HUDView.cpp index 48953ac..5edda65 100644 --- a/Stars45/HUDView.cpp +++ b/Stars45/HUDView.cpp @@ -959,6 +959,10 @@ HUDView::DrawContactMarkers() // draw life bars on targeted ship: if (target && target->Type() == SimObject::SIM_SHIP && target->Rep()) { Ship* tgt_ship = (Ship*) target; + if (tgt_ship == nullptr) { + Print(" Null Pointer in HUDView::DrawContactMarkers(). Please investigate."); + return; + } Graphic* g = tgt_ship->Rep(); Rect r = g->ScreenRect(); diff --git a/Stars45/Main.cpp b/Stars45/Main.cpp index 340e393..6f307d7 100644 --- a/Stars45/Main.cpp +++ b/Stars45/Main.cpp @@ -38,7 +38,7 @@ extern FILE* ErrLog; extern int VD3D_describe_things; int dump_missions = 0; -const char* versionInfo = "5.1.66"; +const char* versionInfo = "5.1.87 EX"; static void PrintLogHeader() { diff --git a/Stars45/ShipAI.cpp b/Stars45/ShipAI.cpp index 27e12d3..876f067 100644 --- a/Stars45/ShipAI.cpp +++ b/Stars45/ShipAI.cpp @@ -101,6 +101,8 @@ ShipAI::GetWard() const void ShipAI::SetWard(Ship* s) { + if (ship == nullptr) + return; if (s == ship->GetWard()) return; diff --git a/Stars45/ShipDesign.cpp b/Stars45/ShipDesign.cpp index 9965d3d..92a5c30 100644 --- a/Stars45/ShipDesign.cpp +++ b/Stars45/ShipDesign.cpp @@ -3590,6 +3590,8 @@ void ShipDesign::ParseSkinMtl(TermStruct* val, Skin* skin) { Material* mtl = new(__FILE__,__LINE__) Material; + if (mtl == nullptr) + return; for (int i = 0; i < val->elements()->size(); i++) { TermDef* def = val->elements()->at(i)->isDef(); @@ -3675,6 +3677,7 @@ ShipDesign::ParseSkinMtl(TermStruct* val, Skin* skin) Print("WARNING: invalid or missing tex_emissive in '%s'\n", filename); DataLoader* loader = DataLoader::GetLoader(); + loader->LoadTexture(tex_name, mtl->tex_emissive); } } diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index 7641227..b2cded4 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -425,6 +425,7 @@ Starshatter::InitGame() input = new(__FILE__,__LINE__) MultiController; Keyboard* k = new(__FILE__,__LINE__) Keyboard; input->AddController(k); + ActivateKeyboardLayout(GetKeyboardLayout(0), 0); mouse_input = new(__FILE__,__LINE__) MouseController; input->AddController(mouse_input); -- cgit v1.1