| Home Page | Recent Changes

Session

UT2003 :: Object >> Session (Ladder1.46)
00001  class Session extends Object within SessionMaster
00002      transient;
00003  
00004  //-----------------------------------------------------------
00005  // Ladder.Session
00006  // Sessions concept by El_Muerte[TDS]
00007  // http://wiki.beyondunreal.com/wiki/Sessions
00008  //
00009  // Data container used by webadmin - tracked by SessionMaster
00010  // Session "hashes" (10 digit number unique to each Session object)
00011  // are generated by SessionMaster at server startup
00012  //
00013  // Session hashes are passed via form submittal, often taking advantage
00014  // of the Webserver's ability to parse directly injected form labels
00015  // (?VarName=VarValue)
00016  //
00017  // Session hashes are queried from the WebRequest object
00018  // each connection - this allows easy access to unlimited amounts
00019  // of related data across the entire class, without risking corruption
00020  // across threads (such as would be the case with global variables)
00021  //-----------------------------------------------------------
00022  
00023  struct SessionData
00024  {
00025      var string Key;
00026      var string Value;
00027  };
00028  
00029  struct SessionMap
00030  {
00031      var string MapName;
00032      var int MapListOrder;
00033      var bool bRequired;
00034  };
00035  
00036  struct SessionMutator
00037  {
00038      var string MutatorName;
00039      var bool bRequired;
00040  };
00041  
00042  struct SessionServerActor
00043  {
00044      var string  SAName;
00045      var bool    bRequired;
00046  };
00047  
00048  // contains the ProfileConfigSet that this session applies to
00049  var private ProfileConfigSet PCS;
00050  
00051  // contains the data for this session
00052  var private array<SessionData>          Data;
00053  var private array<SessionMutator>       Mutators;
00054  var private array<SessionMap>           Maps;
00055  var private array<SessionServerActor>   ServerActors;
00056  
00057  // contains the unique identifier
00058  var private string hash;
00059  
00060  // Input functions
00061  final function bool SetHash(string NewHash)
00062  {
00063      if (NewHash!="")
00064      {
00065          Hash = NewHash;
00066          return true;
00067      }
00068  
00069      return false;
00070  }
00071  
00072  function bool SetPCS(ProfileConfigSet TempPCS)
00073  {
00074      if (TempPCS != None)
00075      {
00076          PCS = TempPCS;
00077          return true;
00078      }
00079  
00080      return false;
00081  }
00082  
00083  function bool setValue(string Dataname, string value, bool bAddIfNotExists, optional out string oldValue)
00084  {
00085      local int i;
00086      local SessionData KVP;
00087  
00088      for (i = 0; i<data.length; i++)
00089      {
00090          if (data[i].key ~= Dataname)
00091          {
00092              oldValue = data[i].value;
00093              data[i].value = value;
00094              return true;
00095          }
00096      }
00097  
00098      if (bAddIfNotExists)
00099      {
00100          KVP.Key = DataName;
00101          KVP.Value = Value;
00102          Data[Data.Length] = KVP;
00103          return true;
00104      }
00105      return false;
00106  }
00107  
00108  function bool setMutator(string NewMutator, bool bAddIfNotExists, optional bool bRequired)
00109  {
00110      local int i;
00111      local SessionMutator tmp;
00112  
00113      for (i=0;i<Mutators.Length;i++)
00114      {
00115          if (Mutators[i].MutatorName ~= NewMutator)
00116          {
00117              Mutators[i].bRequired = bRequired;
00118              return true;
00119          }
00120      }
00121  
00122      if (bAddIfNotExists)
00123      {
00124          tmp.MutatorName = NewMutator;
00125          tmp.bRequired = bRequired;
00126          Mutators[Mutators.Length] = tmp;
00127          return true;
00128      }
00129  
00130      return false;
00131  }
00132  
00133  function bool setMap(string NewMap, int NewOrder, bool bAddIfNotExists, optional bool bRequired)
00134  {
00135      local int i;
00136      local SessionMap tmp;
00137  
00138      for (i=0;i<Maps.Length;i++)
00139      {
00140          if (Maps[i].MapName ~= NewMap)
00141          {
00142              Maps[i].MapListOrder = NewOrder;
00143              Maps[i].bRequired = bRequired;
00144              return true;
00145          }
00146      }
00147  
00148      if (bAddIfNotExists)
00149      {
00150          tmp.MapName = NewMap;
00151          tmp.bRequired = bRequired;
00152          tmp.MapListOrder = NewOrder;
00153          Maps[Maps.Length] = tmp;
00154          return true;
00155      }
00156      return false;
00157  }
00158  
00159  function bool SetServerActor(string NewActor, bool bAddIfNotExists, optional bool bRequired)
00160  {
00161      local int i;
00162      local SessionServerActor tmp;
00163  
00164      for (i=0;i<ServerActors.Length;i++)
00165      {
00166          if (ServerActors[i].SAName ~= NewActor)
00167          {
00168              ServerActors[i].bRequired = bRequired;
00169              return true;
00170          }
00171      }
00172  
00173      if (bAddIfNotExists)
00174      {
00175          tmp.SAName = NewActor;
00176          tmp.bRequired = bRequired;
00177  
00178          ServerActors[ServerActors.Length] = tmp;
00179          return true;
00180      }
00181  
00182      return false;
00183  }
00184  
00185  // Output functions
00186  final function string GetHash()
00187  {
00188      return Hash;
00189  }
00190  
00191  function ProfileConfigSet GetPCS()
00192  {
00193      if (PCS != None)
00194          return PCS;
00195  
00196      return None;
00197  }
00198  
00199  function int getIdValue(int idx, out string DataName, out string DataValue)
00200  {
00201      if (idx < 0 || idx >= Data.Length)
00202          return -1;
00203  
00204      DataName = Data[idx].Key;
00205      DataValue = Data[idx].Value;
00206      return idx;
00207  }
00208  
00209  function string getValue(string name, optional string sdefault)
00210  {
00211      local int i;
00212      for (i = 0; i<data.length; i++)
00213          if (data[i].key == name) return data[i].value;
00214  
00215      return sdefault;
00216  }
00217  
00218  function string getMutator(int idx)
00219  {
00220      if (idx < 0 || idx >= Mutators.Length)
00221          return "";
00222  
00223      return Mutators[idx].MutatorName;
00224  }
00225  
00226  function string getMap(int idx)
00227  {
00228      if (idx < 0 || idx >= Maps.Length)
00229          return "";
00230  
00231      return Maps[idx].MapName;
00232  }
00233  
00234  function string getServerActor(int idx)
00235  {
00236      if (idx < 0 || idx >= ServerActors.Length)
00237          return "";
00238  
00239      return ServerActors[idx].SAName;
00240  }
00241  
00242  // Maintenance
00243  final function ClearMutators()
00244  {
00245      Mutators.Length = 0;
00246  }
00247  
00248  final function ClearMaps()
00249  {
00250      Maps.Length = 0;
00251  }
00252  
00253  final function ClearData()
00254  {
00255      Data.Length = 0;
00256  }
00257  
00258  final function ClearServerActors()
00259  {
00260      ServerActors.Length = 0;
00261  }
00262  
00263  function bool delValue(string DataName)
00264  {
00265      local int i;
00266  
00267      for (i=0;i<Data.Length;i++)
00268      {
00269          if (Data[i].Key ~= DataName)
00270          {
00271              Data.Remove(i,1);
00272              return true;
00273          }
00274      }
00275  
00276      return false;
00277  }
00278  
00279  function bool delMap(string MapName)
00280  {
00281      local int i;
00282  
00283      for (i=0;i<Maps.Length;i++)
00284      {
00285          if (Maps[i].MapName ~= MapName)
00286          {
00287              Maps.Remove(i,1);
00288              return true;
00289          }
00290      }
00291  
00292      return false;
00293  }
00294  
00295  function bool delMutator(string Mutator)
00296  {
00297      local int i;
00298  
00299      for (i=0;i<Mutators.Length;i++)
00300      {
00301          if (Mutators[i].MutatorName ~= Mutator)
00302          {
00303              Mutators.Remove(i,1);
00304              return true;
00305          }
00306      }
00307  
00308      return false;
00309  }
00310  
00311  function bool delServerActor(string ActorName)
00312  {
00313      local int i;
00314      for (i=0;i<ServerActors.Length;i++)
00315      {
00316          if (ServerActors[i].SAName ~= ActorName)
00317          {
00318              ServerActors.Remove(i,1);
00319              return true;
00320          }
00321      }
00322      return false;
00323  }
00324  
00325  // Utility
00326  final function ResetSession()
00327  {
00328      ClearMutators();
00329      ClearMaps();
00330      ClearData();
00331      ClearServerActors();
00332  
00333      PCS = None;
00334  }
00335  
00336  final function int GetMutatorLength()
00337  {
00338      return Mutators.Length;
00339  }
00340  
00341  final function int GetDataLength()
00342  {
00343      return Data.Length;
00344  }
00345  
00346  final function int GetMapLength()
00347  {
00348      return Maps.Length;
00349  }
00350  
00351  final function int GetSALength()
00352  {
00353      return ServerActors.Length;
00354  }
00355  
00356  final function int MapOrder(int idx)
00357  {
00358      if (idx < 0 || idx >= Maps.Length)
00359          return -1;
00360  
00361      return Maps[idx].MapListOrder;
00362  }
00363  
00364  final function bool HasData(string DataName)
00365  {
00366      local int i;
00367  
00368      for (i=0;i<Data.Length;i++)
00369          if (Data[i].key ~= DataName)
00370              return true;
00371      return false;
00372  }
00373  
00374  final function bool HasMutator(string MutatorName)
00375  {
00376      local int i;
00377  
00378      for (i=0;i<Mutators.Length;i++)
00379          if (Mutators[i].MutatorName ~= MutatorName)
00380              return true;
00381      return false;
00382  }
00383  
00384  final function bool HasMap(string MapName)
00385  {
00386      local int i;
00387      for (i=0;i<Maps.Length;i++)
00388          if (Maps[i].MapName ~= MapName)
00389              return true;
00390      return false;
00391  }
00392  
00393  final function bool HasServerActor(string ActorName)
00394  {
00395      local int i;
00396      for (i=0;i<ServerActors.Length;i++)
00397          if (ServerActors[i].SAName ~= ActorName)
00398              return true;
00399      return false;
00400  }
00401  
00402  final function bool MutRequired(string MutatorName)
00403  {
00404      local int i;
00405  
00406      for (i=0;i<Mutators.Length;i++)
00407          if ((Mutators[i].MutatorName ~= MutatorName) && (Mutators[i].bRequired))
00408              return true;
00409      return false;
00410  }
00411  
00412  final function bool MapRequired(string MapName)
00413  {
00414      local int i;
00415      for (i=0;i<Maps.Length;i++)
00416          if (Maps[i].MapName ~= MapName)
00417              return Maps[i].bRequired;
00418      return false;
00419  }
00420  
00421  final function bool SARequired(string ActorName)
00422  {
00423      local int i;
00424      for (i=0;i<ServerActors.Length;i++)
00425          if (ServerActors[i].SAName ~= ActorName)
00426              return ServerActors[i].bRequired;
00427      return false;
00428  }

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In