Example #1
0
  //
  // Constructor
  //
  Table::Table(FScope *fScope)
  {
    // Setup the modifiers
    modifiers = new ModifierProperties *[numModifiers];
    for (U32 m = 0; m < numModifiers; m++)
    {
      modifiers[m] = new ModifierProperties(*Tactical::modifiers[m]);
    }

    FScope *sScope;
    while ((sScope = fScope->NextFunction()) != NULL)
    {
      switch (sScope->NameCrc())
      {
        case 0xFEB2541D: // "ConfigureModifier"
        {
          U8 index;
          const char *modifier = StdLoad::TypeString(sScope);
          if (FindModifierIndex(Crc::CalcStr(modifier), index))
          {
            modifiers[index]->Load(sScope);
          }
          else
          {
            sScope->ScopeError("Could not find modifier '%s'", modifier);
          }
          break;
        }
      }
    }
  }
Example #2
0
  //
  // Constructor
  //
  Modifier::Modifier(FScope *fScope)
  : name(StdLoad::TypeString(fScope)),
    numSettings(0)
  {
    FScope *sScope;
    const char *defaultName = NULL;

    while ((sScope = fScope->NextFunction()) != NULL)
    {
      switch (sScope->NameCrc())
      {
        case 0x5FC15146: // "AddSetting"
          if (numSettings == MAXSETTINGS)
          {
            sScope->ScopeError("Maximum settings exceeded!");
          }
          settings[numSettings++] = new GameIdent(StdLoad::TypeString(sScope));
          break;

        case 0x733C1EB5: // "DefaultSetting"
          defaultName = StdLoad::TypeString(sScope);
          break;
      }
    }

    if (!defaultName)
    {
      fScope->ScopeError("Expected DefaultSetting");
    }

    if (!GetIndex(Crc::CalcStr(defaultName), defaultSetting))
    {
      fScope->ScopeError("Could not find setting '%s' in modifier '%s'", defaultName, GetName());
    }
  }
Example #3
0
  //
  // Load
  //
  void SettingProperties::Load(FScope *fScope)
  {
    FScope *sScope;
    while ((sScope = fScope->NextFunction()) != NULL)
    {
      switch (sScope->NameCrc())
      {
        case 0x2CA06E10: // "Allow"
        {
          U32 index;
          const char *property = StdLoad::TypeString(sScope);
          if (FindPropertyIndex(Crc::CalcStr(property), index))
          {
            values[index] = PV_ALLOW;
          }
          else
          {
            sScope->ScopeError("Unknown Property '%s'", property);
          }
          break;
        }

        case 0xF8765CE8: // "Deny"
        {
          U32 index;
          const char *property = StdLoad::TypeString(sScope);
          if (FindPropertyIndex(Crc::CalcStr(property), index))
          {
            values[index] = PV_DENY;
          }
          else
          {
            sScope->ScopeError("Unknown Property '%s'", property);
          }
          break;
        }
      }
    }
  }
Example #4
0
  //
  // Obj::Obj
  //
  // Constructor
  //
  Obj::Obj(FScope *fScope, const char *name) : 
    name(name)
  {
    FScope *sScope;

    defaultLocation = NULL;

    // Process each function
    while ((sScope = fScope->NextFunction()) != NULL)
    {
      switch (sScope->NameCrc())
      {

        case 0x1E534497: // "Tag"
        {
          U32 tag = Crc::CalcStr(sScope->NextArgString());
          tags.Add(tag, new Location(sScope, name));
          break;
        }

        case 0x1D9D48EC: // "Type"
        {
          U32 type = Crc::CalcStr(sScope->NextArgString());
          types.Add(type, new Location(sScope, name));
          break;
        }

        case 0x666BCB68: // "Property"
        {
          properties.Append(new PropertyLocation(sScope, name));
          break;
        }

        case 0x8F651465: // "Default"
          if (defaultLocation)
          {
            sScope->ScopeError("Default has already been specified");
          }
          defaultLocation = new Location(sScope, name);
          break;
      }
    }
  }
Example #5
0
 //
 // Load
 //
 void ModifierProperties::Load(FScope *fScope)
 {
   FScope *sScope;
   while ((sScope = fScope->NextFunction()) != NULL)
   {
     switch (sScope->NameCrc())
     {
       case 0x32BBA19C: // "Setting"
         const char *setting = StdLoad::TypeString(sScope);
         U8 index;
         if (modifier.GetIndex(Crc::CalcStr(setting), index))
         {
           settings[index].Load(sScope);
         }
         else
         {
           sScope->ScopeError("Could not find Setting '%s' in Modifier '%s'", setting, modifier.GetName());                        
         }
         break;
     }
   }
 }
  //
  // Constructor
  //
  Script::State::State(Script &script, const char *name, FScope *fScope)
  : script(script),
    settings(&Setting::nodeState),
    conditions(&Condition::nodeState),
    transitions(&Transition::nodeState),
    name(name)
  {
    FScope *sScope;
    FScope *iScope;

    // Load the settings
    iScope = fScope->GetFunction("Settings", FALSE);
    if (iScope)
    {
      while ((sScope = iScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0x32BBA19C: // "Setting"
            settings.Append(Setting::Create(script, sScope));
            break;

          default:
            sScope->ScopeError("Unknown function '%s' in settings", sScope->NameStr());
        }
      }
    }

    // Load the action
    iScope = fScope->GetFunction("Action", FALSE);
    if (iScope)
    {
      action = Action::Create(script, iScope);
    }
    else
    {
      action = NULL;
    }

    // Load the conditions
    iScope = fScope->GetFunction("Conditions", FALSE);

    if (iScope)
    {
      while ((sScope = iScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0x6A34146A: // "Condition"
            conditions.Append(Condition::Create(script, sScope));
            break;

          case 0xFBCD164A: // "Status"
          {
            GameIdent code = StdLoad::TypeString(sScope);

            if (transitions.Exists(code.crc))
            {
              sScope->ScopeError("Status '%s' already defined", code.str);
            }

            // Add the new transition
            transitions.Add(code.crc, Transition::Create(sScope));
            break;
          }

          default:
            sScope->ScopeError("Unknown function '%s' in conditions", sScope->NameStr());
        }
      }
    }

    completed = transitions.Find(Status::Completed);
  }