ENIGMA Forums

Contributing to ENIGMA => Developing ENIGMA => Topic started by: Goombert on April 24, 2014, 03:46:45 AM

Title: Inheritance
Post by: Goombert on April 24, 2014, 03:46:45 AM
* This post is for Josh, stay the fag out of it.

I have a couple of questions I need you to answer, I wrote everything the way you told me to, but there are a couple of things you did not consider. Please answer these questions so that I may continue working tomorrow and have most of it done by the time you get home.

1) How do I rewrite events.res?
Code: (YAML) [Select]
alarm: 2
        Group
: Alarm
        Name
: Alarm %1
        Mode
: Stacked
        Sub Check
: {alarm[%1] = (int)alarm[%1]; if ((alarm[%1] == -1) or (alarm[%1]--)) return 0; }
I rewrote that subcheck to look like this.
Code: (YAML) [Select]
Sub Check: { alarm[%1] = (int)alarm[%1]; return !((alarm[%1] == -1) or (alarm[%1]--)); }Also how should the following be rewritten.
Code: (YAML) [Select]
keypress: 9
        Group
: Key Press
        Name
: Press <%1>
        Type
: Key
        Mode
: Stacked
        Super Check
: keyboard_check_pressed(%1)

2) I had to make the non-stackable event base sub check methods virtual for event_parent since that is what the iterator is cast to in ENIGMA_events.
Code: (C++) [Select]
   for (instance_event_iterator = event_nomorehealth->next; instance_event_iterator != NULL; instance_event_iterator = instance_event_iterator->next) {
    if (((enigma::event_parent*)(instance_event_iterator->inst))->myevent_nomorehealth_subcheck()) {
      ((enigma::event_parent*)(instance_event_iterator->inst))->myevent_nomorehealth();
    }
      if (enigma::room_switching_id != -1) goto after_events;
    }
   
    enigma::update_globals();
This is what the virtual subchecks look like in event_parent, and yes I know inline virtuals are redundant, see the next question.
Code: (C++) [Select]
inline virtual bool myevent_draw_subcheck() { return false; }Also, why do we bother duplicating the subcheck code for every instance when it has to go through this many steps? Why not just write all the subcheck code that's needed for every instance to event_parent?

3) I had to write the grouped event bases like event_perform for now, are you alright with this?
Code: (C++) [Select]
// Grouped event bases
      void myevent_alarm()
      {
          if (myevent_alarm_0_subcheck()) {
            myevent_alarm_0();
          }
          if (myevent_alarm_1_subcheck()) {
            myevent_alarm_1();
          }
      }
Title: Re: Inheritance
Post by: Josh @ Dreamland on April 25, 2014, 07:59:38 PM
To summarize our previous discussion for public record,