Script.cpp
//---------------------------------------------------------------------------
// First parameter is pointer to instructions in event to fill, second is event name
First parameter is pointer to instructions in event to fill, second is event name
First parameter is pointer to instructions in event to fill second is event name
void BDScript::AddInstructions(std::vector<BDSInstruction> *eventinstr, string ins) {
  string command;
  string data;
  BDSInstruction instr;
  enum {NONE, STRING, BDVECTOR, DOUBLE, INTEGER} dataType;
  for (unsigned int idx = 0; idx < File->GetSizes(ins); idx++) {
    command = File->GetDatas(ins, idx);
    if (command.find_first_of('(') != 0) {
      data = command.substr(command.find_first_of('(') + 1,
                            command.length() - command.find_first_of('(') - 2);
      command = command.substr(0, command.find_first_of('('));
    } else {
      data = "";
      instr.id = -1;
    }
    dataType = NONE;
    if (command == "msg") {
      instr.type = MSGBOX;
      dataType = STRING;
    } else if (command == "velocity") {
      instr.type = VELOCITY;
      dataType = BDVECTOR;
    } else if (command == "position") {
      instr.type = POSITION;
      dataType = BDVECTOR;
    } else if (command == "addposition") {
      instr.type = ADDPOSITION;
      dataType = BDVECTOR;
    } else if (command == "acceleration") {
      instr.type = ACCELERATION;
      dataType = BDVECTOR;
    } else if (command == "camposition") {
      instr.type = CAMPOSITION;
      dataType = BDVECTOR;
    } else if (command == "camvelocity") {
      instr.type = CAMVELOCITY;
      dataType = BDVECTOR;
    } else if (command == "waitforenter")
      instr.type = WAITFORENTER;
    else if (command == "delay") {
      instr.type = DELAY;
      dataType = DOUBLE;
    } else if (command == "delete")
      instr.type = DELETETHIS;
    else if (command == "nomsg")
      instr.type = NOMSGBOX;
    else if (command == "loadlevel") {
      instr.type = LOADLEVEL;
      dataType = STRING;
    } else if (command == "camposbezier") {
      instr.type = CAMPOSBEZIER;
      dataType = DOUBLE;
    } else if (command == "fadetomusic") {
      instr.type = FADETOMUSIC;
      dataType = INTEGER;
    }
    switch(dataType) {
      case STRING :
        instr.id = sData.size();
        if (data[0] != '\'')
          sData.push_back(File->GetDatas(data));
        else
          sData.push_back(data.substr(1, data.length() - 2));
        break;
      case BDVECTOR :
        instr.id = vecData.size();
        instr.numdata = File->GetSized(data) / 3;
        for (unsigned int i = 0; i < File->GetSized(data); i += 3)
          vecData.push_back(Vector3(File->GetDatad(data, i),
                                    File->GetDatad(data, i+1),
                                    File->GetDatad(data, i+2)));
        break;
      case DOUBLE :
        instr.id = dData.size();
        instr.numdata = File->GetSized(data);
        for (unsigned int i = 0; i < File->GetSized(data); i++)
          dData.push_back(File->GetDatad(data, i));
        break;
      case INTEGER :
        instr.id = iData.size();
        instr.numdata = File->GetSizei(data);
        for (unsigned int i = 0; i < File->GetSizei(data); i++)
          iData.push_back(File->GetDatai(data, i));
        break;
    };
    eventinstr->push_back(instr);
  }
}
void BDScript :: AddInstructions ( std :: vector < BDSInstruction > * eventinstr , string ins ) { string command ; string data ; BDSInstruction instr ; enum { NONE , STRING , BDVECTOR , DOUBLE , INTEGER } dataType ; for ( unsigned int idx = 0 ; idx < File -> GetSizes ( ins ) ; idx ++ ) { command = File -> GetDatas ( ins , idx ) ; if ( command . find_first_of ( ' ' ) != 0 ) { data = command . substr ( command . find_first_of ( ' ' ) + 1 , command . length ( ) - command . find_first_of ( ' ' ) - 2 ) ; command = command . substr ( 0 , command . find_first_of ( ' ' ) ) ; } else { data = " " ; instr . id = -1 ; } dataType = NONE ; if ( command == " " ) { instr . type = MSGBOX ; dataType = STRING ; } else if ( command == " " ) { instr . type = VELOCITY ; dataType = BDVECTOR ; } else if ( command == " " ) { instr . type = POSITION ; dataType = BDVECTOR ; } else if ( command == " " ) { instr . type = ADDPOSITION ; dataType = BDVECTOR ; } else if ( command == " " ) { instr . type = ACCELERATION ; dataType = BDVECTOR ; } else if ( command == " " ) { instr . type = CAMPOSITION ; dataType = BDVECTOR ; } else if ( command == " " ) { instr . type = CAMVELOCITY ; dataType = BDVECTOR ; } else if ( command == " " ) instr . type = WAITFORENTER ; else if ( command == " " ) { instr . type = DELAY ; dataType = DOUBLE ; } else if ( command == " " ) instr . type = DELETETHIS ; else if ( command == " " ) instr . type = NOMSGBOX ; else if ( command == " " ) { instr . type = LOADLEVEL ; dataType = STRING ; } else if ( command == " " ) { instr . type = CAMPOSBEZIER ; dataType = DOUBLE ; } else if ( command == " " ) { instr . type = FADETOMUSIC ; dataType = INTEGER ; } switch ( dataType ) { case STRING : instr . id = sData . size ( ) ; if ( data [ 0 ] != ' \' ' ) sData . push_back ( File -> GetDatas ( data ) ) ; else sData . push_back ( data . substr ( 1 , data . length ( ) - 2 ) ) ; break ; case BDVECTOR : instr . id = vecData . size ( ) ; instr . numdata = File -> GetSized ( data ) / 3 ; for ( unsigned int i = 0 ; i < File -> GetSized ( data ) ; i += 3 ) vecData . push_back ( Vector3 ( File -> GetDatad ( data , i ) , File -> GetDatad ( data , i + 1 ) , File -> GetDatad ( data , i + 2 ) ) ) ; break ; case DOUBLE : instr . id = dData . size ( ) ; instr . numdata = File -> GetSized ( data ) ; for ( unsigned int i = 0 ; i < File -> GetSized ( data ) ; i ++ ) dData . push_back ( File -> GetDatad ( data , i ) ) ; break ; case INTEGER : instr . id = iData . size ( ) ; instr . numdata = File -> GetSizei ( data ) ; for ( unsigned int i = 0 ; i < File -> GetSizei ( data ) ; i ++ ) iData . push_back ( File -> GetDatai ( data , i ) ) ; break ; } ; eventinstr -> push_back ( instr ) ; } }
First parameter is pointer to instructions in event to fill, second is event name
First parameter is pointer to instructions in event to fill second is event name