mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-22 08:50:18 +01:00
TTableLayer v1.
This commit is contained in:
parent
a6425b54f3
commit
3097edf526
11 changed files with 176 additions and 29 deletions
Binary file not shown.
|
@ -185,6 +185,7 @@
|
|||
<ClInclude Include="TComponentGroup.h" />
|
||||
<ClInclude Include="TDemo.h" />
|
||||
<ClInclude Include="TDrain.h" />
|
||||
<ClInclude Include="TEdgeManager.h" />
|
||||
<ClInclude Include="TEdgeSegment.h" />
|
||||
<ClInclude Include="TFlagSpinner.h" />
|
||||
<ClInclude Include="TFlipper.h" />
|
||||
|
@ -253,6 +254,7 @@
|
|||
<ClCompile Include="TComponentGroup.cpp" />
|
||||
<ClCompile Include="TDemo.cpp" />
|
||||
<ClCompile Include="TDrain.cpp" />
|
||||
<ClCompile Include="TEdgeManager.cpp" />
|
||||
<ClCompile Include="TEdgeSegment.cpp" />
|
||||
<ClCompile Include="TFlagSpinner.cpp" />
|
||||
<ClCompile Include="TFlipper.cpp" />
|
||||
|
|
|
@ -216,6 +216,9 @@
|
|||
<ClInclude Include="control.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TEdgeManager.h">
|
||||
<Filter>Header Files\TPinballComponent</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
|
@ -398,6 +401,9 @@
|
|||
<ClCompile Include="control.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TEdgeManager.cpp">
|
||||
<Filter>Source Files\TPinballComponent</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="NatvisFile.natvis" />
|
||||
|
|
6
SpaceCadetPinball/TEdgeManager.cpp
Normal file
6
SpaceCadetPinball/TEdgeManager.cpp
Normal 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)
|
||||
{
|
||||
}
|
20
SpaceCadetPinball/TEdgeManager.h
Normal file
20
SpaceCadetPinball/TEdgeManager.h
Normal 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);
|
||||
};
|
|
@ -56,9 +56,8 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
ListP2->Add(ballObj);
|
||||
if (ballObj)
|
||||
ballObj->UnknownBaseFlag2 = 0;
|
||||
TTableLayer* tableLayerObj = new TTableLayer(this);
|
||||
TLightGroup* lightGroupObj = new TLightGroup(this, 0);
|
||||
this->LightGroup = lightGroupObj;
|
||||
new TTableLayer(this);
|
||||
this->LightGroup = new TLightGroup(this, 0);
|
||||
|
||||
auto score1 = score::create("score1", render::background_bitmap);
|
||||
this->Score1 = score1;
|
||||
|
@ -71,7 +70,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
scorePtr += 7;
|
||||
}
|
||||
while (scoreIndex < 4);
|
||||
this->UnknownP45 = 0;
|
||||
this->CurrentPlayer = 0;
|
||||
this->UnknownP73 = 3;
|
||||
this->ScoreBallcount = (int*)score::create("ballcount1", 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()
|
||||
{
|
||||
//this->VfTable = (TPinballComponent_vtbl*)&TPinballTable::`vftable';
|
||||
scoreStruct** scorePtr = &Score2;
|
||||
int index = 4;
|
||||
do
|
||||
|
@ -216,12 +214,10 @@ TPinballTable::~TPinballTable()
|
|||
memory::free(ScoreBallcount);
|
||||
ScoreBallcount = nullptr;
|
||||
}
|
||||
for (auto i = LightGroup; ; i = static_cast<TLightGroup*>(ListP1->Get(0)))
|
||||
delete LightGroup;
|
||||
while (ListP1->Count() > 0)
|
||||
{
|
||||
//if (i)
|
||||
//(*(void(__thiscall**)(TLightGroup*, int))(*(_DWORD*)i + 16))(i, 1);
|
||||
//if (!ListP1->Count())
|
||||
break;
|
||||
delete static_cast<TPinballComponent*>(ListP1->Get(0));
|
||||
}
|
||||
delete ListP2;
|
||||
delete ListP1;
|
||||
|
|
|
@ -22,9 +22,9 @@ public:
|
|||
int* ScoreBallcount;
|
||||
int* ScorePlayerNumber1;
|
||||
int UnknownP6;
|
||||
int UnknownP7;
|
||||
int UnknownP8;
|
||||
int UnknownP9;
|
||||
int SoundIndex1;
|
||||
int SoundIndex2;
|
||||
int SoundIndex3;
|
||||
int UnknownP10;
|
||||
int UnknownP11;
|
||||
int UnknownP12;
|
||||
|
@ -59,21 +59,21 @@ public:
|
|||
int UnknownP41;
|
||||
int UnknownP42;
|
||||
int UnknownP43;
|
||||
int UnknownP44;
|
||||
int UnknownP45;
|
||||
int PlayerCount;
|
||||
int CurrentPlayer;
|
||||
TPlunger* Plunger;
|
||||
TDrain* Drain;
|
||||
int UnknownP48;
|
||||
int XOffset;
|
||||
int YOffset;
|
||||
int UnknownP51;
|
||||
int UnknownP52;
|
||||
int Width;
|
||||
int Height;
|
||||
objlist_class* ListP1;
|
||||
objlist_class* ListP2;
|
||||
TLightGroup* LightGroup;
|
||||
int UnknownP58;
|
||||
int UnknownP59;
|
||||
int UnknownP60;
|
||||
float TableAngleMult;
|
||||
float TableAngle1;
|
||||
float TableAngle2;
|
||||
float CollisionCompOffset;
|
||||
int UnknownP62;
|
||||
int UnknownP63;
|
||||
|
|
|
@ -1,2 +1,103 @@
|
|||
#include "pch.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;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
#pragma once
|
||||
#include "TCollisionComponent.h"
|
||||
#include "TEdgeManager.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class TTableLayer :
|
||||
public TCollisionComponent
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ void loader::default_vsi(visualStruct* visual)
|
|||
visual->Kicker.SoundIndex = 0;
|
||||
visual->Unknown1F = 0.94999999f;
|
||||
visual->Unknown2F = 0.60000002f;
|
||||
visual->FloatArrSizeDiv8Sub2 = 0;
|
||||
visual->FloatArrCount = 0;
|
||||
visual->SoundIndex2 = 0;
|
||||
visual->Bitmap = 0;
|
||||
visual->ZMap = 0;
|
||||
|
@ -545,23 +545,23 @@ LABEL_33:
|
|||
nextFloatVal = floatArr + 1;
|
||||
if (*floatArr != 600.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);
|
||||
floatArrPtr = nextFloatVal + 1;
|
||||
if ((int)floatVal)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
visual2->FloatArrSizeDiv8Sub2 = 1;
|
||||
visual2->FloatArrCount = 1;
|
||||
}
|
||||
visual2->FloatArr = floatArrPtr;
|
||||
return 0;
|
||||
|
|
|
@ -37,7 +37,7 @@ struct __declspec(align(4)) visualStruct
|
|||
{
|
||||
float Unknown1F;
|
||||
float Unknown2F;
|
||||
int FloatArrSizeDiv8Sub2;
|
||||
int FloatArrCount;
|
||||
float* FloatArr;
|
||||
int SoundIndex2;
|
||||
visualKickerStruct Kicker;
|
||||
|
|
Loading…
Reference in a new issue