1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2025-09-06 08:20:15 +02:00

fix harmless warnings and properly try/catch allocations via new

otherwise the error handling will never be triggered
This commit is contained in:
toxie 2021-10-17 19:28:09 +02:00
parent 06b760e8dd
commit 3b11d6019b
24 changed files with 219 additions and 74 deletions

View file

@ -27,7 +27,7 @@ int main(int argc, char* argv[])
} }
#if _WIN32 #if _WIN32
#include <windows.h> #include <Windows.h>
// Windows subsystem main // Windows subsystem main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

View file

@ -40,10 +40,10 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
Offset = *loader::query_float_attribute(groupIndex, 0, 500); Offset = *loader::query_float_attribute(groupIndex, 0, 500);
auto visualCount = loader::query_visual_states(groupIndex); auto visualCount = loader::query_visual_states(groupIndex);
auto index = 0;
if (visualCount > 0) if (visualCount > 0)
{ {
auto visualZPtr = VisualZArray; auto visualZPtr = VisualZArray;
int index = 0;
do do
{ {
loader::query_visual(groupIndex, index, &visual); loader::query_visual(groupIndex, index, &visual);

View file

@ -20,7 +20,7 @@ void TEdgeSegment::port_draw()
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr, TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
unsigned int collisionGroup, float offset, size_t wallValue) unsigned int collisionGroup, float offset, size_t wallValue)
{ {
vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{}; vector_type center{}, start{}, end{}, vec1{}, vec2{}, dstVec{};
TEdgeSegment* edge = nullptr; TEdgeSegment* edge = nullptr;
wall_type wallType = static_cast<wall_type>(static_cast<int>(floor(*floatArr) - 1.0f)); wall_type wallType = static_cast<wall_type>(static_cast<int>(floor(*floatArr) - 1.0f));
@ -31,7 +31,14 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
center.X = floatArr[1]; center.X = floatArr[1];
center.Y = floatArr[2]; center.Y = floatArr[2];
auto radius = offset + floatArr[3]; auto radius = offset + floatArr[3];
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius); TCircle* circle = nullptr;
try
{
circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius);
}
catch (...)
{
}
edge = circle; edge = circle;
if (circle) if (circle)
@ -49,7 +56,14 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
start.Y = floatArr[2]; start.Y = floatArr[2];
end.X = floatArr[3]; end.X = floatArr[3];
end.Y = floatArr[4]; end.Y = floatArr[4];
auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end); TLine* line = nullptr;
try
{
line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
}
catch (...)
{
}
edge = line; edge = line;
if (line) if (line)
@ -65,6 +79,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
{ {
int wallTypeI = static_cast<int>(wallType); int wallTypeI = static_cast<int>(wallType);
auto floatArrPtr = floatArr + 1; auto floatArrPtr = floatArr + 1;
vector_type prevCenter{};
prevCenter.X = floatArr[2 * wallTypeI - 1]; prevCenter.X = floatArr[2 * wallTypeI - 1];
prevCenter.Y = floatArr[2 * wallTypeI]; prevCenter.Y = floatArr[2 * wallTypeI];
@ -97,7 +112,14 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
dstVec.Z < 0.0f && offset < 0.0f) dstVec.Z < 0.0f && offset < 0.0f)
{ {
float radius = offset * 1.001f; float radius = offset * 1.001f;
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius); TCircle* circle = nullptr;
try
{
circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius);
}
catch (...)
{
}
if (circle) if (circle)
{ {
@ -112,7 +134,14 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
start.Y = floatArrPtr[1]; start.Y = floatArrPtr[1];
end.X = floatArrPtr[2]; end.X = floatArrPtr[2];
end.Y = floatArrPtr[3]; end.Y = floatArrPtr[3];
auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end); TLine* line = nullptr;
try
{
line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
}
catch (...)
{
}
edge = line; edge = line;
if (line) if (line)

View file

@ -21,14 +21,28 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
end.Y = visual.FloatArr[1]; end.Y = visual.FloatArr[1];
start.X = visual.FloatArr[2]; start.X = visual.FloatArr[2];
start.Y = visual.FloatArr[3]; start.Y = visual.FloatArr[3];
auto line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &start, &end); TLine* line = nullptr;
try
{
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &start, &end);
}
catch (...)
{
}
if (line) if (line)
{ {
line->place_in_grid(); line->place_in_grid();
EdgeList.push_back(line); EdgeList.push_back(line);
} }
line = nullptr;
try
{
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start); line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start);
}
catch (...)
{
}
PrevCollider = line; PrevCollider = line;
if (line) if (line)
{ {

View file

@ -34,7 +34,10 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
auto vecT2 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 802)); auto vecT2 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 802));
auto vecT1 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 801)); auto vecT1 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 801));
auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800)); auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800));
auto flipperEdge = new TFlipperEdge( TFlipperEdge* flipperEdge = nullptr;
try
{
flipperEdge = new TFlipperEdge(
this, this,
&ActiveFlag, &ActiveFlag,
visual.CollisionGroup, visual.CollisionGroup,
@ -47,7 +50,10 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
collMult, collMult,
Elasticity, Elasticity,
Smoothness); Smoothness);
}
catch (...)
{
}
FlipperEdge = flipperEdge; FlipperEdge = flipperEdge;
if (flipperEdge) if (flipperEdge)
{ {
@ -65,7 +71,7 @@ TFlipper::~TFlipper()
int TFlipper::Message(int code, float value) int TFlipper::Message(int code, float value)
{ {
if (code == 1 || code == 2 || code > 1008 && code <= 1011 || code == 1022) if (code == 1 || code == 2 || (code > 1008 && code <= 1011) || code == 1022)
{ {
float timerTime; float timerTime;
int command = code; int command = code;

View file

@ -109,7 +109,6 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
{ {
if (FlipperFlag == 0) if (FlipperFlag == 0)
{ {
EdgeCollisionFlag = 0;
CollisionFlag1 = 0; CollisionFlag1 = 0;
CollisionFlag2 = 0; CollisionFlag2 = 0;
set_control_points(ogRay->TimeNow); set_control_points(ogRay->TimeNow);
@ -436,7 +435,6 @@ float TFlipperEdge::flipper_angle(float timeNow)
int TFlipperEdge::is_ball_inside(float x, float y) int TFlipperEdge::is_ball_inside(float x, float y)
{ {
vector_type testPoint{};
float dx = RotOrigin.X - x; float dx = RotOrigin.X - x;
float dy = RotOrigin.Y - y; float dy = RotOrigin.Y - y;
if ((A2.X - A1.X) * (y - A1.Y) - (A2.Y - A1.Y) * (x - A1.X) >= 0.0f && if ((A2.X - A1.X) * (y - A1.Y) - (A2.Y - A1.Y) * (x - A1.X) >= 0.0f &&
@ -447,6 +445,7 @@ int TFlipperEdge::is_ball_inside(float x, float y)
(T1.Y - y) * (T1.Y - y) + (T1.X - x) * (T1.X - x) < CircleT1RadiusSq) (T1.Y - y) * (T1.Y - y) + (T1.X - x) * (T1.X - x) < CircleT1RadiusSq)
{ {
float flipperLR = AngleMax < 0.0f ? -1.0f : 1.0f; float flipperLR = AngleMax < 0.0f ? -1.0f : 1.0f;
vector_type testPoint{};
if (FlipperFlag == 1) if (FlipperFlag == 1)
testPoint = AngleMax < 0.0f ? B1 : B2; testPoint = AngleMax < 0.0f ? B1 : B2;
else if (FlipperFlag == 2) else if (FlipperFlag == 2)

View file

@ -30,9 +30,16 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
if (Circle.RadiusSq == 0.0f) if (Circle.RadiusSq == 0.0f)
Circle.RadiusSq = 0.001f; Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup, TCircle* tCircle = nullptr;
try
{
tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
reinterpret_cast<vector_type*>(visual.FloatArr), reinterpret_cast<vector_type*>(visual.FloatArr),
Circle.RadiusSq); Circle.RadiusSq);
}
catch (...)
{
}
if (tCircle) if (tCircle)
{ {
tCircle->place_in_grid(); tCircle->place_in_grid();

View file

@ -35,8 +35,15 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2]; Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2];
if (Circle.RadiusSq == 0.0f) if (Circle.RadiusSq == 0.0f)
Circle.RadiusSq = 0.001f; Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup, TCircle* tCircle = nullptr;
try
{
tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq); reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
}
catch (...)
{
}
if (tCircle) if (tCircle)
{ {
tCircle->place_in_grid(); tCircle->place_in_grid();

View file

@ -17,7 +17,13 @@ TLightBargraph::TLightBargraph(TPinballTable* table, int groupIndex) : TLightGro
if (floatArr) if (floatArr)
{ {
auto count = 2 * List.size(); auto count = 2 * List.size();
try
{
TimerTimeArray = new float[count]; TimerTimeArray = new float[count];
}
catch (...)
{
}
if (TimerTimeArray) if (TimerTimeArray)
{ {
for (auto i = 0u; i < count; ++floatArr) for (auto i = 0u; i < count; ++floatArr)

View file

@ -432,7 +432,7 @@ int TLightGroup::next_light_up()
{ {
for (auto index = 0u; index < List.size(); ++index) for (auto index = 0u; index < List.size(); ++index)
{ {
if (!List.at(index)->BmpIndex1) if (!List[index]->BmpIndex1)
return static_cast<int>(index); return static_cast<int>(index);
} }
return -1; return -1;

View file

@ -20,8 +20,14 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
linePt2.Y = visual.FloatArr[1]; linePt2.Y = visual.FloatArr[1];
linePt1.X = visual.FloatArr[2]; linePt1.X = visual.FloatArr[2];
linePt1.Y = visual.FloatArr[3]; linePt1.Y = visual.FloatArr[3];
TLine* line = nullptr;
auto line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt2, &linePt1); try
{
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt2, &linePt1);
}
catch (...)
{
}
if (line) if (line)
{ {
line->Offset(table->CollisionCompOffset); line->Offset(table->CollisionCompOffset);
@ -29,7 +35,14 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
EdgeList.push_back(line); EdgeList.push_back(line);
} }
line = nullptr;
try
{
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2); line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);
}
catch (...)
{
}
Line = line; Line = line;
if (line) if (line)
{ {

View file

@ -58,7 +58,14 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
MultiballFlag = 0; MultiballFlag = 0;
PlayerCount = 0; PlayerCount = 0;
auto ballObj = new TBall(this); TBall* ballObj = nullptr;
try
{
ballObj = new TBall(this);
}
catch (...)
{
}
BallList.push_back(ballObj); BallList.push_back(ballObj);
if (ballObj) if (ballObj)
ballObj->ActiveFlag = 0; ballObj->ActiveFlag = 0;
@ -368,7 +375,7 @@ int TPinballTable::Message(int code, float value)
LightGroup->Message(34, 0.0); LightGroup->Message(34, 0.0);
LightGroup->Message(20, 0.0); LightGroup->Message(20, 0.0);
Plunger->Message(1016, 0.0); Plunger->Message(1016, 0.0);
if (Demo->ActiveFlag) if (Demo && Demo->ActiveFlag)
rc_text = pinball::get_rc_string(30, 0); rc_text = pinball::get_rc_string(30, 0);
else else
rc_text = pinball::get_rc_string(26, 0); rc_text = pinball::get_rc_string(26, 0);

View file

@ -116,7 +116,14 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
} }
if (collisionGroup) if (collisionGroup)
{ {
auto line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2); TLine* line = nullptr;
try
{
line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2);
}
catch (...)
{
}
EdgeList.push_back(line); EdgeList.push_back(line);
if (line) if (line)
{ {

View file

@ -44,7 +44,6 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
ball->Position.Y = nextPosition->Y; ball->Position.Y = nextPosition->Y;
ball->RayMaxDistance -= coef; ball->RayMaxDistance -= coef;
ball->not_again(edge); ball->not_again(edge);
gdrv_bitmap8* bmp = nullptr;
if (!PinballTable->TiltLockFlag) if (!PinballTable->TiltLockFlag)
{ {
if (RolloverFlag) if (RolloverFlag)
@ -60,6 +59,7 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
RolloverFlag = RolloverFlag == 0; RolloverFlag = RolloverFlag == 0;
if (ListBitmap) if (ListBitmap)
{ {
gdrv_bitmap8* bmp = nullptr;
if (!RolloverFlag) if (!RolloverFlag)
bmp = ListBitmap->at(0); bmp = ListBitmap->at(0);
render::sprite_set_bitmap(RenderSprite, bmp); render::sprite_set_bitmap(RenderSprite, bmp);

View file

@ -80,13 +80,20 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--) for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
{ {
auto line = new TLine(this, TLine* line = nullptr;
try
{
line = new TLine(this,
&ActiveFlag, &ActiveFlag,
visual.CollisionGroup, visual.CollisionGroup,
visArrPtr[2], visArrPtr[2],
visArrPtr[3], visArrPtr[3],
visArrPtr[0], visArrPtr[0],
visArrPtr[1]); visArrPtr[1]);
}
catch (...)
{
}
if (line) if (line)
{ {
line->place_in_grid(); line->place_in_grid();

View file

@ -123,7 +123,14 @@ void TTextBox::Display(const char* text, float time)
if (Timer == -1) if (Timer == -1)
Clear(); Clear();
auto message = new TTextBoxMessage(text, time); TTextBoxMessage* message = nullptr;
try
{
message = new TTextBoxMessage(text, time);
}
catch (...)
{
}
if (message) if (message)
{ {
if (message->Text) if (message->Text)

View file

@ -10,7 +10,14 @@ TTextBoxMessage::TTextBoxMessage(const char* text, float time)
if (text) if (text)
{ {
const auto textLen = strlen(text) + 1; const auto textLen = strlen(text) + 1;
Text = nullptr;
try
{
Text = new char[textLen]; Text = new char[textLen];
}
catch (...)
{
}
if (Text) if (Text)
strncpy(Text, text, textLen); strncpy(Text, text, textLen);
} }

View file

@ -6,7 +6,7 @@
#include "TBall.h" #include "TBall.h"
#include "TPinballTable.h" #include "TPinballTable.h"
TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, 1) TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, true)
{ {
} }

View file

@ -206,9 +206,6 @@ void maths::line_init(line_type* line, float x0, float y0, float x1, float y1)
float maths::ray_intersect_line(ray_type* ray, line_type* line) float maths::ray_intersect_line(ray_type* ray, line_type* line)
{ {
bool v5;
bool v6;
float perpDot = line->PerpendicularL.Y * ray->Direction.Y + ray->Direction.X * line->PerpendicularL.X; float perpDot = line->PerpendicularL.Y * ray->Direction.Y + ray->Direction.X * line->PerpendicularL.X;
if (perpDot < 0.0f) if (perpDot < 0.0f)
{ {
@ -224,8 +221,8 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
{ {
if (v4 >= line->OriginX) if (v4 >= line->OriginX)
{ {
v5 = v4 < line->OriginY; bool v5 = v4 < line->OriginY;
v6 = v4 == line->OriginY; bool v6 = v4 == line->OriginY;
if (v5 || v6) if (v5 || v6)
return result; return result;
return 1000000000.0; return 1000000000.0;
@ -234,8 +231,8 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
else if (line->OriginX <= line->RayIntersect.X) else if (line->OriginX <= line->RayIntersect.X)
{ {
float v7 = line->RayIntersect.X; float v7 = line->RayIntersect.X;
v5 = v7 < line->OriginY; bool v5 = v7 < line->OriginY;
v6 = v7 == line->OriginY; bool v6 = v7 == line->OriginY;
if (v5 || v6) if (v5 || v6)
return result; return result;
return 1000000000.0; return 1000000000.0;
@ -299,7 +296,7 @@ float maths::basic_collision(TBall* ball, vector_type* nextPosition, vector_type
return projSpeed; return projSpeed;
} }
float maths::Distance_Squared(vector_type vec1, vector_type vec2) float maths::Distance_Squared(vector_type& vec1, vector_type& vec2)
{ {
return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X); return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X);
} }

View file

@ -87,7 +87,7 @@ public:
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity, static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
float smoothness, float smoothness,
float threshold, float boost); float threshold, float boost);
static float Distance_Squared(vector_type vec1, vector_type vec2); static float Distance_Squared(vector_type& vec1, vector_type& vec2);
static float DotProduct(vector_type* vec1, vector_type* vec2); static float DotProduct(vector_type* vec1, vector_type* vec2);
static void vswap(vector_type* vec1, vector_type* vec2); static void vswap(vector_type* vec1, vector_type* vec2);
static float Distance(vector_type* vec1, vector_type* vec2); static float Distance(vector_type* vec1, vector_type* vec2);

View file

@ -27,8 +27,12 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
return nullptr; return nullptr;
} }
auto datFile = new DatFile(); DatFile* datFile;
if (!datFile) try
{
datFile = new DatFile();
}
catch (...)
{ {
fclose(fileHandle); fclose(fileHandle);
return nullptr; return nullptr;
@ -39,8 +43,12 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
if (header.Unknown) if (header.Unknown)
{ {
auto unknownBuf = new char[header.Unknown]; char* unknownBuf;
if (!unknownBuf) try
{
unknownBuf = new char[header.Unknown];
}
catch (...)
{ {
fclose(fileHandle); fclose(fileHandle);
delete datFile; delete datFile;
@ -107,13 +115,18 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
} }
else else
{ {
auto entryBuffer = new char[fieldSize]; char* entryBuffer;
entryData->Buffer = entryBuffer; try
if (!entryBuffer)
{ {
entryBuffer = new char[fieldSize];
}
catch (...)
{
entryData->Buffer = nullptr;
abort = true; abort = true;
break; break;
} }
entryData->Buffer = entryBuffer;
fread(entryBuffer, 1, fieldSize, fileHandle); fread(entryBuffer, 1, fieldSize, fileHandle);
} }

View file

@ -142,9 +142,15 @@ void render::sprite_modified(render_sprite_type_struct* sprite)
render_sprite_type_struct* render::create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp, zmap_header_type* zMap, render_sprite_type_struct* render::create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp, zmap_header_type* zMap,
int xPosition, int yPosition, rectangle_type* rect) int xPosition, int yPosition, rectangle_type* rect)
{ {
auto sprite = new render_sprite_type_struct(); render_sprite_type_struct* sprite;
if (!sprite) try
{
sprite = new render_sprite_type_struct();
}
catch (...)
{
return nullptr; return nullptr;
}
sprite->BmpRect.YPosition = yPosition; sprite->BmpRect.YPosition = yPosition;
sprite->BmpRect.XPosition = xPosition; sprite->BmpRect.XPosition = xPosition;
sprite->Bmp = bmp; sprite->Bmp = bmp;
@ -420,7 +426,7 @@ void render::build_occlude_list()
} }
} }
if (!mainSprite->UnknownFlag && mainSprite->Bmp && spriteArr->size() < 2) if (mainSprite->Bmp && spriteArr->size() < 2)
spriteArr->clear(); spriteArr->clear();
if (!spriteArr->empty()) if (!spriteArr->empty())
{ {

View file

@ -18,9 +18,15 @@ int score::init()
scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp) scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp)
{ {
auto score = new scoreStruct(); scoreStruct* score;
if (!score) try
{
score = new scoreStruct();
}
catch (...)
{
return nullptr; return nullptr;
}
score->Score = -9999; score->Score = -9999;
score->BackgroundBmp = renderBgBmp; score->BackgroundBmp = renderBgBmp;

View file

@ -12,10 +12,17 @@ timer_struct* timer::TimerBuffer;
int timer::init(int count) int timer::init(int count)
{ {
auto buf = new timer_struct[count]; timer_struct* buf;
TimerBuffer = buf; try
if (!buf) {
buf = new timer_struct[count];
}
catch (...)
{
TimerBuffer = nullptr;
return 1; return 1;
}
TimerBuffer = buf;
Count = 0; Count = 0;
MaxCount = count; MaxCount = count;
SetCount = 1; SetCount = 1;