Example #1
0
 //
 // Save the modifier settings
 //
 void ModifierSettings::SaveState(FScope *fScope) const
 {
   // Any settings which are different to the default settings get saved
   for (U8 m = 0; m < numModifiers; m++)
   {
     if (modifiers[m]->GetDefaultSetting() != Get(m))
     {
       FScope *sScope = fScope->AddFunction("Set");
       sScope->AddArgString(modifiers[m]->GetName());
       sScope->AddArgString(modifiers[m]->GetSettingName(Get(m)));
     }
   }
 }
  //
  // SaveState
  //
  // Save state information
  //
  void Script::Manager::SaveState(FScope *scope)
  {
    // Save the recruit id
    StdSave::TypeU32(scope, "RecruitId", recruitId);

    // Save each script
    for (NBinTree<Script>::Iterator s(&scripts); *s; s++)
    {
      // Get the script
      Script *script = *s;

      // Create the scope
      FScope *sScope = scope->AddFunction("Script");

      // Add construction data as arguments
      sScope->AddArgString(script->GetName());
      sScope->AddArgString(script->GetConfigName());
      sScope->AddArgInteger(script->GetWeighting());
      sScope->AddArgInteger(script->GetPriority());

      // Save the script state data
      script->SaveState(sScope);
    }
  }
Example #3
0
  //
  // Save from the Var Scope into the FScope
  //
  void Save(FScope *fScope, VarSys::VarScope *vScope)
  {
    // Add all of the items in this vScope to the fScope
    BinTree<VarSys::VarItem>::Iterator i(&vScope->items);
    for (!i; *i; i++)
    {
      switch ((*i)->type)
      {
        case VarSys::VI_SCOPE:
        {
          // Add this scope to the fScope
          FScope *sScope = fScope->AddFunction("VarScope");
          sScope->AddArgString((*i)->itemId.str);
          Save(sScope, (*i)->scope.ptr);
          break;
        }

        case VarSys::VI_INTEGER:
        {
          FScope *sScope = fScope->AddFunction("VarInteger");
          sScope->AddArgString((*i)->itemId.str);
          sScope->AddArgInteger((*i)->Integer());
          break;
        }

        case VarSys::VI_FPOINT:   
        {
          FScope *sScope = fScope->AddFunction("VarFloat");
          sScope->AddArgString((*i)->itemId.str);
          sScope->AddArgFPoint((*i)->Float());
          break;
        }

        case VarSys::VI_STRING:
        {
          FScope *sScope = fScope->AddFunction("VarString");
          sScope->AddArgString((*i)->itemId.str);
          sScope->AddArgString((*i)->Str());
          break;
        }

        case VarSys::VI_BINARY:
        {
          FScope *sScope = fScope->AddFunction("VarBinary");
          sScope->AddArgString((*i)->itemId.str);
          StdSave::TypeU32(sScope, "Size", (*i)->BinarySize());
          StdSave::TypeBinary(sScope, (*i)->BinarySize(), (*i)->Binary());
          break;
        }

        default:
          // We don't save anything else
          break;
      }
    }
  }