1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-23 01:10:19 +01:00

TTableLayer v1.

This commit is contained in:
oz 2020-12-20 14:13:12 +03:00
parent a6425b54f3
commit 3097edf526
11 changed files with 176 additions and 29 deletions

Binary file not shown.

View file

@ -185,6 +185,7 @@
<ClInclude Include="TComponentGroup.h" /> <ClInclude Include="TComponentGroup.h" />
<ClInclude Include="TDemo.h" /> <ClInclude Include="TDemo.h" />
<ClInclude Include="TDrain.h" /> <ClInclude Include="TDrain.h" />
<ClInclude Include="TEdgeManager.h" />
<ClInclude Include="TEdgeSegment.h" /> <ClInclude Include="TEdgeSegment.h" />
<ClInclude Include="TFlagSpinner.h" /> <ClInclude Include="TFlagSpinner.h" />
<ClInclude Include="TFlipper.h" /> <ClInclude Include="TFlipper.h" />
@ -253,6 +254,7 @@
<ClCompile Include="TComponentGroup.cpp" /> <ClCompile Include="TComponentGroup.cpp" />
<ClCompile Include="TDemo.cpp" /> <ClCompile Include="TDemo.cpp" />
<ClCompile Include="TDrain.cpp" /> <ClCompile Include="TDrain.cpp" />
<ClCompile Include="TEdgeManager.cpp" />
<ClCompile Include="TEdgeSegment.cpp" /> <ClCompile Include="TEdgeSegment.cpp" />
<ClCompile Include="TFlagSpinner.cpp" /> <ClCompile Include="TFlagSpinner.cpp" />
<ClCompile Include="TFlipper.cpp" /> <ClCompile Include="TFlipper.cpp" />

View file

@ -216,6 +216,9 @@
<ClInclude Include="control.h"> <ClInclude Include="control.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="TEdgeManager.h">
<Filter>Header Files\TPinballComponent</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
@ -398,6 +401,9 @@
<ClCompile Include="control.cpp"> <ClCompile Include="control.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="TEdgeManager.cpp">
<Filter>Source Files\TPinballComponent</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="NatvisFile.natvis" /> <Natvis Include="NatvisFile.natvis" />

View file

@ -0,0 +1,6 @@
#include "pch.h"
#include "TEdgeManager.h"
void TEdgeManager::edges_insert_square(float a1, float a2, float a3, float a4, TEdgeSegment* a5, field_effect_type* a6)
{
}

View file

@ -0,0 +1,20 @@
#pragma once
#include "TCollisionComponent.h"
#include "TEdgeSegment.h"
struct field_effect_type
{
char* Flag2Ptr;
int Unknown1;
TCollisionComponent* CollisionComp;
};
class TEdgeManager
{
public:
TEdgeManager(float a2, float a3, float a4, float a5)
{
}
static void edges_insert_square(float a1, float a2, float a3, float a4, TEdgeSegment* a5, field_effect_type* a6);
};

View file

@ -56,9 +56,8 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
ListP2->Add(ballObj); ListP2->Add(ballObj);
if (ballObj) if (ballObj)
ballObj->UnknownBaseFlag2 = 0; ballObj->UnknownBaseFlag2 = 0;
TTableLayer* tableLayerObj = new TTableLayer(this); new TTableLayer(this);
TLightGroup* lightGroupObj = new TLightGroup(this, 0); this->LightGroup = new TLightGroup(this, 0);
this->LightGroup = lightGroupObj;
auto score1 = score::create("score1", render::background_bitmap); auto score1 = score::create("score1", render::background_bitmap);
this->Score1 = score1; this->Score1 = score1;
@ -71,7 +70,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
scorePtr += 7; scorePtr += 7;
} }
while (scoreIndex < 4); while (scoreIndex < 4);
this->UnknownP45 = 0; this->CurrentPlayer = 0;
this->UnknownP73 = 3; this->UnknownP73 = 3;
this->ScoreBallcount = (int*)score::create("ballcount1", render::background_bitmap); this->ScoreBallcount = (int*)score::create("ballcount1", render::background_bitmap);
this->ScorePlayerNumber1 = (int*)score::create("player_number1", render::background_bitmap); this->ScorePlayerNumber1 = (int*)score::create("player_number1", render::background_bitmap);
@ -192,7 +191,6 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
TPinballTable::~TPinballTable() TPinballTable::~TPinballTable()
{ {
//this->VfTable = (TPinballComponent_vtbl*)&TPinballTable::`vftable';
scoreStruct** scorePtr = &Score2; scoreStruct** scorePtr = &Score2;
int index = 4; int index = 4;
do do
@ -216,12 +214,10 @@ TPinballTable::~TPinballTable()
memory::free(ScoreBallcount); memory::free(ScoreBallcount);
ScoreBallcount = nullptr; ScoreBallcount = nullptr;
} }
for (auto i = LightGroup; ; i = static_cast<TLightGroup*>(ListP1->Get(0))) delete LightGroup;
while (ListP1->Count() > 0)
{ {
//if (i) delete static_cast<TPinballComponent*>(ListP1->Get(0));
//(*(void(__thiscall**)(TLightGroup*, int))(*(_DWORD*)i + 16))(i, 1);
//if (!ListP1->Count())
break;
} }
delete ListP2; delete ListP2;
delete ListP1; delete ListP1;

View file

@ -22,9 +22,9 @@ public:
int* ScoreBallcount; int* ScoreBallcount;
int* ScorePlayerNumber1; int* ScorePlayerNumber1;
int UnknownP6; int UnknownP6;
int UnknownP7; int SoundIndex1;
int UnknownP8; int SoundIndex2;
int UnknownP9; int SoundIndex3;
int UnknownP10; int UnknownP10;
int UnknownP11; int UnknownP11;
int UnknownP12; int UnknownP12;
@ -59,21 +59,21 @@ public:
int UnknownP41; int UnknownP41;
int UnknownP42; int UnknownP42;
int UnknownP43; int UnknownP43;
int UnknownP44; int PlayerCount;
int UnknownP45; int CurrentPlayer;
TPlunger* Plunger; TPlunger* Plunger;
TDrain* Drain; TDrain* Drain;
int UnknownP48; int UnknownP48;
int XOffset; int XOffset;
int YOffset; int YOffset;
int UnknownP51; int Width;
int UnknownP52; int Height;
objlist_class* ListP1; objlist_class* ListP1;
objlist_class* ListP2; objlist_class* ListP2;
TLightGroup* LightGroup; TLightGroup* LightGroup;
int UnknownP58; float TableAngleMult;
int UnknownP59; float TableAngle1;
int UnknownP60; float TableAngle2;
float CollisionCompOffset; float CollisionCompOffset;
int UnknownP62; int UnknownP62;
int UnknownP63; int UnknownP63;

View file

@ -1,2 +1,103 @@
#include "pch.h" #include "pch.h"
#include "TTableLayer.h" #include "TTableLayer.h"
#include "loader.h"
#include "proj.h"
#include "TLine.h"
#include "TPinballTable.h"
TEdgeManager* TTableLayer::edge_manager;
TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, false)
{
visualStruct visual{};
rectangle_type rect{};
auto groupIndex = loader::query_handle("table");
loader::query_visual(groupIndex, 0, &visual);
auto projCenter = loader::query_float_attribute(groupIndex, 0, 700);
proj::recenter(projCenter[0], projCenter[1]);
render::set_background_zmap(visual.ZMap, 0, 0);
auto bmp = visual.Bitmap;
VisBmp = visual.Bitmap;
rect.XPosition = 0;
rect.YPosition = 0;
rect.Width = bmp->Width;
rect.Height = bmp->Height;
render::create_sprite(VisualType::None, bmp, visual.ZMap, 0, 0, &rect);
PinballTable->SoundIndex1 = visual.SoundIndex4;
PinballTable->SoundIndex2 = visual.SoundIndex3;
PinballTable->SoundIndex3 = visual.Kicker.SoundIndex;
auto tableAngleArr = loader::query_float_attribute(groupIndex, 0, 305);
if (tableAngleArr)
{
PinballTable->TableAngleMult = tableAngleArr[0];
PinballTable->TableAngle1 = tableAngleArr[1];
PinballTable->TableAngle2 = tableAngleArr[2];
}
else
{
PinballTable->TableAngleMult = 25.0f;
PinballTable->TableAngle1 = 0.5f;
PinballTable->TableAngle2 = 1.570796f;
}
auto table3 = PinballTable;
Angle1 = cos(table3->TableAngle2) * sin(table3->TableAngle1) * table3->TableAngleMult;
Angle2 = sin(table3->TableAngle2) * sin(table3->TableAngle1) * table3->TableAngleMult;
auto angleMultArr = loader::query_float_attribute(groupIndex, 0, 701);
if (angleMultArr)
AngleMult = *angleMultArr;
else
AngleMult = 0.2f;
table->XOffset = bmp->XPosition;
table->YOffset = bmp->YPosition;
table->Width = bmp->Width;
table->Height = bmp->Height;
UnknownC7F = visual.Kicker.Unknown1F;
UnknownC6F = 15.0f;
auto visArrPtr = visual.FloatArr;
Unknown1F = min(visArrPtr[0], min(visArrPtr[2], visArrPtr[4]));
Unknown2F = min(visArrPtr[1], min(visArrPtr[3], visArrPtr[5]));
Unknown3F = max(visArrPtr[0], max(visArrPtr[2], visArrPtr[4]));
Unknown4F = max(visArrPtr[1], max(visArrPtr[3], visArrPtr[5]));
auto a2 = Unknown4F - Unknown2F;
auto a1 = Unknown3F - Unknown1F;
edge_manager = new TEdgeManager(Unknown1F, Unknown2F, a1, a2);
for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
{
auto line = new TLine(this,
&UnknownBaseFlag2,
visual.Flag,
visArrPtr[2],
visArrPtr[3],
visArrPtr[0],
visArrPtr[1]);
if (line)
{
line->place_in_grid();
EdgeList->Add(line);
}
visArrPtr += 2;
}
Field.Unknown1 = -1;
Field.Flag2Ptr = &UnknownBaseFlag2;
Field.CollisionComp = this;
TEdgeManager::edges_insert_square(Unknown2F, Unknown1F, Unknown4F, Unknown3F, nullptr,
&Field);
}
TTableLayer::~TTableLayer()
{
if (edge_manager)
delete edge_manager;
}

View file

@ -1,11 +1,27 @@
#pragma once #pragma once
#include "TCollisionComponent.h" #include "TCollisionComponent.h"
#include "TEdgeManager.h"
class TTableLayer : class TTableLayer :
public TCollisionComponent public TCollisionComponent
{ {
public: public:
TTableLayer(TPinballTable* table) : TCollisionComponent(table, -1, false) static TEdgeManager *edge_manager;
{
} TTableLayer(TPinballTable* table);
~TTableLayer() override;
gdrv_bitmap8* VisBmp;
float Unknown1F;
float Unknown2F;
float Unknown3F;
float Unknown4F;
float Angle1;
float Angle2;
int Unknown7;
float AngleMult;
field_effect_type Field;
}; };

View file

@ -88,7 +88,7 @@ void loader::default_vsi(visualStruct* visual)
visual->Kicker.SoundIndex = 0; visual->Kicker.SoundIndex = 0;
visual->Unknown1F = 0.94999999f; visual->Unknown1F = 0.94999999f;
visual->Unknown2F = 0.60000002f; visual->Unknown2F = 0.60000002f;
visual->FloatArrSizeDiv8Sub2 = 0; visual->FloatArrCount = 0;
visual->SoundIndex2 = 0; visual->SoundIndex2 = 0;
visual->Bitmap = 0; visual->Bitmap = 0;
visual->ZMap = 0; visual->ZMap = 0;
@ -545,23 +545,23 @@ LABEL_33:
nextFloatVal = floatArr + 1; nextFloatVal = floatArr + 1;
if (*floatArr != 600.0) if (*floatArr != 600.0)
return 0; return 0;
visual2->FloatArrSizeDiv8Sub2 = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2; visual2->FloatArrCount = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2;
floatVal = (__int64)(floor(*nextFloatVal) - 1.0); floatVal = (__int64)(floor(*nextFloatVal) - 1.0);
floatArrPtr = nextFloatVal + 1; floatArrPtr = nextFloatVal + 1;
if ((int)floatVal) if ((int)floatVal)
{ {
if ((int)floatVal == 1) if ((int)floatVal == 1)
{ {
visual2->FloatArrSizeDiv8Sub2 = 2; visual2->FloatArrCount = 2;
} }
else if ((int)floatVal != visual2->FloatArrSizeDiv8Sub2) else if ((int)floatVal != visual2->FloatArrCount)
{ {
return error(8, 18); return error(8, 18);
} }
} }
else else
{ {
visual2->FloatArrSizeDiv8Sub2 = 1; visual2->FloatArrCount = 1;
} }
visual2->FloatArr = floatArrPtr; visual2->FloatArr = floatArrPtr;
return 0; return 0;

View file

@ -37,7 +37,7 @@ struct __declspec(align(4)) visualStruct
{ {
float Unknown1F; float Unknown1F;
float Unknown2F; float Unknown2F;
int FloatArrSizeDiv8Sub2; int FloatArrCount;
float* FloatArr; float* FloatArr;
int SoundIndex2; int SoundIndex2;
visualKickerStruct Kicker; visualKickerStruct Kicker;