macrosoft3dpinball/SpaceCadetPinball/TComponentGroup.cpp
type-two b671975742 Vendor SpaceCadetPinball, build for Apple Silicon
Reverse-engineered reimplementation of 3D Pinball for Windows - Space Cadet
from k4zmu2a/SpaceCadetPinball (MIT), upstream cb9b7b8, vendored rather than
submoduled so local patches are just edits.

- CMakeLists: stop hard-setting CMAKE_OSX_ARCHITECTURES so the documented -D
  override works; brew's SDL2 is arm64-only and universal linking failed.
- gitignore original .DAT/.MID assets, which are not ours to redistribute.
- CLAUDE.md: build line, upstream deviation, and where game data goes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 19:05:12 +10:00

65 lines
1.4 KiB
C++

#include "pch.h"
#include "TComponentGroup.h"
#include "control.h"
#include "loader.h"
#include "timer.h"
#include "TPinballTable.h"
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
Timer = 0;
if (groupIndex > 0)
{
int attrCount;
auto shortArr = loader::query_iattribute(groupIndex, 1027, &attrCount);
auto shortArrPtr = shortArr;
for (auto index = 0; index < attrCount; ++index, ++shortArrPtr)
{
auto component = table->find_component(*shortArrPtr);
if (component)
List.push_back(component);
}
}
}
TComponentGroup::~TComponentGroup()
{
if (Timer)
{
timer::kill(Timer);
Timer = 0;
}
}
int TComponentGroup::Message(MessageCode code, float value)
{
if (code == MessageCode::TComponentGroupResetNotifyTimer)
{
if (this->Timer)
{
timer::kill(this->Timer);
this->Timer = 0;
}
if (value > 0.0f)
this->Timer = timer::set(value, this, NotifyTimerExpired);
}
else if (code < MessageCode::Pause || (code > MessageCode::SetTiltLock &&
code != MessageCode::PlayerChanged && code != MessageCode::GameOver))
{
for (auto component : List)
{
component->Message(code, value);
}
}
return 0;
}
void TComponentGroup::NotifyTimerExpired(int timerId, void* caller)
{
auto compGroup = static_cast<TComponentGroup*>(caller);
compGroup->Timer = 0;
control::handler(MessageCode::ControlNotifyTimerExpired, compGroup);
}