mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
DM: Start refactoring Timeline
This commit is contained in:
parent
53a8bda124
commit
7bda512dde
@ -930,7 +930,7 @@ bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
|
|||||||
// Fix original bug - When disabled ticks is equal to zero, increasing the defense leads
|
// Fix original bug - When disabled ticks is equal to zero, increasing the defense leads
|
||||||
// to a permanent increment.
|
// to a permanent increment.
|
||||||
if (_actionDisabledTicks[actionIndex])
|
if (_actionDisabledTicks[actionIndex])
|
||||||
curChampion->_actionDefense += _actionDefense[actionIndex];
|
curChampion->_actionDefense += _vm->_timeline->_actionDefense[actionIndex];
|
||||||
|
|
||||||
setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
|
setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
|
||||||
retVal = isActionPerformed(championIndex, actionIndex);
|
retVal = isActionPerformed(championIndex, actionIndex);
|
||||||
|
@ -40,51 +40,57 @@
|
|||||||
|
|
||||||
namespace DM {
|
namespace DM {
|
||||||
|
|
||||||
signed char _actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
|
void Timeline::initConstants() {
|
||||||
0, /* N */
|
static signed char actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense
|
||||||
36, /* BLOCK */
|
0, /* N */
|
||||||
0, /* CHOP */
|
36, /* BLOCK */
|
||||||
0, /* X */
|
0, /* CHOP */
|
||||||
-4, /* BLOW HORN */
|
0, /* X */
|
||||||
-10, /* FLIP */
|
-4, /* BLOW HORN */
|
||||||
-10, /* PUNCH */
|
-10, /* FLIP */
|
||||||
-5, /* KICK */
|
-10, /* PUNCH */
|
||||||
4, /* WAR CRY */
|
-5, /* KICK */
|
||||||
-20, /* STAB */
|
4, /* WAR CRY */
|
||||||
-15, /* CLIMB DOWN */
|
-20, /* STAB */
|
||||||
-10, /* FREEZE LIFE */
|
-15, /* CLIMB DOWN */
|
||||||
16, /* HIT */
|
-10, /* FREEZE LIFE */
|
||||||
5, /* SWING */
|
16, /* HIT */
|
||||||
-15, /* STAB */
|
5, /* SWING */
|
||||||
-17, /* THRUST */
|
-15, /* STAB */
|
||||||
-5, /* JAB */
|
-17, /* THRUST */
|
||||||
29, /* PARRY */
|
-5, /* JAB */
|
||||||
10, /* HACK */
|
29, /* PARRY */
|
||||||
-10, /* BERZERK */
|
10, /* HACK */
|
||||||
-7, /* FIREBALL */
|
-10, /* BERZERK */
|
||||||
-7, /* DISPELL */
|
-7, /* FIREBALL */
|
||||||
-7, /* CONFUSE */
|
-7, /* DISPELL */
|
||||||
-7, /* LIGHTNING */
|
-7, /* CONFUSE */
|
||||||
-7, /* DISRUPT */
|
-7, /* LIGHTNING */
|
||||||
-5, /* MELEE */
|
-7, /* DISRUPT */
|
||||||
-15, /* X */
|
-5, /* MELEE */
|
||||||
-9, /* INVOKE */
|
-15, /* X */
|
||||||
4, /* SLASH */
|
-9, /* INVOKE */
|
||||||
0, /* CLEAVE */
|
4, /* SLASH */
|
||||||
0, /* BASH */
|
0, /* CLEAVE */
|
||||||
5, /* STUN */
|
0, /* BASH */
|
||||||
-15, /* SHOOT */
|
5, /* STUN */
|
||||||
-7, /* SPELLSHIELD */
|
-15, /* SHOOT */
|
||||||
-7, /* FIRESHIELD */
|
-7, /* SPELLSHIELD */
|
||||||
8, /* FLUXCAGE */
|
-7, /* FIRESHIELD */
|
||||||
-20, /* HEAL */
|
8, /* FLUXCAGE */
|
||||||
-5, /* CALM */
|
-20, /* HEAL */
|
||||||
0, /* LIGHT */
|
-5, /* CALM */
|
||||||
-15, /* WINDOW */
|
0, /* LIGHT */
|
||||||
-7, /* SPIT */
|
-15, /* WINDOW */
|
||||||
-4, /* BRANDISH */
|
-7, /* SPIT */
|
||||||
0, /* THROW */
|
-4, /* BRANDISH */
|
||||||
8}; /* FUSE */
|
0, /* THROW */
|
||||||
|
8 /* FUSE */
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < 44; i++)
|
||||||
|
_actionDefense[i] = actionDefense[i];
|
||||||
|
}
|
||||||
|
|
||||||
Timeline::Timeline(DMEngine* vm) : _vm(vm) {
|
Timeline::Timeline(DMEngine* vm) : _vm(vm) {
|
||||||
_eventMaxCount = 0;
|
_eventMaxCount = 0;
|
||||||
@ -92,6 +98,8 @@ Timeline::Timeline(DMEngine* vm) : _vm(vm) {
|
|||||||
_eventCount = 0;
|
_eventCount = 0;
|
||||||
_timeline = nullptr;
|
_timeline = nullptr;
|
||||||
_firstUnusedEventIndex = 0;
|
_firstUnusedEventIndex = 0;
|
||||||
|
|
||||||
|
initConstants();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timeline::~Timeline() {
|
Timeline::~Timeline() {
|
||||||
@ -111,45 +119,37 @@ void Timeline::initTimeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timeline::deleteEvent(uint16 eventIndex) {
|
void Timeline::deleteEvent(uint16 eventIndex) {
|
||||||
uint16 L0586_ui_TimelineIndex;
|
|
||||||
uint16 L0587_ui_EventCount;
|
|
||||||
|
|
||||||
|
|
||||||
_events[eventIndex]._type = k0_TMEventTypeNone;
|
_events[eventIndex]._type = k0_TMEventTypeNone;
|
||||||
if (eventIndex < _firstUnusedEventIndex) {
|
if (eventIndex < _firstUnusedEventIndex)
|
||||||
_firstUnusedEventIndex = eventIndex;
|
_firstUnusedEventIndex = eventIndex;
|
||||||
}
|
|
||||||
_eventCount--;
|
_eventCount--;
|
||||||
if ((L0587_ui_EventCount = _eventCount) == 0) {
|
|
||||||
|
uint16 eventCount = _eventCount;
|
||||||
|
if (eventCount == 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
L0586_ui_TimelineIndex = getIndex(eventIndex);
|
uint16 timelineIndex = getIndex(eventIndex);
|
||||||
if (L0586_ui_TimelineIndex == L0587_ui_EventCount) {
|
if (timelineIndex == eventCount)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
_timeline[L0586_ui_TimelineIndex] = _timeline[L0587_ui_EventCount];
|
_timeline[timelineIndex] = _timeline[eventCount];
|
||||||
fixChronology(L0586_ui_TimelineIndex);
|
fixChronology(timelineIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline::fixChronology(uint16 timelineIndex) {
|
void Timeline::fixChronology(uint16 timelineIndex) {
|
||||||
uint16 L0581_ui_TimelineIndex;
|
uint16 eventCount = _eventCount;
|
||||||
uint16 L0582_ui_EventIndex;
|
if (eventCount == 1)
|
||||||
uint16 L0583_ui_EventCount;
|
|
||||||
TimelineEvent* L0584_ps_Event;
|
|
||||||
bool L0585_B_ChronologyFixed;
|
|
||||||
|
|
||||||
|
|
||||||
if ((L0583_ui_EventCount = _eventCount) == 1) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
L0584_ps_Event = &_events[L0582_ui_EventIndex = _timeline[timelineIndex]];
|
uint16 L0582_ui_EventIndex = _timeline[timelineIndex];
|
||||||
L0585_B_ChronologyFixed = false;
|
TimelineEvent *timelineEvent = &_events[L0582_ui_EventIndex];
|
||||||
|
bool L0585_B_ChronologyFixed = false;
|
||||||
while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
|
while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */
|
||||||
L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1;
|
uint16 altTimelineIndex = (timelineIndex - 1) >> 1;
|
||||||
if (isEventABeforeB(L0584_ps_Event, &_events[_timeline[L0581_ui_TimelineIndex]])) {
|
if (isEventABeforeB(timelineEvent, &_events[_timeline[altTimelineIndex]])) {
|
||||||
_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
|
_timeline[timelineIndex] = _timeline[altTimelineIndex];
|
||||||
timelineIndex = L0581_ui_TimelineIndex;
|
timelineIndex = altTimelineIndex;
|
||||||
L0585_B_ChronologyFixed = true;
|
L0585_B_ChronologyFixed = true;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -157,15 +157,15 @@ void Timeline::fixChronology(uint16 timelineIndex) {
|
|||||||
}
|
}
|
||||||
if (L0585_B_ChronologyFixed)
|
if (L0585_B_ChronologyFixed)
|
||||||
goto T0236011;
|
goto T0236011;
|
||||||
L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1;
|
eventCount = ((eventCount - 1) - 1) >> 1;
|
||||||
while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */
|
while (timelineIndex <= eventCount) { /* Check if the event should be moved later in the timeline */
|
||||||
L0581_ui_TimelineIndex = (timelineIndex << 1) + 1;
|
uint16 altTimelineIndex = (timelineIndex << 1) + 1;
|
||||||
if (((L0581_ui_TimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex + 1]], &_events[_timeline[L0581_ui_TimelineIndex]]))) {
|
if (((altTimelineIndex + 1) < _eventCount) && (isEventABeforeB(&_events[_timeline[altTimelineIndex + 1]], &_events[_timeline[altTimelineIndex]]))) {
|
||||||
L0581_ui_TimelineIndex++;
|
altTimelineIndex++;
|
||||||
}
|
}
|
||||||
if (isEventABeforeB(&_events[_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) {
|
if (isEventABeforeB(&_events[_timeline[altTimelineIndex]], timelineEvent)) {
|
||||||
_timeline[timelineIndex] = _timeline[L0581_ui_TimelineIndex];
|
_timeline[timelineIndex] = _timeline[altTimelineIndex];
|
||||||
timelineIndex = L0581_ui_TimelineIndex;
|
timelineIndex = altTimelineIndex;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,6 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
|
|||||||
k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP
|
k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP
|
||||||
};
|
};
|
||||||
|
|
||||||
extern signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
|
|
||||||
|
|
||||||
class TimelineEvent {
|
class TimelineEvent {
|
||||||
public:
|
public:
|
||||||
int32 _mapTime;
|
int32 _mapTime;
|
||||||
@ -191,6 +189,10 @@ public:
|
|||||||
void saveTimelinePart(Common::OutSaveFile *file);
|
void saveTimelinePart(Common::OutSaveFile *file);
|
||||||
void loadEventsPart(Common::InSaveFile* file);
|
void loadEventsPart(Common::InSaveFile* file);
|
||||||
void loadTimelinePart(Common::InSaveFile* file);
|
void loadTimelinePart(Common::InSaveFile* file);
|
||||||
|
|
||||||
|
signed char _actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
|
||||||
|
|
||||||
|
void initConstants();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user