void TupleDescriberFlexible::m_append(const string &s, const bool remember_insert_position)
{
  if (m_help_length)
  {
    const size_t capacity = m_help_length + 1 + s.length() + 1;
    char *storage = m_allocate(capacity, this);
    if (storage[m_help_length - 1] == '\n')
    {
      memcpy(&storage[m_help_length], s.c_str(), s.length() + 1);
      if (remember_insert_position)
      {
        m_help_length = capacity - 2;
      }
    }
    else
    {
      storage[m_help_length] = '\n';
      memcpy(&storage[m_help_length + 1], s.c_str(), s.length() + 1);
      if (remember_insert_position)
      {
        m_help_length = capacity - 1;
      }
    }
  }
  else
  {
    const size_t capacity = s.length() + 1;
    memcpy(m_allocate(capacity, this), s.c_str(), capacity);
    if (remember_insert_position)
    {
      m_help_length = capacity - 1;
    }
  }
}
예제 #2
0
void create() {
  seteuid(getuid(this_object()));
  if (!restore_object(NEWSPATH+"GroupList"))
    grouplist=m_allocate(0,G_MESSAGES);
  else
    grouplist=saveload;
  // ersten reset sobald wie moeglich. ;-)
  set_next_reset(1);
}
예제 #3
0
파일: finger.c 프로젝트: Kebap/mg-mudlib
string sponsoring(string name)
{
  int i,w;
  string *s,s2,s3,s4;
  // Daten einlesen, wenn die daten aelter als 1 Tag sind oder sich
  // /log/SPONSORS geaendert hat.
  if ((time() > filetime+86400) ||
      filetime!=file_time("/log/SPONSOR")) 
  {
      relatives=m_allocate(0,2);
      filetime=file_time("/log/SPONSOR");
      s=explode(read_file("/log/SPONSOR"),"\n");
      foreach(string str: s) { 
	  sscanf(str,"%s: %s macht %s zum Learner.",s2,s3,s4);
	  if (IS_LEARNER(lower_case(s3)) && IS_LEARNER(lower_case(s4)))
          {
             relatives[lower_case(s4),0]=s3;
             s3=lower_case(s3);
             s4+=" ("+query_wiz_level(lower_case(s4))+")";
             if (!relatives[s3,1]) relatives[s3,1]=({s4});
             else relatives[s3,1]+=({s4});
예제 #4
0
파일: merlin.c 프로젝트: Kebap/mg-mudlib
void create()
{
  string s;
  seteuid(ROOTID);
  if (file_size("/etc/maxusers")<=0)
    maxusers=0;
  else
  {
    s=read_file("/etc/maxusers",0,1);
    sscanf(s,"%d",maxusers);
  }
  set_living_name("merlin");
  enable_commands();
  call_out("wandern",25);
  move("/gilden/abenteurer",0);
  MBanishListe = m_allocate(0,2);
  restore_object(SAVEFILE);
  EVENTD->RegisterEvent(EVT_LIB_PLAYER_CREATION, "player_change", ME);
  EVENTD->RegisterEvent(EVT_LIB_LOGIN, "player_change", ME);
  // absichtlich kein EVT_LIB_LOGOUT, s. Kommentar zu notify_player_leave().
}