1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-09-15 21:00:24 +02:00

Replaced objlist_class with std::vector.

Fixed minor bug in TLightGroup.
Cleaned up some warnings.
This commit is contained in:
Muzychenko Andrey 2021-10-01 18:55:44 +03:00
parent 8a421a2623
commit 81c2034a16
54 changed files with 249 additions and 453 deletions

View file

@ -48,7 +48,6 @@ set(SOURCE_FILES
SpaceCadetPinball/midi.h
SpaceCadetPinball/nudge.cpp
SpaceCadetPinball/nudge.h
SpaceCadetPinball/objlist_class.h
SpaceCadetPinball/options.cpp
SpaceCadetPinball/options.h
SpaceCadetPinball/partman.cpp
@ -83,7 +82,6 @@ set(SOURCE_FILES
SpaceCadetPinball/TDemo.h
SpaceCadetPinball/TDrain.cpp
SpaceCadetPinball/TDrain.h
SpaceCadetPinball/TEdgeBox.cpp
SpaceCadetPinball/TEdgeBox.h
SpaceCadetPinball/TEdgeManager.cpp
SpaceCadetPinball/TEdgeManager.h

View file

@ -247,8 +247,8 @@ int DatFile::record_labeled(LPCSTR targetGroupName)
if (!groupName)
continue;
int index;
for (index = 0; index < targetLength; index++)
auto index = 0u;
for (; index < targetLength; index++)
if (targetGroupName[index] != groupName[index])
break;
if (index == targetLength && !targetGroupName[index] && !groupName[index])

View file

@ -12,7 +12,7 @@ int Sound::Init(int voices)
channelCount = 8;
num_channels = channelCount;
auto init = Mix_Init(MIX_INIT_MID);
Mix_Init(MIX_INIT_MID);
return Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
}

View file

@ -5,7 +5,6 @@
#include "fullscrn.h"
#include "loader.h"
#include "maths.h"
#include "objlist_class.h"
#include "pb.h"
#include "proj.h"
#include "render.h"
@ -32,7 +31,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
Position.X = 0.0;
Position.Y = 0.0;
ListBitmap = new objlist_class<gdrv_bitmap8>(0, 4);
ListBitmap = new std::vector<gdrv_bitmap8*>();
/*Full tilt: ball is ballN, where N[0,2] resolution*/
if (pb::FullTiltMode)
@ -49,7 +48,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
{
loader::query_visual(groupIndex, index, &visual);
if (ListBitmap)
ListBitmap->Add(visual.Bitmap);
ListBitmap->push_back(visual.Bitmap);
auto visVec = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, index, 501));
auto zDepth = proj::z_distance(visVec);
++index;
@ -79,13 +78,13 @@ void TBall::Repaint()
auto zDepth = proj::z_distance(&Position);
auto zArrPtr = VisualZArray;
int index;
for (index = 0; index < ListBitmap->GetCount() - 1; ++index, zArrPtr++)
auto index = 0u;
for (; index < ListBitmap->size() - 1; ++index, zArrPtr++)
{
if (*zArrPtr <= zDepth) break;
}
auto bmp = ListBitmap->Get(index);
auto bmp = ListBitmap->at(index);
render::ball_set(
RenderSprite,
bmp,

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
@ -46,7 +45,7 @@ int TBlocker::Message(int code, float value)
case 52:
ActiveFlag = 1;
loader::play_sound(SoundIndex4);
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
break;
case 59:
break;

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
@ -29,8 +28,9 @@ int TBumper::Message(int code, float value)
case 11:
{
auto nextBmp = static_cast<int>(floor(value));
if (2 * nextBmp > ListBitmap->GetCount() - 1)
nextBmp = (ListBitmap->GetCount() - 1) / 2;
auto maxBmp = static_cast<int>(ListBitmap->size()) - 1;
if (2 * nextBmp > maxBmp)
nextBmp = maxBmp / 2;
if (nextBmp < 0)
nextBmp = 0;
if (nextBmp != BmpIndex)
@ -48,7 +48,7 @@ int TBumper::Message(int code, float value)
case 12:
{
auto nextBmp = BmpIndex + 1;
auto maxBmp = ListBitmap->GetCount() - 1;
auto maxBmp = static_cast<int>(ListBitmap->size()) - 1;
if (2 * nextBmp > maxBmp)
nextBmp = maxBmp / 2;
TBumper::Message(11, static_cast<float>(nextBmp));
@ -124,8 +124,8 @@ int TBumper::get_scoring(int index)
void TBumper::TimerExpired(int timerId, void* caller)
{
auto bump = static_cast<TBumper*>(caller);
auto bmp = bump->ListBitmap->Get(bump->BmpIndex * 2);
auto zMap = bump->ListZMap->Get(bump->BmpIndex * 2);
auto bmp = bump->ListBitmap->at(bump->BmpIndex * 2);
auto zMap = bump->ListZMap->at(bump->BmpIndex * 2);
bump->Timer = 0;
render::sprite_set(
bump->RenderSprite,
@ -139,8 +139,8 @@ void TBumper::TimerExpired(int timerId, void* caller)
void TBumper::Fire()
{
int bmpIndex = 2 * BmpIndex + 1;
auto bmp = ListBitmap->Get(bmpIndex);
auto zMap = ListZMap->Get(bmpIndex);
auto bmp = ListBitmap->at(bmpIndex);
auto zMap = ListZMap->at(bmpIndex);
render::sprite_set(
RenderSprite,
bmp,

View file

@ -2,17 +2,15 @@
#include "TCollisionComponent.h"
#include "loader.h"
#include "maths.h"
#include "objlist_class.h"
#include "TEdgeSegment.h"
#include "TPinballTable.h"
TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall) : TPinballComponent(
table, groupIndex, true)
TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall) :
TPinballComponent(table, groupIndex, true)
{
visualStruct visual{};
EdgeList = new objlist_class<TEdgeSegment>(4, 4);
ActiveFlag = 1;
if (GroupName != nullptr)
UnusedBaseFlag = 1;
@ -42,22 +40,15 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
TCollisionComponent::~TCollisionComponent()
{
for (TEdgeSegment* edge; EdgeList->GetCount() > 0;)
{
edge = EdgeList->Get(0);
EdgeList->Delete(edge);
for (auto edge : EdgeList)
delete edge;
}
delete EdgeList;
}
void TCollisionComponent::port_draw()
{
for (int index = EdgeList->GetCount() - 1; index >= 0; index--)
{
EdgeList->Get(index)->port_draw();
}
for (auto edge : EdgeList)
edge->port_draw();
}
int TCollisionComponent::DefaultCollision(TBall* ball, vector_type* nextPosition, vector_type* direction)

View file

@ -8,7 +8,7 @@ class TBall;
class TCollisionComponent : public TPinballComponent
{
public:
objlist_class<TEdgeSegment>* EdgeList;
std::vector<TEdgeSegment*> EdgeList;
float Elasticity;
float Smoothness;
float Boost;

View file

@ -4,13 +4,11 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "timer.h"
#include "TPinballTable.h"
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
List = new objlist_class<TPinballComponent>(4, 4);
Timer = 0;
if (groupIndex > 0)
{
@ -21,7 +19,7 @@ TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinbal
{
auto component = table->find_component(*shortArrPtr);
if (component)
List->Add(component);
List.push_back(component);
}
}
}
@ -33,7 +31,6 @@ TComponentGroup::~TComponentGroup()
timer::kill(Timer);
Timer = 0;
}
delete List;
}
int TComponentGroup::Message(int code, float value)
@ -50,9 +47,9 @@ int TComponentGroup::Message(int code, float value)
}
else if (code <= 1007 || code > 1011 && code != 1020 && code != 1022)
{
for (int i = 0; i < List->GetCount(); i++)
for (auto component : List)
{
List->Get(i)->Message(code, value);
component->Message(code, value);
}
}
return 0;

View file

@ -11,6 +11,6 @@ public:
int Message(int code, float value) override;
static void NotifyTimerExpired(int timerId, void* caller);
objlist_class<TPinballComponent>* List;
std::vector<TPinballComponent*> List;
int Timer;
};

View file

@ -1,16 +0,0 @@
#include "pch.h"
#include "TEdgeBox.h"
#include "objlist_class.h"
TEdgeBox::TEdgeBox()
{
EdgeList = new objlist_class<TEdgeSegment>(0, 4);
FieldList = new objlist_class<field_effect_type>(0, 1);
}
TEdgeBox::~TEdgeBox()
{
delete EdgeList;
delete FieldList;
}

View file

@ -1,6 +1,4 @@
#pragma once
#include "objlist_class.h"
struct field_effect_type;
class TEdgeSegment;
@ -8,10 +6,6 @@ class TEdgeSegment;
class TEdgeBox
{
public:
TEdgeBox();
~TEdgeBox();
objlist_class<TEdgeSegment>* EdgeList;
objlist_class<field_effect_type>* FieldList;
std::vector<TEdgeSegment*> EdgeList{};
std::vector<field_effect_type*> FieldList{};
};

View file

@ -3,7 +3,6 @@
#include "maths.h"
#include "objlist_class.h"
#include "TBall.h"
#include "TEdgeBox.h"
#include "TEdgeSegment.h"
@ -49,12 +48,12 @@ int TEdgeManager::increment_box_y(int y)
void TEdgeManager::add_edge_to_box(int x, int y, TEdgeSegment* edge)
{
BoxArray[x + y * MaxBoxX].EdgeList->Add(edge);
BoxArray[x + y * MaxBoxX].EdgeList.push_back(edge);
}
void TEdgeManager::add_field_to_box(int x, int y, field_effect_type* field)
{
BoxArray[x + y * MaxBoxX].FieldList->Add(field);
BoxArray[x + y * MaxBoxX].FieldList.push_back(field);
}
int TEdgeManager::TestGridBox(int x, int y, float* distPtr, TEdgeSegment** edgeDst, ray_type* ray, TBall* ball,
@ -64,9 +63,9 @@ int TEdgeManager::TestGridBox(int x, int y, float* distPtr, TEdgeSegment** edgeD
{
TEdgeBox* edgeBox = &BoxArray[x + y * MaxBoxX];
TEdgeSegment** edgePtr = &EdgeArray[edgeIndex];
for (auto index = edgeBox->EdgeList->GetCount() - 1; index >= 0; --index)
for (auto it = edgeBox->EdgeList.rbegin(); it != edgeBox->EdgeList.rend(); ++it)
{
auto edge = edgeBox->EdgeList->Get(index);
auto edge = *it;
if (!edge->ProcessedFlag && *edge->ActiveFlag && (edge->CollisionGroup & ray->FieldFlag))
{
if (!ball->already_hit(edge))
@ -94,9 +93,9 @@ void TEdgeManager::FieldEffects(TBall* ball, vector_type* dstVec)
TEdgeBox* edgeBox = &BoxArray[box_x(ball->Position.X) + box_y(ball->Position.Y) *
MaxBoxX];
for (int index = edgeBox->FieldList->GetCount() - 1; index >= 0; --index)
for (auto it = edgeBox->FieldList.rbegin(); it != edgeBox->FieldList.rend(); ++it)
{
auto field = edgeBox->FieldList->Get(index);
auto field = *it;
if (*field->Flag2Ptr && ball->FieldFlag & field->Mask)
{
if (field->CollisionComp->FieldEffect(ball, &vec))

View file

@ -1,7 +1,6 @@
#include "pch.h"
#include "TEdgeSegment.h"
#include "objlist_class.h"
#include "TCircle.h"
#include "TCollisionComponent.h"
#include "TLine.h"
@ -41,7 +40,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
circle->place_in_grid();
}
collComp->EdgeList->Add(circle);
collComp->EdgeList.push_back(circle);
break;
}
case wall_type::Line:
@ -58,7 +57,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
line->WallValue = reinterpret_cast<void*>(wallValue);
line->Offset(offset);
line->place_in_grid();
collComp->EdgeList->Add(line);
collComp->EdgeList.push_back(line);
}
break;
}
@ -104,7 +103,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
{
circle->WallValue = reinterpret_cast<void*>(wallValue);
circle->place_in_grid();
collComp->EdgeList->Add(circle);
collComp->EdgeList.push_back(circle);
}
}
}
@ -121,7 +120,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
line->WallValue = reinterpret_cast<void*>(wallValue);
line->Offset(offset);
line->place_in_grid();
collComp->EdgeList->Add(line);
collComp->EdgeList.push_back(line);
}
prevCenter = center;

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "TBall.h"
#include "timer.h"
@ -26,7 +25,7 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
if (line)
{
line->place_in_grid();
EdgeList->Add(line);
EdgeList.push_back(line);
}
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start);
@ -34,7 +33,7 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
if (line)
{
line->place_in_grid();
EdgeList->Add(line);
EdgeList.push_back(line);
}
SpeedDecrement = 0.64999998f;
@ -61,8 +60,8 @@ int TFlagSpinner::Message(int code, float value)
Timer = 0;
}
BmpIndex = 0;
auto bmp = ListBitmap->Get(0);
auto zMap = ListZMap->Get(0);
auto bmp = ListBitmap->at(0);
auto zMap = ListZMap->at(0);
render::sprite_set(
RenderSprite,
bmp,
@ -108,7 +107,7 @@ void TFlagSpinner::NextFrame()
{
BmpIndex += SpinDirection;
int bmpIndex = BmpIndex;
int bmpCount = ListBitmap->GetCount();
int bmpCount = ListBitmap->size();
if (bmpIndex >= bmpCount)
BmpIndex = 0;
else if (bmpIndex < 0)
@ -123,8 +122,8 @@ void TFlagSpinner::NextFrame()
control::handler(62, this);
}
auto bmp = ListBitmap->Get(BmpIndex);
auto zMap = ListZMap->Get(BmpIndex);
auto bmp = ListBitmap->at(BmpIndex);
auto zMap = ListZMap->at(BmpIndex);
render::sprite_set(
RenderSprite,
bmp,

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "pb.h"
#include "render.h"
#include "TFlipperEdge.h"
@ -52,8 +51,8 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
FlipperEdge = flipperEdge;
if (flipperEdge)
{
BmpCoef1 = flipperEdge->BmpCoef1 / static_cast<float>(ListBitmap->GetCount() - 1);
BmpCoef2 = flipperEdge->BmpCoef2 / static_cast<float>(ListBitmap->GetCount() - 1);
BmpCoef1 = flipperEdge->BmpCoef1 / static_cast<float>(ListBitmap->size() - 1);
BmpCoef2 = flipperEdge->BmpCoef2 / static_cast<float>(ListBitmap->size() - 1);
}
BmpIndex = 0;
InputTime = 0.0;
@ -142,7 +141,7 @@ void TFlipper::TimerExpired(int timerId, void* caller)
bool bmpIndexOutOfBounds = false;
auto bmpIndexAdvance = static_cast<int>(floor((pb::time_now - flip->InputTime) / flip->TimerTime + 0.5f));
int bmpCount = flip->ListBitmap->GetCount();
int bmpCount = flip->ListBitmap->size();
if (bmpIndexAdvance > bmpCount)
bmpIndexAdvance = bmpCount;
if (bmpIndexAdvance < 0)
@ -154,7 +153,7 @@ void TFlipper::TimerExpired(int timerId, void* caller)
if (flip->MessageField == 1)
{
flip->BmpIndex += bmpIndexAdvance;
int countSub1 = flip->ListBitmap->GetCount() - 1;
int countSub1 = flip->ListBitmap->size() - 1;
if (flip->BmpIndex >= countSub1)
{
flip->BmpIndex = countSub1;
@ -182,8 +181,8 @@ void TFlipper::TimerExpired(int timerId, void* caller)
timer = timer::set(flip->TimerTime, flip, TimerExpired);
flip->Timer = timer;
auto bmp = flip->ListBitmap->Get(flip->BmpIndex);
auto zMap = flip->ListZMap->Get(flip->BmpIndex);
auto bmp = flip->ListBitmap->at(flip->BmpIndex);
auto zMap = flip->ListZMap->at(flip->BmpIndex);
render::sprite_set(
flip->RenderSprite,
bmp,

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
@ -15,7 +14,7 @@ TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
SoundIndex4 = visual.SoundIndex4;
SoundIndex3 = visual.SoundIndex3;
ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
control::handler(1024, this);
}
@ -32,7 +31,7 @@ int TGate::Message(int code, float value)
else if (code == 54 || code == 1024)
{
ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
if (code == 54)
loader::play_sound(SoundIndex4);
}

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "pb.h"
#include "TBall.h"
#include "timer.h"
@ -37,7 +36,7 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
if (tCircle)
{
tCircle->place_in_grid();
EdgeList->Add(tCircle);
EdgeList.push_back(tCircle);
}
ZSetValue = loader::query_float_attribute(groupIndex, 0, 408)[2];

View file

@ -5,7 +5,6 @@
#include "control.h"
#include "loader.h"
#include "maths.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
@ -66,8 +65,8 @@ void TKickback::TimerExpired(int timerId, void* caller)
loader::play_sound(kick->HardHitSoundId);
if (kick->ListBitmap)
{
auto bmp = kick->ListBitmap->Get(1);
auto zMap = kick->ListZMap->Get(1);
auto bmp = kick->ListBitmap->at(1);
auto zMap = kick->ListZMap->at(1);
render::sprite_set(
kick->RenderSprite,
bmp,
@ -80,8 +79,8 @@ void TKickback::TimerExpired(int timerId, void* caller)
{
if (kick->ListBitmap)
{
auto bmp = kick->ListBitmap->Get(0);
auto zMap = kick->ListZMap->Get(0);
auto bmp = kick->ListBitmap->at(0);
auto zMap = kick->ListZMap->at(0);
render::sprite_set(
kick->RenderSprite,
bmp,

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "TBall.h"
#include "TCircle.h"
#include "timer.h"
@ -40,7 +39,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
if (tCircle)
{
tCircle->place_in_grid();
EdgeList->Add(tCircle);
EdgeList.push_back(tCircle);
}
Circle.RadiusSq = visual.FloatArr[2] * visual.FloatArr[2];

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
@ -143,14 +142,14 @@ int TLight::Message(int code, float value)
schedule_timeout(value);
break;
case 11:
BmpIndex2 = static_cast<int>(floor(value));
if (BmpIndex2 > ListBitmap->GetCount())
BmpIndex2 = ListBitmap->GetCount();
bmpIndex = 0;
BmpIndex2 = static_cast<int>(floor(value));
if (BmpIndex2 > static_cast<int>(ListBitmap->size()))
BmpIndex2 = ListBitmap->size();
if (BmpIndex2 < 0)
BmpIndex2 = 0;
Flasher.BmpArr[0] = nullptr;
Flasher.BmpArr[1] = ListBitmap->Get(BmpIndex2);
Flasher.BmpArr[1] = ListBitmap->at(BmpIndex2);
if (FlasherActive == 0)
{
if (!FlasherFlag1)
@ -169,8 +168,8 @@ int TLight::Message(int code, float value)
break;
case 12:
bmpIndex = BmpIndex2 + 1;
if (bmpIndex > ListBitmap->GetCount())
bmpIndex = ListBitmap->GetCount();
if (bmpIndex > static_cast<int>(ListBitmap->size()))
bmpIndex = ListBitmap->size();
Message(11, static_cast<float>(bmpIndex));
break;
case 13:
@ -257,7 +256,7 @@ void TLight::Reset()
Flasher.Sprite = RenderSprite;
Flasher.BmpArr[0] = nullptr;
if (ListBitmap)
Flasher.BmpArr[1] = ListBitmap->Get(0);
Flasher.BmpArr[1] = ListBitmap->at(0);
Flasher.Unknown4 = 0;
Flasher.Unknown3 = 0;
MessageField = 0;

View file

@ -5,7 +5,6 @@
#include "control.h"
#include "loader.h"
#include "memory.h"
#include "objlist_class.h"
#include "timer.h"
#include "TPinballTable.h"
@ -18,7 +17,7 @@ TLightBargraph::TLightBargraph(TPinballTable* table, int groupIndex) : TLightGro
float* floatArr = loader::query_float_attribute(groupIndex, 0, 904);
if (floatArr)
{
int count = 2 * List->GetCount();
int count = 2 * List.size();
TimerTimeArray = memory::allocate<float>(count);
if (TimerTimeArray)
{
@ -49,7 +48,7 @@ int TLightBargraph::Message(int code, float value)
TimerBargraph = 0;
}
auto timeIndex = static_cast<int>(floor(value));
auto maxCount = 2 * List->GetCount();
auto maxCount = static_cast<int>(List.size()) * 2;
if (timeIndex >= maxCount)
timeIndex = maxCount - 1;
if (timeIndex >= 0)

View file

@ -4,17 +4,15 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "timer.h"
#include "TLight.h"
#include "TPinballTable.h"
TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
List = new objlist_class<TLight>(4, 4);
Timer = 0;
NotifyTimer = 0;
Reset();
TLightGroup::Reset();
if (groupIndex > 0)
{
int count;
@ -24,7 +22,7 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone
{
auto comp = dynamic_cast<TLight*>(table->find_component(*groupIndArr));
if (comp)
List->Add(comp);
List.push_back(comp);
++index;
}
}
@ -32,11 +30,11 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone
TLightGroup::~TLightGroup()
{
delete List;
}
int TLightGroup::Message(int code, float value)
{
auto count = static_cast<int>(List.size());
switch (code)
{
case 1011:
@ -71,8 +69,7 @@ int TLightGroup::Message(int code, float value)
break;
case 24:
{
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
auto lastLight = List.at(count - 1);
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
break;
if (MessageField2)
@ -85,12 +82,12 @@ int TLightGroup::Message(int code, float value)
auto bmpIndex1 = lastLight->BmpIndex1;
for (auto index = count - 1; index > 0; --index)
{
auto lightCur = List->Get(index);
auto lightPrev = List->Get(index - 1);
auto lightCur = List.at(index);
auto lightPrev = List.at(index - 1);
lightCur->Message(lightPrev->BmpIndex1 != 0, 0.0);
lightCur->MessageField = lightPrev->MessageField;
}
auto firstLight = List->Get(0);
auto firstLight = List.at(0);
firstLight->Message(bmpIndex1 != 0, 0.0);
firstLight->MessageField = lightMessageField;
reschedule_animation(value);
@ -98,23 +95,22 @@ int TLightGroup::Message(int code, float value)
}
case 25:
{
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
auto lastLight = List.at(count - 1);
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
break;
if (MessageField2)
{
TLightGroup::Message(34, 0.0);
}
auto firstLight = List->Get(0);
auto firstLight = List.at(0);
AnimationFlag = 1;
MessageField2 = code;
auto lightMessageField = firstLight->MessageField;
auto bmpIndex1 = firstLight->BmpIndex1;
for (auto index = 0; index < count - 1; index++)
{
auto lightCur = List->Get(index);
auto lightNext = List->Get(index + 1);
auto lightCur = List.at(index);
auto lightNext = List.at(index + 1);
lightCur->Message(lightNext->BmpIndex1 != 0, 0.0);
lightCur->MessageField = lightNext->MessageField;
}
@ -129,16 +125,15 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
auto lastLight = List.at(count - 1);
auto flasherFlag2 = lastLight->FlasherFlag2;
for (auto i = count - 1; i > 0; --i)
{
auto lightCur = List->Get(i);
auto lightPrev = List->Get(i - 1);
auto lightCur = List.at(i);
auto lightPrev = List.at(i - 1);
lightCur->Message((lightPrev->FlasherFlag2 != 0) + 8, 0.0);
}
auto firstLight = List->Get(0);
auto firstLight = List.at(0);
firstLight->Message((flasherFlag2 != 0) + 8, 0);
reschedule_animation(value);
break;
@ -149,16 +144,15 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->GetCount();
auto firstLight = List->Get(0);
auto firstLight = List.at(0);
auto flasherFlag2 = firstLight->FlasherFlag2;
for (auto i = 0; i < count - 1; i++)
{
auto lightCur = List->Get(i);
auto lightNext = List->Get(i + 1);
auto lightCur = List.at(i);
auto lightNext = List.at(i + 1);
lightCur->Message((lightNext->FlasherFlag2 != 0) + 8, 0.0);
}
auto lastLight = List->Get(count - 1);
auto lastLight = List.at(count - 1);
lastLight->Message((flasherFlag2 != 0) + 8, 0);
reschedule_animation(value);
break;
@ -169,12 +163,10 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->GetCount();
for (auto i = 0; i < count - 1; i++)
for (auto light : List)
{
if (rand() % 100 > 70)
{
auto light = List->Get(i);
auto randVal = RandFloat() * value * 3.0f + 0.1f;
light->Message(9, randVal);
}
@ -188,10 +180,8 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->GetCount();
for (auto i = 0; i < count - 1; i++)
for (auto light : List)
{
auto light = List->Get(i);
auto randVal = static_cast<float>(rand() % 100 > 70);
light->Message(18, randVal);
}
@ -201,22 +191,18 @@ int TLightGroup::Message(int code, float value)
case 30:
{
auto noBmpInd1Count = 0;
auto countSub1 = List->GetCount() - 1;
if (countSub1 < 0)
break;
for (auto i = countSub1; i >= 0; i--)
for (auto light : List)
{
if (!List->Get(i)->BmpIndex1)
if (!light->BmpIndex1)
++noBmpInd1Count;
}
if (!noBmpInd1Count)
break;
auto randModCount = rand() % noBmpInd1Count;
for (auto i = countSub1; i >= 0; i--)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
auto light = List->Get(i);
auto light = *it;
if (!light->BmpIndex1 && randModCount-- == 0)
{
light->Message(1, 0.0);
@ -231,22 +217,18 @@ int TLightGroup::Message(int code, float value)
case 31:
{
auto bmpInd1Count = 0;
auto countSub1 = List->GetCount() - 1;
if (countSub1 < 0)
break;
for (auto i = countSub1; i >= 0; i--)
for (auto light : List)
{
if (List->Get(i)->BmpIndex1)
if (light->BmpIndex1)
++bmpInd1Count;
}
if (!bmpInd1Count)
break;
auto randModCount = rand() % bmpInd1Count;
for (auto i = countSub1; i >= 0; i--)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
auto light = List->Get(i);
auto light = *it;
if (light->BmpIndex1 && randModCount-- == 0)
{
light->Message(0, 0.0);
@ -263,7 +245,7 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_up();
if (index < 0)
break;
List->Get(index)->Message(1, 0.0);
List.at(index)->Message(1, 0.0);
if (MessageField2)
start_animation();
return 1;
@ -273,7 +255,7 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_down();
if (index < 0)
break;
List->Get(index)->Message(0, 0.0);
List.at(index)->Message(0, 0.0);
if (MessageField2)
start_animation();
return 1;
@ -292,10 +274,10 @@ int TLightGroup::Message(int code, float value)
case 35:
{
auto index = static_cast<int>(floor(value));
if (index >= List->GetCount() || index < 0)
if (index >= count || index < 0)
break;
auto light = List->Get(index);
auto light = List.at(index);
light->Message(1, 0.0);
if (MessageField2)
start_animation();
@ -304,10 +286,10 @@ int TLightGroup::Message(int code, float value)
case 36:
{
auto index = static_cast<int>(floor(value));
if (index >= List->GetCount() || index < 0)
if (index >= count || index < 0)
break;
auto light = List->Get(index);
auto light = List.at(index);
light->Message(0, 0.0);
if (MessageField2)
start_animation();
@ -316,16 +298,15 @@ int TLightGroup::Message(int code, float value)
case 37:
{
auto bmp1Count = 0;
auto countSub1 = List->GetCount() - 1;
for (auto i = countSub1; i >= 0; i--)
for (auto light : List)
{
if (List->Get(i)->BmpIndex1)
if (light->BmpIndex1)
++bmp1Count;
}
return bmp1Count;
}
case 38:
return List->GetCount();
return count;
case 39:
return MessageField2;
case 40:
@ -337,7 +318,7 @@ int TLightGroup::Message(int code, float value)
break;
if (MessageField2 || AnimationFlag)
TLightGroup::Message(34, 0.0);
List->Get(index)->Message(15, value);
List.at(index)->Message(15, value);
return 1;
}
case 42:
@ -347,7 +328,7 @@ int TLightGroup::Message(int code, float value)
break;
if (MessageField2 || AnimationFlag)
TLightGroup::Message(34, 0.0);
List->Get(index)->Message(16, value);
List.at(index)->Message(16, value);
return 1;
}
case 43:
@ -359,10 +340,9 @@ int TLightGroup::Message(int code, float value)
break;
case 44:
{
auto countSub1 = List->GetCount() - 1;
for (auto index = countSub1; index >= 0; index--)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
auto light = List->Get(index);
auto light = *it;
if (light->BmpIndex1)
{
light->Message(0, 0.0);
@ -378,26 +358,21 @@ int TLightGroup::Message(int code, float value)
auto index = static_cast<int>(floor(value));
if (index >= 0)
{
auto count = List->GetCount();
if (index <= count)
{
auto countSub1 = count - 1;
if (countSub1 > index)
{
countSub1 = index;
for (auto i = countSub1, k = countSub1 - index; k != 0; i--, k--)
{
auto light = List->Get(i);
auto light = List.at(i);
light->Message(20, 0.0);
}
}
if (countSub1 >= 0)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
for (auto i = countSub1; i != 0; i--)
{
auto light = List->Get(i);
light->Message(19, 0.0);
}
(*it)->Message(19, 0.0);
}
}
}
@ -408,14 +383,14 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_down();
if (index >= 0)
{
List->Get(index)->Message(4, 0.0);
List.at(index)->Message(4, 0.0);
}
break;
}
default:
for (auto index = List->GetCount() - 1; index >= 0; index--)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
List->Get(index)->Message(code, value);
(*it)->Message(code, value);
}
break;
}
@ -453,9 +428,9 @@ void TLightGroup::reschedule_animation(float time)
void TLightGroup::start_animation()
{
for (int index = List->GetCount() - 1; index >= 0; --index)
for (auto it = List.rbegin(); it != List.rend(); ++it)
{
auto light = List->Get(index);
auto light = *it;
if (light->BmpIndex1)
light->Message(9, 0.0);
else
@ -465,19 +440,19 @@ void TLightGroup::start_animation()
int TLightGroup::next_light_up()
{
for (int index = 0; index < List->GetCount(); ++index)
for (auto index = 0u; index < List.size(); ++index)
{
if (!List->Get(index)->BmpIndex1)
return index;
if (!List.at(index)->BmpIndex1)
return static_cast<int>(index);
}
return -1;
}
int TLightGroup::next_light_down()
{
for (int index = List->GetCount() - 1; index >= 0; --index)
for (auto index = static_cast<int>(List.size()) - 1; index >= 0; --index)
{
if (!List->Get(index)->BmpIndex1)
if (!List.at(index)->BmpIndex1)
return index;
}
return -1;

View file

@ -29,7 +29,7 @@ public:
static void TimerExpired(int timerId, void* caller);
static void NotifyTimerExpired(int timerId, void* caller);
objlist_class<TLight>* List;
std::vector<TLight*> List;
float Timer1Time;
float Timer1TimeDefault;
int MessageField2;

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "TBall.h"
#include "timer.h"
@ -58,7 +57,7 @@ void TLightRollover::Collision(TBall* ball, vector_type* nextPosition, vector_ty
control::handler(63, this);
RolloverFlag = RolloverFlag == 0;
if (ListBitmap)
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
}
}
}

View file

@ -4,7 +4,6 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "TBall.h"
#include "TLine.h"
#include "TPinballTable.h"
@ -27,7 +26,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
{
line->Offset(table->CollisionCompOffset);
line->place_in_grid();
EdgeList->Add(line);
EdgeList.push_back(line);
}
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);