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

Some renames, cleanup partman, loader.

This commit is contained in:
oz 2021-01-28 18:01:26 +03:00
parent 74306179a7
commit 262b098610
40 changed files with 435 additions and 502 deletions

View file

@ -16,7 +16,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
TimeNow = 0.0; TimeNow = 0.0;
RayMaxDistance = 0.0; RayMaxDistance = 0.0;
UnknownBaseFlag2 = 1; ActiveFlag = 1;
CollisionComp = nullptr; CollisionComp = nullptr;
EdgeCollisionCount = 0; EdgeCollisionCount = 0;
TimeDelta = 0.0; TimeDelta = 0.0;
@ -115,7 +115,7 @@ int TBall::Message(int code, float value)
Position.X = 0.0; Position.X = 0.0;
CollisionComp = nullptr; CollisionComp = nullptr;
Position.Y = 0.0; Position.Y = 0.0;
UnknownBaseFlag2 = 0; ActiveFlag = 0;
CollisionFlag = 0; CollisionFlag = 0;
FieldFlag = 1; FieldFlag = 1;
Acceleration.Y = 0.0; Acceleration.Y = 0.0;

View file

@ -20,7 +20,7 @@ TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(t
Threshold = 1000000000.0f; Threshold = 1000000000.0f;
Timer = 0; Timer = 0;
MessageField = 0; MessageField = 0;
UnknownBaseFlag2 = 0; ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
} }
@ -38,13 +38,13 @@ int TBlocker::Message(int code, float value)
Timer = 0; Timer = 0;
} }
MessageField = 0; MessageField = 0;
UnknownBaseFlag2 = 0; ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
if (code == 51) if (code == 51)
loader::play_sound(SoundIndex3); loader::play_sound(SoundIndex3);
return 0; return 0;
case 52: case 52:
UnknownBaseFlag2 = 1; ActiveFlag = 1;
loader::play_sound(SoundIndex4); loader::play_sound(SoundIndex4);
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0))); render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
break; break;

View file

@ -5,8 +5,8 @@
#include "TCollisionComponent.h" #include "TCollisionComponent.h"
#include "TTableLayer.h" #include "TTableLayer.h"
TCircle::TCircle(TCollisionComponent* collComp, char* someFlagPtr, unsigned visualFlag, vector_type* center, TCircle::TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup, vector_type* center,
float radius): TEdgeSegment(collComp, someFlagPtr, visualFlag) float radius): TEdgeSegment(collComp, activeFlag, collisionGroup)
{ {
Circle.RadiusSq = radius * radius; Circle.RadiusSq = radius * radius;
Circle.Center = *center; Circle.Center = *center;

View file

@ -8,7 +8,7 @@ class TCircle :
public: public:
circle_type Circle; circle_type Circle;
TCircle(TCollisionComponent* collComp, char* someFlagPtr, unsigned int visualFlag, vector_type* center, TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, vector_type* center,
float radius); float radius);
float FindCollisionDistance(ray_type* ray) override; float FindCollisionDistance(ray_type* ray) override;
void EdgeCollision(TBall* ball, float coef) override; void EdgeCollision(TBall* ball, float coef) override;

View file

@ -13,9 +13,9 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
visualStruct visual{}; visualStruct visual{};
EdgeList = new objlist_class(4, 4); EdgeList = new objlist_class(4, 4);
UnknownBaseFlag2 = 1; ActiveFlag = 1;
if (GroupName != nullptr) if (GroupName != nullptr)
UnknownBaseFlag1 = 1; UnusedBaseFlag = 1;
if (groupIndex <= 0) if (groupIndex <= 0)
{ {
loader::default_vsi(&visual); loader::default_vsi(&visual);
@ -27,7 +27,7 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
{ {
float offset = table->CollisionCompOffset; float offset = table->CollisionCompOffset;
float* floatArr = loader::query_float_attribute(groupIndex, 0, 600); float* floatArr = loader::query_float_attribute(groupIndex, 0, 600);
TEdgeSegment::install_wall(floatArr, this, &UnknownBaseFlag2, visual.Flag, offset, 0); TEdgeSegment::install_wall(floatArr, this, &ActiveFlag, visual.CollisionGroup, offset, 0);
} }
} }

View file

@ -19,8 +19,8 @@ TDemo::TDemo(TPinballTable* table, int groupIndex)
FlipLeftTimer = 0; FlipLeftTimer = 0;
FlipRightTimer = 0; FlipRightTimer = 0;
MessageField = 0; MessageField = 0;
UnknownBaseFlag1 = 0; UnusedBaseFlag = 0;
UnknownBaseFlag2 = 0; ActiveFlag = 0;
FlipRightFlag = 0; FlipRightFlag = 0;
FlipLeftFlag = 0; FlipLeftFlag = 0;
table->Demo = this; table->Demo = this;
@ -41,19 +41,19 @@ TDemo::TDemo(TPinballTable* table, int groupIndex)
} }
loader::query_visual(groupIndex, 0, &visual); loader::query_visual(groupIndex, 0, &visual);
auto v5 = loader::query_float_attribute(groupIndex, 0, 1400); auto v5 = loader::query_float_attribute(groupIndex, 0, 1400);
Edge1 = TEdgeSegment::install_wall(v5, this, &UnknownBaseFlag2, visual.Flag, 0.0, 1400); Edge1 = TEdgeSegment::install_wall(v5, this, &ActiveFlag, visual.CollisionGroup, 0.0, 1400);
auto v6 = loader::query_float_attribute(groupIndex, 0, 1401); auto v6 = loader::query_float_attribute(groupIndex, 0, 1401);
TEdgeSegment::install_wall(v6, this, &UnknownBaseFlag2, visual.Flag, 0.0, 1401); TEdgeSegment::install_wall(v6, this, &ActiveFlag, visual.CollisionGroup, 0.0, 1401);
auto v7 = loader::query_float_attribute(groupIndex, 0, 1402); auto v7 = loader::query_float_attribute(groupIndex, 0, 1402);
Edge2 = TEdgeSegment::install_wall(v7, this, &UnknownBaseFlag2, visual.Flag, 0.0, 1402); Edge2 = TEdgeSegment::install_wall(v7, this, &ActiveFlag, visual.CollisionGroup, 0.0, 1402);
auto v8 = loader::query_float_attribute(groupIndex, 0, 1403); auto v8 = loader::query_float_attribute(groupIndex, 0, 1403);
TEdgeSegment::install_wall(v8, this, &UnknownBaseFlag2, visual.Flag, 0.0, 1403); TEdgeSegment::install_wall(v8, this, &ActiveFlag, visual.CollisionGroup, 0.0, 1403);
auto v9 = loader::query_float_attribute(groupIndex, 0, 1404); auto v9 = loader::query_float_attribute(groupIndex, 0, 1404);
Edge3 = TEdgeSegment::install_wall(v9, this, &UnknownBaseFlag2, visual.Flag, table->CollisionCompOffset, 1404); Edge3 = TEdgeSegment::install_wall(v9, this, &ActiveFlag, visual.CollisionGroup, table->CollisionCompOffset, 1404);
} }
int TDemo::Message(int code, float value) int TDemo::Message(int code, float value)
@ -69,7 +69,7 @@ int TDemo::Message(int code, float value)
if (RestartGameTimer) if (RestartGameTimer)
timer::kill(RestartGameTimer); timer::kill(RestartGameTimer);
RestartGameTimer = 0; RestartGameTimer = 0;
if (UnknownBaseFlag2 != 0) if (ActiveFlag != 0)
RestartGameTimer = timer::set(5.0, this, NewGameRestartTimer); RestartGameTimer = timer::set(5.0, this, NewGameRestartTimer);
break; break;
case 1024: case 1024:

View file

@ -67,7 +67,7 @@ int TEdgeManager::TestGridBox(int x, int y, float* distPtr, TEdgeSegment** edgeD
for (auto index = edgeBox->EdgeList->Count() - 1; index >= 0; --index) for (auto index = edgeBox->EdgeList->Count() - 1; index >= 0; --index)
{ {
auto edge = static_cast<TEdgeSegment*>(edgeBox->EdgeList->Get(index)); auto edge = static_cast<TEdgeSegment*>(edgeBox->EdgeList->Get(index));
if (!edge->ProcessedFlag && *edge->PinbCompFlag2Ptr && (edge->VisualFlag & ray->FieldFlag)) if (!edge->ProcessedFlag && *edge->ActiveFlag && (edge->CollisionGroup & ray->FieldFlag))
{ {
if (!ball->already_hit(edge)) if (!ball->already_hit(edge))
{ {

View file

@ -6,11 +6,11 @@
#include "TCollisionComponent.h" #include "TCollisionComponent.h"
#include "TLine.h" #include "TLine.h"
TEdgeSegment::TEdgeSegment(TCollisionComponent* collComp, char* someFlag, unsigned visualFlag) TEdgeSegment::TEdgeSegment(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup)
{ {
CollisionComponent = collComp; CollisionComponent = collComp;
PinbCompFlag2Ptr = someFlag; ActiveFlag = activeFlag;
VisualFlag = visualFlag; CollisionGroup = collisionGroup;
ProcessedFlag = 0; ProcessedFlag = 0;
} }
@ -18,9 +18,8 @@ void TEdgeSegment::port_draw()
{ {
} }
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* flagPtr, TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
unsigned int visual_flag, unsigned int collisionGroup, float offset, int wallValue)
float offset, int wallValue)
{ {
vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{}; vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{};
TEdgeSegment* edge = nullptr; TEdgeSegment* edge = nullptr;
@ -33,7 +32,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
center.X = floatArr[1]; center.X = floatArr[1];
center.Y = floatArr[2]; center.Y = floatArr[2];
auto radius = offset + floatArr[3]; auto radius = offset + floatArr[3];
auto circle = new TCircle(collComp, flagPtr, visual_flag, &center, radius); auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius);
edge = circle; edge = circle;
if (circle) if (circle)
@ -51,7 +50,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
start.Y = floatArr[2]; start.Y = floatArr[2];
end.X = floatArr[3]; end.X = floatArr[3];
end.Y = floatArr[4]; end.Y = floatArr[4];
auto line = new TLine(collComp, flagPtr, visual_flag, &start, &end); auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
edge = line; edge = line;
if (line) if (line)
@ -99,7 +98,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
dstVec.Z < 0.0 && offset < 0.0) dstVec.Z < 0.0 && offset < 0.0)
{ {
float radius = offset * 1.001f; float radius = offset * 1.001f;
auto circle = new TCircle(collComp, flagPtr, visual_flag, &center, radius); auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius);
if (circle) if (circle)
{ {
@ -114,7 +113,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
start.Y = floatArrPtr[1]; start.Y = floatArrPtr[1];
end.X = floatArrPtr[2]; end.X = floatArrPtr[2];
end.Y = floatArrPtr[3]; end.Y = floatArrPtr[3];
auto line = new TLine(collComp, flagPtr, visual_flag, &start, &end); auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
edge = line; edge = line;
if (line) if (line)

View file

@ -14,12 +14,12 @@ class TEdgeSegment
{ {
public: public:
TCollisionComponent* CollisionComponent; TCollisionComponent* CollisionComponent;
char* PinbCompFlag2Ptr; char* ActiveFlag;
char ProcessedFlag; char ProcessedFlag;
void* WallValue; void* WallValue;
int VisualFlag; unsigned int CollisionGroup;
TEdgeSegment(TCollisionComponent* collComp, char* someFlag, unsigned int visualFlag); TEdgeSegment(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup);
virtual ~TEdgeSegment() = default; virtual ~TEdgeSegment() = default;
virtual void EdgeCollision(TBall* ball, float coef) = 0; virtual void EdgeCollision(TBall* ball, float coef) = 0;
@ -27,6 +27,6 @@ public:
virtual void place_in_grid() = 0; virtual void place_in_grid() = 0;
virtual float FindCollisionDistance(ray_type* ray) = 0; virtual float FindCollisionDistance(ray_type* ray) = 0;
static TEdgeSegment* install_wall(float* floatArr, TCollisionComponent* collComp, char* flagPtr, static TEdgeSegment* install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
unsigned int visual_flag, float offset, int wallValue); unsigned int collisionGroup, float offset, int wallValue);
}; };

View file

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

View file

@ -32,8 +32,8 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800)); auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800));
auto flipperEdge = new TFlipperEdge( auto flipperEdge = new TFlipperEdge(
this, this,
&UnknownBaseFlag2, &ActiveFlag,
visual.Flag, visual.CollisionGroup,
table, table,
origin, origin,
vecT1, vecT1,

View file

@ -11,9 +11,9 @@ vector_type TFlipperEdge::A1, TFlipperEdge::A2, TFlipperEdge::B1, TFlipperEdge::
line_type TFlipperEdge::lineA, TFlipperEdge::lineB; line_type TFlipperEdge::lineA, TFlipperEdge::lineB;
circle_type TFlipperEdge::circlebase, TFlipperEdge::circleT1; circle_type TFlipperEdge::circlebase, TFlipperEdge::circleT1;
TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* someFlag, unsigned int visualFlag, TPinballTable* table, TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
vector_type* origin, vector_type* vecT1, vector_type* vecT2, float bmpCoef1, float bmpCoef2, vector_type* origin, vector_type* vecT1, vector_type* vecT2, float bmpCoef1, float bmpCoef2,
float collMult, float elasticity, float smoothness): TEdgeSegment(collComp, someFlag, visualFlag) float collMult, float elasticity, float smoothness): TEdgeSegment(collComp, activeFlag, collisionGroup)
{ {
vector_type crossProd{}, vecDir1{}, vecDir2{}; vector_type crossProd{}, vecDir1{}, vecDir2{};

View file

@ -7,7 +7,7 @@ class TPinballTable;
class TFlipperEdge : public TEdgeSegment class TFlipperEdge : public TEdgeSegment
{ {
public: public:
TFlipperEdge(TCollisionComponent* collComp, char* someFlag, unsigned int visualFlag, TPinballTable* table, TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
vector_type* origin, vector_type* vecT1, vector_type* vecT2, float bmpCoef1, float bmpCoef2, float collMult, vector_type* origin, vector_type* vecT1, vector_type* vecT2, float bmpCoef1, float bmpCoef2, float collMult,
float elasticity, float smoothness); float elasticity, float smoothness);
void port_draw() override; void port_draw() override;

View file

@ -14,7 +14,7 @@ TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
loader::query_visual(groupIndex, 0, &visual); loader::query_visual(groupIndex, 0, &visual);
SoundIndex4 = visual.SoundIndex4; SoundIndex4 = visual.SoundIndex4;
SoundIndex3 = visual.SoundIndex3; SoundIndex3 = visual.SoundIndex3;
UnknownBaseFlag2 = 1; ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0))); render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
control::handler(1024, this); control::handler(1024, this);
} }
@ -25,13 +25,13 @@ int TGate::Message(int code, float value)
{ {
if (code == 53) if (code == 53)
{ {
UnknownBaseFlag2 = 0; ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
loader::play_sound(SoundIndex3); loader::play_sound(SoundIndex3);
} }
else if (code == 54 || code == 1024) else if (code == 54 || code == 1024)
{ {
UnknownBaseFlag2 = 1; ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0))); render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
if (code == 54) if (code == 54)
loader::play_sound(SoundIndex4); loader::play_sound(SoundIndex4);

View file

@ -38,7 +38,7 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
if (Circle.RadiusSq == 0.0) if (Circle.RadiusSq == 0.0)
Circle.RadiusSq = 0.001f; Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &UnknownBaseFlag2, visual.Flag, reinterpret_cast<vector_type*>(visual.FloatArr), auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup, reinterpret_cast<vector_type*>(visual.FloatArr),
Circle.RadiusSq); Circle.RadiusSq);
if (tCircle) if (tCircle)
{ {
@ -55,9 +55,9 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
circle.Center.Y = Circle.Center.Y; circle.Center.Y = Circle.Center.Y;
circle.Center.Z = Circle.Center.Z; circle.Center.Z = Circle.Center.Z;
Field.Flag2Ptr = &UnknownBaseFlag2; Field.Flag2Ptr = &ActiveFlag;
Field.CollisionComp = this; Field.CollisionComp = this;
Field.Mask = visual.Flag; Field.Mask = visual.CollisionGroup;
TTableLayer::edges_insert_circle(&circle, nullptr, &Field); TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
} }

View file

@ -19,7 +19,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
NotSomeFlag = !someFlag; NotSomeFlag = !someFlag;
if (!someFlag) if (!someFlag)
UnknownBaseFlag2 = 0; ActiveFlag = 0;
TimerTime1 = 1.5; TimerTime1 = 1.5;
TimerTime2 = 0.05f; TimerTime2 = 0.05f;
MessageField = 0; MessageField = 0;
@ -35,7 +35,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2]; Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2];
if (Circle.RadiusSq == 0.0) if (Circle.RadiusSq == 0.0)
Circle.RadiusSq = 0.001f; Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &UnknownBaseFlag2, visual.Flag, auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq); reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
if (tCircle) if (tCircle)
{ {
@ -54,9 +54,9 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
circle.Center.X = Circle.Center.X; circle.Center.X = Circle.Center.X;
circle.Center.Y = Circle.Center.Y; circle.Center.Y = Circle.Center.Y;
circle.Center.Z = Circle.Center.Z; circle.Center.Z = Circle.Center.Z;
Field.Flag2Ptr = &UnknownBaseFlag2; Field.Flag2Ptr = &ActiveFlag;
Field.CollisionComp = this; Field.CollisionComp = this;
Field.Mask = visual.Flag; Field.Mask = visual.CollisionGroup;
TTableLayer::edges_insert_circle(&circle, nullptr, &Field); TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
} }
@ -74,7 +74,7 @@ int TKickout::Message(int code, float value)
break; break;
case 1011: case 1011:
if (NotSomeFlag) if (NotSomeFlag)
UnknownBaseFlag2 = 0; ActiveFlag = 0;
break; break;
case 1024: case 1024:
if (KickFlag1) if (KickFlag1)
@ -84,7 +84,7 @@ int TKickout::Message(int code, float value)
TimerExpired(0, this); TimerExpired(0, this);
} }
if (NotSomeFlag) if (NotSomeFlag)
UnknownBaseFlag2 = 0; ActiveFlag = 0;
break; break;
default: default:
break; break;
@ -156,7 +156,7 @@ void TKickout::TimerExpired(int timerId, void* caller)
kick->Ball->Position.Z = kick->OriginalBallZ; kick->Ball->Position.Z = kick->OriginalBallZ;
TBall::throw_ball(kick->Ball, &kick->BallAcceleration, kick->ThrowAngleMult, kick->ThrowSpeedMult1, TBall::throw_ball(kick->Ball, &kick->BallAcceleration, kick->ThrowAngleMult, kick->ThrowSpeedMult1,
kick->ThrowSpeedMult2); kick->ThrowSpeedMult2);
kick->UnknownBaseFlag2 = 0; kick->ActiveFlag = 0;
kick->Ball = nullptr; kick->Ball = nullptr;
loader::play_sound(kick->HardHitSoundId); loader::play_sound(kick->HardHitSoundId);
} }
@ -167,6 +167,6 @@ void TKickout::ResetTimerExpired(int timerId, void* caller)
{ {
auto kick = static_cast<TKickout*>(caller); auto kick = static_cast<TKickout*>(caller);
if (!kick->NotSomeFlag) if (!kick->NotSomeFlag)
kick->UnknownBaseFlag2 = 1; kick->ActiveFlag = 1;
kick->Timer = 0; kick->Timer = 0;
} }

View file

@ -87,7 +87,7 @@ int TLight::Message(int code, float value)
FlasherActive = 1; FlasherActive = 1;
FlasherFlag2 = 0; FlasherFlag2 = 0;
FlasherFlag1 = 0; FlasherFlag1 = 0;
Unknown13 = 0; TurnOffAfterFlashingFg = 0;
flasher_start(&Flasher, BmpIndex1); flasher_start(&Flasher, BmpIndex1);
} }
break; break;
@ -104,7 +104,7 @@ int TLight::Message(int code, float value)
flasher_start(&Flasher, BmpIndex1); flasher_start(&Flasher, BmpIndex1);
FlasherActive = 1; FlasherActive = 1;
FlasherFlag2 = 0; FlasherFlag2 = 0;
Unknown13 = 0; TurnOffAfterFlashingFg = 0;
FlasherFlag1 = 0; FlasherFlag1 = 0;
schedule_timeout(value); schedule_timeout(value);
break; break;
@ -191,7 +191,7 @@ int TLight::Message(int code, float value)
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[BmpIndex1]); render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[BmpIndex1]);
break; break;
case 15: case 15:
Unknown13 = 0; TurnOffAfterFlashingFg = 0;
if (Timer2) if (Timer2)
timer::kill(Timer2); timer::kill(Timer2);
Timer2 = 0; Timer2 = 0;
@ -203,7 +203,7 @@ int TLight::Message(int code, float value)
timer::kill(Timer2); timer::kill(Timer2);
Timer2 = 0; Timer2 = 0;
Message(7, value); Message(7, value);
Unknown13 = 1; TurnOffAfterFlashingFg = 1;
break; break;
case 17: case 17:
Message(static_cast<int>(floor(value)) != 0, 0.0); Message(static_cast<int>(floor(value)) != 0, 0.0);
@ -252,7 +252,7 @@ void TLight::Reset()
FlasherFlag1 = 0; FlasherFlag1 = 0;
FlasherFlag2 = 0; FlasherFlag2 = 0;
FlasherActive = 0; FlasherActive = 0;
Unknown13 = 0; TurnOffAfterFlashingFg = 0;
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
Flasher.Sprite = RenderSprite; Flasher.Sprite = RenderSprite;
Flasher.BmpArr[0] = nullptr; Flasher.BmpArr[0] = nullptr;
@ -284,9 +284,9 @@ void TLight::TimerExpired(int timerId, void* caller)
light->FlasherFlag2 = 0; light->FlasherFlag2 = 0;
light->FlasherActive = 0; light->FlasherActive = 0;
light->Timer1 = 0; light->Timer1 = 0;
if (light->Unknown13 != 0) if (light->TurnOffAfterFlashingFg != 0)
{ {
light->Unknown13 = 0; light->TurnOffAfterFlashingFg = 0;
light->Message(20, 0.0); light->Message(20, 0.0);
} }
if (light->Control) if (light->Control)

View file

@ -45,7 +45,7 @@ public:
int FlasherActive; int FlasherActive;
int FlasherFlag1; int FlasherFlag1;
int FlasherFlag2; int FlasherFlag2;
int Unknown13; int TurnOffAfterFlashingFg;
int BmpIndex2; int BmpIndex2;
float FlasherDelay[2]; float FlasherDelay[2];
int Timer1; int Timer1;

View file

@ -24,7 +24,7 @@ int TLightRollover::Message(int code, float value)
{ {
if (code == 1024) if (code == 1024)
{ {
UnknownBaseFlag2 = 1; ActiveFlag = 1;
RolloverFlag = 0; RolloverFlag = 0;
if (Timer) if (Timer)
timer::kill(Timer); timer::kill(Timer);
@ -47,7 +47,7 @@ void TLightRollover::Collision(TBall* ball, vector_type* nextPosition, vector_ty
if (RolloverFlag) if (RolloverFlag)
{ {
timer::set(0.1f, this, TimerExpired); timer::set(0.1f, this, TimerExpired);
UnknownBaseFlag2 = 0; ActiveFlag = 0;
RolloverFlag = RolloverFlag == 0; RolloverFlag = RolloverFlag == 0;
if (Timer == 0) if (Timer == 0)
Timer = timer::set(FloatArr, this, delay_expired); Timer = timer::set(FloatArr, this, delay_expired);

View file

@ -4,8 +4,8 @@
#include "TTableLayer.h" #include "TTableLayer.h"
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, float x0, float y0, float x1, TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1,
float y1): TEdgeSegment(collCmp, flagPtr, visualFlag) float y1): TEdgeSegment(collCmp, activeFlag, collisionGroup)
{ {
X0 = x0; X0 = x0;
Y0 = y0; Y0 = y0;
@ -14,8 +14,8 @@ TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFla
maths::line_init(&Line, x0, y0, x1, y1); maths::line_init(&Line, x0, y0, x1, y1);
} }
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, struct vector_type* start, TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, struct vector_type* start,
struct vector_type* end) : TEdgeSegment(collCmp, flagPtr, visualFlag) struct vector_type* end) : TEdgeSegment(collCmp, activeFlag, collisionGroup)
{ {
X0 = start->X; X0 = start->X;
Y0 = start->Y; Y0 = start->Y;

View file

@ -8,8 +8,8 @@ class TLine :
public: public:
line_type Line; line_type Line;
float X0, Y0, X1, Y1; float X0, Y0, X1, Y1;
TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, float x0, float y0, float x1, float y1); TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1);
TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, vector_type* start, vector_type* end); TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector_type* start, vector_type* end);
void Offset(float offset); void Offset(float offset);
float FindCollisionDistance(ray_type* ray) override; float FindCollisionDistance(ray_type* ray) override;
void EdgeCollision(TBall* ball, float coef) override; void EdgeCollision(TBall* ball, float coef) override;

View file

@ -22,7 +22,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
linePt1.X = visual.FloatArr[2]; linePt1.X = visual.FloatArr[2];
linePt1.Y = visual.FloatArr[3]; linePt1.Y = visual.FloatArr[3];
auto line = new TLine(this, &UnknownBaseFlag2, visual.Flag, &linePt2, &linePt1); auto line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt2, &linePt1);
if (line) if (line)
{ {
line->Offset(table->CollisionCompOffset); line->Offset(table->CollisionCompOffset);
@ -30,7 +30,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
EdgeList->Add(line); EdgeList->Add(line);
} }
line = new TLine(this, &UnknownBaseFlag2, visual.Flag, &linePt1, &linePt2); line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);
Line = line; Line = line;
if (line) if (line)
{ {

View file

@ -11,8 +11,8 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
visualStruct visual{}; visualStruct visual{};
MessageField = 0; MessageField = 0;
UnknownBaseFlag1 = 0; UnusedBaseFlag = 0;
UnknownBaseFlag2 = 0; ActiveFlag = 0;
PinballTable = table; PinballTable = table;
RenderSprite = nullptr; RenderSprite = nullptr;
ListBitmap = nullptr; ListBitmap = nullptr;

View file

@ -26,8 +26,8 @@ public:
void* operator new(size_t Size); void* operator new(size_t Size);
void operator delete(void* p); void operator delete(void* p);
__int8 UnknownBaseFlag1; __int8 UnusedBaseFlag;
__int8 UnknownBaseFlag2; __int8 ActiveFlag;
int MessageField; int MessageField;
char* GroupName; char* GroupName;
int Unknown4; int Unknown4;

View file

@ -54,7 +54,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
ScoreBallcount = nullptr; ScoreBallcount = nullptr;
ScorePlayerNumber1 = nullptr; ScorePlayerNumber1 = nullptr;
BallInSink = 0; BallInSink = 0;
UnknownBaseFlag2 = 1; ActiveFlag = 1;
TiltLockFlag = 0; TiltLockFlag = 0;
EndGameTimeoutTimer = 0; EndGameTimeoutTimer = 0;
LightShowTimer = 0; LightShowTimer = 0;
@ -66,7 +66,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
auto ballObj = new TBall(this); auto ballObj = new TBall(this);
BallList->Add(ballObj); BallList->Add(ballObj);
if (ballObj) if (ballObj)
ballObj->UnknownBaseFlag2 = 0; ballObj->ActiveFlag = 0;
new TTableLayer(this); new TTableLayer(this);
LightGroup = new TLightGroup(this, 0); LightGroup = new TLightGroup(this, 0);
@ -381,7 +381,7 @@ int TPinballTable::Message(int code, float value)
LightGroup->Message(34, 0.0); LightGroup->Message(34, 0.0);
LightGroup->Message(20, 0.0); LightGroup->Message(20, 0.0);
Plunger->Message(1016, 0.0); Plunger->Message(1016, 0.0);
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
rc_text = pinball::get_rc_string(30, 0); rc_text = pinball::get_rc_string(30, 0);
else else
rc_text = pinball::get_rc_string(26, 0); rc_text = pinball::get_rc_string(26, 0);
@ -478,7 +478,7 @@ int TPinballTable::Message(int code, float value)
if (PlayerCount <= 1) if (PlayerCount <= 1)
{ {
char* textboxText; char* textboxText;
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(30, 0); textboxText = pinball::get_rc_string(30, 0);
else else
textboxText = pinball::get_rc_string(26, 0); textboxText = pinball::get_rc_string(26, 0);
@ -522,25 +522,25 @@ int TPinballTable::Message(int code, float value)
switch (nextPlayer) switch (nextPlayer)
{ {
case 0: case 0:
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(30, 0); textboxText = pinball::get_rc_string(30, 0);
else else
textboxText = pinball::get_rc_string(26, 0); textboxText = pinball::get_rc_string(26, 0);
break; break;
case 1: case 1:
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(31, 0); textboxText = pinball::get_rc_string(31, 0);
else else
textboxText = pinball::get_rc_string(27, 0); textboxText = pinball::get_rc_string(27, 0);
break; break;
case 2: case 2:
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(32, 0); textboxText = pinball::get_rc_string(32, 0);
else else
textboxText = pinball::get_rc_string(28, 0); textboxText = pinball::get_rc_string(28, 0);
break; break;
case 3: case 3:
if (Demo->UnknownBaseFlag2) if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(33, 0); textboxText = pinball::get_rc_string(33, 0);
else else
textboxText = pinball::get_rc_string(29, 0); textboxText = pinball::get_rc_string(29, 0);

View file

@ -83,7 +83,7 @@ int TPlunger::Message(int code, float value)
ball->Message(1024, 0.0); ball->Message(1024, 0.0);
ball->Position.X = PinballTable->PlungerPositionX; ball->Position.X = PinballTable->PlungerPositionX;
ball->Position.Y = PinballTable->PlungerPositionY; ball->Position.Y = PinballTable->PlungerPositionY;
ball->UnknownBaseFlag2 = 1; ball->ActiveFlag = 1;
PinballTable->BallInSink = 0; PinballTable->BallInSink = 0;
pb::tilt_no_more(); pb::tilt_no_more();
control::handler(code, this); control::handler(code, this);

View file

@ -20,7 +20,7 @@ int TPopupTarget::Message(int code, float value)
switch (code) switch (code)
{ {
case 49: case 49:
this->UnknownBaseFlag2 = 0; this->ActiveFlag = 0;
render::sprite_set_bitmap(this->RenderSprite, nullptr); render::sprite_set_bitmap(this->RenderSprite, nullptr);
break; break;
case 50: case 50:
@ -90,7 +90,7 @@ void TPopupTarget::TimerExpired(int timerId, void* caller)
{ {
auto target = static_cast<TPopupTarget*>(caller); auto target = static_cast<TPopupTarget*>(caller);
target->Timer = 0; target->Timer = 0;
target->UnknownBaseFlag2 = 1; target->ActiveFlag = 1;
render::sprite_set_bitmap(target->RenderSprite, static_cast<gdrv_bitmap8*>(target->ListBitmap->Get(0))); render::sprite_set_bitmap(target->RenderSprite, static_cast<gdrv_bitmap8*>(target->ListBitmap->Get(0)));
if (timerId) if (timerId)
{ {

View file

@ -18,9 +18,9 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
vector_type end{}, start{}, *end2, *start2, *start3, *end3; vector_type end{}, start{}, *end2, *start2, *start3, *end3;
MessageField = 0; MessageField = 0;
UnknownBaseFlag1 = 1; UnusedBaseFlag = 1;
loader::query_visual(groupIndex, 0, &visual); loader::query_visual(groupIndex, 0, &visual);
VisualFlag = visual.Flag; CollisionGroup = visual.CollisionGroup;
auto floatArr1 = loader::query_float_attribute(groupIndex, 0, 701); auto floatArr1 = loader::query_float_attribute(groupIndex, 0, 701);
if (floatArr1) if (floatArr1)
@ -42,7 +42,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
end.Y = floatArr4[3]; end.Y = floatArr4[3];
start.X = floatArr4[4]; start.X = floatArr4[4];
start.Y = floatArr4[5]; start.Y = floatArr4[5];
Line1 = new TLine(this, &UnknownBaseFlag2, 1 << static_cast<int>(floor(floatArr4[0])), &start, &end); Line1 = new TLine(this, &ActiveFlag, 1 << static_cast<int>(floor(floatArr4[0])), &start, &end);
EdgeList->Add(Line1); EdgeList->Add(Line1);
if (Line1) if (Line1)
{ {
@ -60,7 +60,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
reinterpret_cast<wall_point_type*>(floatArr5WallPoint + 3), reinterpret_cast<wall_point_type*>(floatArr5WallPoint + 3),
&end2, &end2,
&start2); &start2);
Line2 = new TLine(this, &UnknownBaseFlag2, VisualFlag, start2, end2); Line2 = new TLine(this, &ActiveFlag, CollisionGroup, start2, end2);
EdgeList->Add(Line2); EdgeList->Add(Line2);
if (Line2) if (Line2)
{ {
@ -78,7 +78,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
reinterpret_cast<wall_point_type*>(floatArr6WallPoint + 3), reinterpret_cast<wall_point_type*>(floatArr6WallPoint + 3),
&end3, &end3,
&start3); &start3);
Line3 = new TLine(this, &UnknownBaseFlag2, VisualFlag, start3, end3); Line3 = new TLine(this, &ActiveFlag, CollisionGroup, start3, end3);
EdgeList->Add(Line3); EdgeList->Add(Line3);
if (Line3) if (Line3)
{ {
@ -107,25 +107,25 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
for (auto pt = 0; pt < 3; pt++) for (auto pt = 0; pt < 3; pt++)
{ {
auto point1 = pointOrder[pt], point2 = pointOrder[pt + 1]; auto point1 = pointOrder[pt], point2 = pointOrder[pt + 1];
auto lineFlag = 0; auto collisionGroup = 0;
if (point1 != end2 || point2 != start2) if (point1 != end2 || point2 != start2)
{ {
if (point1 != end3 || point2 != start3) if (point1 != end3 || point2 != start3)
{ {
lineFlag = visual.Flag; collisionGroup = visual.CollisionGroup;
} }
else if (wall2Pt1_2) else if (wall2Pt1_2)
{ {
lineFlag = Wall2PointFirst; collisionGroup = Wall2PointFirst;
} }
} }
else if (wallPt1_2) else if (wallPt1_2)
{ {
lineFlag = Wall1PointFirst; collisionGroup = Wall1PointFirst;
} }
if (lineFlag) if (collisionGroup)
{ {
auto line = new TLine(this, &UnknownBaseFlag2, lineFlag, point1, point2); auto line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2);
EdgeList->Add(line); EdgeList->Add(line);
if (line) if (line)
{ {
@ -141,9 +141,9 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
PinballTable->GravityDirVectMult; PinballTable->GravityDirVectMult;
} }
Field.Flag2Ptr = &UnknownBaseFlag2; Field.Flag2Ptr = &ActiveFlag;
Field.CollisionComp = this; Field.CollisionComp = this;
Field.Mask = visual.Flag; Field.Mask = visual.CollisionGroup;
auto x1 = xMax; auto x1 = xMax;
auto y1 = yMax; auto y1 = yMax;
@ -181,7 +181,7 @@ void TRamp::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
ball->RampFieldForce.Y = plane->FieldForce.Y; ball->RampFieldForce.Y = plane->FieldForce.Y;
ball->Position.Z = ball->Position.X * ball->CollisionOffset.X + ball->Position.Y * ball->CollisionOffset.Y + ball->Position.Z = ball->Position.X * ball->CollisionOffset.X + ball->Position.Y * ball->CollisionOffset.Y +
ball->Offset + ball->CollisionOffset.Z; ball->Offset + ball->CollisionOffset.Z;
ball->FieldFlag = VisualFlag; ball->FieldFlag = CollisionGroup;
return; return;
} }

View file

@ -19,7 +19,7 @@ public:
int Scores[4]; int Scores[4];
field_effect_type Field; field_effect_type Field;
int VisualFlag; int CollisionGroup;
int RampFlag1; int RampFlag1;
int RampPlaneCount; int RampPlaneCount;
float BallFieldMult; float BallFieldMult;

View file

@ -31,7 +31,7 @@ int TRollover::Message(int code, float value)
{ {
if (code == 1024) if (code == 1024)
{ {
this->UnknownBaseFlag2 = 1; this->ActiveFlag = 1;
this->RolloverFlag = 0; this->RolloverFlag = 0;
if (this->ListBitmap) if (this->ListBitmap)
render::sprite_set_bitmap(this->RenderSprite, static_cast<gdrv_bitmap8*>(this->ListBitmap->Get(0))); render::sprite_set_bitmap(this->RenderSprite, static_cast<gdrv_bitmap8*>(this->ListBitmap->Get(0)));
@ -52,7 +52,7 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
if (RolloverFlag) if (RolloverFlag)
{ {
timer::set(0.1f, this, TimerExpired); timer::set(0.1f, this, TimerExpired);
UnknownBaseFlag2 = 0; ActiveFlag = 0;
} }
else else
{ {
@ -87,13 +87,13 @@ void TRollover::build_walls(int groupIndex)
loader::query_visual(groupIndex, 0, &visual); loader::query_visual(groupIndex, 0, &visual);
float* arr1 = loader::query_float_attribute(groupIndex, 0, 600); float* arr1 = loader::query_float_attribute(groupIndex, 0, 600);
TEdgeSegment::install_wall(arr1, this, &UnknownBaseFlag2, visual.Flag, 0.0, 600); TEdgeSegment::install_wall(arr1, this, &ActiveFlag, visual.CollisionGroup, 0.0, 600);
float* arr2 = loader::query_float_attribute(groupIndex, 0, 603); float* arr2 = loader::query_float_attribute(groupIndex, 0, 603);
TEdgeSegment::install_wall(arr2, this, &RolloverFlag, visual.Flag, 0.0, 603); TEdgeSegment::install_wall(arr2, this, &RolloverFlag, visual.CollisionGroup, 0.0, 603);
} }
void TRollover::TimerExpired(int timerId, void* caller) void TRollover::TimerExpired(int timerId, void* caller)
{ {
auto roll = static_cast<TRollover*>(caller); auto roll = static_cast<TRollover*>(caller);
roll->UnknownBaseFlag2 = 1; roll->ActiveFlag = 1;
} }

View file

@ -85,7 +85,7 @@ void TSink::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
} }
else else
{ {
ball->UnknownBaseFlag2 = 0; ball->ActiveFlag = 0;
render::sprite_set_bitmap(ball->RenderSprite, nullptr); render::sprite_set_bitmap(ball->RenderSprite, nullptr);
loader::play_sound(SoundIndex4); loader::play_sound(SoundIndex4);
control::handler(63, this); control::handler(63, this);
@ -97,7 +97,7 @@ void TSink::TimerExpired(int timerId, void* caller)
auto sink = static_cast<TSink*>(caller); auto sink = static_cast<TSink*>(caller);
auto ball = static_cast<TBall*>(sink->PinballTable->BallList->Get(0)); auto ball = static_cast<TBall*>(sink->PinballTable->BallList->Get(0));
ball->CollisionComp = nullptr; ball->CollisionComp = nullptr;
ball->UnknownBaseFlag2 = 1; ball->ActiveFlag = 1;
ball->Position.X = sink->BallPosition.X; ball->Position.X = sink->BallPosition.X;
ball->Position.Y = sink->BallPosition.Y; ball->Position.Y = sink->BallPosition.Y;
TBall::throw_ball(ball, &sink->BallAcceleration, sink->ThrowAngleMult, sink->ThrowSpeedMult1, TBall::throw_ball(ball, &sink->BallAcceleration, sink->ThrowAngleMult, sink->ThrowSpeedMult1,

View file

@ -26,13 +26,13 @@ int TSoloTarget::Message(int code, float value)
{ {
case 49: case 49:
case 50: case 50:
UnknownBaseFlag2 = code == 50; ActiveFlag = code == 50;
break; break;
case 1024: case 1024:
if (Timer) if (Timer)
timer::kill(Timer); timer::kill(Timer);
Timer = 0; Timer = 0;
UnknownBaseFlag2 = 1; ActiveFlag = 1;
break; break;
default: default:
return 0; return 0;
@ -40,7 +40,7 @@ int TSoloTarget::Message(int code, float value)
if (ListBitmap) if (ListBitmap)
{ {
auto index = 1 - UnknownBaseFlag2; auto index = 1 - ActiveFlag;
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index)); auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index));
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(index)); auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(index));
render::sprite_set( render::sprite_set(

View file

@ -77,8 +77,8 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--) for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
{ {
auto line = new TLine(this, auto line = new TLine(this,
&UnknownBaseFlag2, &ActiveFlag,
visual.Flag, visual.CollisionGroup,
visArrPtr[2], visArrPtr[2],
visArrPtr[3], visArrPtr[3],
visArrPtr[0], visArrPtr[0],
@ -93,7 +93,7 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
} }
Field.Mask = -1; Field.Mask = -1;
Field.Flag2Ptr = &UnknownBaseFlag2; Field.Flag2Ptr = &ActiveFlag;
Field.CollisionComp = this; Field.CollisionComp = this;
edges_insert_square(Unknown2F, Unknown1F, Unknown4F, Unknown3F, nullptr, edges_insert_square(Unknown2F, Unknown1F, Unknown4F, Unknown3F, nullptr,
&Field); &Field);

View file

@ -1917,7 +1917,7 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller)
sprintf_s(Buffer, pinball::get_rc_string(81, 0), addedScore); sprintf_s(Buffer, pinball::get_rc_string(81, 0), addedScore);
control_info_text_box_tag.Component->Display(Buffer, 2.0); control_info_text_box_tag.Component->Display(Buffer, 2.0);
control_lite62_tag.Component->Message(20, 0.0); control_lite62_tag.Component->Message(20, 0.0);
caller->UnknownBaseFlag2 = 0; caller->ActiveFlag = 0;
auto duration = control_soundwave7_tag.Component->Play(); auto duration = control_soundwave7_tag.Component->Play();
caller->Message(55, duration); caller->Message(55, duration);
break; break;
@ -1935,11 +1935,11 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller)
} }
control_info_text_box_tag.Component->Display(Buffer, 2.0); control_info_text_box_tag.Component->Display(Buffer, 2.0);
control_lite62_tag.Component->Message(4, 0.0); control_lite62_tag.Component->Message(4, 0.0);
control_kickout1_tag.Component->UnknownBaseFlag2 = 1; control_kickout1_tag.Component->ActiveFlag = 1;
break; break;
} }
case 1024: case 1024:
control_kickout1_tag.Component->UnknownBaseFlag2 = 0; control_kickout1_tag.Component->ActiveFlag = 0;
break; break;
} }
} }

View file

@ -7,23 +7,8 @@
#include "zdrv.h" #include "zdrv.h"
/*_loader_errors dd 0, offset aBadHandle, 1, offset aNoTypeField, 2, offset aNoAttributesFi errorMsg loader::loader_errors[] =
{
dd 0Bh, offset aNoFloatAttribu, 3, offset aWrongTypeMater; "Unknown" ...
dd 4, offset aWrongTypeKicke, 5, offset aWrongTypeAnObj, 6
dd offset aWrongTypeAStat, 7, offset aStatesReDefine, 9, offset aUnrecognizedAt
dd 0Ah, offset aUnrecognizedFl, 0Dh, offset aFloatAttribute
dd 0Ch, offset aStateIndexOutO, 0Fh, offset aLoaderMaterial_0
dd 0Eh, offset aLoaderKickerRe, 10h, offset aLoaderStateIdR
dd 8, offset aWallsDoesnTMat, 11h, offset aLoaderQueryVis_0
dd 12h, offset aLoaderQueryVis, 15h, offset aLoaderMaterial
dd 14h, offset aLoaderKicker, 16h, offset aLoaderQueryAtt
dd 17h, offset aLoaderQueryIat, 13h, offset aLoaderQueryNam
dd 18h, offset aLoaderStateId, 19h, offset aLoaderGetSound
dd 1Ah, offset aSoundReference, 0FFFFFFFFh, offset aUnknown*/
errorMsg loader::loader_errors[] = {
errorMsg{0, "Bad Handle"}, errorMsg{0, "Bad Handle"},
errorMsg{1, "No Type Field"}, errorMsg{1, "No Type Field"},
errorMsg{2, "No Attributes Field"}, errorMsg{2, "No Attributes Field"},
@ -82,63 +67,48 @@ int loader::error(int errorCode, int captionCode)
return -1; return -1;
} }
void loader::default_vsi(visualStruct* visual) void loader::default_vsi(visualStruct* visual)
{ {
visual->Flag = 0; visual->CollisionGroup = 0;
visual->Kicker.Threshold = 8.9999999e10f; visual->Kicker.Threshold = 8.9999999e10f;
visual->Kicker.HardHitSoundId = 0; visual->Kicker.HardHitSoundId = 0;
visual->Smoothness = 0.94999999f; visual->Smoothness = 0.94999999f;
visual->Elasticity = 0.60000002f; visual->Elasticity = 0.60000002f;
visual->FloatArrCount = 0; visual->FloatArrCount = 0;
visual->SoftHitSoundId = 0; visual->SoftHitSoundId = 0;
visual->Bitmap = 0; visual->Bitmap = nullptr;
visual->ZMap = 0; visual->ZMap = nullptr;
visual->SoundIndex3 = 0; visual->SoundIndex3 = 0;
visual->SoundIndex4 = 0; visual->SoundIndex4 = 0;
} }
void loader::loadfrom(datFileStruct* datFile) void loader::loadfrom(datFileStruct* datFile)
{ {
int groupIndex = 0;
loader_table = datFile; loader_table = datFile;
sound_record_table = loader_table; sound_record_table = loader_table;
int soundIndex = sound_count;
if (datFile->NumberOfGroups > 0) for (auto groupIndex = 0; groupIndex < datFile->NumberOfGroups; ++groupIndex)
{ {
do auto value = reinterpret_cast<__int16*>(partman::field(datFile, groupIndex, datFieldTypes::ShortValue));
if (value && *value == 202)
{ {
__int16* value = (__int16*)partman::field(datFile, groupIndex, datFieldTypes::ShortValue); if (sound_count < 65)
if (value && *value == 202)
{ {
soundIndex = sound_count; sound_list[sound_count].WavePtr = nullptr;
if (sound_count < 65) sound_list[sound_count].GroupIndex = groupIndex;
{ sound_count++;
sound_list[soundIndex].WavePtr = nullptr;
sound_list[soundIndex].GroupIndex = groupIndex;
sound_count = ++soundIndex;
}
} }
++groupIndex;
} }
while (groupIndex < datFile->NumberOfGroups);
} }
loader_sound_count = soundIndex; loader_sound_count = sound_count;
} }
void loader::unload() void loader::unload()
{ {
int index = 1; int index;
if (sound_count > 1) for (index = 1; index < sound_count; ++index)
{ Sound::FreeSound(sound_list[index].WavePtr);
soundListStruct* soundListPtr = &sound_list[1];
do
{
Sound::FreeSound(soundListPtr->WavePtr);
++index;
++soundListPtr;
}
while (index < sound_count);
}
if (sound_list[index].PtrToSmth) if (sound_list[index].PtrToSmth)
memory::free(sound_list[index].PtrToSmth); memory::free(sound_list[index].PtrToSmth);
sound_count = 1; sound_count = 1;
@ -146,45 +116,45 @@ void loader::unload()
int loader::get_sound_id(int groupIndex) int loader::get_sound_id(int groupIndex)
{ {
int result;
__int16 soundIndex = 1; __int16 soundIndex = 1;
if (sound_count <= 1) if (sound_count <= 1)
{ {
error(25, 26); error(25, 26);
result = -1; return -1;
} }
else
while (sound_list[soundIndex].GroupIndex != groupIndex)
{ {
while (sound_list[soundIndex].GroupIndex != groupIndex) ++soundIndex;
if (soundIndex >= sound_count)
{ {
++soundIndex; error(25, 26);
if (soundIndex >= sound_count) return -1;
{
error(25, 26);
return -1;
}
} }
if (!sound_list[soundIndex].Loaded && !sound_list[soundIndex].WavePtr)
{
int soundGroupId = sound_list[soundIndex].GroupIndex;
sound_list[soundIndex].Duration = 0.0;
if (soundGroupId > 0 && !pinball::quickFlag)
{
__int16* value = (__int16*)partman::field(loader_table, soundGroupId, datFieldTypes::ShortValue);
if (value && *value == 202)
{
const CHAR* fileName = partman::field(loader_table, soundGroupId, datFieldTypes::String);
HFILE hFile = _lopen(fileName, 0);
sound_list[soundIndex].Duration = (float)((double)_llseek(hFile, 0, 2) * 0.0000909090909090909);
_lclose(hFile);
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(fileName);
}
}
}
++sound_list[soundIndex].Loaded;
result = soundIndex;
} }
return result;
if (!sound_list[soundIndex].Loaded && !sound_list[soundIndex].WavePtr)
{
int soundGroupId = sound_list[soundIndex].GroupIndex;
sound_list[soundIndex].Duration = 0.0;
if (soundGroupId > 0 && !pinball::quickFlag)
{
auto value = reinterpret_cast<__int16*>(partman::field(loader_table, soundGroupId,
datFieldTypes::ShortValue));
if (value && *value == 202)
{
auto fileName = partman::field(loader_table, soundGroupId, datFieldTypes::String);
HFILE hFile = _lopen(fileName, 0);
sound_list[soundIndex].Duration = static_cast<float>(static_cast<double>(_llseek(hFile, 0, SEEK_END)) *
0.0000909090909090909);
_lclose(hFile);
sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(fileName);
}
}
}
++sound_list[soundIndex].Loaded;
return soundIndex;
} }
@ -198,7 +168,7 @@ short loader::query_visual_states(int groupIndex)
short result; short result;
if (groupIndex < 0) if (groupIndex < 0)
return error(0, 17); return error(0, 17);
__int16* shortArr = (__int16*)partman::field(loader_table, groupIndex, datFieldTypes::ShortArray); auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortArray));
if (shortArr && *shortArr == 100) if (shortArr && *shortArr == 100)
result = shortArr[1]; result = shortArr[1];
else else
@ -208,114 +178,100 @@ short loader::query_visual_states(int groupIndex)
char* loader::query_name(int groupIndex) char* loader::query_name(int groupIndex)
{ {
if (groupIndex >= 0) if (groupIndex < 0)
return partman::field(loader_table, groupIndex, datFieldTypes::GroupName); {
error(0, 19); error(0, 19);
return nullptr; return nullptr;
}
return partman::field(loader_table, groupIndex, datFieldTypes::GroupName);
} }
__int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize) __int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize)
{ {
__int16* result; if (groupIndex < 0)
__int16 skipIndex = 0;
if (groupIndex >= 0)
{
while (true)
{
__int16* shortArr = (__int16*)partman::field_nth(loader_table, groupIndex, datFieldTypes::ShortArray, skipIndex);
if (!shortArr)
break;
if (*shortArr == firstValue)
{
*arraySize = partman::field_size(loader_table, groupIndex, datFieldTypes::ShortArray) / 2 - 1;
return shortArr + 1;
}
++skipIndex;
}
error(2, 23);
*arraySize = 0;
result = nullptr;
}
else
{ {
error(0, 22); error(0, 22);
result = nullptr; return nullptr;
} }
return result;
for (auto skipIndex = 0;; ++skipIndex)
{
auto shortArr = reinterpret_cast<__int16*>(partman::field_nth(loader_table, groupIndex,
datFieldTypes::ShortArray, skipIndex));
if (!shortArr)
break;
if (*shortArr == firstValue)
{
*arraySize = partman::field_size(loader_table, groupIndex, datFieldTypes::ShortArray) / 2 - 1;
return shortArr + 1;
}
}
error(2, 23);
*arraySize = 0;
return nullptr;
} }
float* loader::query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue) float* loader::query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue)
{ {
float* result; if (groupIndex < 0)
__int16 skipIndex = 0;
if (groupIndex >= 0)
{
int groupIndexSum = state_id(groupIndex, groupIndexOffset);
if (groupIndexSum >= 0)
{
while (true)
{
float* floatArr = (float*)partman::field_nth(loader_table, groupIndexSum, datFieldTypes::FloatArray, skipIndex);
if (!floatArr)
break;
if (static_cast<__int16>(static_cast<__int64>(floor(*floatArr))) == firstValue)
return floatArr + 1;
++skipIndex;
}
error(13, 22);
result = nullptr;
}
else
{
error(16, 22);
result = nullptr;
}
}
else
{ {
error(0, 22); error(0, 22);
result = nullptr; return nullptr;
} }
return result;
int stateId = state_id(groupIndex, groupIndexOffset);
if (stateId < 0)
{
error(16, 22);
return nullptr;
}
for (auto skipIndex = 0;; ++skipIndex)
{
auto floatArr = reinterpret_cast<float*>(partman::field_nth(loader_table, stateId, datFieldTypes::FloatArray,
skipIndex));
if (!floatArr)
break;
if (static_cast<__int16>(floor(*floatArr)) == firstValue)
return floatArr + 1;
}
error(13, 22);
return nullptr;
} }
int loader::material(int groupIndex, visualStruct* visual) int loader::material(int groupIndex, visualStruct* visual)
{ {
if (groupIndex < 0) if (groupIndex < 0)
return error(0, 21); return error(0, 21);
__int16* shortArr = (__int16*)partman::field(loader_table, groupIndex, datFieldTypes::ShortValue); auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue));
if (!shortArr) if (!shortArr)
return error(1, 21); return error(1, 21);
if (*shortArr != 300) if (*shortArr != 300)
return error(3, 21); return error(3, 21);
float* floatArr = (float*)partman::field(loader_table, groupIndex, datFieldTypes::FloatArray); auto floatArr = reinterpret_cast<float*>(partman::field(loader_table, groupIndex, datFieldTypes::FloatArray));
if (!floatArr) if (!floatArr)
return error(11, 21); return error(11, 21);
int index = 0;
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) >> 2; int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) / 4;
if (floatArrLength > 0) for (auto index = 0; index < floatArrLength; index += 2)
{ {
do switch (static_cast<int>(floor(floatArr[index])))
{ {
float* nextFloatVal = floatArr + 1; case 301:
switch (static_cast<int>(floor(*floatArr))) visual->Smoothness = floatArr[index + 1];
{ break;
case 301: case 302:
visual->Smoothness = *nextFloatVal; visual->Elasticity = floatArr[index + 1];
break; break;
case 302: case 304:
visual->Elasticity = *nextFloatVal; visual->SoftHitSoundId = get_sound_id(static_cast<int>(floor(floatArr[index + 1])));
break; break;
case 304: default:
visual->SoftHitSoundId = get_sound_id((int)floor(*nextFloatVal)); return error(9, 21);
break;
default:
return error(9, 21);
}
floatArr = nextFloatVal + 1;
index += 2;
} }
while (index < floatArrLength);
} }
return 0; return 0;
} }
@ -331,12 +287,10 @@ float loader::play_sound(int soundIndex)
int loader::state_id(int groupIndex, int groupIndexOffset) int loader::state_id(int groupIndex, int groupIndexOffset)
{ {
int result; auto visualState = query_visual_states(groupIndex);
int groupIndex2 = groupIndex;
__int16 visualState = query_visual_states(groupIndex);
if (visualState <= 0) if (visualState <= 0)
return error(12, 24); return error(12, 24);
__int16* shortArr = (__int16*)partman::field(loader_table, groupIndex, datFieldTypes::ShortValue); auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue));
if (!shortArr) if (!shortArr)
return error(1, 24); return error(1, 24);
if (*shortArr != 200) if (*shortArr != 200)
@ -344,36 +298,34 @@ int loader::state_id(int groupIndex, int groupIndexOffset)
if (groupIndexOffset > visualState) if (groupIndexOffset > visualState)
return error(12, 24); return error(12, 24);
if (!groupIndexOffset) if (!groupIndexOffset)
return groupIndex2; return groupIndex;
groupIndex2 = groupIndexOffset + groupIndex; groupIndex += groupIndexOffset;
shortArr = (__int16*)partman::field(loader_table, groupIndexOffset + groupIndex, datFieldTypes::ShortValue); shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue));
if (!shortArr) if (!shortArr)
return error(1, 24); return error(1, 24);
if (*shortArr != 201) if (*shortArr != 201)
result = error(6, 24); return error(6, 24);
else return groupIndex;
result = groupIndex2;
return result;
} }
int loader::kicker(int groupIndex, visualKickerStruct* kicker) int loader::kicker(int groupIndex, visualKickerStruct* kicker)
{ {
if (groupIndex < 0) if (groupIndex < 0)
return error(0, 20); return error(0, 20);
__int16* shortArr = (__int16*)partman::field(loader_table, groupIndex, datFieldTypes::ShortValue); auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue));
if (!shortArr) if (!shortArr)
return error(1, 20); return error(1, 20);
if (*shortArr != 400) if (*shortArr != 400)
return error(4, 20); return error(4, 20);
float* floatArr = (float*)partman::field(loader_table, groupIndex, datFieldTypes::FloatArray); auto floatArr = reinterpret_cast<float*>(partman::field(loader_table, groupIndex, datFieldTypes::FloatArray));
if (!floatArr) if (!floatArr)
return error(11, 20); return error(11, 20);
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) >> 2; int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) / 4;
int index = 0;
if (floatArrLength <= 0) if (floatArrLength <= 0)
return 0; return 0;
while (index < floatArrLength)
for (auto index = 0; index < floatArrLength;)
{ {
int floorVal = static_cast<int>(floor(*floatArr++)); int floorVal = static_cast<int>(floor(*floatArr++));
switch (floorVal) switch (floorVal)
@ -411,158 +363,135 @@ int loader::kicker(int groupIndex, visualKickerStruct* kicker)
} }
int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* visual)
int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* visual)
{ {
visualStruct* visual2; int shortVal;
int groupIndexSum; __int16* nextShortVal;
int groupIndexSum2; int shortValSub100;
zmap_header_type* bitmap16; int shortValSub300;
__int16* shortArr; int shortValSub304;
unsigned int shortArrSize; int shortValSub602;
int index; int shortValSub1100;
int shortVal; int shortValSub1101;
__int16* nextShortVal;
int nextIndex;
int shortValSub100;
int shortValSub300;
int shortValSub304;
int shortValSub602;
int shortValSub1100;
int shortValSub1101;
float* floatArr;
float* nextFloatVal;
__int64 floatVal;
float* floatArrPtr;
int groupIndexSum3;
int shortArrLength;
visual2 = visual;
default_vsi(visual); default_vsi(visual);
if (groupIndex < 0) if (groupIndex < 0)
return error(0, 18); return error(0, 18);
groupIndexSum = state_id(groupIndex, groupIndexOffset); auto stateId = state_id(groupIndex, groupIndexOffset);
groupIndexSum2 = groupIndexSum; if (stateId < 0)
groupIndexSum3 = groupIndexSum;
if (groupIndexSum < 0)
return error(16, 18); return error(16, 18);
visual->Bitmap = (gdrv_bitmap8*)partman::field(loader_table, groupIndexSum, datFieldTypes::Bitmap8bit);
bitmap16 = (zmap_header_type*)partman::field(loader_table, groupIndexSum2, datFieldTypes::Bitmap16bit); visual->Bitmap = reinterpret_cast<gdrv_bitmap8*>(partman::field(loader_table, stateId, datFieldTypes::Bitmap8bit));
visual->ZMap = bitmap16; visual->ZMap = reinterpret_cast<zmap_header_type*>(partman::field(loader_table, stateId, datFieldTypes::Bitmap16bit)
if (bitmap16) );
if (visual->ZMap)
{ {
bitmap16->ZPtr1 = bitmap16->ZBuffer; visual->ZMap->ZPtr1 = visual->ZMap->ZBuffer;
visual->ZMap->ZPtr2 = visual->ZMap->ZPtr1; visual->ZMap->ZPtr2 = visual->ZMap->ZPtr1;
} }
shortArr = (__int16*)partman::field(loader_table, groupIndexSum2, datFieldTypes::ShortArray);
auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, stateId, datFieldTypes::ShortArray));
if (shortArr) if (shortArr)
{ {
shortArrSize = partman::field_size(loader_table, groupIndexSum2, datFieldTypes::ShortArray); unsigned int shortArrSize = partman::field_size(loader_table, stateId, datFieldTypes::ShortArray);
index = 0; for (auto index = 0u; index < shortArrSize / 2;)
shortArrLength = shortArrSize >> 1;
if ((__int16)(shortArrSize >> 1) > 0)
{ {
while (1) shortVal = *shortArr;
nextShortVal = shortArr + 1;
if (shortVal <= 406)
{ {
shortVal = *shortArr; if (shortVal == 406)
nextShortVal = shortArr + 1;
nextIndex = index + 1;
if (shortVal <= 406)
{ {
if (shortVal == 406) visual->Kicker.HardHitSoundId = get_sound_id(*nextShortVal);
}
else
{
shortValSub100 = shortVal - 100;
if (shortValSub100)
{ {
visual2->Kicker.HardHitSoundId = get_sound_id(*nextShortVal); shortValSub300 = shortValSub100 - 200;
} if (shortValSub300)
else
{
shortValSub100 = shortVal - 100;
if (shortValSub100)
{ {
shortValSub300 = shortValSub100 - 200; shortValSub304 = shortValSub300 - 4;
if (shortValSub300) if (shortValSub304)
{ {
shortValSub304 = shortValSub300 - 4; if (shortValSub304 != 96)
if (shortValSub304) return error(9, 18);
{ if (kicker(*nextShortVal, &visual->Kicker))
if (shortValSub304 != 96) return error(14, 18);
return error(9, 18);
if (kicker(*nextShortVal, &visual2->Kicker))
return error(14, 18);
}
else
{
visual2->SoftHitSoundId = get_sound_id(*nextShortVal);
}
} }
else if (material(*nextShortVal, visual2)) else
{ {
return error(15, 18); visual->SoftHitSoundId = get_sound_id(*nextShortVal);
} }
} }
else if (groupIndexOffset) else if (material(*nextShortVal, visual))
{ {
return error(7, 18); return error(15, 18);
} }
} }
goto LABEL_31; else if (groupIndexOffset)
{
return error(7, 18);
}
} }
shortValSub602 = shortVal - 602; goto LABEL_31;
if (!shortValSub602) }
{ shortValSub602 = shortVal - 602;
visual2->Flag |= 1 << *nextShortVal; if (!shortValSub602)
goto LABEL_31; {
} visual->CollisionGroup |= 1 << *nextShortVal;
shortValSub1100 = shortValSub602 - 498; goto LABEL_31;
if (!shortValSub1100) }
break; shortValSub1100 = shortValSub602 - 498;
shortValSub1101 = shortValSub1100 - 1; if (!shortValSub1100)
if (!shortValSub1101) {
{ visual->SoundIndex4 = get_sound_id(*nextShortVal);
visual2->SoundIndex3 = get_sound_id(*nextShortVal); goto LABEL_31;
LABEL_31: }
shortArr = nextShortVal + 1; shortValSub1101 = shortValSub1100 - 1;
index = nextIndex + 1; if (!shortValSub1101)
goto LABEL_32; {
} visual->SoundIndex3 = get_sound_id(*nextShortVal);
if (shortValSub1101 != 399) LABEL_31:
return error(9, 18); shortArr = nextShortVal + 1;
shortArr = nextShortVal + 8; index = index + 2;
index = nextIndex + 8; goto LABEL_32;
LABEL_32: }
if (index >= shortArrLength) if (shortValSub1101 != 399)
goto LABEL_33; return error(9, 18);
shortArr = nextShortVal + 8;
index = index + 9;
LABEL_32:
{
} }
visual2->SoundIndex4 = get_sound_id(*nextShortVal);
goto LABEL_31;
} }
} }
LABEL_33:
if (!visual2->Flag) if (!visual->CollisionGroup)
visual2->Flag = 1; visual->CollisionGroup = 1;
floatArr = (float*)partman::field(loader_table, groupIndexSum3, datFieldTypes::FloatArray); auto floatArr = reinterpret_cast<float*>(partman::field(loader_table, stateId, datFieldTypes::FloatArray));
if (!floatArr) if (!floatArr)
return 0; return 0;
nextFloatVal = floatArr + 1;
if (*floatArr != 600.0) if (*floatArr != 600.0)
return 0; return 0;
visual2->FloatArrCount = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2;
floatVal = (__int64)(floor(*nextFloatVal) - 1.0); visual->FloatArrCount = (partman::field_size(loader_table, stateId, datFieldTypes::FloatArray) / 4) / 2 - 2;
floatArrPtr = nextFloatVal + 1; auto floatVal = static_cast<int>(floor(floatArr[1]) - 1.0);
if ((int)floatVal) switch (floatVal)
{ {
if ((int)floatVal == 1) case 0:
{ visual->FloatArrCount = 1;
visual2->FloatArrCount = 2; break;
} case 1:
else if ((int)floatVal != visual2->FloatArrCount) visual->FloatArrCount = 2;
{ break;
default:
if (floatVal != visual->FloatArrCount)
return error(8, 18); return error(8, 18);
} break;
} }
else
{ visual->FloatArr = floatArr + 2;
visual2->FloatArrCount = 1;
}
visual2->FloatArr = floatArrPtr;
return 0; return 0;
} }

View file

@ -41,7 +41,7 @@ struct __declspec(align(4)) visualStruct
float* FloatArr; float* FloatArr;
int SoftHitSoundId; int SoftHitSoundId;
visualKickerStruct Kicker; visualKickerStruct Kicker;
int Flag; int CollisionGroup;
int SoundIndex4; int SoundIndex4;
int SoundIndex3; int SoundIndex3;
gdrv_bitmap8* Bitmap; gdrv_bitmap8* Bitmap;

View file

@ -74,7 +74,7 @@ void nudge::_nudge(float xDiff, float yDiff)
for (auto index = 0; index < ballList->Count(); index++) for (auto index = 0; index < ballList->Count(); index++)
{ {
auto ball = static_cast<TBall*>(ballList->Get(index)); auto ball = static_cast<TBall*>(ballList->Get(index));
if (ball->UnknownBaseFlag2 && !ball->CollisionComp) if (ball->ActiveFlag && !ball->CollisionComp)
{ {
ball->Acceleration.X = ball->Acceleration.X * ball->Speed; ball->Acceleration.X = ball->Acceleration.X * ball->Speed;
ball->Acceleration.Y = ball->Acceleration.Y * ball->Speed; ball->Acceleration.Y = ball->Acceleration.Y * ball->Speed;

View file

@ -3,7 +3,8 @@
#include "gdrv.h" #include "gdrv.h"
#include "memory.h" #include "memory.h"
short partman::_field_size[] = { short partman::_field_size[] =
{
2, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 2, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0
}; };
@ -11,34 +12,31 @@ short partman::_field_size[] = {
datFileStruct* partman::load_records(LPCSTR lpFileName) datFileStruct* partman::load_records(LPCSTR lpFileName)
{ {
_OFSTRUCT ReOpenBuff{}; _OFSTRUCT ReOpenBuff{};
datFileHeader Buffer{}; datFileHeader header{};
dat8BitBmpHeader bmpHeader{}; dat8BitBmpHeader bmpHeader{};
datFileStruct* datFile;
int groupIndex, groupDataSize;
datGroupData** groupDataBuf;
const HFILE fileHandle = OpenFile(lpFileName, &ReOpenBuff, 0); const HFILE fileHandle = OpenFile(lpFileName, &ReOpenBuff, 0);
if (fileHandle == -1) if (fileHandle == -1)
return nullptr; return nullptr;
_lread(fileHandle, &Buffer, 183u); _lread(fileHandle, &header, 183u);
if (lstrcmpA("PARTOUT(4.0)RESOURCE", Buffer.FileSignature)) if (lstrcmpA("PARTOUT(4.0)RESOURCE", header.FileSignature))
{ {
_lclose(fileHandle); _lclose(fileHandle);
return nullptr; return nullptr;
} }
datFile = (datFileStruct*)memory::allocate(sizeof(datFileStruct)); auto datFile = (datFileStruct*)memory::allocate(sizeof(datFileStruct));
if (!datFile) if (!datFile)
{ {
_lclose(fileHandle); _lclose(fileHandle);
return nullptr; return nullptr;
} }
if (lstrlenA(Buffer.Description) <= 0) if (lstrlenA(header.Description) <= 0)
{ {
datFile->Description = nullptr; datFile->Description = nullptr;
} }
else else
{ {
int lenOfStr = lstrlenA(Buffer.Description); int lenOfStr = lstrlenA(header.Description);
auto descriptionBuf = static_cast<char*>(memory::allocate(lenOfStr + 1)); auto descriptionBuf = static_cast<char*>(memory::allocate(lenOfStr + 1));
datFile->Description = descriptionBuf; datFile->Description = descriptionBuf;
if (!descriptionBuf) if (!descriptionBuf)
@ -47,12 +45,12 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
memory::free(datFile); memory::free(datFile);
return nullptr; return nullptr;
} }
lstrcpyA(descriptionBuf, Buffer.Description); lstrcpyA(descriptionBuf, header.Description);
} }
if (Buffer.Unknown) if (header.Unknown)
{ {
auto unknownBuf = static_cast<char*>(memory::allocate(Buffer.Unknown)); auto unknownBuf = static_cast<char*>(memory::allocate(header.Unknown));
if (!unknownBuf) if (!unknownBuf)
{ {
_lclose(fileHandle); _lclose(fileHandle);
@ -61,11 +59,11 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
memory::free(datFile); memory::free(datFile);
return nullptr; return nullptr;
} }
_lread(fileHandle, static_cast<void*>(unknownBuf), Buffer.Unknown); _lread(fileHandle, static_cast<void*>(unknownBuf), header.Unknown);
memory::free(unknownBuf); memory::free(unknownBuf);
} }
groupDataBuf = (datGroupData**)memory::allocate(sizeof(void*) * Buffer.NumberOfGroups); auto groupDataBuf = (datGroupData**)memory::allocate(sizeof(void*) * header.NumberOfGroups);
datFile->GroupData = groupDataBuf; datFile->GroupData = groupDataBuf;
if (!groupDataBuf) if (!groupDataBuf)
{ {
@ -75,75 +73,70 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
return nullptr; return nullptr;
} }
groupIndex = 0; bool abort = false;
if (Buffer.NumberOfGroups) for (auto groupIndex = 0; !abort && groupIndex < header.NumberOfGroups; ++groupIndex)
{ {
do auto entryCount = _lread_char(fileHandle);
{ auto groupDataSize = entryCount <= 0 ? 0 : entryCount - 1;
char entryCount = _lread_char(fileHandle); auto groupData = reinterpret_cast<datGroupData*>(memory::allocate(
if (entryCount <= 0) sizeof(datEntryData) * groupDataSize + sizeof(datGroupData)));
groupDataSize = 0; datFile->GroupData[groupIndex] = groupData;
else if (!groupData)
groupDataSize = entryCount - 1; break;
datFile->GroupData[groupIndex] = (datGroupData*)memory::allocate(
sizeof(datEntryData) * groupDataSize + sizeof(datGroupData));
datGroupData* groupData = datFile->GroupData[groupIndex];
if (!groupData)
break;
int entryIndex = 0;
groupData->EntryCount = entryCount;
if (entryCount > 0)
{
datEntryData* entryData = groupData->Entries;
do
{
auto entryType = static_cast<datFieldTypes>(_lread_char(fileHandle));
entryData->EntryType = entryType;
int fieldSize = _field_size[static_cast<int>(entryType)];
if (fieldSize < 0)
{
fieldSize = _lread_long(fileHandle);
}
if (entryType == datFieldTypes::Bitmap8bit)
{
_hread(fileHandle, &bmpHeader, 14);
auto bmp = (gdrv_bitmap8*)memory::allocate(sizeof(gdrv_bitmap8));
entryData->Buffer = (char*)bmp;
if (!bmp)
goto LABEL_41;
if (bmpHeader.Unknown2 & 2
? gdrv::create_bitmap(bmp, bmpHeader.Width, bmpHeader.Height)
: gdrv::create_raw_bitmap(bmp, bmpHeader.Width, bmpHeader.Height,
bmpHeader.Unknown2 & 1))
goto LABEL_41;
_hread(fileHandle, bmp->BmpBufPtr1, bmpHeader.Size);
bmp->XPosition = bmpHeader.XPosition;
bmp->YPosition = bmpHeader.YPosition;
}
else
{
char* entryBuffer = static_cast<char*>(memory::allocate(fieldSize));
entryData->Buffer = entryBuffer;
if (!entryBuffer)
goto LABEL_41;
_hread(fileHandle, entryBuffer, fieldSize);
}
++entryIndex; groupData->EntryCount = entryCount;
entryData->FieldSize = fieldSize; datEntryData* entryData = groupData->Entries;
datFile->NumberOfGroups = groupIndex + 1; for (auto entryIndex = 0; entryIndex < entryCount; ++entryIndex)
++entryData; {
} auto entryType = static_cast<datFieldTypes>(_lread_char(fileHandle));
while (entryIndex < entryCount); entryData->EntryType = entryType;
int fieldSize = _field_size[static_cast<int>(entryType)];
if (fieldSize < 0)
{
fieldSize = _lread_long(fileHandle);
} }
++groupIndex; if (entryType == datFieldTypes::Bitmap8bit)
{
_hread(fileHandle, &bmpHeader, sizeof(dat8BitBmpHeader));
auto bmp = reinterpret_cast<gdrv_bitmap8*>(memory::allocate(sizeof(gdrv_bitmap8)));
entryData->Buffer = reinterpret_cast<char*>(bmp);
if (!bmp)
{
abort = true;
break;
}
if (bmpHeader.IsFlagSet(bmp8Flags::DibBitmap)
? gdrv::create_bitmap(bmp, bmpHeader.Width, bmpHeader.Height)
: gdrv::create_raw_bitmap(bmp, bmpHeader.Width, bmpHeader.Height,
bmpHeader.IsFlagSet(bmp8Flags::RawBmpUnaligned)))
{
abort = true;
break;
}
_hread(fileHandle, bmp->BmpBufPtr1, bmpHeader.Size);
bmp->XPosition = bmpHeader.XPosition;
bmp->YPosition = bmpHeader.YPosition;
}
else
{
char* entryBuffer = static_cast<char*>(memory::allocate(fieldSize));
entryData->Buffer = entryBuffer;
if (!entryBuffer)
{
abort = true;
break;
}
_hread(fileHandle, entryBuffer, fieldSize);
}
entryData->FieldSize = fieldSize;
datFile->NumberOfGroups = groupIndex + 1;
++entryData;
} }
while (groupIndex < Buffer.NumberOfGroups);
} }
LABEL_41:
_lclose(fileHandle); _lclose(fileHandle);
if (datFile->NumberOfGroups == Buffer.NumberOfGroups) if (datFile->NumberOfGroups == header.NumberOfGroups)
return datFile; return datFile;
unload_records(datFile); unload_records(datFile);
return nullptr; return nullptr;

View file

@ -25,6 +25,13 @@ enum class datFieldTypes : __int16
// 16 bpp bitmap(Heightmap ? ) // 16 bpp bitmap(Heightmap ? )
}; };
enum class bmp8Flags : unsigned char
{
RawBmpUnaligned = 1 << 0,
DibBitmap = 1 << 1,
};
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
struct datFileHeader struct datFileHeader
@ -70,7 +77,12 @@ struct dat8BitBmpHeader
__int16 XPosition; __int16 XPosition;
__int16 YPosition; __int16 YPosition;
int Size; int Size;
char Unknown2; bmp8Flags Flags;
bool IsFlagSet(bmp8Flags flag)
{
return static_cast<char>(Flags) & static_cast<char>(flag);
}
}; };
#pragma pack(pop) #pragma pack(pop)

View file

@ -146,7 +146,7 @@ void pb::mode_change(int mode)
if (MainTable) if (MainTable)
{ {
if (MainTable->Demo) if (MainTable->Demo)
MainTable->Demo->UnknownBaseFlag2 = 1; MainTable->Demo->ActiveFlag = 1;
} }
} }
else else
@ -157,7 +157,7 @@ void pb::mode_change(int mode)
if (MainTable) if (MainTable)
{ {
if (MainTable->Demo) if (MainTable->Demo)
MainTable->Demo->UnknownBaseFlag2 = 0; MainTable->Demo->ActiveFlag = 0;
} }
} }
break; break;
@ -260,7 +260,7 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
for (int i = 0; i < MainTable->BallList->Count(); i++) for (int i = 0; i < MainTable->BallList->Count(); i++)
{ {
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i)); auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
if (ball->UnknownBaseFlag2 != 0) if (ball->ActiveFlag != 0)
{ {
auto collComp = ball->CollisionComp; auto collComp = ball->CollisionComp;
if (collComp) if (collComp)
@ -270,7 +270,7 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
} }
else else
{ {
if (MainTable->UnknownBaseFlag2) if (MainTable->ActiveFlag)
{ {
vec2.X = 0.0; vec2.X = 0.0;
vec2.Y = 0.0; vec2.Y = 0.0;
@ -303,7 +303,7 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
for (int i = 0; i < MainTable->BallList->Count(); i++) for (int i = 0; i < MainTable->BallList->Count(); i++)
{ {
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i)); auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
if (ball->UnknownBaseFlag2) if (ball->ActiveFlag)
ball->Repaint(); ball->Repaint();
} }
} }
@ -449,7 +449,7 @@ void pb::keydown(int key)
for (auto index = 0; ;) for (auto index = 0; ;)
{ {
ball = static_cast<TBall*>(MainTable->BallList->Get(index)); ball = static_cast<TBall*>(MainTable->BallList->Get(index));
if (!ball->UnknownBaseFlag2) if (!ball->ActiveFlag)
break; break;
++index; ++index;
if (index >= MainTable->BallList->Count()) if (index >= MainTable->BallList->Count())
@ -460,7 +460,7 @@ void pb::keydown(int key)
} }
} }
ball->Position.X = 1.0; ball->Position.X = 1.0;
ball->UnknownBaseFlag2 = 1; ball->ActiveFlag = 1;
ball->Position.Z = ball->Offset; ball->Position.Z = ball->Offset;
ball->Position.Y = 1.0; ball->Position.Y = 1.0;
ball->Acceleration.Z = 0.0; ball->Acceleration.Z = 0.0;
@ -601,7 +601,7 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
ray_type ray{}; ray_type ray{};
vector_type positionMod{}; vector_type positionMod{};
if (ball->UnknownBaseFlag2 && !ball->CollisionComp) if (ball->ActiveFlag && !ball->CollisionComp)
{ {
if (ball_speed_limit < ball->Speed) if (ball_speed_limit < ball->Speed)
ball->Speed = ball_speed_limit; ball->Speed = ball_speed_limit;