mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-17 15:20:17 +01:00
Replaced objlist_class with std::vector.
Fixed minor bug in TLightGroup. Cleaned up some warnings.
This commit is contained in:
parent
8a421a2623
commit
81c2034a16
54 changed files with 249 additions and 453 deletions
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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{};
|
||||
};
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -36,7 +35,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
|||
{
|
||||
line->Offset(-table->CollisionCompOffset * 0.8f);
|
||||
Line->place_in_grid();
|
||||
EdgeList->Add(Line);
|
||||
EdgeList.push_back(Line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "pch.h"
|
||||
#include "TPinballComponent.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
|
@ -19,7 +18,7 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
|||
GroupName = nullptr;
|
||||
Control = nullptr;
|
||||
if (table)
|
||||
table->ComponentList->Add(this);
|
||||
table->ComponentList.push_back(this);
|
||||
if (groupIndex >= 0)
|
||||
GroupName = loader::query_name(groupIndex);
|
||||
if (loadVisuals && groupIndex >= 0)
|
||||
|
@ -31,32 +30,31 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
|||
if (visual.Bitmap)
|
||||
{
|
||||
if (!ListBitmap)
|
||||
ListBitmap = new objlist_class<gdrv_bitmap8>(visualCount, 4);
|
||||
ListBitmap = new std::vector<gdrv_bitmap8*>();
|
||||
if (ListBitmap)
|
||||
ListBitmap->Add(visual.Bitmap);
|
||||
ListBitmap->push_back(visual.Bitmap);
|
||||
}
|
||||
if (visual.ZMap)
|
||||
{
|
||||
if (!ListZMap)
|
||||
ListZMap = new objlist_class<zmap_header_type>(visualCount, 4);
|
||||
ListZMap = new std::vector<zmap_header_type*>();
|
||||
if (ListZMap)
|
||||
ListZMap->Add(visual.ZMap);
|
||||
ListZMap->push_back(visual.ZMap);
|
||||
}
|
||||
}
|
||||
zmap_header_type* zMap = nullptr;
|
||||
if (ListZMap)
|
||||
zMap = ListZMap->Get(0);
|
||||
|
||||
auto zMap = ListZMap ? ListZMap->at(0) : nullptr;
|
||||
if (ListBitmap)
|
||||
{
|
||||
rectangle_type bmp1Rect{}, tmpRect{};
|
||||
auto rootBmp = ListBitmap->Get(0);
|
||||
auto rootBmp = ListBitmap->at(0);
|
||||
bmp1Rect.XPosition = rootBmp->XPosition - table->XOffset;
|
||||
bmp1Rect.YPosition = rootBmp->YPosition - table->YOffset;
|
||||
bmp1Rect.Width = rootBmp->Width;
|
||||
bmp1Rect.Height = rootBmp->Height;
|
||||
for (int index = 1; index < ListBitmap->GetCount(); index++)
|
||||
for (auto index = 1u; index < ListBitmap->size(); index++)
|
||||
{
|
||||
auto bmp = ListBitmap->Get(index);
|
||||
auto bmp = ListBitmap->at(index);
|
||||
tmpRect.XPosition = bmp->XPosition - table->XOffset;
|
||||
tmpRect.YPosition = bmp->YPosition - table->YOffset;
|
||||
tmpRect.Width = bmp->Width;
|
||||
|
@ -79,9 +77,14 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
|||
|
||||
TPinballComponent::~TPinballComponent()
|
||||
{
|
||||
TPinballTable* table = PinballTable;
|
||||
if (table)
|
||||
table->ComponentList->Delete(this);
|
||||
if (PinballTable)
|
||||
{
|
||||
// ComponentList contains one reference to each component.
|
||||
auto& components = PinballTable->ComponentList;
|
||||
auto position = std::find(components.begin(), components.end(), this);
|
||||
if (position != components.end())
|
||||
components.erase(position);
|
||||
}
|
||||
|
||||
delete ListBitmap;
|
||||
delete ListZMap;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#include "objlist_class.h"
|
||||
|
||||
struct zmap_header_type;
|
||||
struct gdrv_bitmap8;
|
||||
|
@ -32,11 +31,10 @@ public:
|
|||
char ActiveFlag;
|
||||
int MessageField;
|
||||
char* GroupName;
|
||||
int Unknown4;
|
||||
component_control* Control;
|
||||
int GroupIndex;
|
||||
render_sprite_type_struct* RenderSprite;
|
||||
TPinballTable* PinballTable;
|
||||
objlist_class<gdrv_bitmap8>* ListBitmap;
|
||||
objlist_class<zmap_header_type>* ListZMap;
|
||||
std::vector<gdrv_bitmap8*>* ListBitmap;
|
||||
std::vector<zmap_header_type*>* ListZMap;
|
||||
};
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "memory.h"
|
||||
#include "objlist_class.h"
|
||||
#include "pb.h"
|
||||
#include "pinball.h"
|
||||
#include "render.h"
|
||||
#include "Sound.h"
|
||||
#include "TBall.h"
|
||||
#include "TBlocker.h"
|
||||
#include "TBumper.h"
|
||||
|
@ -48,8 +46,6 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
{
|
||||
int shortArrLength;
|
||||
|
||||
ComponentList = new objlist_class<TPinballComponent>(32, 16);
|
||||
BallList = new objlist_class<TBall>(3, 1);
|
||||
CurScoreStruct = nullptr;
|
||||
ScoreBallcount = nullptr;
|
||||
ScorePlayerNumber1 = nullptr;
|
||||
|
@ -64,7 +60,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
PlayerCount = 0;
|
||||
|
||||
auto ballObj = new TBall(this);
|
||||
BallList->Add(ballObj);
|
||||
BallList.push_back(ballObj);
|
||||
if (ballObj)
|
||||
ballObj->ActiveFlag = 0;
|
||||
new TTableLayer(this);
|
||||
|
@ -103,7 +99,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
Plunger = new TPlunger(this, groupIndex);
|
||||
break;
|
||||
case 1002:
|
||||
LightGroup->List->Add(new TLight(this, groupIndex));
|
||||
LightGroup->List.push_back(new TLight(this, groupIndex));
|
||||
break;
|
||||
case 1003:
|
||||
FlipperL = new TFlipper(this, groupIndex);
|
||||
|
@ -213,30 +209,25 @@ TPinballTable::~TPinballTable()
|
|||
ScoreBallcount = nullptr;
|
||||
}
|
||||
delete LightGroup;
|
||||
while (ComponentList->GetCount() > 0)
|
||||
while (!ComponentList.empty())
|
||||
{
|
||||
delete ComponentList->Get(0);
|
||||
// Component destructor removes it from the list.
|
||||
delete ComponentList[0];
|
||||
}
|
||||
delete BallList;
|
||||
delete ComponentList;
|
||||
control::ClearLinks();
|
||||
}
|
||||
|
||||
TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
|
||||
{
|
||||
int objCount = ComponentList->GetCount();
|
||||
if (objCount > 0)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
for (int index = 0; index < objCount; ++index)
|
||||
const char* groupName = component->GroupName;
|
||||
if (groupName && !strcmp(groupName, componentName))
|
||||
{
|
||||
TPinballComponent* obj = ComponentList->Get(index);
|
||||
const char* groupName = obj->GroupName;
|
||||
if (groupName && !strcmp(groupName, componentName))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find:", componentName, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -244,16 +235,12 @@ TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
|
|||
TPinballComponent* TPinballTable::find_component(int groupIndex)
|
||||
{
|
||||
char Buffer[40]{};
|
||||
int objCount = ComponentList->GetCount();
|
||||
if (objCount > 0)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
for (int index = 0; index < objCount; ++index)
|
||||
{
|
||||
TPinballComponent* obj = ComponentList->Get(index);
|
||||
if (obj->GroupIndex == groupIndex)
|
||||
return obj;
|
||||
}
|
||||
if (component->GroupIndex == groupIndex)
|
||||
return component;
|
||||
}
|
||||
|
||||
snprintf(Buffer, sizeof Buffer, "%d", groupIndex);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find (lh):", Buffer, nullptr);
|
||||
return nullptr;
|
||||
|
@ -308,9 +295,9 @@ void TPinballTable::tilt(float time)
|
|||
loader::play_sound(SoundIndex3);
|
||||
TiltTimeoutTimer = timer::set(30.0, this, tilt_timeout);
|
||||
|
||||
for (int i = 0; i < ComponentList->GetCount(); i++)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
ComponentList->Get(i)->Message(1011, time);
|
||||
component->Message(1011, time);
|
||||
}
|
||||
LightGroup->Message(8, 0);
|
||||
TiltLockFlag = 1;
|
||||
|
@ -321,9 +308,9 @@ void TPinballTable::tilt(float time)
|
|||
|
||||
void TPinballTable::port_draw()
|
||||
{
|
||||
for (int index = ComponentList->GetCount() - 1; index >= 0; index--)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
ComponentList->Get(index)->port_draw();
|
||||
component->port_draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,9 +350,9 @@ int TPinballTable::Message(int code, float value)
|
|||
case 1008:
|
||||
case 1009:
|
||||
case 1010:
|
||||
for (int i = 0; i < ComponentList->GetCount(); i++)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
ComponentList->Get(i)->Message(code, value);
|
||||
component->Message(code, value);
|
||||
}
|
||||
break;
|
||||
case 1012:
|
||||
|
@ -407,7 +394,7 @@ int TPinballTable::Message(int code, float value)
|
|||
{
|
||||
CheatsUsed = 0;
|
||||
Message(1024, 0.0);
|
||||
auto ball = BallList->Get(0);
|
||||
auto ball = BallList[0];
|
||||
ball->Position.Y = 0.0;
|
||||
ball->Position.X = 0.0;
|
||||
ball->Position.Z = -0.8f;
|
||||
|
@ -452,7 +439,7 @@ int TPinballTable::Message(int code, float value)
|
|||
{
|
||||
score::set(PlayerScores[scoreIndex].ScoreStruct, -1);
|
||||
}
|
||||
|
||||
|
||||
ScoreSpecial3Flag = 0;
|
||||
ScoreSpecial2Flag = 0;
|
||||
UnknownP71 = 0;
|
||||
|
@ -509,9 +496,9 @@ int TPinballTable::Message(int code, float value)
|
|||
score::set(ScorePlayerNumber1, nextPlayer + 1);
|
||||
score::update(ScorePlayerNumber1);
|
||||
|
||||
for (int i = 0; i < ComponentList->GetCount(); i++)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
ComponentList->Get(i)->Message(1020, static_cast<float>(nextPlayer));
|
||||
component->Message(1020, static_cast<float>(nextPlayer));
|
||||
}
|
||||
|
||||
char* textboxText = nullptr;
|
||||
|
@ -560,9 +547,9 @@ int TPinballTable::Message(int code, float value)
|
|||
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
|
||||
break;
|
||||
case 1024:
|
||||
for (int i = 0; i < ComponentList->GetCount(); i++)
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
ComponentList->Get(i)->Message(1024, 0);
|
||||
component->Message(1024, 0);
|
||||
}
|
||||
if (ReplayTimer)
|
||||
timer::kill(ReplayTimer);
|
||||
|
@ -604,9 +591,9 @@ void TPinballTable::EndGame_timeout(int timerId, void* caller)
|
|||
table->EndGameTimeoutTimer = 0;
|
||||
pb::end_game();
|
||||
|
||||
for (int i = 0; i < table->ComponentList->GetCount(); i++)
|
||||
for (auto component : table->ComponentList)
|
||||
{
|
||||
table->ComponentList->Get(i)->Message(1022, 0);
|
||||
component->Message(1022, 0);
|
||||
}
|
||||
if (table->Demo)
|
||||
table->Demo->Message(1022, 0.0);
|
||||
|
@ -636,9 +623,9 @@ void TPinballTable::tilt_timeout(int timerId, void* caller)
|
|||
table->TiltTimeoutTimer = 0;
|
||||
if (table->TiltLockFlag)
|
||||
{
|
||||
for (int i = 0; i < table->BallList->GetCount(); i++)
|
||||
for (auto ball : table->BallList)
|
||||
{
|
||||
table->Drain->Collision(table->BallList->Get(i), &vec, &vec, 0.0, nullptr);
|
||||
table->Drain->Collision(ball, &vec, &vec, 0.0, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,8 +65,8 @@ public:
|
|||
int YOffset;
|
||||
int Width;
|
||||
int Height;
|
||||
objlist_class<TPinballComponent>* ComponentList;
|
||||
objlist_class<TBall>* BallList;
|
||||
std::vector<TPinballComponent*> ComponentList;
|
||||
std::vector<TBall*> BallList;
|
||||
TLightGroup* LightGroup;
|
||||
float GravityDirVectMult;
|
||||
float GravityAngleX;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "maths.h"
|
||||
#include "objlist_class.h"
|
||||
#include "pb.h"
|
||||
#include "render.h"
|
||||
#include "TBall.h"
|
||||
|
@ -27,7 +26,7 @@ TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent(t
|
|||
MaxPullback = 100;
|
||||
Elasticity = 0.5f;
|
||||
Smoothness = 0.5f;
|
||||
PullbackIncrement = static_cast<int>(100.0 / (ListBitmap->GetCount() * 8.0));
|
||||
PullbackIncrement = static_cast<int>(100.0 / (ListBitmap->size() * 8.0));
|
||||
Unknown4F = 0.025f;
|
||||
float* floatArr = loader::query_float_attribute(groupIndex, 0, 601);
|
||||
table->PlungerPositionX = floatArr[0];
|
||||
|
@ -65,8 +64,8 @@ int TPlunger::Message(int code, float value)
|
|||
PullbackTimer_ = 0;
|
||||
if (code == 1005)
|
||||
loader::play_sound(SoundIndexP2);
|
||||
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,
|
||||
|
@ -79,7 +78,7 @@ int TPlunger::Message(int code, float value)
|
|||
}
|
||||
case 1015:
|
||||
{
|
||||
auto ball = PinballTable->BallList->Get(0);
|
||||
auto ball = PinballTable->BallList.at(0);
|
||||
ball->Message(1024, 0.0);
|
||||
ball->Position.X = PinballTable->PlungerPositionX;
|
||||
ball->Position.Y = PinballTable->PlungerPositionY;
|
||||
|
@ -112,8 +111,8 @@ int TPlunger::Message(int code, float value)
|
|||
PullbackTimer_ = 0;
|
||||
if (code == 1005)
|
||||
loader::play_sound(SoundIndexP2);
|
||||
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,
|
||||
|
@ -151,10 +150,10 @@ void TPlunger::PullbackTimer(int timerId, void* caller)
|
|||
plunger->Boost = static_cast<float>(plunger->MaxPullback);
|
||||
}
|
||||
int index = static_cast<int>(floor(
|
||||
static_cast<float>(plunger->ListBitmap->GetCount() - 1) *
|
||||
static_cast<float>(plunger->ListBitmap->size() - 1) *
|
||||
(plunger->Boost / static_cast<float>(plunger->MaxPullback))));
|
||||
auto bmp = plunger->ListBitmap->Get(index);
|
||||
auto zMap = plunger->ListZMap->Get(index);
|
||||
auto bmp = plunger->ListBitmap->at(index);
|
||||
auto zMap = plunger->ListZMap->at(index);
|
||||
render::sprite_set(
|
||||
plunger->RenderSprite,
|
||||
bmp,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "timer.h"
|
||||
#include "TPinballTable.h"
|
||||
|
@ -91,7 +90,7 @@ void TPopupTarget::TimerExpired(int timerId, void* caller)
|
|||
auto target = static_cast<TPopupTarget*>(caller);
|
||||
target->Timer = 0;
|
||||
target->ActiveFlag = 1;
|
||||
render::sprite_set_bitmap(target->RenderSprite, target->ListBitmap->Get(0));
|
||||
render::sprite_set_bitmap(target->RenderSprite, target->ListBitmap->at(0));
|
||||
if (timerId)
|
||||
{
|
||||
if (target->SoftHitSoundId)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "TBall.h"
|
||||
#include "TEdgeSegment.h"
|
||||
#include "TLine.h"
|
||||
|
@ -35,7 +34,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
start.X = floatArr4[4];
|
||||
start.Y = floatArr4[5];
|
||||
Line1 = new TLine(this, &ActiveFlag, 1 << static_cast<int>(floor(floatArr4[0])), &start, &end);
|
||||
EdgeList->Add(Line1);
|
||||
EdgeList.push_back(Line1);
|
||||
if (Line1)
|
||||
{
|
||||
Line1->WallValue = nullptr;
|
||||
|
@ -53,7 +52,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
&end2,
|
||||
&start2);
|
||||
Line2 = new TLine(this, &ActiveFlag, CollisionGroup, start2, end2);
|
||||
EdgeList->Add(Line2);
|
||||
EdgeList.push_back(Line2);
|
||||
if (Line2)
|
||||
{
|
||||
Line2->WallValue = nullptr;
|
||||
|
@ -71,7 +70,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
&end3,
|
||||
&start3);
|
||||
Line3 = new TLine(this, &ActiveFlag, CollisionGroup, start3, end3);
|
||||
EdgeList->Add(Line3);
|
||||
EdgeList.push_back(Line3);
|
||||
if (Line3)
|
||||
{
|
||||
Line3->WallValue = nullptr;
|
||||
|
@ -118,7 +117,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
if (collisionGroup)
|
||||
{
|
||||
auto line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2);
|
||||
EdgeList->Add(line);
|
||||
EdgeList.push_back(line);
|
||||
if (line)
|
||||
{
|
||||
line->WallValue = plane;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "control.h"
|
||||
#include "gdrv.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "TBall.h"
|
||||
#include "TEdgeSegment.h"
|
||||
|
@ -22,7 +21,7 @@ TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent
|
|||
{
|
||||
RolloverFlag = 0;
|
||||
if (ListBitmap)
|
||||
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
|
||||
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
|
||||
build_walls(groupIndex);
|
||||
}
|
||||
|
||||
|
@ -34,7 +33,7 @@ int TRollover::Message(int code, float value)
|
|||
this->ActiveFlag = 1;
|
||||
this->RolloverFlag = 0;
|
||||
if (this->ListBitmap)
|
||||
render::sprite_set_bitmap(this->RenderSprite, this->ListBitmap->Get(0));
|
||||
render::sprite_set_bitmap(this->RenderSprite, this->ListBitmap->at(0));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,7 +62,7 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
|
|||
if (ListBitmap)
|
||||
{
|
||||
if (!RolloverFlag)
|
||||
bmp = ListBitmap->Get(0);
|
||||
bmp = ListBitmap->at(0);
|
||||
render::sprite_set_bitmap(RenderSprite, bmp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "TPinballTable.h"
|
||||
#include "TBall.h"
|
||||
|
@ -95,7 +94,7 @@ void TSink::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
|
|||
void TSink::TimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto sink = static_cast<TSink*>(caller);
|
||||
auto ball = sink->PinballTable->BallList->Get(0);
|
||||
auto ball = sink->PinballTable->BallList.at(0);
|
||||
ball->CollisionComp = nullptr;
|
||||
ball->ActiveFlag = 1;
|
||||
ball->Position.X = sink->BallPosition.X;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "control.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "timer.h"
|
||||
#include "TPinballTable.h"
|
||||
|
@ -41,8 +40,8 @@ int TSoloTarget::Message(int code, float value)
|
|||
if (ListBitmap)
|
||||
{
|
||||
auto index = 1 - ActiveFlag;
|
||||
auto bmp = ListBitmap->Get(index);
|
||||
auto zMap = ListZMap->Get(index);
|
||||
auto bmp = ListBitmap->at(index);
|
||||
auto zMap = ListZMap->at(index);
|
||||
render::sprite_set(
|
||||
RenderSprite,
|
||||
bmp,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "fullscrn.h"
|
||||
#include "loader.h"
|
||||
#include "objlist_class.h"
|
||||
#include "pb.h"
|
||||
#include "proj.h"
|
||||
#include "render.h"
|
||||
|
@ -91,7 +90,7 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
|
|||
if (line)
|
||||
{
|
||||
line->place_in_grid();
|
||||
EdgeList->Add(line);
|
||||
EdgeList.push_back(line);
|
||||
}
|
||||
|
||||
visArrPtr += 2;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "control.h"
|
||||
#include "fullscrn.h"
|
||||
#include "loader.h"
|
||||
#include "pb.h"
|
||||
#include "render.h"
|
||||
#include "score.h"
|
||||
#include "timer.h"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
|
||||
#include "control.h"
|
||||
#include "objlist_class.h"
|
||||
#include "render.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
@ -12,7 +11,7 @@ TWall::TWall(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
if (RenderSprite)
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
if (ListBitmap)
|
||||
BmpPtr = ListBitmap->Get(0);
|
||||
BmpPtr = ListBitmap->at(0);
|
||||
Timer = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "pch.h"
|
||||
#include "control.h"
|
||||
|
||||
#include "objlist_class.h"
|
||||
#include "pb.h"
|
||||
#include "pinball.h"
|
||||
#include "TBlocker.h"
|
||||
|
@ -606,16 +605,14 @@ TPinballComponent* control::make_component_link(component_tag_base* tag)
|
|||
if (tag->GetComponent())
|
||||
return tag->GetComponent();
|
||||
|
||||
auto compList = TableG->ComponentList;
|
||||
for (int index = 0; index < compList->GetCount(); index++)
|
||||
for (auto component: TableG->ComponentList)
|
||||
{
|
||||
auto comp = compList->Get(index);
|
||||
if (comp->GroupName)
|
||||
if (component->GroupName)
|
||||
{
|
||||
if (!strcmp(comp->GroupName, tag->Name))
|
||||
if (!strcmp(component->GroupName, tag->Name))
|
||||
{
|
||||
tag->SetComponent(comp);
|
||||
return comp;
|
||||
tag->SetComponent(component);
|
||||
return component;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "GroupData.h"
|
||||
#include "memory.h"
|
||||
#include "options.h"
|
||||
#include "partman.h"
|
||||
#include "pb.h"
|
||||
#include "score.h"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "pch.h"
|
||||
#include "high_score.h"
|
||||
|
||||
#include "memory.h"
|
||||
#include "options.h"
|
||||
#include "pinball.h"
|
||||
#include "score.h"
|
||||
|
|
|
@ -87,7 +87,7 @@ void loader::loadfrom(DatFile* datFile)
|
|||
loader_table = datFile;
|
||||
sound_record_table = loader_table;
|
||||
|
||||
for (auto groupIndex = 0; groupIndex < datFile->Groups.size(); ++groupIndex)
|
||||
for (auto groupIndex = 0; groupIndex < static_cast<int>(datFile->Groups.size()); ++groupIndex)
|
||||
{
|
||||
auto value = reinterpret_cast<int16_t*>(datFile->field(groupIndex, FieldTypes::ShortValue));
|
||||
if (value && *value == 202)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "zdrv.h"
|
||||
|
||||
|
||||
struct DatFile;
|
||||
class DatFile;
|
||||
|
||||
struct errorMsg
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "pinball.h"
|
||||
|
||||
|
||||
objlist_class<Mix_Music>* midi::LoadedTracks;
|
||||
std::vector<Mix_Music*> midi::LoadedTracks{};
|
||||
Mix_Music *midi::track1, *midi::track2, *midi::track3, *midi::active_track, *midi::NextTrack;
|
||||
bool midi::SetNextTrackFlag;
|
||||
|
||||
|
@ -50,7 +50,6 @@ int midi::music_stop()
|
|||
int midi::music_init()
|
||||
{
|
||||
active_track = nullptr;
|
||||
LoadedTracks = new objlist_class<Mix_Music>(0, 1);
|
||||
|
||||
if (pb::FullTiltMode)
|
||||
{
|
||||
|
@ -76,14 +75,12 @@ void midi::music_shutdown()
|
|||
if (active_track)
|
||||
Mix_HaltMusic();
|
||||
|
||||
while (LoadedTracks->GetCount())
|
||||
for (auto midi : LoadedTracks)
|
||||
{
|
||||
auto midi = LoadedTracks->Get(0);
|
||||
Mix_FreeMusic(midi);
|
||||
LoadedTracks->Delete(midi);
|
||||
}
|
||||
active_track = nullptr;
|
||||
delete LoadedTracks;
|
||||
LoadedTracks.clear();
|
||||
}
|
||||
|
||||
Mix_Music* midi::load_track(std::string fileName)
|
||||
|
@ -132,7 +129,7 @@ Mix_Music* midi::load_track(std::string fileName)
|
|||
if (!audio)
|
||||
return nullptr;
|
||||
|
||||
LoadedTracks->Add(audio);
|
||||
LoadedTracks.push_back(audio);
|
||||
return audio;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#include "objlist_class.h"
|
||||
|
||||
constexpr uint32_t SwapByteOrderInt(uint32_t val)
|
||||
{
|
||||
|
@ -92,7 +91,7 @@ public:
|
|||
static int music_init();
|
||||
static void music_shutdown();
|
||||
private:
|
||||
static objlist_class<Mix_Music>* LoadedTracks;
|
||||
static std::vector<Mix_Music*> LoadedTracks;
|
||||
static Mix_Music *track1, *track2, *track3, *active_track, *NextTrack;
|
||||
static bool SetNextTrackFlag;
|
||||
static Mix_Music* load_track(std::string fileName);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "nudge.h"
|
||||
|
||||
|
||||
#include "objlist_class.h"
|
||||
#include "pb.h"
|
||||
#include "render.h"
|
||||
#include "TBall.h"
|
||||
|
@ -68,12 +67,10 @@ void nudge::_nudge(float xDiff, float yDiff)
|
|||
vector_type accelMod;
|
||||
float invAccelX, invAccelY;
|
||||
|
||||
auto ballList = pb::MainTable->BallList;
|
||||
accelMod.X = xDiff * 0.5f;
|
||||
accelMod.Y = yDiff * 0.5f;
|
||||
for (auto index = 0; index < ballList->GetCount(); index++)
|
||||
for (auto ball : pb::MainTable->BallList)
|
||||
{
|
||||
auto ball = ballList->Get(index);
|
||||
if (ball->ActiveFlag && !ball->CollisionComp)
|
||||
{
|
||||
ball->Acceleration.X = ball->Acceleration.X * ball->Speed;
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
template <class T>
|
||||
class objlist_class
|
||||
{
|
||||
public:
|
||||
objlist_class(int sizeInt, int growSize)
|
||||
{
|
||||
ListPtr = memory::allocate<T*>(sizeInt);
|
||||
Count = 0;
|
||||
Size = sizeInt;
|
||||
GrowSize = growSize;
|
||||
}
|
||||
|
||||
~objlist_class()
|
||||
{
|
||||
if (ListPtr)
|
||||
memory::free(ListPtr);
|
||||
}
|
||||
|
||||
void Add(T* value)
|
||||
{
|
||||
if (Count == Size)
|
||||
Grow();
|
||||
if (Count >= Size)
|
||||
return;
|
||||
|
||||
ListPtr[Count] = value;
|
||||
Count++;
|
||||
}
|
||||
|
||||
void Grow()
|
||||
{
|
||||
if (!ListPtr)
|
||||
return;
|
||||
auto newSize = Count + GrowSize;
|
||||
if (newSize <= Size)
|
||||
return;
|
||||
|
||||
auto newList = memory::realloc(ListPtr, sizeof(T*) * newSize);
|
||||
if (!newList)
|
||||
return;
|
||||
|
||||
ListPtr = newList;
|
||||
Size = newSize;
|
||||
}
|
||||
|
||||
int Delete(T* value)
|
||||
{
|
||||
for (auto index = Count - 1; index >= 0; index--)
|
||||
{
|
||||
if (ListPtr[index] == value)
|
||||
{
|
||||
ListPtr[index] = ListPtr[Count - 1];
|
||||
Count--;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
T* Get(int index) const
|
||||
{
|
||||
if (index >= Count)
|
||||
return nullptr;
|
||||
return ListPtr[index];
|
||||
}
|
||||
|
||||
int GetCount() const { return Count; }
|
||||
int GetSize() const { return Size; }
|
||||
private:
|
||||
T** ListPtr;
|
||||
int GrowSize;
|
||||
int Size;
|
||||
int Count;
|
||||
};
|
|
@ -4,7 +4,6 @@
|
|||
#include "fullscrn.h"
|
||||
#include "memory.h"
|
||||
#include "midi.h"
|
||||
#include "pb.h"
|
||||
#include "Sound.h"
|
||||
#include "winmain.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "pch.h"
|
||||
#include "partman.h"
|
||||
|
||||
#include "fullscrn.h"
|
||||
#include "gdrv.h"
|
||||
#include "GroupData.h"
|
||||
#include "memory.h"
|
||||
|
@ -56,27 +55,25 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
bool abort = false;
|
||||
for (auto groupIndex = 0; !abort && groupIndex < header.NumberOfGroups; ++groupIndex)
|
||||
{
|
||||
auto entryCount = _lread_char(fileHandle);
|
||||
auto entryCount = LRead<uint8_t>(fileHandle);
|
||||
auto groupData = new GroupData(groupIndex);
|
||||
groupData->ReserveEntries(entryCount);
|
||||
|
||||
for (auto entryIndex = 0; entryIndex < entryCount; ++entryIndex)
|
||||
{
|
||||
auto entryData = new EntryData();
|
||||
auto entryType = static_cast<FieldTypes>(_lread_char(fileHandle));
|
||||
auto entryType = static_cast<FieldTypes>(LRead<uint8_t>(fileHandle));
|
||||
entryData->EntryType = entryType;
|
||||
|
||||
int fieldSize = _field_size[static_cast<int>(entryType)];
|
||||
if (fieldSize < 0)
|
||||
fieldSize = _lread_long(fileHandle);
|
||||
entryData->FieldSize = fieldSize;
|
||||
int fixedSize = _field_size[static_cast<int>(entryType)];
|
||||
size_t fieldSize = fixedSize >= 0 ? fixedSize : LRead<uint32_t>(fileHandle);
|
||||
entryData->FieldSize = static_cast<int>(fieldSize);
|
||||
|
||||
if (entryType == FieldTypes::Bitmap8bit)
|
||||
{
|
||||
fread(&bmpHeader, 1, sizeof(dat8BitBmpHeader), fileHandle);
|
||||
assertm(bmpHeader.Size + sizeof(dat8BitBmpHeader) == fieldSize, "partman: Wrong bitmap field size");
|
||||
assertm(bmpHeader.Resolution >= 0 && bmpHeader.Resolution <= 2,
|
||||
"partman: bitmap resolution out of bounds");
|
||||
assertm(bmpHeader.Resolution <= 2, "partman: bitmap resolution out of bounds");
|
||||
|
||||
auto bmp = memory::allocate<gdrv_bitmap8>();
|
||||
entryData->Buffer = reinterpret_cast<char*>(bmp);
|
||||
|
@ -90,28 +87,28 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
else if (entryType == FieldTypes::Bitmap16bit)
|
||||
{
|
||||
/*Full tilt has extra byte(@0:resolution) in zMap*/
|
||||
char zMapResolution = 0;
|
||||
auto zMapResolution = 0u;
|
||||
if (fullTiltMode)
|
||||
{
|
||||
zMapResolution = _lread_char(fileHandle);
|
||||
zMapResolution = LRead<uint8_t>(fileHandle);
|
||||
fieldSize--;
|
||||
assertm(zMapResolution >= 0 && zMapResolution <= 2, "partman: zMap resolution out of bounds");
|
||||
assertm(zMapResolution <= 2, "partman: zMap resolution out of bounds");
|
||||
}
|
||||
|
||||
fread(&zMapHeader, 1, sizeof(dat16BitBmpHeader), fileHandle);
|
||||
int length = fieldSize - sizeof(dat16BitBmpHeader);
|
||||
auto length = fieldSize - sizeof(dat16BitBmpHeader);
|
||||
|
||||
auto zMap = memory::allocate<zmap_header_type>();
|
||||
zdrv::create_zmap(zMap, zMapHeader.Width, zMapHeader.Height, zMapHeader.Stride);
|
||||
zMap->Resolution = zMapResolution;
|
||||
if (zMapHeader.Stride * zMapHeader.Height * 2 == length)
|
||||
if (zMapHeader.Stride * zMapHeader.Height * 2u == length)
|
||||
{
|
||||
fread(zMap->ZPtr1, 1, length, fileHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3DPB .dat has zeroed zMap headers, in groups 497 and 498, skip them.
|
||||
fseek(fileHandle, length, SEEK_CUR);
|
||||
fseek(fileHandle, static_cast<int>(length), SEEK_CUR);
|
||||
}
|
||||
entryData->Buffer = reinterpret_cast<char*>(zMap);
|
||||
}
|
||||
|
@ -140,17 +137,3 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
delete datFile;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char partman::_lread_char(FILE* file)
|
||||
{
|
||||
char Buffer = 0;
|
||||
fread(&Buffer, 1, 1, file);
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
int partman::_lread_long(FILE* file)
|
||||
{
|
||||
int Buffer = 0;
|
||||
fread(&Buffer, 1, 4, file);
|
||||
return Buffer;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,15 @@ static_assert(sizeof(dat16BitBmpHeader) == 14, "Wrong size of zmap_header_type")
|
|||
class partman
|
||||
{
|
||||
public:
|
||||
static struct DatFile* load_records(LPCSTR lpFileName, bool fullTiltMode);
|
||||
static class DatFile* load_records(LPCSTR lpFileName, bool fullTiltMode);
|
||||
private:
|
||||
static short _field_size[];
|
||||
static char _lread_char(FILE* file);
|
||||
static int _lread_long(FILE* file);
|
||||
|
||||
template <typename T>
|
||||
static T LRead(FILE* file)
|
||||
{
|
||||
T Buffer{};
|
||||
fread(&Buffer, 1, sizeof(T), file);
|
||||
return Buffer;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "loader.h"
|
||||
#include "midi.h"
|
||||
#include "nudge.h"
|
||||
#include "objlist_class.h"
|
||||
#include "options.h"
|
||||
#include "timer.h"
|
||||
#include "winmain.h"
|
||||
|
@ -75,7 +74,7 @@ int pb::init()
|
|||
zMin = cameraInfo[1];
|
||||
zScaler = cameraInfo[2];
|
||||
}
|
||||
|
||||
|
||||
render::init(nullptr, zMin, zScaler, resInfo->TableWidth, resInfo->TableHeight);
|
||||
gdrv::copy_bitmap(
|
||||
&render::vscreen,
|
||||
|
@ -101,7 +100,7 @@ int pb::init()
|
|||
MainTable = new TPinballTable();
|
||||
|
||||
high_score::read(highscore_table);
|
||||
ball_speed_limit = MainTable->BallList->Get(0)->Offset * 200.0f;
|
||||
ball_speed_limit = MainTable->BallList.at(0)->Offset * 200.0f;
|
||||
--memory::critical_allocation;
|
||||
return 0;
|
||||
}
|
||||
|
@ -112,8 +111,7 @@ int pb::uninit()
|
|||
loader::unload();
|
||||
delete record_table;
|
||||
high_score::write(highscore_table);
|
||||
if (MainTable)
|
||||
delete MainTable;
|
||||
delete MainTable;
|
||||
MainTable = nullptr;
|
||||
timer::uninit();
|
||||
render::uninit();
|
||||
|
@ -208,7 +206,7 @@ void pb::replay_level(int demoMode)
|
|||
|
||||
void pb::ballset(int x, int y)
|
||||
{
|
||||
TBall* ball = MainTable->BallList->Get(0);
|
||||
TBall* ball = MainTable->BallList.at(0);
|
||||
ball->Acceleration.X = x * 30.0f;
|
||||
ball->Acceleration.Y = y * 30.0f;
|
||||
ball->Speed = maths::normalize_2d(&ball->Acceleration);
|
||||
|
@ -216,7 +214,6 @@ void pb::ballset(int x, int y)
|
|||
|
||||
void pb::frame(int dtMilliSec)
|
||||
{
|
||||
|
||||
if (dtMilliSec > 100)
|
||||
dtMilliSec = 100;
|
||||
if (dtMilliSec <= 0)
|
||||
|
@ -258,9 +255,8 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
|||
{
|
||||
vector_type vec1{}, vec2{};
|
||||
|
||||
for (int i = 0; i < MainTable->BallList->GetCount(); i++)
|
||||
for (auto ball : MainTable->BallList)
|
||||
{
|
||||
auto ball = MainTable->BallList->Get(i);
|
||||
if (ball->ActiveFlag != 0)
|
||||
{
|
||||
auto collComp = ball->CollisionComp;
|
||||
|
@ -301,9 +297,8 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
|||
|
||||
if (drawBalls)
|
||||
{
|
||||
for (int i = 0; i < MainTable->BallList->GetCount(); i++)
|
||||
for (auto ball : MainTable->BallList)
|
||||
{
|
||||
auto ball = MainTable->BallList->Get(i);
|
||||
if (ball->ActiveFlag)
|
||||
ball->Repaint();
|
||||
}
|
||||
|
@ -444,19 +439,19 @@ void pb::keydown(int key)
|
|||
{
|
||||
case 'b':
|
||||
TBall* ball;
|
||||
if (MainTable->BallList->GetCount() <= 0)
|
||||
if (MainTable->BallList.empty())
|
||||
{
|
||||
ball = new TBall(MainTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto index = 0; ;)
|
||||
for (auto index = 0u; ;)
|
||||
{
|
||||
ball = MainTable->BallList->Get(index);
|
||||
ball = MainTable->BallList.at(index);
|
||||
if (!ball->ActiveFlag)
|
||||
break;
|
||||
++index;
|
||||
if (index >= MainTable->BallList->GetCount())
|
||||
if (index >= MainTable->BallList.size())
|
||||
{
|
||||
ball = new TBall(MainTable);
|
||||
break;
|
||||
|
|
|
@ -517,7 +517,7 @@ void render::SpriteViewer(bool* show)
|
|||
if (!bmp)
|
||||
continue;
|
||||
|
||||
auto type = BitmapTypes[static_cast<char>(bmp->BitmapType)];
|
||||
auto type = BitmapTypes[static_cast<uint8_t>(bmp->BitmapType)];
|
||||
ImGui::Text("type:%s, size:%d, resolution: %dx%d, offset:%dx%d", type,
|
||||
bmp->Resolution,
|
||||
bmp->Width, bmp->Height, bmp->XPosition, bmp->YPosition);
|
||||
|
@ -575,7 +575,7 @@ void render::BlitVScreen()
|
|||
reinterpret_cast<void**>(&lockedPixels),
|
||||
&pitch
|
||||
);
|
||||
assertm(pitch == vscreen.Width * sizeof(ColorRgba), "Padding on vScreen texture");
|
||||
assertm(static_cast<unsigned>(pitch) == vscreen.Width * sizeof(ColorRgba), "Padding on vScreen texture");
|
||||
|
||||
if (offset_x == 0 && offset_y == 0)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "pch.h"
|
||||
#include "zdrv.h"
|
||||
#include "memory.h"
|
||||
#include "pb.h"
|
||||
#include "winmain.h"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue