1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-22 08:50:18 +01:00

Cleaned up objlist_class.

This commit is contained in:
Muzychenko Andrey 2021-01-30 14:19:25 +03:00
parent 5b9a1ff95d
commit 6ff457eb68
42 changed files with 276 additions and 340 deletions

View file

@ -29,7 +29,7 @@ int main()
auto dib = gdrv::DibCreate(8, 1, 1);
gdrv::DibSetUsage(dib, 0, 1);
objlist_class d = objlist_class(2, 4);
auto d = objlist_class<void>(2, 4);
for (int i = 0; i < 100; i++)
{
d.Add((void*)i);

View file

@ -219,7 +219,6 @@
<ClInclude Include="TTimer.h" />
<ClInclude Include="TTripwire.h" />
<ClInclude Include="TWall.h" />
<ClInclude Include="TZmapList.h" />
<ClInclude Include="WaveMix.h" />
<ClInclude Include="winmain.h" />
<ClInclude Include="zdrv.h" />
@ -234,7 +233,6 @@
<ClCompile Include="memory.cpp" />
<ClCompile Include="midi.cpp" />
<ClCompile Include="nudge.cpp" />
<ClCompile Include="objlist_class.cpp" />
<ClCompile Include="options.cpp" />
<ClCompile Include="partman.cpp" />
<ClCompile Include="pb.cpp" />

View file

@ -81,9 +81,6 @@
<ClInclude Include="TTimer.h">
<Filter>Header Files\TPinballComponent</Filter>
</ClInclude>
<ClInclude Include="TZmapList.h">
<Filter>Header Files\TPinballComponent</Filter>
</ClInclude>
<ClInclude Include="memory.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -236,9 +233,6 @@
<ClCompile Include="SpaceCadetPinball.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="objlist_class.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="partman.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View file

@ -8,7 +8,6 @@
#include "proj.h"
#include "render.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
{
@ -30,7 +29,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
Position.X = 0.0;
Position.Y = 0.0;
ListBitmap = new TZmapList(0, 4);
ListBitmap = new objlist_class<gdrv_bitmap8>(0, 4);
auto groupIndex = loader::query_handle("ball");
Offset = *loader::query_float_attribute(groupIndex, 0, 500);
auto visualCount = loader::query_visual_states(groupIndex);
@ -73,12 +72,12 @@ void TBall::Repaint()
auto zArrPtr = VisualZArray;
int index;
for (index = 0; index < ListBitmap->Count() - 1; ++index, zArrPtr++)
for (index = 0; index < ListBitmap->GetCount() - 1; ++index, zArrPtr++)
{
if (*zArrPtr <= zDepth) break;
}
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index));
auto bmp = ListBitmap->Get(index);
render::ball_set(
RenderSprite,
bmp,

View file

@ -4,9 +4,9 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TZmapList.h"
TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
@ -46,7 +46,7 @@ int TBlocker::Message(int code, float value)
case 52:
ActiveFlag = 1;
loader::play_sound(SoundIndex4);
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
break;
case 59:
break;

View file

@ -4,10 +4,10 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TBumper::TBumper(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
@ -29,8 +29,8 @@ int TBumper::Message(int code, float value)
case 11:
{
auto nextBmp = static_cast<int>(floor(value));
if (2 * nextBmp > ListBitmap->Count() - 1)
nextBmp = (ListBitmap->Count() - 1) / 2;
if (2 * nextBmp > ListBitmap->GetCount() - 1)
nextBmp = (ListBitmap->GetCount() - 1) / 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->Count() - 1;
auto maxBmp = ListBitmap->GetCount() - 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 = static_cast<gdrv_bitmap8*>(bump->ListBitmap->Get(bump->BmpIndex * 2));
auto zMap = static_cast<zmap_header_type*>(bump->ListZMap->Get(bump->BmpIndex * 2));
auto bmp = bump->ListBitmap->Get(bump->BmpIndex * 2);
auto zMap = bump->ListZMap->Get(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 = static_cast<gdrv_bitmap8*>(ListBitmap->Get(bmpIndex));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(bmpIndex));
auto bmp = ListBitmap->Get(bmpIndex);
auto zMap = ListZMap->Get(bmpIndex);
render::sprite_set(
RenderSprite,
bmp,

View file

@ -12,7 +12,7 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
{
visualStruct visual{};
EdgeList = new objlist_class(4, 4);
EdgeList = new objlist_class<TEdgeSegment>(4, 4);
ActiveFlag = 1;
if (GroupName != nullptr)
UnusedBaseFlag = 1;
@ -42,9 +42,9 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
TCollisionComponent::~TCollisionComponent()
{
for (TEdgeSegment* edge; EdgeList->Count() > 0;)
for (TEdgeSegment* edge; EdgeList->GetCount() > 0;)
{
edge = static_cast<TEdgeSegment*>(EdgeList->Get(0));
edge = EdgeList->Get(0);
EdgeList->Delete(edge);
delete edge;
}
@ -54,9 +54,9 @@ TCollisionComponent::~TCollisionComponent()
void TCollisionComponent::port_draw()
{
for (int index = EdgeList->Count() - 1; index >= 0; index--)
for (int index = EdgeList->GetCount() - 1; index >= 0; index--)
{
static_cast<TEdgeSegment*>(EdgeList->Get(index))->port_draw();
EdgeList->Get(index)->port_draw();
}
}

View file

@ -1,7 +1,6 @@
#pragma once
#include "TPinballComponent.h"
class objlist_class;
struct vector_type;
class TEdgeSegment;
class TBall;
@ -9,7 +8,7 @@ class TBall;
class TCollisionComponent : public TPinballComponent
{
public:
objlist_class* EdgeList;
objlist_class<TEdgeSegment>* EdgeList;
float Elasticity;
float Smoothness;
float Boost;

View file

@ -10,7 +10,7 @@
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
List = new objlist_class(4, 4);
List = new objlist_class<TPinballComponent>(4, 4);
Timer = 0;
if (groupIndex > 0)
{
@ -50,9 +50,9 @@ int TComponentGroup::Message(int code, float value)
}
else if (code <= 1007 || code > 1011 && code != 1020 && code != 1022)
{
for (int i = 0; i < List->Count(); i++)
for (int i = 0; i < List->GetCount(); i++)
{
static_cast<TPinballComponent*>(List->Get(i))->Message(code, value);
List->Get(i)->Message(code, value);
}
}
return 0;

View file

@ -1,7 +1,6 @@
#pragma once
#include "TPinballComponent.h"
class objlist_class;
class TComponentGroup :
public TPinballComponent
@ -12,6 +11,6 @@ public:
int Message(int code, float value) override;
static void NotifyTimerExpired(int timerId, void* caller);
objlist_class* List;
objlist_class<TPinballComponent>* List;
int Timer;
};

View file

@ -5,8 +5,8 @@
TEdgeBox::TEdgeBox()
{
EdgeList = new objlist_class(0, 4);
FieldList = new objlist_class(0, 1);
EdgeList = new objlist_class<TEdgeSegment>(0, 4);
FieldList = new objlist_class<field_effect_type>(0, 1);
}
TEdgeBox::~TEdgeBox()

View file

@ -1,5 +1,9 @@
#pragma once
class objlist_class;
#include "objlist_class.h"
struct field_effect_type;
class TEdgeSegment;
class TEdgeBox
{
@ -7,7 +11,7 @@ public:
TEdgeBox();
~TEdgeBox();
objlist_class* EdgeList;
objlist_class* FieldList;
objlist_class<TEdgeSegment>* EdgeList;
objlist_class<field_effect_type>* FieldList;
};

View file

@ -64,9 +64,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->Count() - 1; index >= 0; --index)
for (auto index = edgeBox->EdgeList->GetCount() - 1; index >= 0; --index)
{
auto edge = static_cast<TEdgeSegment*>(edgeBox->EdgeList->Get(index));
auto edge = edgeBox->EdgeList->Get(index);
if (!edge->ProcessedFlag && *edge->ActiveFlag && (edge->CollisionGroup & ray->FieldFlag))
{
if (!ball->already_hit(edge))
@ -94,9 +94,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->Count() - 1; index >= 0; --index)
for (int index = edgeBox->FieldList->GetCount() - 1; index >= 0; --index)
{
auto field = static_cast<field_effect_type*>(edgeBox->FieldList->Get(index));
auto field = edgeBox->FieldList->Get(index);
if (*field->Flag2Ptr && ball->FieldFlag & field->Mask)
{
if (field->CollisionComp->FieldEffect(ball, &vec))

View file

@ -10,7 +10,6 @@
#include "timer.h"
#include "TLine.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
{
@ -62,8 +61,8 @@ int TFlagSpinner::Message(int code, float value)
Timer = 0;
}
BmpIndex = 0;
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(0));
auto bmp = ListBitmap->Get(0);
auto zMap = ListZMap->Get(0);
render::sprite_set(
RenderSprite,
bmp,
@ -109,7 +108,7 @@ void TFlagSpinner::NextFrame()
{
BmpIndex += SpinDirection;
int bmpIndex = BmpIndex;
int bmpCount = ListBitmap->Count();
int bmpCount = ListBitmap->GetCount();
if (bmpIndex >= bmpCount)
BmpIndex = 0;
else if (bmpIndex < 0)
@ -124,8 +123,8 @@ void TFlagSpinner::NextFrame()
control::handler(62, this);
}
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(BmpIndex));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(BmpIndex));
auto bmp = ListBitmap->Get(BmpIndex);
auto zMap = ListZMap->Get(BmpIndex);
render::sprite_set(
RenderSprite,
bmp,

View file

@ -4,11 +4,11 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "pb.h"
#include "render.h"
#include "TFlipperEdge.h"
#include "timer.h"
#include "TZmapList.h"
TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
{
@ -47,8 +47,8 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
FlipperEdge = flipperEdge;
if (flipperEdge)
{
BmpCoef1 = flipperEdge->BmpCoef1 / static_cast<float>(ListBitmap->Count() - 1);
BmpCoef2 = flipperEdge->BmpCoef2 / static_cast<float>(ListBitmap->Count() - 1);
BmpCoef1 = flipperEdge->BmpCoef1 / static_cast<float>(ListBitmap->GetCount() - 1);
BmpCoef2 = flipperEdge->BmpCoef2 / static_cast<float>(ListBitmap->GetCount() - 1);
}
BmpIndex = 0;
InputTime = 0.0;
@ -137,7 +137,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->Count();
int bmpCount = flip->ListBitmap->GetCount();
if (bmpIndexAdvance > bmpCount)
bmpIndexAdvance = bmpCount;
if (bmpIndexAdvance < 0)
@ -149,7 +149,7 @@ void TFlipper::TimerExpired(int timerId, void* caller)
if (flip->MessageField == 1)
{
flip->BmpIndex += bmpIndexAdvance;
int countSub1 = flip->ListBitmap->Count() - 1;
int countSub1 = flip->ListBitmap->GetCount() - 1;
if (flip->BmpIndex >= countSub1)
{
flip->BmpIndex = countSub1;
@ -177,8 +177,8 @@ void TFlipper::TimerExpired(int timerId, void* caller)
timer = timer::set(flip->TimerTime, flip, TimerExpired);
flip->Timer = timer;
auto bmp = static_cast<gdrv_bitmap8*>(flip->ListBitmap->Get(flip->BmpIndex));
auto zMap = static_cast<zmap_header_type*>(flip->ListZMap->Get(flip->BmpIndex));
auto bmp = flip->ListBitmap->Get(flip->BmpIndex);
auto zMap = flip->ListZMap->Get(flip->BmpIndex);
render::sprite_set(
flip->RenderSprite,
bmp,

View file

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

View file

@ -5,10 +5,10 @@
#include "control.h"
#include "loader.h"
#include "maths.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TKickback::TKickback(TPinballTable* table, int groupIndex): TCollisionComponent(table, groupIndex, true)
{
@ -66,8 +66,8 @@ void TKickback::TimerExpired(int timerId, void* caller)
loader::play_sound(kick->HardHitSoundId);
if (kick->ListBitmap)
{
auto bmp = static_cast<gdrv_bitmap8*>(kick->ListBitmap->Get(1));
auto zMap = static_cast<zmap_header_type*>(kick->ListZMap->Get(1));
auto bmp = kick->ListBitmap->Get(1);
auto zMap = kick->ListZMap->Get(1);
render::sprite_set(
kick->RenderSprite,
bmp,
@ -80,8 +80,8 @@ void TKickback::TimerExpired(int timerId, void* caller)
{
if (kick->ListBitmap)
{
auto bmp = static_cast<gdrv_bitmap8*>(kick->ListBitmap->Get(0));
auto zMap = static_cast<zmap_header_type*>(kick->ListZMap->Get(0));
auto bmp = kick->ListBitmap->Get(0);
auto zMap = kick->ListZMap->Get(0);
render::sprite_set(
kick->RenderSprite,
bmp,

View file

@ -4,10 +4,10 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
{
@ -144,13 +144,13 @@ int TLight::Message(int code, float value)
break;
case 11:
BmpIndex2 = static_cast<int>(floor(value));
if (BmpIndex2 > ListBitmap->Count())
BmpIndex2 = ListBitmap->Count();
if (BmpIndex2 > ListBitmap->GetCount())
BmpIndex2 = ListBitmap->GetCount();
bmpIndex = 0;
if (BmpIndex2 < 0)
BmpIndex2 = 0;
Flasher.BmpArr[0] = nullptr;
Flasher.BmpArr[1] = static_cast<gdrv_bitmap8*>(ListBitmap->Get(BmpIndex2));
Flasher.BmpArr[1] = ListBitmap->Get(BmpIndex2);
if (FlasherActive == 0)
{
if (!FlasherFlag1)
@ -169,8 +169,8 @@ int TLight::Message(int code, float value)
break;
case 12:
bmpIndex = BmpIndex2 + 1;
if (bmpIndex > ListBitmap->Count())
bmpIndex = ListBitmap->Count();
if (bmpIndex > ListBitmap->GetCount())
bmpIndex = ListBitmap->GetCount();
Message(11, static_cast<float>(bmpIndex));
break;
case 13:
@ -257,7 +257,7 @@ void TLight::Reset()
Flasher.Sprite = RenderSprite;
Flasher.BmpArr[0] = nullptr;
if (ListBitmap)
Flasher.BmpArr[1] = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
Flasher.BmpArr[1] = ListBitmap->Get(0);
Flasher.Unknown4 = 0;
Flasher.Unknown3 = 0;
MessageField = 0;

View file

@ -18,7 +18,7 @@ TLightBargraph::TLightBargraph(TPinballTable* table, int groupIndex) : TLightGro
float* floatArr = loader::query_float_attribute(groupIndex, 0, 904);
if (floatArr)
{
int count = 2 * List->Count();
int count = 2 * List->GetCount();
TimerTimeArray = reinterpret_cast<float*>(memory::allocate(count * sizeof(float)));
if (TimerTimeArray)
{
@ -49,7 +49,7 @@ int TLightBargraph::Message(int code, float value)
TimerBargraph = 0;
}
auto timeIndex = static_cast<int>(floor(value));
auto maxCount = 2 * List->Count();
auto maxCount = 2 * List->GetCount();
if (timeIndex >= maxCount)
timeIndex = maxCount - 1;
if (timeIndex >= 0)

View file

@ -11,7 +11,7 @@
TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
List = new objlist_class(4, 4);
List = new objlist_class<TLight>(4, 4);
Timer = 0;
NotifyTimer = 0;
Reset();
@ -22,7 +22,7 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone
__int16* groupIndArr = loader::query_iattribute(groupIndex, 1027, &count);
for (int index = 0; index < count; ++groupIndArr)
{
auto comp = table->find_component(*groupIndArr);
auto comp = dynamic_cast<TLight*>(table->find_component(*groupIndArr));
if (comp)
List->Add(comp);
++index;
@ -71,8 +71,8 @@ int TLightGroup::Message(int code, float value)
break;
case 24:
{
auto count = List->Count();
auto lastLight = static_cast<TLight*>(List->Get(count - 1));
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
break;
if (MessageField2)
@ -85,12 +85,12 @@ int TLightGroup::Message(int code, float value)
auto bmpIndex1 = lastLight->BmpIndex1;
for (auto index = count - 1; index > 0; --index)
{
auto lightCur = static_cast<TLight*>(List->Get(index));
auto lightPrev = static_cast<TLight*>(List->Get(index - 1));
auto lightCur = List->Get(index);
auto lightPrev = List->Get(index - 1);
lightCur->Message(lightPrev->BmpIndex1 != 0, 0.0);
lightCur->MessageField = lightPrev->MessageField;
}
auto firstLight = static_cast<TLight*>(List->Get(0));
auto firstLight = List->Get(0);
firstLight->Message(bmpIndex1 != 0, 0.0);
firstLight->MessageField = lightMessageField;
reschedule_animation(value);
@ -98,23 +98,23 @@ int TLightGroup::Message(int code, float value)
}
case 25:
{
auto count = List->Count();
auto lastLight = static_cast<TLight*>(List->Get(count - 1));
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
break;
if (MessageField2)
{
TLightGroup::Message(34, 0.0);
}
auto firstLight = static_cast<TLight*>(List->Get(0));
auto firstLight = List->Get(0);
AnimationFlag = 1;
MessageField2 = code;
auto lightMessageField = firstLight->MessageField;
auto bmpIndex1 = firstLight->BmpIndex1;
for (auto index = 0; index < count - 1; index++)
{
auto lightCur = static_cast<TLight*>(List->Get(index));
auto lightNext = static_cast<TLight*>(List->Get(index + 1));
auto lightCur = List->Get(index);
auto lightNext = List->Get(index + 1);
lightCur->Message(lightNext->BmpIndex1 != 0, 0.0);
lightCur->MessageField = lightNext->MessageField;
}
@ -129,16 +129,16 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->Count();
auto lastLight = static_cast<TLight*>(List->Get(count - 1));
auto count = List->GetCount();
auto lastLight = List->Get(count - 1);
auto flasherFlag2 = lastLight->FlasherFlag2;
for (auto i = count - 1; i > 0; --i)
{
auto lightCur = static_cast<TLight*>(List->Get(i));
auto lightPrev = static_cast<TLight*>(List->Get(i - 1));
auto lightCur = List->Get(i);
auto lightPrev = List->Get(i - 1);
lightCur->Message((lightPrev->FlasherFlag2 != 0) + 8, 0.0);
}
auto firstLight = static_cast<TLight*>(List->Get(0));
auto firstLight = List->Get(0);
firstLight->Message((flasherFlag2 != 0) + 8, 0);
reschedule_animation(value);
break;
@ -149,16 +149,16 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->Count();
auto firstLight = static_cast<TLight*>(List->Get(0));
auto count = List->GetCount();
auto firstLight = List->Get(0);
auto flasherFlag2 = firstLight->FlasherFlag2;
for (auto i = 0; i < count - 1; i++)
{
auto lightCur = static_cast<TLight*>(List->Get(i));
auto lightNext = static_cast<TLight*>(List->Get(i + 1));
auto lightCur = List->Get(i);
auto lightNext = List->Get(i + 1);
lightCur->Message((lightNext->FlasherFlag2 != 0) + 8, 0.0);
}
auto lastLight = static_cast<TLight*>(List->Get(count - 1));
auto lastLight = List->Get(count - 1);
lastLight->Message((flasherFlag2 != 0) + 8, 0);
reschedule_animation(value);
break;
@ -169,12 +169,12 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->Count();
auto count = List->GetCount();
for (auto i = 0; i < count - 1; i++)
{
if (rand() % 100 > 70)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
auto randVal = static_cast<float>(rand()) * 0.00003051850947599719f * value * 3.0f + 0.1f;
light->Message(9, randVal);
}
@ -188,10 +188,10 @@ int TLightGroup::Message(int code, float value)
start_animation();
MessageField2 = code;
AnimationFlag = 0;
auto count = List->Count();
auto count = List->GetCount();
for (auto i = 0; i < count - 1; i++)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
auto randVal = static_cast<float>(rand() % 100 > 70);
light->Message(18, randVal);
}
@ -201,13 +201,13 @@ int TLightGroup::Message(int code, float value)
case 30:
{
auto noBmpInd1Count = 0;
auto countSub1 = List->Count() - 1;
auto countSub1 = List->GetCount() - 1;
if (countSub1 < 0)
break;
for (auto i = countSub1; i >= 0; i--)
{
if (!static_cast<TLight*>(List->Get(i))->BmpIndex1)
if (!List->Get(i)->BmpIndex1)
++noBmpInd1Count;
}
if (!noBmpInd1Count)
@ -216,7 +216,7 @@ int TLightGroup::Message(int code, float value)
auto randModCount = rand() % noBmpInd1Count;
for (auto i = countSub1; i >= 0; i--)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
if (!light->BmpIndex1 && randModCount-- == 0)
{
light->Message(1, 0.0);
@ -231,13 +231,13 @@ int TLightGroup::Message(int code, float value)
case 31:
{
auto bmpInd1Count = 0;
auto countSub1 = List->Count() - 1;
auto countSub1 = List->GetCount() - 1;
if (countSub1 < 0)
break;
for (auto i = countSub1; i >= 0; i--)
{
if (static_cast<TLight*>(List->Get(i))->BmpIndex1)
if (List->Get(i)->BmpIndex1)
++bmpInd1Count;
}
if (!bmpInd1Count)
@ -246,7 +246,7 @@ int TLightGroup::Message(int code, float value)
auto randModCount = rand() % bmpInd1Count;
for (auto i = countSub1; i >= 0; i--)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
if (light->BmpIndex1 && randModCount-- == 0)
{
light->Message(0, 0.0);
@ -263,7 +263,7 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_up();
if (index < 0)
break;
static_cast<TLight*>(List->Get(index))->Message(1, 0.0);
List->Get(index)->Message(1, 0.0);
if (MessageField2)
start_animation();
return 1;
@ -273,7 +273,7 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_down();
if (index < 0)
break;
static_cast<TLight*>(List->Get(index))->Message(0, 0.0);
List->Get(index)->Message(0, 0.0);
if (MessageField2)
start_animation();
return 1;
@ -292,10 +292,10 @@ int TLightGroup::Message(int code, float value)
case 35:
{
auto index = static_cast<int>(floor(value));
if (index >= List->Count() || index < 0)
if (index >= List->GetCount() || index < 0)
break;
auto light = static_cast<TLight*>(List->Get(index));
auto light = List->Get(index);
light->Message(1, 0.0);
if (MessageField2)
start_animation();
@ -304,10 +304,10 @@ int TLightGroup::Message(int code, float value)
case 36:
{
auto index = static_cast<int>(floor(value));
if (index >= List->Count() || index < 0)
if (index >= List->GetCount() || index < 0)
break;
auto light = static_cast<TLight*>(List->Get(index));
auto light = List->Get(index);
light->Message(0, 0.0);
if (MessageField2)
start_animation();
@ -316,16 +316,16 @@ int TLightGroup::Message(int code, float value)
case 37:
{
auto bmp1Count = 0;
auto countSub1 = List->Count() - 1;
auto countSub1 = List->GetCount() - 1;
for (auto i = countSub1; i >= 0; i--)
{
if (static_cast<TLight*>(List->Get(i))->BmpIndex1)
if (List->Get(i)->BmpIndex1)
++bmp1Count;
}
return bmp1Count;
}
case 38:
return List->Count();
return List->GetCount();
case 39:
return MessageField2;
case 40:
@ -337,7 +337,7 @@ int TLightGroup::Message(int code, float value)
break;
if (MessageField2 || AnimationFlag)
TLightGroup::Message(34, 0.0);
static_cast<TLight*>(List->Get(index))->Message(15, value);
List->Get(index)->Message(15, value);
return 1;
}
case 42:
@ -347,7 +347,7 @@ int TLightGroup::Message(int code, float value)
break;
if (MessageField2 || AnimationFlag)
TLightGroup::Message(34, 0.0);
static_cast<TLight*>(List->Get(index))->Message(16, value);
List->Get(index)->Message(16, value);
return 1;
}
case 43:
@ -359,10 +359,10 @@ int TLightGroup::Message(int code, float value)
break;
case 44:
{
auto countSub1 = List->Count() - 1;
auto countSub1 = List->GetCount() - 1;
for (auto index = countSub1; index >= 0; index--)
{
auto light = static_cast<TLight*>(List->Get(index));
auto light = List->Get(index);
if (light->BmpIndex1)
{
light->Message(0, 0.0);
@ -378,7 +378,7 @@ int TLightGroup::Message(int code, float value)
auto index = static_cast<int>(floor(value));
if (index >= 0)
{
auto count = List->Count();
auto count = List->GetCount();
if (index <= count)
{
auto countSub1 = count - 1;
@ -387,7 +387,7 @@ int TLightGroup::Message(int code, float value)
countSub1 = index;
for (auto i = countSub1, k = countSub1 - index; k != 0; i--, k--)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
light->Message(20, 0.0);
}
}
@ -395,7 +395,7 @@ int TLightGroup::Message(int code, float value)
{
for (auto i = countSub1; i != 0; i--)
{
auto light = static_cast<TLight*>(List->Get(i));
auto light = List->Get(i);
light->Message(19, 0.0);
}
}
@ -408,14 +408,14 @@ int TLightGroup::Message(int code, float value)
auto index = next_light_down();
if (index >= 0)
{
static_cast<TLight*>(List->Get(index))->Message(4, 0.0);
List->Get(index)->Message(4, 0.0);
}
break;
}
default:
for (auto index = List->Count() - 1; index >= 0; index--)
for (auto index = List->GetCount() - 1; index >= 0; index--)
{
static_cast<TLight*>(List->Get(index))->Message(code, value);
List->Get(index)->Message(code, value);
}
break;
}
@ -453,9 +453,9 @@ void TLightGroup::reschedule_animation(float time)
void TLightGroup::start_animation()
{
for (int index = List->Count() - 1; index >= 0; --index)
for (int index = List->GetCount() - 1; index >= 0; --index)
{
auto light = static_cast<TLight*>(List->Get(index));
auto light = List->Get(index);
if (light->BmpIndex1)
light->Message(9, 0.0);
else
@ -465,9 +465,9 @@ void TLightGroup::start_animation()
int TLightGroup::next_light_up()
{
for (int index = 0; index < List->Count(); ++index)
for (int index = 0; index < List->GetCount(); ++index)
{
if (!static_cast<TLight*>(List->Get(index))->BmpIndex1)
if (!List->Get(index)->BmpIndex1)
return index;
}
return -1;
@ -475,9 +475,9 @@ int TLightGroup::next_light_up()
int TLightGroup::next_light_down()
{
for (int index = List->Count() - 1; index >= 0; --index)
for (int index = List->GetCount() - 1; index >= 0; --index)
{
if (!static_cast<TLight*>(List->Get(index))->BmpIndex1)
if (!List->Get(index)->BmpIndex1)
return index;
}
return -1;

View file

@ -1,6 +1,8 @@
#pragma once
#include "TPinballComponent.h"
class objlist_class;
class TLight;
struct TLightGroup_player_backup
{
@ -27,7 +29,7 @@ public:
static void TimerExpired(int timerId, void* caller);
static void NotifyTimerExpired(int timerId, void* caller);
objlist_class* List;
objlist_class<TLight>* List;
float Timer1Time;
float Timer1TimeDefault;
int MessageField2;

View file

@ -4,11 +4,11 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "TBall.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TLightRollover::TLightRollover(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, false)
{
@ -58,7 +58,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, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
}
}
}

View file

@ -3,7 +3,6 @@
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "TZmapList.h"
#include "TPinballTable.h"
TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool loadVisuals)
@ -32,32 +31,32 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
if (visual.Bitmap)
{
if (!ListBitmap)
ListBitmap = new TZmapList(visualCount, 4);
ListBitmap = new objlist_class<gdrv_bitmap8>(visualCount, 4);
if (ListBitmap)
ListBitmap->Add(visual.Bitmap);
}
if (visual.ZMap)
{
if (!ListZMap)
ListZMap = new TZmapList(visualCount, 4);
ListZMap = new objlist_class<zmap_header_type>(visualCount, 4);
if (ListZMap)
ListZMap->Add(visual.ZMap);
}
}
zmap_header_type* zMap = nullptr;
if (ListZMap)
zMap = static_cast<zmap_header_type*>(ListZMap->Get(0));
zMap = ListZMap->Get(0);
if (ListBitmap)
{
rectangle_type bmp1Rect{}, tmpRect{};
auto rootBmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
auto rootBmp = ListBitmap->Get(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->Count(); index++)
for (int index = 1; index < ListBitmap->GetCount(); index++)
{
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index));
auto bmp = ListBitmap->Get(index);
tmpRect.XPosition = bmp->XPosition - table->XOffset;
tmpRect.YPosition = bmp->YPosition - table->YOffset;
tmpRect.Width = bmp->Width;

View file

@ -1,9 +1,11 @@
#pragma once
#include "objlist_class.h"
struct zmap_header_type;
struct gdrv_bitmap8;
struct render_sprite_type_struct;
struct component_control;
class TPinballTable;
class TZmapList;
enum class message_code
{
@ -35,6 +37,6 @@ public:
int GroupIndex;
render_sprite_type_struct* RenderSprite;
TPinballTable* PinballTable;
TZmapList* ListBitmap;
TZmapList* ListZMap;
objlist_class<gdrv_bitmap8>* ListBitmap;
objlist_class<zmap_header_type>* ListZMap;
};

View file

@ -48,8 +48,8 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
{
int shortArrLength;
ComponentList = new objlist_class(32, 16);
BallList = new objlist_class(3, 1);
ComponentList = new objlist_class<TPinballComponent>(32, 16);
BallList = new objlist_class<TBall>(3, 1);
CurScoreStruct = nullptr;
ScoreBallcount = nullptr;
ScorePlayerNumber1 = nullptr;
@ -213,9 +213,9 @@ TPinballTable::~TPinballTable()
ScoreBallcount = nullptr;
}
delete LightGroup;
while (ComponentList->Count() > 0)
while (ComponentList->GetCount() > 0)
{
delete static_cast<TPinballComponent*>(ComponentList->Get(0));
delete ComponentList->Get(0);
}
delete BallList;
delete ComponentList;
@ -223,12 +223,12 @@ TPinballTable::~TPinballTable()
TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
{
int objCount = ComponentList->Count();
int objCount = ComponentList->GetCount();
if (objCount > 0)
{
for (int index = 0; index < objCount; ++index)
{
TPinballComponent* obj = static_cast<TPinballComponent*>(ComponentList->Get(index));
TPinballComponent* obj = ComponentList->Get(index);
const CHAR* groupName = obj->GroupName;
if (groupName && !lstrcmpA(groupName, componentName))
{
@ -243,12 +243,12 @@ TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
TPinballComponent* TPinballTable::find_component(int groupIndex)
{
char Buffer[40];
int objCount = ComponentList->Count();
int objCount = ComponentList->GetCount();
if (objCount > 0)
{
for (int index = 0; index < objCount; ++index)
{
TPinballComponent* obj = static_cast<TPinballComponent*>(ComponentList->Get(index));
TPinballComponent* obj = ComponentList->Get(index);
if (obj->GroupIndex == groupIndex)
return obj;
}
@ -307,9 +307,9 @@ void TPinballTable::tilt(float time)
loader::play_sound(SoundIndex3);
TiltTimeoutTimer = timer::set(30.0, this, tilt_timeout);
for (int i = 0; i < ComponentList->Count(); i++)
for (int i = 0; i < ComponentList->GetCount(); i++)
{
static_cast<TPinballComponent*>(ComponentList->Get(i))->Message(1011, time);
ComponentList->Get(i)->Message(1011, time);
}
LightGroup->Message(8, 0);
TiltLockFlag = 1;
@ -320,9 +320,9 @@ void TPinballTable::tilt(float time)
void TPinballTable::port_draw()
{
for (int index = ComponentList->Count() - 1; index >= 0; index--)
for (int index = ComponentList->GetCount() - 1; index >= 0; index--)
{
static_cast<TPinballComponent*>(ComponentList->Get(index))->port_draw();
ComponentList->Get(index)->port_draw();
}
}
@ -362,9 +362,9 @@ int TPinballTable::Message(int code, float value)
case 1008:
case 1009:
case 1010:
for (int i = 0; i < ComponentList->Count(); i++)
for (int i = 0; i < ComponentList->GetCount(); i++)
{
static_cast<TPinballComponent*>(ComponentList->Get(i))->Message(code, value);
ComponentList->Get(i)->Message(code, value);
}
break;
case 1012:
@ -406,7 +406,7 @@ int TPinballTable::Message(int code, float value)
{
CheatsUsed = 0;
Message(1024, 0.0);
auto ball = static_cast<TBall*>(BallList->Get(0));
auto ball = BallList->Get(0);
ball->Position.Y = 0.0;
ball->Position.X = 0.0;
ball->Position.Z = -0.8f;
@ -513,9 +513,9 @@ int TPinballTable::Message(int code, float value)
score::set(ScorePlayerNumber1, nextPlayer + 1);
score::update(ScorePlayerNumber1);
for (int i = 0; i < ComponentList->Count(); i++)
for (int i = 0; i < ComponentList->GetCount(); i++)
{
static_cast<TPinballComponent*>(ComponentList->Get(i))->Message(1020, static_cast<float>(nextPlayer));
ComponentList->Get(i)->Message(1020, static_cast<float>(nextPlayer));
}
char* textboxText = nullptr;
@ -564,9 +564,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->Count(); i++)
for (int i = 0; i < ComponentList->GetCount(); i++)
{
static_cast<TPinballComponent*>(ComponentList->Get(i))->Message(1024, 0);
ComponentList->Get(i)->Message(1024, 0);
}
if (ReplayTimer)
timer::kill(ReplayTimer);
@ -608,9 +608,9 @@ void TPinballTable::EndGame_timeout(int timerId, void* caller)
table->EndGameTimeoutTimer = 0;
pb::end_game();
for (int i = 0; i < table->ComponentList->Count(); i++)
for (int i = 0; i < table->ComponentList->GetCount(); i++)
{
static_cast<TPinballComponent*>(table->ComponentList->Get(i))->Message(1022, 0);
table->ComponentList->Get(i)->Message(1022, 0);
}
if (table->Demo)
table->Demo->Message(1022, 0.0);
@ -640,9 +640,9 @@ void TPinballTable::tilt_timeout(int timerId, void* caller)
table->TiltTimeoutTimer = 0;
if (table->TiltLockFlag)
{
for (int i = 0; i < table->BallList->Count(); i++)
for (int i = 0; i < table->BallList->GetCount(); i++)
{
table->Drain->Collision(static_cast<TBall*>(table->BallList->Get(i)), &vec, &vec, 0.0, nullptr);
table->Drain->Collision(table->BallList->Get(i), &vec, &vec, 0.0, nullptr);
}
}
}

View file

@ -2,12 +2,12 @@
#include "TPinballComponent.h"
class TBall;
struct scoreStruct;
class TFlipper;
class TPlunger;
class TDrain;
class TDemo;
class objlist_class;
class TLightGroup;
struct score_struct_super
@ -65,8 +65,8 @@ public:
int YOffset;
int Width;
int Height;
objlist_class* ComponentList;
objlist_class* BallList;
objlist_class<TPinballComponent>* ComponentList;
objlist_class<TBall>* BallList;
TLightGroup* LightGroup;
float GravityDirVectMult;
float GravityAngleX;

View file

@ -5,12 +5,12 @@
#include "control.h"
#include "loader.h"
#include "maths.h"
#include "objlist_class.h"
#include "pb.h"
#include "render.h"
#include "TBall.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
@ -27,7 +27,7 @@ TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent(t
MaxPullback = 100;
Elasticity = 0.5f;
Smoothness = 0.5f;
PullbackIncrement = static_cast<int>(100.0 / (ListBitmap->Count() * 8.0));
PullbackIncrement = static_cast<int>(100.0 / (ListBitmap->GetCount() * 8.0));
Unknown4F = 0.025f;
float* floatArr = loader::query_float_attribute(groupIndex, 0, 601);
table->PlungerPositionX = floatArr[0];
@ -65,8 +65,8 @@ int TPlunger::Message(int code, float value)
PullbackTimer_ = 0;
if (code == 1005)
loader::play_sound(SoundIndexP2);
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(0));
auto bmp = ListBitmap->Get(0);
auto zMap = ListZMap->Get(0);
render::sprite_set(
RenderSprite,
bmp,
@ -79,7 +79,7 @@ int TPlunger::Message(int code, float value)
}
case 1015:
{
auto ball = static_cast<TBall*>(PinballTable->ComponentList->Get(0));
auto ball = PinballTable->BallList->Get(0);
ball->Message(1024, 0.0);
ball->Position.X = PinballTable->PlungerPositionX;
ball->Position.Y = PinballTable->PlungerPositionY;
@ -112,8 +112,8 @@ int TPlunger::Message(int code, float value)
PullbackTimer_ = 0;
if (code == 1005)
loader::play_sound(SoundIndexP2);
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(0));
auto bmp = ListBitmap->Get(0);
auto zMap = ListZMap->Get(0);
render::sprite_set(
RenderSprite,
bmp,
@ -151,10 +151,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->Count() - 1) *
static_cast<float>(plunger->ListBitmap->GetCount() - 1) *
(plunger->Boost / static_cast<float>(plunger->MaxPullback))));
auto bmp = static_cast<gdrv_bitmap8*>(plunger->ListBitmap->Get(index));
auto zMap = static_cast<zmap_header_type*>(plunger->ListZMap->Get(index));
auto bmp = plunger->ListBitmap->Get(index);
auto zMap = plunger->ListZMap->Get(index);
render::sprite_set(
plunger->RenderSprite,
bmp,

View file

@ -4,10 +4,10 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TPopupTarget::TPopupTarget(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
@ -91,7 +91,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, static_cast<gdrv_bitmap8*>(target->ListBitmap->Get(0)));
render::sprite_set_bitmap(target->RenderSprite, target->ListBitmap->Get(0));
if (timerId)
{
if (target->SoftHitSoundId)

View file

@ -5,12 +5,12 @@
#include "control.h"
#include "gdrv.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "TBall.h"
#include "TEdgeSegment.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TRollover::TRollover(TPinballTable* table, int groupIndex, bool createWall) : TCollisionComponent(
table, groupIndex, createWall)
@ -22,7 +22,7 @@ TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent
{
RolloverFlag = 0;
if (ListBitmap)
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
build_walls(groupIndex);
}
@ -34,7 +34,7 @@ int TRollover::Message(int code, float value)
this->ActiveFlag = 1;
this->RolloverFlag = 0;
if (this->ListBitmap)
render::sprite_set_bitmap(this->RenderSprite, static_cast<gdrv_bitmap8*>(this->ListBitmap->Get(0)));
render::sprite_set_bitmap(this->RenderSprite, this->ListBitmap->Get(0));
}
return 0;
}
@ -63,7 +63,7 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
if (ListBitmap)
{
if (!RolloverFlag)
bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
bmp = ListBitmap->Get(0);
render::sprite_set_bitmap(RenderSprite, bmp);
}
}

View file

@ -95,7 +95,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 = static_cast<TBall*>(sink->PinballTable->BallList->Get(0));
auto ball = sink->PinballTable->BallList->Get(0);
ball->CollisionComp = nullptr;
ball->ActiveFlag = 1;
ball->Position.X = sink->BallPosition.X;

View file

@ -4,10 +4,10 @@
#include "control.h"
#include "loader.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TPinballTable.h"
#include "TZmapList.h"
TSoloTarget::TSoloTarget(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
@ -41,8 +41,8 @@ int TSoloTarget::Message(int code, float value)
if (ListBitmap)
{
auto index = 1 - ActiveFlag;
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(index));
auto bmp = ListBitmap->Get(index);
auto zMap = ListZMap->Get(index);
render::sprite_set(
RenderSprite,
bmp,

View file

@ -262,7 +262,7 @@ void TTextBox::Draw()
}
else
{
auto timeLeft = (Message1->TimeLeft());
auto timeLeft = Message1->TimeLeft();
if (timeLeft >= -2.0f)
{
int timer;

View file

@ -3,16 +3,16 @@
#include "control.h"
#include "objlist_class.h"
#include "render.h"
#include "timer.h"
#include "TZmapList.h"
TWall::TWall(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
if (RenderSprite)
render::sprite_set_bitmap(RenderSprite, nullptr);
if (ListBitmap)
BmpPtr = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
BmpPtr = ListBitmap->Get(0);
Timer = 0;
}

View file

@ -1,15 +0,0 @@
#pragma once
#include "objlist_class.h"
class TZmapList : // TImageList, template?
public objlist_class
{
public:
TZmapList(int SizeInt, int growSize): objlist_class(SizeInt, growSize)
{
};
~TZmapList()
{
};
};

View file

@ -290,7 +290,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
break;
}
memset(&pmmioinfo, 0, sizeof(pmmioinfo));
memset(&pmmioinfo, 0, sizeof pmmioinfo);
pmmioinfo.pchBuffer = static_cast<HPSTR>(LockResource(hResData));
if (!pmmioinfo.pchBuffer)
{
@ -319,7 +319,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
}
else if ((dwFlags & 4) != 0)
{
memcpy(&pmmioinfo, szWaveFilename, sizeof(pmmioinfo));
memcpy(&pmmioinfo, szWaveFilename, sizeof pmmioinfo);
hMmio = mmioOpenA(nullptr, &pmmioinfo, 0);
if (!hMmio)
{
@ -667,7 +667,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
if (!channel)
break;
memcpy(&channel->PlayParams, lpMixPlayParams, sizeof(channel->PlayParams));
memcpy(&channel->PlayParams, lpMixPlayParams, sizeof channel->PlayParams);
channel->lpMixWave = channel->PlayParams.lpMixWave;
channel->dwNumSamples = channel->PlayParams.lpMixWave->wh.dwBufferLength;
auto lpData = (unsigned __int8*)channel->PlayParams.lpMixWave->wh.lpData;

View file

@ -597,9 +597,9 @@ TPinballComponent* control::make_component_link(component_tag_base* tag)
return tag->GetComponent();
auto compList = TableG->ComponentList;
for (int index = 0; index < compList->Count(); index++)
for (int index = 0; index < compList->GetCount(); index++)
{
auto comp = static_cast<TPinballComponent*>(compList->Get(index));
auto comp = compList->Get(index);
if (comp->GroupName)
{
if (!strcmp(comp->GroupName, tag->Name))

View file

@ -436,7 +436,7 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vis
if (*floatArr != 600.0)
return 0;
visual->FloatArrCount = (partman::field_size(loader_table, stateId, datFieldTypes::FloatArray) / 4) / 2 - 2;
visual->FloatArrCount = partman::field_size(loader_table, stateId, datFieldTypes::FloatArray) / 4 / 2 - 2;
auto floatVal = static_cast<int>(floor(floatArr[1]) - 1.0);
switch (floatVal)
{

View file

@ -71,9 +71,9 @@ void nudge::_nudge(float xDiff, float yDiff)
auto ballList = pb::MainTable->BallList;
accelMod.X = xDiff * 0.5f;
accelMod.Y = yDiff * 0.5f;
for (auto index = 0; index < ballList->Count(); index++)
for (auto index = 0; index < ballList->GetCount(); index++)
{
auto ball = static_cast<TBall*>(ballList->Get(index));
auto ball = ballList->Get(index);
if (ball->ActiveFlag && !ball->CollisionComp)
{
ball->Acceleration.X = ball->Acceleration.X * ball->Speed;

View file

@ -1,94 +0,0 @@
#include "pch.h"
#include "objlist_class.h"
#include <cstdlib>
#include "memory.h"
// v1 from Ida
objlist_class::objlist_class(int SizeInt, int growSize)
{
ListPtr = objlist_new(SizeInt);
GrowSize = growSize;
}
objlist_class::~objlist_class()
{
if (ListPtr)
memory::free(ListPtr);
}
void objlist_class::Add(void* value)
{
if (this->ListPtr->Count == this->ListPtr->Size)
Grow();
objlist_add_object(ListPtr, value);
}
void objlist_class::Grow()
{
this->ListPtr = objlist_grow(this->ListPtr, this->GrowSize);
}
int objlist_class::Delete(void* value)
{
return objlist_delete_object(ListPtr, value);
}
void* objlist_class::Get(int index)
{
if (index >= ListPtr->Count)
return nullptr;
return this->ListPtr->Array[index];
}
objlist_struct1* objlist_class::objlist_new(int sizeInt)
{
objlist_struct1* result = (objlist_struct1 *)memory::allocate(sizeof(void*) * sizeInt + sizeof(objlist_struct1));
if (!result)
return result;
result->Count = 0;
result->Size = sizeInt;
return result;
}
int objlist_class::objlist_add_object(objlist_struct1* ptrToStruct, void* value)
{
int addIndex = ptrToStruct->Count;
if (addIndex >= ptrToStruct->Size)
return 0;
ptrToStruct->Array[addIndex] = value;
return ++ptrToStruct->Count;
}
objlist_struct1* objlist_class::objlist_grow(objlist_struct1* ptrToStruct, int growSize)
{
objlist_struct1* resultPtr = ptrToStruct;
if (!ptrToStruct)
return resultPtr;
int newSizeInt = growSize + ptrToStruct->Count;
if (newSizeInt <= ptrToStruct->Size)
return resultPtr;
objlist_struct1* resultPtr2 = (objlist_struct1*)memory::realloc(ptrToStruct, sizeof(void*) * newSizeInt + sizeof(objlist_struct1));
if (!resultPtr2)
return resultPtr;
resultPtr = resultPtr2;
resultPtr2->Size = growSize + resultPtr2->Count;
return resultPtr;
}
int objlist_class::objlist_delete_object(objlist_struct1* ptrToStruct, void* value)
{
int count = ptrToStruct->Count;
int index = count - 1;
if (count - 1 < 0)
return 0;
for (void** i = &ptrToStruct->Array[index]; *i != value; --i)
{
if (--index < 0)
return 0;
}
ptrToStruct->Array[index] = ptrToStruct->Array[count - 1];
--ptrToStruct->Count;
return 1;
}

View file

@ -1,28 +1,78 @@
#pragma once
struct objlist_struct1
{
int Size;
int Count;
void* Array[1];
};
#include "memory.h"
template <class T>
class objlist_class
{
public:
objlist_class(int SizeInt, int growSize);
~objlist_class();
void Add(void* value);
void Grow();
int Delete(void* value);
void* Get(int index);
int Count() const { return !ListPtr ? 0 : ListPtr->Count; }
int Size() const { return !ListPtr ? 0 : ListPtr->Size; }
objlist_class(int sizeInt, int growSize)
{
ListPtr = reinterpret_cast<T**>(memory::allocate(sizeof(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 = reinterpret_cast<T**>(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:
objlist_struct1* ListPtr;
T** ListPtr;
int GrowSize;
static objlist_struct1* objlist_new(int sizeInt);
static int objlist_add_object(objlist_struct1* ptrToStruct, void* value);
static objlist_struct1* objlist_grow(objlist_struct1* ptrToStruct, int growSize);
static int objlist_delete_object(objlist_struct1* ptrToStruct, void* value);
int Size;
int Count;
};

View file

@ -94,7 +94,7 @@ int pb::init()
MainTable = new TPinballTable();
high_score::read(highscore_table, &state);
ball_speed_limit = static_cast<TBall*>(MainTable->BallList->Get(0))->Offset * 200.0f;
ball_speed_limit = MainTable->BallList->Get(0)->Offset * 200.0f;
--memory::critical_allocation;
return 0;
}
@ -209,7 +209,7 @@ void pb::replay_level(int demoMode)
void pb::ballset(int x, int y)
{
TBall* ball = static_cast<TBall*>(MainTable->BallList->Get(0));
TBall* ball = MainTable->BallList->Get(0);
ball->Acceleration.X = x * 30.0f;
ball->Acceleration.Y = y * 30.0f;
ball->Speed = maths::normalize_2d(&ball->Acceleration);
@ -257,9 +257,9 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
{
vector_type vec1{}, vec2{};
for (int i = 0; i < MainTable->BallList->Count(); i++)
for (int i = 0; i < MainTable->BallList->GetCount(); i++)
{
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
auto ball = MainTable->BallList->Get(i);
if (ball->ActiveFlag != 0)
{
auto collComp = ball->CollisionComp;
@ -300,9 +300,9 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
if (drawBalls)
{
for (int i = 0; i < MainTable->BallList->Count(); i++)
for (int i = 0; i < MainTable->BallList->GetCount(); i++)
{
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
auto ball = MainTable->BallList->Get(i);
if (ball->ActiveFlag)
ball->Repaint();
}
@ -440,7 +440,7 @@ void pb::keydown(int key)
{
case 'B':
TBall* ball;
if (MainTable->BallList->Count() <= 0)
if (MainTable->BallList->GetCount() <= 0)
{
ball = new TBall(MainTable);
}
@ -448,11 +448,11 @@ void pb::keydown(int key)
{
for (auto index = 0; ;)
{
ball = static_cast<TBall*>(MainTable->BallList->Get(index));
ball = MainTable->BallList->Get(index);
if (!ball->ActiveFlag)
break;
++index;
if (index >= MainTable->BallList->Count())
if (index >= MainTable->BallList->GetCount())
{
ball = new TBall(MainTable);
break;

View file

@ -70,7 +70,7 @@ void score::load_msg_font(LPCSTR lpName)
FreeResource(resGlobal);
return;
}
memset(fontp->Chars, 0, sizeof(fontp->Chars));
memset(fontp->Chars, 0, sizeof fontp->Chars);
auto maxWidth = 0;
auto ptrToWidths = (char*)rcData + 6;