mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-22 02:32:39 +01:00
Some renames, cleanup partman, loader.
This commit is contained in:
parent
74306179a7
commit
262b098610
@ -16,7 +16,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
|
||||
|
||||
TimeNow = 0.0;
|
||||
RayMaxDistance = 0.0;
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
CollisionComp = nullptr;
|
||||
EdgeCollisionCount = 0;
|
||||
TimeDelta = 0.0;
|
||||
@ -115,7 +115,7 @@ int TBall::Message(int code, float value)
|
||||
Position.X = 0.0;
|
||||
CollisionComp = nullptr;
|
||||
Position.Y = 0.0;
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
CollisionFlag = 0;
|
||||
FieldFlag = 1;
|
||||
Acceleration.Y = 0.0;
|
||||
|
@ -20,7 +20,7 @@ TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(t
|
||||
Threshold = 1000000000.0f;
|
||||
Timer = 0;
|
||||
MessageField = 0;
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
}
|
||||
|
||||
@ -38,13 +38,13 @@ int TBlocker::Message(int code, float value)
|
||||
Timer = 0;
|
||||
}
|
||||
MessageField = 0;
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
if (code == 51)
|
||||
loader::play_sound(SoundIndex3);
|
||||
return 0;
|
||||
case 52:
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
loader::play_sound(SoundIndex4);
|
||||
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
|
||||
break;
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "TCollisionComponent.h"
|
||||
#include "TTableLayer.h"
|
||||
|
||||
TCircle::TCircle(TCollisionComponent* collComp, char* someFlagPtr, unsigned visualFlag, vector_type* center,
|
||||
float radius): TEdgeSegment(collComp, someFlagPtr, visualFlag)
|
||||
TCircle::TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup, vector_type* center,
|
||||
float radius): TEdgeSegment(collComp, activeFlag, collisionGroup)
|
||||
{
|
||||
Circle.RadiusSq = radius * radius;
|
||||
Circle.Center = *center;
|
||||
|
@ -8,7 +8,7 @@ class TCircle :
|
||||
public:
|
||||
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 FindCollisionDistance(ray_type* ray) override;
|
||||
void EdgeCollision(TBall* ball, float coef) override;
|
||||
|
@ -13,9 +13,9 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
|
||||
visualStruct visual{};
|
||||
|
||||
EdgeList = new objlist_class(4, 4);
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
if (GroupName != nullptr)
|
||||
UnknownBaseFlag1 = 1;
|
||||
UnusedBaseFlag = 1;
|
||||
if (groupIndex <= 0)
|
||||
{
|
||||
loader::default_vsi(&visual);
|
||||
@ -27,7 +27,7 @@ TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, b
|
||||
{
|
||||
float offset = table->CollisionCompOffset;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ TDemo::TDemo(TPinballTable* table, int groupIndex)
|
||||
FlipLeftTimer = 0;
|
||||
FlipRightTimer = 0;
|
||||
MessageField = 0;
|
||||
UnknownBaseFlag1 = 0;
|
||||
UnknownBaseFlag2 = 0;
|
||||
UnusedBaseFlag = 0;
|
||||
ActiveFlag = 0;
|
||||
FlipRightFlag = 0;
|
||||
FlipLeftFlag = 0;
|
||||
table->Demo = this;
|
||||
@ -41,19 +41,19 @@ TDemo::TDemo(TPinballTable* table, int groupIndex)
|
||||
}
|
||||
loader::query_visual(groupIndex, 0, &visual);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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)
|
||||
@ -69,7 +69,7 @@ int TDemo::Message(int code, float value)
|
||||
if (RestartGameTimer)
|
||||
timer::kill(RestartGameTimer);
|
||||
RestartGameTimer = 0;
|
||||
if (UnknownBaseFlag2 != 0)
|
||||
if (ActiveFlag != 0)
|
||||
RestartGameTimer = timer::set(5.0, this, NewGameRestartTimer);
|
||||
break;
|
||||
case 1024:
|
||||
|
@ -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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -6,11 +6,11 @@
|
||||
#include "TCollisionComponent.h"
|
||||
#include "TLine.h"
|
||||
|
||||
TEdgeSegment::TEdgeSegment(TCollisionComponent* collComp, char* someFlag, unsigned visualFlag)
|
||||
TEdgeSegment::TEdgeSegment(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup)
|
||||
{
|
||||
CollisionComponent = collComp;
|
||||
PinbCompFlag2Ptr = someFlag;
|
||||
VisualFlag = visualFlag;
|
||||
ActiveFlag = activeFlag;
|
||||
CollisionGroup = collisionGroup;
|
||||
ProcessedFlag = 0;
|
||||
}
|
||||
|
||||
@ -18,9 +18,8 @@ void TEdgeSegment::port_draw()
|
||||
{
|
||||
}
|
||||
|
||||
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* flagPtr,
|
||||
unsigned int visual_flag,
|
||||
float offset, int wallValue)
|
||||
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
|
||||
unsigned int collisionGroup, float offset, int wallValue)
|
||||
{
|
||||
vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{};
|
||||
TEdgeSegment* edge = nullptr;
|
||||
@ -33,7 +32,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
||||
center.X = floatArr[1];
|
||||
center.Y = floatArr[2];
|
||||
auto radius = offset + floatArr[3];
|
||||
auto circle = new TCircle(collComp, flagPtr, visual_flag, ¢er, radius);
|
||||
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
edge = circle;
|
||||
|
||||
if (circle)
|
||||
@ -51,7 +50,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
||||
start.Y = floatArr[2];
|
||||
end.X = floatArr[3];
|
||||
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;
|
||||
|
||||
if (line)
|
||||
@ -99,7 +98,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
||||
dstVec.Z < 0.0 && offset < 0.0)
|
||||
{
|
||||
float radius = offset * 1.001f;
|
||||
auto circle = new TCircle(collComp, flagPtr, visual_flag, ¢er, radius);
|
||||
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
|
||||
if (circle)
|
||||
{
|
||||
@ -114,7 +113,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
||||
start.Y = floatArrPtr[1];
|
||||
end.X = floatArrPtr[2];
|
||||
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;
|
||||
|
||||
if (line)
|
||||
|
@ -14,12 +14,12 @@ class TEdgeSegment
|
||||
{
|
||||
public:
|
||||
TCollisionComponent* CollisionComponent;
|
||||
char* PinbCompFlag2Ptr;
|
||||
char* ActiveFlag;
|
||||
char ProcessedFlag;
|
||||
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 void EdgeCollision(TBall* ball, float coef) = 0;
|
||||
@ -27,6 +27,6 @@ public:
|
||||
virtual void place_in_grid() = 0;
|
||||
virtual float FindCollisionDistance(ray_type* ray) = 0;
|
||||
|
||||
static TEdgeSegment* install_wall(float* floatArr, TCollisionComponent* collComp, char* flagPtr,
|
||||
unsigned int visual_flag, float offset, int wallValue);
|
||||
static TEdgeSegment* install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
|
||||
unsigned int collisionGroup, float offset, int wallValue);
|
||||
};
|
||||
|
@ -23,14 +23,14 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
|
||||
end.Y = visual.FloatArr[1];
|
||||
start.X = visual.FloatArr[2];
|
||||
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)
|
||||
{
|
||||
line->place_in_grid();
|
||||
EdgeList->Add(line);
|
||||
}
|
||||
|
||||
line = new TLine(this, &UnknownBaseFlag2, visual.Flag, &end, &start);
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start);
|
||||
PrevCollider = line;
|
||||
if (line)
|
||||
{
|
||||
|
@ -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 flipperEdge = new TFlipperEdge(
|
||||
this,
|
||||
&UnknownBaseFlag2,
|
||||
visual.Flag,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
table,
|
||||
origin,
|
||||
vecT1,
|
||||
|
@ -11,9 +11,9 @@ vector_type TFlipperEdge::A1, TFlipperEdge::A2, TFlipperEdge::B1, TFlipperEdge::
|
||||
line_type TFlipperEdge::lineA, TFlipperEdge::lineB;
|
||||
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,
|
||||
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{};
|
||||
|
||||
|
@ -7,7 +7,7 @@ class TPinballTable;
|
||||
class TFlipperEdge : public TEdgeSegment
|
||||
{
|
||||
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,
|
||||
float elasticity, float smoothness);
|
||||
void port_draw() override;
|
||||
|
@ -14,7 +14,7 @@ TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
loader::query_visual(groupIndex, 0, &visual);
|
||||
SoundIndex4 = visual.SoundIndex4;
|
||||
SoundIndex3 = visual.SoundIndex3;
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
|
||||
control::handler(1024, this);
|
||||
}
|
||||
@ -25,13 +25,13 @@ int TGate::Message(int code, float value)
|
||||
{
|
||||
if (code == 53)
|
||||
{
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
loader::play_sound(SoundIndex3);
|
||||
}
|
||||
else if (code == 54 || code == 1024)
|
||||
{
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
render::sprite_set_bitmap(RenderSprite, static_cast<gdrv_bitmap8*>(ListBitmap->Get(0)));
|
||||
if (code == 54)
|
||||
loader::play_sound(SoundIndex4);
|
||||
|
@ -38,7 +38,7 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
if (Circle.RadiusSq == 0.0)
|
||||
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);
|
||||
if (tCircle)
|
||||
{
|
||||
@ -55,9 +55,9 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
circle.Center.Y = Circle.Center.Y;
|
||||
circle.Center.Z = Circle.Center.Z;
|
||||
|
||||
Field.Flag2Ptr = &UnknownBaseFlag2;
|
||||
Field.Flag2Ptr = &ActiveFlag;
|
||||
Field.CollisionComp = this;
|
||||
Field.Mask = visual.Flag;
|
||||
Field.Mask = visual.CollisionGroup;
|
||||
TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
|
||||
|
||||
NotSomeFlag = !someFlag;
|
||||
if (!someFlag)
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
TimerTime1 = 1.5;
|
||||
TimerTime2 = 0.05f;
|
||||
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];
|
||||
if (Circle.RadiusSq == 0.0)
|
||||
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);
|
||||
if (tCircle)
|
||||
{
|
||||
@ -54,9 +54,9 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
|
||||
circle.Center.X = Circle.Center.X;
|
||||
circle.Center.Y = Circle.Center.Y;
|
||||
circle.Center.Z = Circle.Center.Z;
|
||||
Field.Flag2Ptr = &UnknownBaseFlag2;
|
||||
Field.Flag2Ptr = &ActiveFlag;
|
||||
Field.CollisionComp = this;
|
||||
Field.Mask = visual.Flag;
|
||||
Field.Mask = visual.CollisionGroup;
|
||||
TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ int TKickout::Message(int code, float value)
|
||||
break;
|
||||
case 1011:
|
||||
if (NotSomeFlag)
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
break;
|
||||
case 1024:
|
||||
if (KickFlag1)
|
||||
@ -84,7 +84,7 @@ int TKickout::Message(int code, float value)
|
||||
TimerExpired(0, this);
|
||||
}
|
||||
if (NotSomeFlag)
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -156,7 +156,7 @@ void TKickout::TimerExpired(int timerId, void* caller)
|
||||
kick->Ball->Position.Z = kick->OriginalBallZ;
|
||||
TBall::throw_ball(kick->Ball, &kick->BallAcceleration, kick->ThrowAngleMult, kick->ThrowSpeedMult1,
|
||||
kick->ThrowSpeedMult2);
|
||||
kick->UnknownBaseFlag2 = 0;
|
||||
kick->ActiveFlag = 0;
|
||||
kick->Ball = nullptr;
|
||||
loader::play_sound(kick->HardHitSoundId);
|
||||
}
|
||||
@ -167,6 +167,6 @@ void TKickout::ResetTimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto kick = static_cast<TKickout*>(caller);
|
||||
if (!kick->NotSomeFlag)
|
||||
kick->UnknownBaseFlag2 = 1;
|
||||
kick->ActiveFlag = 1;
|
||||
kick->Timer = 0;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int TLight::Message(int code, float value)
|
||||
FlasherActive = 1;
|
||||
FlasherFlag2 = 0;
|
||||
FlasherFlag1 = 0;
|
||||
Unknown13 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
flasher_start(&Flasher, BmpIndex1);
|
||||
}
|
||||
break;
|
||||
@ -104,7 +104,7 @@ int TLight::Message(int code, float value)
|
||||
flasher_start(&Flasher, BmpIndex1);
|
||||
FlasherActive = 1;
|
||||
FlasherFlag2 = 0;
|
||||
Unknown13 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
FlasherFlag1 = 0;
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
@ -191,7 +191,7 @@ int TLight::Message(int code, float value)
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[BmpIndex1]);
|
||||
break;
|
||||
case 15:
|
||||
Unknown13 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
if (Timer2)
|
||||
timer::kill(Timer2);
|
||||
Timer2 = 0;
|
||||
@ -203,7 +203,7 @@ int TLight::Message(int code, float value)
|
||||
timer::kill(Timer2);
|
||||
Timer2 = 0;
|
||||
Message(7, value);
|
||||
Unknown13 = 1;
|
||||
TurnOffAfterFlashingFg = 1;
|
||||
break;
|
||||
case 17:
|
||||
Message(static_cast<int>(floor(value)) != 0, 0.0);
|
||||
@ -252,7 +252,7 @@ void TLight::Reset()
|
||||
FlasherFlag1 = 0;
|
||||
FlasherFlag2 = 0;
|
||||
FlasherActive = 0;
|
||||
Unknown13 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
Flasher.Sprite = RenderSprite;
|
||||
Flasher.BmpArr[0] = nullptr;
|
||||
@ -284,9 +284,9 @@ void TLight::TimerExpired(int timerId, void* caller)
|
||||
light->FlasherFlag2 = 0;
|
||||
light->FlasherActive = 0;
|
||||
light->Timer1 = 0;
|
||||
if (light->Unknown13 != 0)
|
||||
if (light->TurnOffAfterFlashingFg != 0)
|
||||
{
|
||||
light->Unknown13 = 0;
|
||||
light->TurnOffAfterFlashingFg = 0;
|
||||
light->Message(20, 0.0);
|
||||
}
|
||||
if (light->Control)
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
int FlasherActive;
|
||||
int FlasherFlag1;
|
||||
int FlasherFlag2;
|
||||
int Unknown13;
|
||||
int TurnOffAfterFlashingFg;
|
||||
int BmpIndex2;
|
||||
float FlasherDelay[2];
|
||||
int Timer1;
|
||||
|
@ -24,7 +24,7 @@ int TLightRollover::Message(int code, float value)
|
||||
{
|
||||
if (code == 1024)
|
||||
{
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
RolloverFlag = 0;
|
||||
if (Timer)
|
||||
timer::kill(Timer);
|
||||
@ -47,7 +47,7 @@ void TLightRollover::Collision(TBall* ball, vector_type* nextPosition, vector_ty
|
||||
if (RolloverFlag)
|
||||
{
|
||||
timer::set(0.1f, this, TimerExpired);
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
RolloverFlag = RolloverFlag == 0;
|
||||
if (Timer == 0)
|
||||
Timer = timer::set(FloatArr, this, delay_expired);
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include "TTableLayer.h"
|
||||
|
||||
|
||||
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, float x0, float y0, float x1,
|
||||
float y1): TEdgeSegment(collCmp, flagPtr, visualFlag)
|
||||
TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1,
|
||||
float y1): TEdgeSegment(collCmp, activeFlag, collisionGroup)
|
||||
{
|
||||
X0 = x0;
|
||||
Y0 = y0;
|
||||
@ -14,8 +14,8 @@ TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFla
|
||||
maths::line_init(&Line, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, struct vector_type* start,
|
||||
struct vector_type* end) : TEdgeSegment(collCmp, flagPtr, visualFlag)
|
||||
TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, struct vector_type* start,
|
||||
struct vector_type* end) : TEdgeSegment(collCmp, activeFlag, collisionGroup)
|
||||
{
|
||||
X0 = start->X;
|
||||
Y0 = start->Y;
|
||||
|
@ -8,8 +8,8 @@ class TLine :
|
||||
public:
|
||||
line_type Line;
|
||||
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* flagPtr, unsigned int visualFlag, vector_type* start, vector_type* end);
|
||||
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1);
|
||||
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector_type* start, vector_type* end);
|
||||
void Offset(float offset);
|
||||
float FindCollisionDistance(ray_type* ray) override;
|
||||
void EdgeCollision(TBall* ball, float coef) override;
|
||||
|
@ -22,7 +22,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
||||
linePt1.X = visual.FloatArr[2];
|
||||
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)
|
||||
{
|
||||
line->Offset(table->CollisionCompOffset);
|
||||
@ -30,7 +30,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
||||
EdgeList->Add(line);
|
||||
}
|
||||
|
||||
line = new TLine(this, &UnknownBaseFlag2, visual.Flag, &linePt1, &linePt2);
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);
|
||||
Line = line;
|
||||
if (line)
|
||||
{
|
||||
|
@ -11,8 +11,8 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
||||
visualStruct visual{};
|
||||
|
||||
MessageField = 0;
|
||||
UnknownBaseFlag1 = 0;
|
||||
UnknownBaseFlag2 = 0;
|
||||
UnusedBaseFlag = 0;
|
||||
ActiveFlag = 0;
|
||||
PinballTable = table;
|
||||
RenderSprite = nullptr;
|
||||
ListBitmap = nullptr;
|
||||
|
@ -26,8 +26,8 @@ public:
|
||||
void* operator new(size_t Size);
|
||||
void operator delete(void* p);
|
||||
|
||||
__int8 UnknownBaseFlag1;
|
||||
__int8 UnknownBaseFlag2;
|
||||
__int8 UnusedBaseFlag;
|
||||
__int8 ActiveFlag;
|
||||
int MessageField;
|
||||
char* GroupName;
|
||||
int Unknown4;
|
||||
|
@ -54,7 +54,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
||||
ScoreBallcount = nullptr;
|
||||
ScorePlayerNumber1 = nullptr;
|
||||
BallInSink = 0;
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
TiltLockFlag = 0;
|
||||
EndGameTimeoutTimer = 0;
|
||||
LightShowTimer = 0;
|
||||
@ -66,7 +66,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
||||
auto ballObj = new TBall(this);
|
||||
BallList->Add(ballObj);
|
||||
if (ballObj)
|
||||
ballObj->UnknownBaseFlag2 = 0;
|
||||
ballObj->ActiveFlag = 0;
|
||||
new TTableLayer(this);
|
||||
LightGroup = new TLightGroup(this, 0);
|
||||
|
||||
@ -381,7 +381,7 @@ int TPinballTable::Message(int code, float value)
|
||||
LightGroup->Message(34, 0.0);
|
||||
LightGroup->Message(20, 0.0);
|
||||
Plunger->Message(1016, 0.0);
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
rc_text = pinball::get_rc_string(30, 0);
|
||||
else
|
||||
rc_text = pinball::get_rc_string(26, 0);
|
||||
@ -478,7 +478,7 @@ int TPinballTable::Message(int code, float value)
|
||||
if (PlayerCount <= 1)
|
||||
{
|
||||
char* textboxText;
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(30, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(26, 0);
|
||||
@ -522,25 +522,25 @@ int TPinballTable::Message(int code, float value)
|
||||
switch (nextPlayer)
|
||||
{
|
||||
case 0:
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(30, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(26, 0);
|
||||
break;
|
||||
case 1:
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(31, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(27, 0);
|
||||
break;
|
||||
case 2:
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(32, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(28, 0);
|
||||
break;
|
||||
case 3:
|
||||
if (Demo->UnknownBaseFlag2)
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(33, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(29, 0);
|
||||
|
@ -83,7 +83,7 @@ int TPlunger::Message(int code, float value)
|
||||
ball->Message(1024, 0.0);
|
||||
ball->Position.X = PinballTable->PlungerPositionX;
|
||||
ball->Position.Y = PinballTable->PlungerPositionY;
|
||||
ball->UnknownBaseFlag2 = 1;
|
||||
ball->ActiveFlag = 1;
|
||||
PinballTable->BallInSink = 0;
|
||||
pb::tilt_no_more();
|
||||
control::handler(code, this);
|
||||
|
@ -20,7 +20,7 @@ int TPopupTarget::Message(int code, float value)
|
||||
switch (code)
|
||||
{
|
||||
case 49:
|
||||
this->UnknownBaseFlag2 = 0;
|
||||
this->ActiveFlag = 0;
|
||||
render::sprite_set_bitmap(this->RenderSprite, nullptr);
|
||||
break;
|
||||
case 50:
|
||||
@ -90,7 +90,7 @@ void TPopupTarget::TimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto target = static_cast<TPopupTarget*>(caller);
|
||||
target->Timer = 0;
|
||||
target->UnknownBaseFlag2 = 1;
|
||||
target->ActiveFlag = 1;
|
||||
render::sprite_set_bitmap(target->RenderSprite, static_cast<gdrv_bitmap8*>(target->ListBitmap->Get(0)));
|
||||
if (timerId)
|
||||
{
|
||||
|
@ -18,9 +18,9 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
vector_type end{}, start{}, *end2, *start2, *start3, *end3;
|
||||
|
||||
MessageField = 0;
|
||||
UnknownBaseFlag1 = 1;
|
||||
UnusedBaseFlag = 1;
|
||||
loader::query_visual(groupIndex, 0, &visual);
|
||||
VisualFlag = visual.Flag;
|
||||
CollisionGroup = visual.CollisionGroup;
|
||||
|
||||
auto floatArr1 = loader::query_float_attribute(groupIndex, 0, 701);
|
||||
if (floatArr1)
|
||||
@ -42,7 +42,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
end.Y = floatArr4[3];
|
||||
start.X = floatArr4[4];
|
||||
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);
|
||||
if (Line1)
|
||||
{
|
||||
@ -60,7 +60,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
reinterpret_cast<wall_point_type*>(floatArr5WallPoint + 3),
|
||||
&end2,
|
||||
&start2);
|
||||
Line2 = new TLine(this, &UnknownBaseFlag2, VisualFlag, start2, end2);
|
||||
Line2 = new TLine(this, &ActiveFlag, CollisionGroup, start2, end2);
|
||||
EdgeList->Add(Line2);
|
||||
if (Line2)
|
||||
{
|
||||
@ -78,7 +78,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
reinterpret_cast<wall_point_type*>(floatArr6WallPoint + 3),
|
||||
&end3,
|
||||
&start3);
|
||||
Line3 = new TLine(this, &UnknownBaseFlag2, VisualFlag, start3, end3);
|
||||
Line3 = new TLine(this, &ActiveFlag, CollisionGroup, start3, end3);
|
||||
EdgeList->Add(Line3);
|
||||
if (Line3)
|
||||
{
|
||||
@ -107,25 +107,25 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
for (auto pt = 0; pt < 3; pt++)
|
||||
{
|
||||
auto point1 = pointOrder[pt], point2 = pointOrder[pt + 1];
|
||||
auto lineFlag = 0;
|
||||
auto collisionGroup = 0;
|
||||
if (point1 != end2 || point2 != start2)
|
||||
{
|
||||
if (point1 != end3 || point2 != start3)
|
||||
{
|
||||
lineFlag = visual.Flag;
|
||||
collisionGroup = visual.CollisionGroup;
|
||||
}
|
||||
else if (wall2Pt1_2)
|
||||
{
|
||||
lineFlag = Wall2PointFirst;
|
||||
collisionGroup = Wall2PointFirst;
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (line)
|
||||
{
|
||||
@ -141,9 +141,9 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||
PinballTable->GravityDirVectMult;
|
||||
}
|
||||
|
||||
Field.Flag2Ptr = &UnknownBaseFlag2;
|
||||
Field.Flag2Ptr = &ActiveFlag;
|
||||
Field.CollisionComp = this;
|
||||
Field.Mask = visual.Flag;
|
||||
Field.Mask = visual.CollisionGroup;
|
||||
|
||||
auto x1 = xMax;
|
||||
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->Position.Z = ball->Position.X * ball->CollisionOffset.X + ball->Position.Y * ball->CollisionOffset.Y +
|
||||
ball->Offset + ball->CollisionOffset.Z;
|
||||
ball->FieldFlag = VisualFlag;
|
||||
ball->FieldFlag = CollisionGroup;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
int Scores[4];
|
||||
field_effect_type Field;
|
||||
int VisualFlag;
|
||||
int CollisionGroup;
|
||||
int RampFlag1;
|
||||
int RampPlaneCount;
|
||||
float BallFieldMult;
|
||||
|
@ -31,7 +31,7 @@ int TRollover::Message(int code, float value)
|
||||
{
|
||||
if (code == 1024)
|
||||
{
|
||||
this->UnknownBaseFlag2 = 1;
|
||||
this->ActiveFlag = 1;
|
||||
this->RolloverFlag = 0;
|
||||
if (this->ListBitmap)
|
||||
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)
|
||||
{
|
||||
timer::set(0.1f, this, TimerExpired);
|
||||
UnknownBaseFlag2 = 0;
|
||||
ActiveFlag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -87,13 +87,13 @@ void TRollover::build_walls(int groupIndex)
|
||||
|
||||
loader::query_visual(groupIndex, 0, &visual);
|
||||
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);
|
||||
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)
|
||||
{
|
||||
auto roll = static_cast<TRollover*>(caller);
|
||||
roll->UnknownBaseFlag2 = 1;
|
||||
roll->ActiveFlag = 1;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void TSink::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
|
||||
}
|
||||
else
|
||||
{
|
||||
ball->UnknownBaseFlag2 = 0;
|
||||
ball->ActiveFlag = 0;
|
||||
render::sprite_set_bitmap(ball->RenderSprite, nullptr);
|
||||
loader::play_sound(SoundIndex4);
|
||||
control::handler(63, this);
|
||||
@ -97,7 +97,7 @@ void TSink::TimerExpired(int timerId, void* caller)
|
||||
auto sink = static_cast<TSink*>(caller);
|
||||
auto ball = static_cast<TBall*>(sink->PinballTable->BallList->Get(0));
|
||||
ball->CollisionComp = nullptr;
|
||||
ball->UnknownBaseFlag2 = 1;
|
||||
ball->ActiveFlag = 1;
|
||||
ball->Position.X = sink->BallPosition.X;
|
||||
ball->Position.Y = sink->BallPosition.Y;
|
||||
TBall::throw_ball(ball, &sink->BallAcceleration, sink->ThrowAngleMult, sink->ThrowSpeedMult1,
|
||||
|
@ -26,13 +26,13 @@ int TSoloTarget::Message(int code, float value)
|
||||
{
|
||||
case 49:
|
||||
case 50:
|
||||
UnknownBaseFlag2 = code == 50;
|
||||
ActiveFlag = code == 50;
|
||||
break;
|
||||
case 1024:
|
||||
if (Timer)
|
||||
timer::kill(Timer);
|
||||
Timer = 0;
|
||||
UnknownBaseFlag2 = 1;
|
||||
ActiveFlag = 1;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -40,7 +40,7 @@ int TSoloTarget::Message(int code, float value)
|
||||
|
||||
if (ListBitmap)
|
||||
{
|
||||
auto index = 1 - UnknownBaseFlag2;
|
||||
auto index = 1 - ActiveFlag;
|
||||
auto bmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(index));
|
||||
auto zMap = static_cast<zmap_header_type*>(ListZMap->Get(index));
|
||||
render::sprite_set(
|
||||
|
@ -77,8 +77,8 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
|
||||
for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
|
||||
{
|
||||
auto line = new TLine(this,
|
||||
&UnknownBaseFlag2,
|
||||
visual.Flag,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
visArrPtr[2],
|
||||
visArrPtr[3],
|
||||
visArrPtr[0],
|
||||
@ -93,7 +93,7 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
|
||||
}
|
||||
|
||||
Field.Mask = -1;
|
||||
Field.Flag2Ptr = &UnknownBaseFlag2;
|
||||
Field.Flag2Ptr = &ActiveFlag;
|
||||
Field.CollisionComp = this;
|
||||
edges_insert_square(Unknown2F, Unknown1F, Unknown4F, Unknown3F, nullptr,
|
||||
&Field);
|
||||
|
@ -1917,7 +1917,7 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller)
|
||||
sprintf_s(Buffer, pinball::get_rc_string(81, 0), addedScore);
|
||||
control_info_text_box_tag.Component->Display(Buffer, 2.0);
|
||||
control_lite62_tag.Component->Message(20, 0.0);
|
||||
caller->UnknownBaseFlag2 = 0;
|
||||
caller->ActiveFlag = 0;
|
||||
auto duration = control_soundwave7_tag.Component->Play();
|
||||
caller->Message(55, duration);
|
||||
break;
|
||||
@ -1935,11 +1935,11 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller)
|
||||
}
|
||||
control_info_text_box_tag.Component->Display(Buffer, 2.0);
|
||||
control_lite62_tag.Component->Message(4, 0.0);
|
||||
control_kickout1_tag.Component->UnknownBaseFlag2 = 1;
|
||||
control_kickout1_tag.Component->ActiveFlag = 1;
|
||||
break;
|
||||
}
|
||||
case 1024:
|
||||
control_kickout1_tag.Component->UnknownBaseFlag2 = 0;
|
||||
control_kickout1_tag.Component->ActiveFlag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,23 +7,8 @@
|
||||
#include "zdrv.h"
|
||||
|
||||
|
||||
/*_loader_errors dd 0, offset aBadHandle, 1, offset aNoTypeField, 2, offset aNoAttributesFi
|
||||
|
||||
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 loader::loader_errors[] =
|
||||
{
|
||||
errorMsg{0, "Bad Handle"},
|
||||
errorMsg{1, "No Type Field"},
|
||||
errorMsg{2, "No Attributes Field"},
|
||||
@ -84,61 +69,46 @@ int loader::error(int errorCode, int captionCode)
|
||||
|
||||
void loader::default_vsi(visualStruct* visual)
|
||||
{
|
||||
visual->Flag = 0;
|
||||
visual->CollisionGroup = 0;
|
||||
visual->Kicker.Threshold = 8.9999999e10f;
|
||||
visual->Kicker.HardHitSoundId = 0;
|
||||
visual->Smoothness = 0.94999999f;
|
||||
visual->Elasticity = 0.60000002f;
|
||||
visual->FloatArrCount = 0;
|
||||
visual->SoftHitSoundId = 0;
|
||||
visual->Bitmap = 0;
|
||||
visual->ZMap = 0;
|
||||
visual->Bitmap = nullptr;
|
||||
visual->ZMap = nullptr;
|
||||
visual->SoundIndex3 = 0;
|
||||
visual->SoundIndex4 = 0;
|
||||
}
|
||||
|
||||
void loader::loadfrom(datFileStruct* datFile)
|
||||
{
|
||||
int groupIndex = 0;
|
||||
loader_table = datFile;
|
||||
sound_record_table = loader_table;
|
||||
int soundIndex = sound_count;
|
||||
if (datFile->NumberOfGroups > 0)
|
||||
|
||||
for (auto groupIndex = 0; groupIndex < datFile->NumberOfGroups; ++groupIndex)
|
||||
{
|
||||
do
|
||||
{
|
||||
__int16* value = (__int16*)partman::field(datFile, groupIndex, datFieldTypes::ShortValue);
|
||||
auto value = reinterpret_cast<__int16*>(partman::field(datFile, groupIndex, datFieldTypes::ShortValue));
|
||||
if (value && *value == 202)
|
||||
{
|
||||
soundIndex = sound_count;
|
||||
if (sound_count < 65)
|
||||
{
|
||||
sound_list[soundIndex].WavePtr = nullptr;
|
||||
sound_list[soundIndex].GroupIndex = groupIndex;
|
||||
sound_count = ++soundIndex;
|
||||
sound_list[sound_count].WavePtr = nullptr;
|
||||
sound_list[sound_count].GroupIndex = groupIndex;
|
||||
sound_count++;
|
||||
}
|
||||
}
|
||||
++groupIndex;
|
||||
}
|
||||
while (groupIndex < datFile->NumberOfGroups);
|
||||
}
|
||||
loader_sound_count = soundIndex;
|
||||
loader_sound_count = sound_count;
|
||||
}
|
||||
|
||||
void loader::unload()
|
||||
{
|
||||
int index = 1;
|
||||
if (sound_count > 1)
|
||||
{
|
||||
soundListStruct* soundListPtr = &sound_list[1];
|
||||
do
|
||||
{
|
||||
Sound::FreeSound(soundListPtr->WavePtr);
|
||||
++index;
|
||||
++soundListPtr;
|
||||
}
|
||||
while (index < sound_count);
|
||||
}
|
||||
int index;
|
||||
for (index = 1; index < sound_count; ++index)
|
||||
Sound::FreeSound(sound_list[index].WavePtr);
|
||||
|
||||
if (sound_list[index].PtrToSmth)
|
||||
memory::free(sound_list[index].PtrToSmth);
|
||||
sound_count = 1;
|
||||
@ -146,15 +116,13 @@ void loader::unload()
|
||||
|
||||
int loader::get_sound_id(int groupIndex)
|
||||
{
|
||||
int result;
|
||||
__int16 soundIndex = 1;
|
||||
if (sound_count <= 1)
|
||||
{
|
||||
error(25, 26);
|
||||
result = -1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
while (sound_list[soundIndex].GroupIndex != groupIndex)
|
||||
{
|
||||
++soundIndex;
|
||||
@ -164,27 +132,29 @@ int loader::get_sound_id(int groupIndex)
|
||||
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);
|
||||
auto value = reinterpret_cast<__int16*>(partman::field(loader_table, soundGroupId,
|
||||
datFieldTypes::ShortValue));
|
||||
if (value && *value == 202)
|
||||
{
|
||||
const CHAR* fileName = partman::field(loader_table, soundGroupId, datFieldTypes::String);
|
||||
auto 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);
|
||||
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;
|
||||
result = soundIndex;
|
||||
}
|
||||
return result;
|
||||
return soundIndex;
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +168,7 @@ short loader::query_visual_states(int groupIndex)
|
||||
short result;
|
||||
if (groupIndex < 0)
|
||||
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)
|
||||
result = shortArr[1];
|
||||
else
|
||||
@ -208,21 +178,27 @@ short loader::query_visual_states(int groupIndex)
|
||||
|
||||
char* loader::query_name(int groupIndex)
|
||||
{
|
||||
if (groupIndex >= 0)
|
||||
return partman::field(loader_table, groupIndex, datFieldTypes::GroupName);
|
||||
if (groupIndex < 0)
|
||||
{
|
||||
error(0, 19);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return partman::field(loader_table, groupIndex, datFieldTypes::GroupName);
|
||||
}
|
||||
|
||||
__int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize)
|
||||
{
|
||||
__int16* result;
|
||||
__int16 skipIndex = 0;
|
||||
if (groupIndex >= 0)
|
||||
if (groupIndex < 0)
|
||||
{
|
||||
while (true)
|
||||
error(0, 22);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (auto skipIndex = 0;; ++skipIndex)
|
||||
{
|
||||
__int16* shortArr = (__int16*)partman::field_nth(loader_table, groupIndex, datFieldTypes::ShortArray, skipIndex);
|
||||
auto shortArr = reinterpret_cast<__int16*>(partman::field_nth(loader_table, groupIndex,
|
||||
datFieldTypes::ShortArray, skipIndex));
|
||||
if (!shortArr)
|
||||
break;
|
||||
if (*shortArr == firstValue)
|
||||
@ -230,92 +206,72 @@ __int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize
|
||||
*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);
|
||||
result = nullptr;
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float* loader::query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue)
|
||||
{
|
||||
float* result;
|
||||
__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
|
||||
if (groupIndex < 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (groupIndex < 0)
|
||||
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)
|
||||
return error(1, 21);
|
||||
if (*shortArr != 300)
|
||||
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)
|
||||
return error(11, 21);
|
||||
int index = 0;
|
||||
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) >> 2;
|
||||
if (floatArrLength > 0)
|
||||
|
||||
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) / 4;
|
||||
for (auto index = 0; index < floatArrLength; index += 2)
|
||||
{
|
||||
do
|
||||
{
|
||||
float* nextFloatVal = floatArr + 1;
|
||||
switch (static_cast<int>(floor(*floatArr)))
|
||||
switch (static_cast<int>(floor(floatArr[index])))
|
||||
{
|
||||
case 301:
|
||||
visual->Smoothness = *nextFloatVal;
|
||||
visual->Smoothness = floatArr[index + 1];
|
||||
break;
|
||||
case 302:
|
||||
visual->Elasticity = *nextFloatVal;
|
||||
visual->Elasticity = floatArr[index + 1];
|
||||
break;
|
||||
case 304:
|
||||
visual->SoftHitSoundId = get_sound_id((int)floor(*nextFloatVal));
|
||||
visual->SoftHitSoundId = get_sound_id(static_cast<int>(floor(floatArr[index + 1])));
|
||||
break;
|
||||
default:
|
||||
return error(9, 21);
|
||||
}
|
||||
floatArr = nextFloatVal + 1;
|
||||
index += 2;
|
||||
}
|
||||
while (index < floatArrLength);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -331,12 +287,10 @@ float loader::play_sound(int soundIndex)
|
||||
|
||||
int loader::state_id(int groupIndex, int groupIndexOffset)
|
||||
{
|
||||
int result;
|
||||
int groupIndex2 = groupIndex;
|
||||
__int16 visualState = query_visual_states(groupIndex);
|
||||
auto visualState = query_visual_states(groupIndex);
|
||||
if (visualState <= 0)
|
||||
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)
|
||||
return error(1, 24);
|
||||
if (*shortArr != 200)
|
||||
@ -344,36 +298,34 @@ int loader::state_id(int groupIndex, int groupIndexOffset)
|
||||
if (groupIndexOffset > visualState)
|
||||
return error(12, 24);
|
||||
if (!groupIndexOffset)
|
||||
return groupIndex2;
|
||||
return groupIndex;
|
||||
|
||||
groupIndex2 = groupIndexOffset + groupIndex;
|
||||
shortArr = (__int16*)partman::field(loader_table, groupIndexOffset + groupIndex, datFieldTypes::ShortValue);
|
||||
groupIndex += groupIndexOffset;
|
||||
shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue));
|
||||
if (!shortArr)
|
||||
return error(1, 24);
|
||||
if (*shortArr != 201)
|
||||
result = error(6, 24);
|
||||
else
|
||||
result = groupIndex2;
|
||||
return result;
|
||||
return error(6, 24);
|
||||
return groupIndex;
|
||||
}
|
||||
|
||||
int loader::kicker(int groupIndex, visualKickerStruct* kicker)
|
||||
{
|
||||
if (groupIndex < 0)
|
||||
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)
|
||||
return error(1, 20);
|
||||
if (*shortArr != 400)
|
||||
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)
|
||||
return error(11, 20);
|
||||
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) >> 2;
|
||||
int index = 0;
|
||||
int floatArrLength = partman::field_size(loader_table, groupIndex, datFieldTypes::FloatArray) / 4;
|
||||
if (floatArrLength <= 0)
|
||||
return 0;
|
||||
while (index < floatArrLength)
|
||||
|
||||
for (auto index = 0; index < floatArrLength;)
|
||||
{
|
||||
int floorVal = static_cast<int>(floor(*floatArr++));
|
||||
switch (floorVal)
|
||||
@ -411,67 +363,46 @@ int loader::kicker(int groupIndex, visualKickerStruct* kicker)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* visual)
|
||||
{
|
||||
visualStruct* visual2;
|
||||
int groupIndexSum;
|
||||
int groupIndexSum2;
|
||||
zmap_header_type* bitmap16;
|
||||
__int16* shortArr;
|
||||
unsigned int shortArrSize;
|
||||
int index;
|
||||
int shortVal;
|
||||
__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);
|
||||
if (groupIndex < 0)
|
||||
return error(0, 18);
|
||||
groupIndexSum = state_id(groupIndex, groupIndexOffset);
|
||||
groupIndexSum2 = groupIndexSum;
|
||||
groupIndexSum3 = groupIndexSum;
|
||||
if (groupIndexSum < 0)
|
||||
auto stateId = state_id(groupIndex, groupIndexOffset);
|
||||
if (stateId < 0)
|
||||
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->ZMap = bitmap16;
|
||||
if (bitmap16)
|
||||
|
||||
visual->Bitmap = reinterpret_cast<gdrv_bitmap8*>(partman::field(loader_table, stateId, datFieldTypes::Bitmap8bit));
|
||||
visual->ZMap = reinterpret_cast<zmap_header_type*>(partman::field(loader_table, stateId, datFieldTypes::Bitmap16bit)
|
||||
);
|
||||
if (visual->ZMap)
|
||||
{
|
||||
bitmap16->ZPtr1 = bitmap16->ZBuffer;
|
||||
visual->ZMap->ZPtr1 = visual->ZMap->ZBuffer;
|
||||
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)
|
||||
{
|
||||
shortArrSize = partman::field_size(loader_table, groupIndexSum2, datFieldTypes::ShortArray);
|
||||
index = 0;
|
||||
shortArrLength = shortArrSize >> 1;
|
||||
if ((__int16)(shortArrSize >> 1) > 0)
|
||||
{
|
||||
while (1)
|
||||
unsigned int shortArrSize = partman::field_size(loader_table, stateId, datFieldTypes::ShortArray);
|
||||
for (auto index = 0u; index < shortArrSize / 2;)
|
||||
{
|
||||
shortVal = *shortArr;
|
||||
nextShortVal = shortArr + 1;
|
||||
nextIndex = index + 1;
|
||||
if (shortVal <= 406)
|
||||
{
|
||||
if (shortVal == 406)
|
||||
{
|
||||
visual2->Kicker.HardHitSoundId = get_sound_id(*nextShortVal);
|
||||
visual->Kicker.HardHitSoundId = get_sound_id(*nextShortVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -486,15 +417,15 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vi
|
||||
{
|
||||
if (shortValSub304 != 96)
|
||||
return error(9, 18);
|
||||
if (kicker(*nextShortVal, &visual2->Kicker))
|
||||
if (kicker(*nextShortVal, &visual->Kicker))
|
||||
return error(14, 18);
|
||||
}
|
||||
else
|
||||
{
|
||||
visual2->SoftHitSoundId = get_sound_id(*nextShortVal);
|
||||
visual->SoftHitSoundId = get_sound_id(*nextShortVal);
|
||||
}
|
||||
}
|
||||
else if (material(*nextShortVal, visual2))
|
||||
else if (material(*nextShortVal, visual))
|
||||
{
|
||||
return error(15, 18);
|
||||
}
|
||||
@ -509,60 +440,58 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vi
|
||||
shortValSub602 = shortVal - 602;
|
||||
if (!shortValSub602)
|
||||
{
|
||||
visual2->Flag |= 1 << *nextShortVal;
|
||||
visual->CollisionGroup |= 1 << *nextShortVal;
|
||||
goto LABEL_31;
|
||||
}
|
||||
shortValSub1100 = shortValSub602 - 498;
|
||||
if (!shortValSub1100)
|
||||
break;
|
||||
{
|
||||
visual->SoundIndex4 = get_sound_id(*nextShortVal);
|
||||
goto LABEL_31;
|
||||
}
|
||||
shortValSub1101 = shortValSub1100 - 1;
|
||||
if (!shortValSub1101)
|
||||
{
|
||||
visual2->SoundIndex3 = get_sound_id(*nextShortVal);
|
||||
visual->SoundIndex3 = get_sound_id(*nextShortVal);
|
||||
LABEL_31:
|
||||
shortArr = nextShortVal + 1;
|
||||
index = nextIndex + 1;
|
||||
index = index + 2;
|
||||
goto LABEL_32;
|
||||
}
|
||||
if (shortValSub1101 != 399)
|
||||
return error(9, 18);
|
||||
shortArr = nextShortVal + 8;
|
||||
index = nextIndex + 8;
|
||||
index = index + 9;
|
||||
LABEL_32:
|
||||
if (index >= shortArrLength)
|
||||
goto LABEL_33;
|
||||
}
|
||||
visual2->SoundIndex4 = get_sound_id(*nextShortVal);
|
||||
goto LABEL_31;
|
||||
{
|
||||
}
|
||||
}
|
||||
LABEL_33:
|
||||
if (!visual2->Flag)
|
||||
visual2->Flag = 1;
|
||||
floatArr = (float*)partman::field(loader_table, groupIndexSum3, datFieldTypes::FloatArray);
|
||||
}
|
||||
|
||||
if (!visual->CollisionGroup)
|
||||
visual->CollisionGroup = 1;
|
||||
auto floatArr = reinterpret_cast<float*>(partman::field(loader_table, stateId, datFieldTypes::FloatArray));
|
||||
if (!floatArr)
|
||||
return 0;
|
||||
nextFloatVal = floatArr + 1;
|
||||
if (*floatArr != 600.0)
|
||||
return 0;
|
||||
visual2->FloatArrCount = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2;
|
||||
floatVal = (__int64)(floor(*nextFloatVal) - 1.0);
|
||||
floatArrPtr = nextFloatVal + 1;
|
||||
if ((int)floatVal)
|
||||
{
|
||||
if ((int)floatVal == 1)
|
||||
{
|
||||
visual2->FloatArrCount = 2;
|
||||
}
|
||||
else if ((int)floatVal != visual2->FloatArrCount)
|
||||
|
||||
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)
|
||||
{
|
||||
case 0:
|
||||
visual->FloatArrCount = 1;
|
||||
break;
|
||||
case 1:
|
||||
visual->FloatArrCount = 2;
|
||||
break;
|
||||
default:
|
||||
if (floatVal != visual->FloatArrCount)
|
||||
return error(8, 18);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
visual2->FloatArrCount = 1;
|
||||
}
|
||||
visual2->FloatArr = floatArrPtr;
|
||||
|
||||
visual->FloatArr = floatArr + 2;
|
||||
return 0;
|
||||
}
|
@ -41,7 +41,7 @@ struct __declspec(align(4)) visualStruct
|
||||
float* FloatArr;
|
||||
int SoftHitSoundId;
|
||||
visualKickerStruct Kicker;
|
||||
int Flag;
|
||||
int CollisionGroup;
|
||||
int SoundIndex4;
|
||||
int SoundIndex3;
|
||||
gdrv_bitmap8* Bitmap;
|
||||
|
@ -74,7 +74,7 @@ void nudge::_nudge(float xDiff, float yDiff)
|
||||
for (auto index = 0; index < ballList->Count(); 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.Y = ball->Acceleration.Y * ball->Speed;
|
||||
|
@ -3,7 +3,8 @@
|
||||
#include "gdrv.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
|
||||
};
|
||||
|
||||
@ -11,34 +12,31 @@ short partman::_field_size[] = {
|
||||
datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
{
|
||||
_OFSTRUCT ReOpenBuff{};
|
||||
datFileHeader Buffer{};
|
||||
datFileHeader header{};
|
||||
dat8BitBmpHeader bmpHeader{};
|
||||
datFileStruct* datFile;
|
||||
int groupIndex, groupDataSize;
|
||||
datGroupData** groupDataBuf;
|
||||
|
||||
const HFILE fileHandle = OpenFile(lpFileName, &ReOpenBuff, 0);
|
||||
if (fileHandle == -1)
|
||||
return nullptr;
|
||||
_lread(fileHandle, &Buffer, 183u);
|
||||
if (lstrcmpA("PARTOUT(4.0)RESOURCE", Buffer.FileSignature))
|
||||
_lread(fileHandle, &header, 183u);
|
||||
if (lstrcmpA("PARTOUT(4.0)RESOURCE", header.FileSignature))
|
||||
{
|
||||
_lclose(fileHandle);
|
||||
return nullptr;
|
||||
}
|
||||
datFile = (datFileStruct*)memory::allocate(sizeof(datFileStruct));
|
||||
auto datFile = (datFileStruct*)memory::allocate(sizeof(datFileStruct));
|
||||
if (!datFile)
|
||||
{
|
||||
_lclose(fileHandle);
|
||||
return nullptr;
|
||||
}
|
||||
if (lstrlenA(Buffer.Description) <= 0)
|
||||
if (lstrlenA(header.Description) <= 0)
|
||||
{
|
||||
datFile->Description = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
int lenOfStr = lstrlenA(Buffer.Description);
|
||||
int lenOfStr = lstrlenA(header.Description);
|
||||
auto descriptionBuf = static_cast<char*>(memory::allocate(lenOfStr + 1));
|
||||
datFile->Description = descriptionBuf;
|
||||
if (!descriptionBuf)
|
||||
@ -47,12 +45,12 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
memory::free(datFile);
|
||||
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)
|
||||
{
|
||||
_lclose(fileHandle);
|
||||
@ -61,11 +59,11 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
memory::free(datFile);
|
||||
return nullptr;
|
||||
}
|
||||
_lread(fileHandle, static_cast<void*>(unknownBuf), Buffer.Unknown);
|
||||
_lread(fileHandle, static_cast<void*>(unknownBuf), header.Unknown);
|
||||
memory::free(unknownBuf);
|
||||
}
|
||||
|
||||
groupDataBuf = (datGroupData**)memory::allocate(sizeof(void*) * Buffer.NumberOfGroups);
|
||||
auto groupDataBuf = (datGroupData**)memory::allocate(sizeof(void*) * header.NumberOfGroups);
|
||||
datFile->GroupData = groupDataBuf;
|
||||
if (!groupDataBuf)
|
||||
{
|
||||
@ -75,27 +73,20 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
groupIndex = 0;
|
||||
if (Buffer.NumberOfGroups)
|
||||
bool abort = false;
|
||||
for (auto groupIndex = 0; !abort && groupIndex < header.NumberOfGroups; ++groupIndex)
|
||||
{
|
||||
do
|
||||
{
|
||||
char entryCount = _lread_char(fileHandle);
|
||||
if (entryCount <= 0)
|
||||
groupDataSize = 0;
|
||||
else
|
||||
groupDataSize = entryCount - 1;
|
||||
datFile->GroupData[groupIndex] = (datGroupData*)memory::allocate(
|
||||
sizeof(datEntryData) * groupDataSize + sizeof(datGroupData));
|
||||
datGroupData* groupData = datFile->GroupData[groupIndex];
|
||||
auto entryCount = _lread_char(fileHandle);
|
||||
auto groupDataSize = entryCount <= 0 ? 0 : entryCount - 1;
|
||||
auto groupData = reinterpret_cast<datGroupData*>(memory::allocate(
|
||||
sizeof(datEntryData) * groupDataSize + sizeof(datGroupData)));
|
||||
datFile->GroupData[groupIndex] = groupData;
|
||||
if (!groupData)
|
||||
break;
|
||||
int entryIndex = 0;
|
||||
|
||||
groupData->EntryCount = entryCount;
|
||||
if (entryCount > 0)
|
||||
{
|
||||
datEntryData* entryData = groupData->Entries;
|
||||
do
|
||||
for (auto entryIndex = 0; entryIndex < entryCount; ++entryIndex)
|
||||
{
|
||||
auto entryType = static_cast<datFieldTypes>(_lread_char(fileHandle));
|
||||
entryData->EntryType = entryType;
|
||||
@ -106,16 +97,22 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
}
|
||||
if (entryType == datFieldTypes::Bitmap8bit)
|
||||
{
|
||||
_hread(fileHandle, &bmpHeader, 14);
|
||||
auto bmp = (gdrv_bitmap8*)memory::allocate(sizeof(gdrv_bitmap8));
|
||||
entryData->Buffer = (char*)bmp;
|
||||
_hread(fileHandle, &bmpHeader, sizeof(dat8BitBmpHeader));
|
||||
auto bmp = reinterpret_cast<gdrv_bitmap8*>(memory::allocate(sizeof(gdrv_bitmap8)));
|
||||
entryData->Buffer = reinterpret_cast<char*>(bmp);
|
||||
if (!bmp)
|
||||
goto LABEL_41;
|
||||
if (bmpHeader.Unknown2 & 2
|
||||
{
|
||||
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.Unknown2 & 1))
|
||||
goto LABEL_41;
|
||||
bmpHeader.IsFlagSet(bmp8Flags::RawBmpUnaligned)))
|
||||
{
|
||||
abort = true;
|
||||
break;
|
||||
}
|
||||
_hread(fileHandle, bmp->BmpBufPtr1, bmpHeader.Size);
|
||||
bmp->XPosition = bmpHeader.XPosition;
|
||||
bmp->YPosition = bmpHeader.YPosition;
|
||||
@ -125,25 +122,21 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
|
||||
char* entryBuffer = static_cast<char*>(memory::allocate(fieldSize));
|
||||
entryData->Buffer = entryBuffer;
|
||||
if (!entryBuffer)
|
||||
goto LABEL_41;
|
||||
{
|
||||
abort = true;
|
||||
break;
|
||||
}
|
||||
_hread(fileHandle, entryBuffer, fieldSize);
|
||||
}
|
||||
|
||||
++entryIndex;
|
||||
entryData->FieldSize = fieldSize;
|
||||
datFile->NumberOfGroups = groupIndex + 1;
|
||||
++entryData;
|
||||
}
|
||||
while (entryIndex < entryCount);
|
||||
}
|
||||
++groupIndex;
|
||||
}
|
||||
while (groupIndex < Buffer.NumberOfGroups);
|
||||
}
|
||||
|
||||
LABEL_41:
|
||||
_lclose(fileHandle);
|
||||
if (datFile->NumberOfGroups == Buffer.NumberOfGroups)
|
||||
if (datFile->NumberOfGroups == header.NumberOfGroups)
|
||||
return datFile;
|
||||
unload_records(datFile);
|
||||
return nullptr;
|
||||
|
@ -25,6 +25,13 @@ enum class datFieldTypes : __int16
|
||||
// 16 bpp bitmap(Heightmap ? )
|
||||
};
|
||||
|
||||
enum class bmp8Flags : unsigned char
|
||||
{
|
||||
RawBmpUnaligned = 1 << 0,
|
||||
DibBitmap = 1 << 1,
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct datFileHeader
|
||||
@ -70,7 +77,12 @@ struct dat8BitBmpHeader
|
||||
__int16 XPosition;
|
||||
__int16 YPosition;
|
||||
int Size;
|
||||
char Unknown2;
|
||||
bmp8Flags Flags;
|
||||
|
||||
bool IsFlagSet(bmp8Flags flag)
|
||||
{
|
||||
return static_cast<char>(Flags) & static_cast<char>(flag);
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@ -146,7 +146,7 @@ void pb::mode_change(int mode)
|
||||
if (MainTable)
|
||||
{
|
||||
if (MainTable->Demo)
|
||||
MainTable->Demo->UnknownBaseFlag2 = 1;
|
||||
MainTable->Demo->ActiveFlag = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -157,7 +157,7 @@ void pb::mode_change(int mode)
|
||||
if (MainTable)
|
||||
{
|
||||
if (MainTable->Demo)
|
||||
MainTable->Demo->UnknownBaseFlag2 = 0;
|
||||
MainTable->Demo->ActiveFlag = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -260,7 +260,7 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
||||
for (int i = 0; i < MainTable->BallList->Count(); i++)
|
||||
{
|
||||
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
|
||||
if (ball->UnknownBaseFlag2 != 0)
|
||||
if (ball->ActiveFlag != 0)
|
||||
{
|
||||
auto collComp = ball->CollisionComp;
|
||||
if (collComp)
|
||||
@ -270,7 +270,7 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainTable->UnknownBaseFlag2)
|
||||
if (MainTable->ActiveFlag)
|
||||
{
|
||||
vec2.X = 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++)
|
||||
{
|
||||
auto ball = static_cast<TBall*>(MainTable->BallList->Get(i));
|
||||
if (ball->UnknownBaseFlag2)
|
||||
if (ball->ActiveFlag)
|
||||
ball->Repaint();
|
||||
}
|
||||
}
|
||||
@ -449,7 +449,7 @@ void pb::keydown(int key)
|
||||
for (auto index = 0; ;)
|
||||
{
|
||||
ball = static_cast<TBall*>(MainTable->BallList->Get(index));
|
||||
if (!ball->UnknownBaseFlag2)
|
||||
if (!ball->ActiveFlag)
|
||||
break;
|
||||
++index;
|
||||
if (index >= MainTable->BallList->Count())
|
||||
@ -460,7 +460,7 @@ void pb::keydown(int key)
|
||||
}
|
||||
}
|
||||
ball->Position.X = 1.0;
|
||||
ball->UnknownBaseFlag2 = 1;
|
||||
ball->ActiveFlag = 1;
|
||||
ball->Position.Z = ball->Offset;
|
||||
ball->Position.Y = 1.0;
|
||||
ball->Acceleration.Z = 0.0;
|
||||
@ -601,7 +601,7 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
||||
ray_type ray{};
|
||||
vector_type positionMod{};
|
||||
|
||||
if (ball->UnknownBaseFlag2 && !ball->CollisionComp)
|
||||
if (ball->ActiveFlag && !ball->CollisionComp)
|
||||
{
|
||||
if (ball_speed_limit < ball->Speed)
|
||||
ball->Speed = ball_speed_limit;
|
||||
|
Loading…
Reference in New Issue
Block a user