예제 #1
0
vsx_engine_param* vsx_engine_param::alias_to_level(vsx_engine_param* dest) {
  // this will only work for params belonging to a io == 1 list
  if (owner->io == 1) {
    vsx_string src_name = owner->component->name;
    vsx_string dest_name = dest->owner->component->name;
    str_remove_equal_prefix(&src_name, &dest_name,".");

    vsx_string deli = ".";
    std::vector<vsx_string> dest_name_parts;
    explode(dest_name,deli,dest_name_parts);
    dest_name_parts.pop_back();
    dest_name = implode(dest_name_parts,deli);

    std::vector<vsx_string> src_name_parts;
    explode(src_name,deli,src_name_parts);
    src_name_parts.pop_back();
    dest_name = implode(src_name_parts,deli);

    if (dest_name_parts.size() == 0) {
      if (src_name_parts.size() == 0) return this; else {
        // go through our connections to see if there is an alias already

        for (std::vector<vsx_engine_param_connection*>::iterator it = connections.begin(); it != connections.end(); ++it) {
          if ((*it)->alias_connection) return (*it)->dest->alias_to_level(dest);
        }

        vsx_string new_name = owner->component->parent->get_params_out()->alias_get_unique_name("alias_"+name);
        owner->component->parent->get_params_out()->alias(this,new_name,-1);
        return owner->component->parent->get_params_out()->get_by_name(new_name)->alias_to_level(dest);
      }
    } else return this;
  }
  return 0;
}
예제 #2
0
파일: id.c 프로젝트: kimch2/xkx2001
int main(object me, string arg)
{
	int i, j;
	object obj, *inv;
	string *id;

	if( !arg ) {
		inv = all_inventory(me);
		if( !sizeof(inv) )
			return notify_fail("你身上没有任何东西。\n");
        write( "你(你)身上携带物品的别称如下(右方) :\n");
		for(i=0; i<sizeof(inv); i++) {
			if( !me->visible(inv[i]) ) continue;
			printf("%-20s = %s\n", inv[i]->name(),
				implode(inv[i]->parse_command_id_list(), ", ") );
		}
		return 1;
	}

	if( arg=="here" ) {
		inv = all_inventory(environment(me));
		if( !sizeof(inv) )
			return notify_fail("这里没有任何东西。\n");
        write( "在这个房间中, 生物及物品的(英文)名称如下 :\n");
		for(i=0; i<sizeof(inv); i++) {
			if( !me->visible(inv[i]) ) continue;
			printf("%-20s = %s\n", inv[i]->name(),
	//	inv[i]->query_temp("apply/name") && !wizardp(me) ? "Unknown" : implode(inv[i]->parse_command_id_list(), ", ") );
		implode(inv[i]->parse_command_id_list(), ", ") );
			
		}
		return 1;
	}
}
예제 #3
0
파일: consolidate.c 프로젝트: ehershey/pd
string consolidate(int x, string str) {
    string tmp, atmp;
    string *words;
    int i, y;

    if(x==1 || !str || str == "") return str;
    i = sizeof(words = explode(str, " "));
    if (words[i-1][0]=='(')
     {
      atmp = words[i-1];
      words[i-1]="";
      i -=1;
     }

    if((tmp = lower_case(words[0])) == "a" || tmp == "an" || tmp =="the")
      i = sizeof(words = words[1..i-1]);
    if((y=member_array("of", words))  > 0)
        words[y-1] = pluralize(words[y-1]);
    else words[i-1] =  pluralize(words[i-1]);
    tmp = cardinal(x)+" ";

if (atmp)
     return tmp+implode(words, " ")+" "+atmp;
   return tmp+implode(words, " ");
}
예제 #4
0
static nomask int check_access(string tmp) {
    int i;
    string *parts;

    debug("Passed to check_access: " + tmp);
    init_access();
    debug("past init_access()");

    // okay, first check for a direct match.  This will be a lot of
    // cases for variables, less for files.

    if (perms[tmp]) return perms[tmp];

    // there was no match, so let's split this string up into segments.
    // If there is only one element in the resulting array, then we
    // know it's been passed already.

    parts = explode(tmp, "/");

    // question, what to do here?  For file security, it probably
    // means they are trying to write to /, but for variables it sounds
    // like they are adding a new one.... one is harmless, the other isn't.
    // for now, I'll assume that there is another way to lock the root
    // directory... it may be necessary to add a "/" entry.
    // This is my solution, but I suspect there's a better way where
    // I won't have to do this for all objects.

    if (sizeof(parts) == 1) {
        debug("Only one level depth to resolve");
        if (file_name(this_object()) == "adm/newaccess")
            return MASTER_ONLY;
        else return PUBLIC;
    }

    // okay, let's look for the closest match we can find for this,
    // starting with things most similar and working towards root.

    for (i=sizeof(parts)-1; i>=0; i--) {
        tmp = implode(parts[0..i], "/");
        debug("debug: checking for an entry for " + tmp);
        if(perms[tmp]) {
            debug("Matched " + implode(parts, "/") + " with " + tmp);
            return perms[tmp];
        }
    }
    debug("No match, returning PUBLIC status.");
    return PUBLIC;
}
예제 #5
0
// Получение списка пользователей указанного канала.
void meth::GetChannelUsers(LogicalConnections::iterator conn, String channel_name, String &response) {
	if (IsUserInChannel(GetOnlineUserName(GetConnectionUser(conn)), channel_name)) {
		response = "[" + implode(::GetChannelUsers(channel_name)) + "]";
	} else {
		throw(JSONError(-32001, "Virtual user is not connected to this channel. You must be in this channel to get it's members"));
	}
}
mixed cmd(string arg) {
  string *args;
  int     i, j, trace_arg;
  
  /* ok lets make this clever...
   */
  notify_fail( "Usage: trace <" + implode(OPTIONS, "|") + ">\n" );

  if( !arg ) return 0;

  args = explode( arg, " " );
  
  if( !sizeof( args ) )
    return 0;
  
  for( i = 0; i < sizeof( args ); i++ )
    if( (j = member_array( args[ i ], OPTIONS )) != -1 )
    {
      if( !j )
      {
        trace( 0 );
        write( "Trace off.\n" );
        return 1;
      }
      else
        trace_arg |= ({ 0, 1, 2, 4, 8, 16, 32, 64, 128 })[ j ];
    }
예제 #7
0
int cmd_which(string str) {
   string cmd, *path;
   mapping alias;
   object act_ob;
   
   if (!str || str=="") return help() ;

   // search aliases
   act_ob = previous_object();
   alias = (mapping)act_ob->query_aliases() +
         (mapping)GA_SERVER_D->query_global_aliases() +
         (mapping)GA_SERVER_D->query_global_xaliases();
   if (alias && alias[str]) {
      write(str + ":\taliased to \"" + alias[str] + "\"\n");
      return 1;
   }

   // search path
   path = explode((string)this_player()->query("PATH"), ":");
   if (path) {
       cmd = CMD_D->find_cmd(str, path);
       if (!cmd)
           write("No " + str + " in " + implode(path, " ") + "\n");
       else
           write(cmd + "\n");
       return 1;
   }

   return 0;
}
예제 #8
0
파일: goofy.c 프로젝트: Lundex/lima
string hax0r(string s)
{
  string array words;


  words = explode(s, " ");
  for(int i=0;i<sizeof(words);i++)
  {
     switch(lower_case(words[i])) {
      case "i": words[i] = "3y3"; break;
      case "you": words[i] = "j00"; break;
      case "dude": words[i] = "d00d"; break;         
      case "elite": words[i] = "3133+"; break;         
      case "are": words[i] = "R"; break;         
      case "hack": words[i] = "hax0r"; break;
      case "hacker": words[i] = "hax0r"; break;
      case "i'm" : words[i] = "3y3'/\\/\\"; break;
      case "i'll" : words[i] = "3y3'77"; break;
      case "see": words[i] = "C"; break;
       case "oh": words[i] = "O"; break;
      case "sucks": words[i] = "$ux"; break;
      case "off": words[i] = "0ph"; break;
      case "too": words[i] = "2"; break;
      case "to": words[i] = "2"; break;
      case "for": words[i] = "4"; break;
      default:         
        words[i] = hax0r_letters(words[i]);         
    }
    }
  s = implode(words, " ");

     return s;
}
예제 #9
0
 void vsx_widget_popup_menu::add_commands(vsx_command_s *command) {
   // split the title
   vsx_string title = command->title;
   vsx_string deli = ";";
   std::vector<vsx_string> add_c;
   explode(title,deli,add_c);
   if (add_c.size() > 1) {
     // ok, we're not topmost
     vsx_widget* t = 0;
     if (l_list.find(add_c[0]) == l_list.end()) {
       t = add(new vsx_widget_popup_menu, add_c[0]);
       t->pos.x = 0;
       t->pos.y = pos.y;
       t->init();
       menu_items.adds(VSX_COMMAND_MENU, add_c[0],"","");
     } else t = l_list[add_c[0]];
     add_c.erase(add_c.begin());
     // mod the command, yeah!
     command->title = implode(add_c,deli);
     ((vsx_widget_popup_menu*)t)->add_commands(command);
     // GAH I'M TIRED OF THIS, THIS IS LIKE THE 5TH similar thing i write ARGHH
     // AND it's not WORKING :(
   } else {
     menu_items.add(command);
   }
 }
예제 #10
0
int main(object me, string arg)
{
	int i;
	object *inv, ob;

	if( wizardp(me) && arg ) {
		ob = find_player(arg);
		if( !ob ) ob = find_living(arg);
		if( !ob ) ob = present(arg, environment(me));
	}

	if( !ob ) ob = me;

	inv = all_inventory(ob);
	if( !sizeof(inv) ) {
		write((ob==me)? "目前你身上没有任何东西。\n"
			: ob->name() + "身上没有携带任何东西。\n");
		return 1;
	}
	printf("%s身上带著下列这些东西(负重 %d%%):\n%s\n",
		(ob==me)? "你": ob->name(),
		(int)ob->query_encumbrance() * 100 / (int)ob->query_max_encumbrance(),
		implode(map_array(inv, "inventory_desc", this_object()), "\n") );

	return 1;
}
예제 #11
0
int main(int argc, char ** argv)
{
  printf("Welcome to PA03!\n");
  char * buff;
  buff = (char *) malloc(10*sizeof(char));
  strcpy(buff, "This is the start");
  char * er = ", and this is the end!";
  int size = 10;

  //Testing strcat_ex

  printf("buff = %s\n\n\n", strcat_ex(&buff, &size,er));
 
  //Testing explode
  int length;
  const char * hi = "What in the F**k?";
  length = strlen(hi);
  char * * strArr = explode(hi," ", &length);
  printf("strArr[1] = %s\n\n\n", strArr[1]);

  //Testing implode
  printf("Implosion: %s\n\n\n",implode(strArr,4," "));

  printf("Freeing Memory...\n");
  free(buff);
  free(strArr);
  printf("Memory Free!\n");
  return 0;
}
예제 #12
0
파일: dbxframe.c 프로젝트: Lundex/lima
string print_vars(mixed *vars) {
    string *result = allocate(sizeof(vars));
    int i;

    for (i=0; i<sizeof(vars); i++) {
	if (mapp(vars[i]))
	    result[i] = "([ ... ])";
	else if (functionp(vars[i]))
	    result[i] = "(: ... :)";
	else if (intp(vars[i]))
	{
	    if (vars[i]) result[i]=vars[i]+"";
	    else if (nullp(vars[i])) result[i]="NULL";
	    else if (undefinedp(vars[i])) result[i]="UNDEFINED";
	    else result[i]="0";
	}
	else if (stringp(vars[i]))
	    result[i] = "\""+vars[i]+"\"";
	else if (arrayp(vars[i]))
	    result[i] = "({ ... })";
	else if (floatp(vars[i]))
	    result[i] = vars[i]+"";
	else if (bufferp(vars[i]))
	    result[i] = "<BUFFER>";
    }
    return implode(result, ", ");
}
예제 #13
0
파일: imap.c 프로젝트: simonthoresen/viking
static int main(string arg) {
    object ply, island;
    string file, *map;
    if (!objectp(ply = this_player())) {
	return 0;
    }
    if (!stringp(arg) || !strlen(arg = getopts("ac", arg))) {
        if (!stringp(file = environment(ply)->query_island())) {
            return notify_fail("Usage: " + query_verb() + " <island>");
        }
        sscanf(file, EMP_DIR_ISLANDS + "%s/island", arg);
    } else {
        file = EMP_DIR_ISLANDS + arg + "/island";
    }
    if (file_size(file + ".c") < 0 ||
        !objectp(island = file->__bootstrap()) ||
	!arrayp(map = island->create_island_view()))
    {
        return notify_fail("Island '" + file + "' not found.");
    }
    if (opts['a']) {
	map = island->format_view(map, 1);
    } else if (opts['c']) {
	map = island->format_view(map, store_fp("do_unload"), arg);
    } else {
	map = island->format_view(map, store_fp("is_loaded"), arg);
    }
    tell_ansi(ply, "\n" + implode(map, "\n"));
    return 1;
}
예제 #14
0
static void Compress_PKLIB(
    char * pbOutBuffer,
    int * pcbOutBuffer,
    char * pbInBuffer,
    int cbInBuffer,
    int * /* pCmpType */,
    int /* nCmpLevel */)
{
    TDataInfo Info;                                      // Data information
    char * work_buf = STORM_ALLOC(char, CMP_BUFFER_SIZE);// Pklib's work buffer
    unsigned int dict_size;                              // Dictionary size
    unsigned int ctype = CMP_BINARY;                     // Compression type

    // Fill data information structure
    memset(work_buf, 0, CMP_BUFFER_SIZE);
    Info.pbInBuff     = pbInBuffer;
    Info.pbInBuffEnd  = pbInBuffer + cbInBuffer;
    Info.pbOutBuff    = pbOutBuffer;
    Info.pbOutBuffEnd = pbOutBuffer + *pcbOutBuffer;

    // Set the compression type and dictionary size
    if (cbInBuffer < 0x600)
        dict_size = CMP_IMPLODE_DICT_SIZE1;
    else if(0x600 <= cbInBuffer && cbInBuffer < 0xC00)
        dict_size = CMP_IMPLODE_DICT_SIZE2;
    else
        dict_size = CMP_IMPLODE_DICT_SIZE3;

    // Do the compression
    if(implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size) == CMP_NO_ERROR)
        *pcbOutBuffer = (int)(Info.pbOutBuff - pbOutBuffer);

    STORM_FREE(work_buf);
}
예제 #15
0
파일: which.c 프로젝트: abzde/dock9
int main(string args)
{
    string *commandPath = this_player()->query_path();
    mixed *actions = previous_object()->query_commands();
    mapping aliases = this_player()->get_aliases(1);
    int i, isLocated = 0;
    
    if(!args) return notify_fail("Error: Syntax: which <verb/command>\n");
    
    for(i = 0; i < sizeof(commandPath); i ++)
    {
	    if(file_exists(commandPath[i] + args + ".c"))
	    {
	        isLocated = 1;
    	    write(commandPath[i] + args + "\n");
    	}
    }
    
    for(i = 0; i < sizeof(actions); i++)
    {
        if(actions[i][0] == args)
        {
            isLocated = 1;
            write("Local:  " + sprintf("%O/%s", actions[i][2], actions[i][3]) + "\n");
        }
    }
    
    if(mapp(aliases) && aliases[args])
    {
        isLocated = 1;
        write("Alias: " + args + " -> " + aliases[args] + "\n");
    }
    
    if(member_array(args, SOUL_D->query_emotes()) != -1)
    {
        isLocated = 1;
        write("Soul: " + args + "\n");
    }
    
    
    if(member_array(args + "/t", SOUL_D->query_emotes()) != -1)
    {
        isLocated = 1;
        write("Targetted Soul: " + args + "\n");
    }
    
    if(environment(previous_object())->valid_exit(args))
    {
        isLocated = 1;
        write("Local Exit: " + 
            environment(this_player())->query_exit(args) + "\n");
    }
        
    
    if(!isLocated) return notify_fail("%^RED%^Error:%^RESET%^ '" + args 
        + "' not found in " +  implode(commandPath, ", ") 
         + " nor via a local add_action, alias, soul, or exit.\n");
    
    return 1;   
}
예제 #16
0
nomask private void main()
{
  outf("%s currently has the following quests:\n", mud_name());
  out(implode(QUEST_D->get_goals_for_quests_cmd(),"\n"));
  out("\n\nType help <questname> for more info about a quest.\n");

}
예제 #17
0
파일: types.c 프로젝트: Elohim/FGmud
varargs int cmd(string str){
    int err, i;
    string s1, s2;
    string file = "/open/typecheck.c";
    mixed ret, tmpret;
    if(!str){
        write("Try: help types");
        return 1;
    }
    i = sscanf(str,"%s %s", s1, s2);
    if(i != 2 || member_array(s1, types) == -1){
        write("Try: help types");
        return 1;
    }
    contents = header+program;
    contents = replace_string(contents,"$S",s2);
    unguarded((: write_file($(file), contents,1) :));
    reload(file,0,1);
    err = catch( tmpret = file->typecheck() );
    if(err || (stringp(tmpret) && !strsrch(tmpret,"DEFINED_D:"))){
        write("\n"+ tmpret +" appears to be an invalid integer value.");
        return 1;
    }
    else ret = TYPES_D->eventCalculateTypes(s1, tmpret);
    if(arrayp(ret)) ret = implode(ret," ");
    write("The value "+tmpret+" for "+s1+" is: "+ret);
    return 1;
}
예제 #18
0
int cmd_cripple(string str) {
  object tp=this_player();
  object env=environment(tp);
  object tgt;
  object wep;
  object *weps;
  string name, limb;
  int caught=0;

  if (!abil()) return 0;

  // both the limb name and the monster identifier can have spaces in them,
  // so start searching from the second-to-last word given for a monster
  // example: cripple stupid goblin 2 right leg
  // first looks for stupid goblin 2 right,
  // then stupid goblin 2 - bingo, found it.. so right leg is the limb
  if (str) {
    string *tmp = explode(str, " ");
    int i = sizeof(tmp);
    if (i == 1)
      tgt = present(str, env);
    else {
      for (i -= 2; i >= 0; i--) {
        if (tgt = present(implode(tmp[0..i], " "), env)) {
          limb = implode(tmp[i+1..<1], " ");
          break;
        }
      }
    }
  }
예제 #19
0
파일: env.c 프로젝트: Elohim/FGmud
mixed cmd(string args) {
    object player = this_player();
    mixed replee = player->GetProperty("reply");
    string ret = "";
    string *tmp;
    ret += "Screen: \t\t"+identify(this_player()->GetScreen())+"\n";
    ret += "Terminal: \t\t"+this_player()->GetTerminal()+"\n";
    ret += "Brief mode: \t\t"+ ( (this_player()->GetBriefMode()) ? "on" : "off" )+"\n";
    ret += "Cursefilter: \t\t"+ ( (this_player()->GetParanoia("cursefilter")) ? "on" : "off" )+"\n";
    ret += "Channel message colors: "+ ( (this_player()->GetNoChanColors()) ? "off" : "on" )+"\n";
    ret += "Playerkiller mode: \t"+ ( (this_player()->GetPK()) ? "on" : "off" )+"\n";
    ret += "Mute mode: \t\t"+ GetMuted()+" \n";
    ret += "Gag mode: \t\t"+ GetGagged()+" \n";
    ret += "Wimpy mode: \t\t"+ ( (this_player()->GetWimpy()) ? "on" : "off" )+"\n";
#if efun_defined(compressedp)
    ret += "MCCP mode: \t\t"+(compressedp(this_player()) ? "on" : "off")+"\n";
#endif
#if MINIMAP
    ret += "Minimap mode: \t\t"+ ( this_player()->GetProperty("minimapping") ? "on" : "off" )+"\n";
#endif
    ret += "Annoyblock: \t\t"+ ( (this_player()->GetAnnoyblock()) ? "on" : "off" )+"\n";
    ret += "Reprompt mode: \t\t"+ ( this_player()->GetProperty("reprompt") ? "on" : "off" )+"\n";
    ret += "Screenlock mode: \t"+ ( this_player()->GetProperty("screenlock") ? "on" : "off" )+"\n";
    ret += "Timezone: \t\t"+ ( this_player()->GetProperty("timezone") ? 
            this_player()->GetProperty("timezone") : "None specified" )+"\n";
#ifdef __GET_CHAR_IS_BUFFERED__
    ret += "Charmode: \t\t"+ 
        //( (query_charmode(player) > 0) ? "on" : "off" )+"\n";
        ( (player->GetCharmode()) ? "on" : "off" )+"\n";
#endif
    ret += "Commandecho: \t\t"+ ( this_player()->GetProperty("commandecho") ? this_player()->GetProperty("commandecho") : "off" )+"\n";
#ifdef __DSLIB__
    ret += "Keepalive mode: \t"+ ( this_player()->GetProperty("keepalive") 
            ? this_player()->GetProperty("keepalive") : "off" )+"\n";
#endif

    if(creatorp(this_player())){ 
        ret += "Homedir: \t\t"+user_path(this_player())+"\n";
        if(this_player()->GetParanoia("homeroom")){
            ret += "Homeroom: \t\t"+this_player()->GetParanoia("homeroom")+"\n";
        }
        ret += "Debug mode: \t\t"+ ( (this_player()->GetProperty("debug")) ? "on" : "off" )+"\n";
        ret += "Godmode: \t\t"+ ( (this_player()->GetGodMode()) ? "on" : "off" )+"\n";
        ret += "Wizvision: \t\t"+ ( (this_player()->GetWizVision()) ? "on" : "off" )+"\n";
#if GRID
        ret += "Showgrid: \t\t"+ ( (this_player()->GetVisibleGrid()) ? "on" : "off" )+"\n";
        ret += "Wizmap mode: \t\t"+ ( this_player()->GetProperty("wizmapping") ? "on" : "off" )+"\n";
        ret += "Noclip mode: \t\t"+ ( this_player()->GetProperty("noclip") ? "on" : "off" )+"\n";
        ret += "Anchor: \t\t"+ ( this_player()->GetAnchored() ? "on" : "off" )+"\n";
#endif
    }
    if(replee){
        ret += "Reply target: \t\t"+replee+"\n";
    }
    tmp = sort_array(explode(ret, "\n"),1);
    ret = implode(tmp, "\n");
    write(ret);
    return 1;
}
예제 #20
0
// Get user channels.
void meth::GetUserChannels(LogicalConnections::iterator conn, String &response) {
	StringList channels = ::GetUserChannels(GetConnectionUserName(conn));

	if (!channels.empty()) {
		response = "[" + implode(channels) + "]";
	} else {
		response = "null";
	}
}
예제 #21
0
char * STD_Implode(char * from, long from_size, long * to_size)
{
	if (WorkBuff == NULL)
	{
		return NULL;
	}

	unsigned int type  = CMP_BINARY;
	unsigned int dsize;// = 2048;

	if (from_size <= 32768)
		dsize = 1024;
	else if (from_size <= 131072)
		dsize = 2048;
	else dsize = 4096;

	PARAM Param;
	memset(&Param, 0, sizeof(PARAM));

	Param.pSource = from;
	Param.pDestination = (char *)malloc(from_size);

	bool bFirst = true; 

	for (;;)
	{
		Param.CompressedSize = 0;
		Param.UnCompressedSize = from_size;
		Param.BufferSize = Param.UnCompressedSize; 
		Param.SourceOffset      = 0L;
		Param.DestinationOffset = 0L;
		Param.Crc               = (unsigned long) - 1;
		long lResult = implode(ReadUnCompressed, WriteCompressed, WorkBuff, &Param, &type, &dsize);

		if (!lResult)
		{
			break;
		}

		if (bFirst)
		{
			bFirst = false;
			continue;
		}

		lResult = MessageBox(NULL, "Failed while saving...", "Save Error", MB_RETRYCANCEL | MB_ICONERROR);

		if (lResult == IDCANCEL)
		{
			break;
		}
	}

	*to_size = Param.CompressedSize;
	return Param.pDestination;
}
예제 #22
0
void test_implode(const char * str, const char * delims, const char * glue)
{
  int len;
  char * * strArr = explode(str, delims, &len);
  char * resultStr = implode(strArr, len, glue);
  printf("Exploding \"%s\" by \"%s\" then imploding using \"%s\" gives \"%s\"\n", str, delims, glue, resultStr);
  
  destroyStringArray(strArr, len);
  free(resultStr);
}
예제 #23
0
파일: read_file.c 프로젝트: BPotato/fluffos
void do_tests() {
    string foo = read_bytes("/testfile");
    string mid = implode(explode(foo, "\n")[99..198], "\n") + "\n";
    
    ASSERT(!read_file("/single", 10, 10));
    ASSERT(read_file("/testfile") == foo);
    ASSERT(read_file("/testfile", 100, 100) == mid);
    ASSERT(!read_file("/does_not_exist"));
    ASSERT(!read_file("/testfile", 10000, 1));
}
예제 #24
0
파일: mappings.c 프로젝트: Elohim/FGmud
    foreach( key, val in carte){
        if(arrayp(key)){
            if(!sizeof(key)) retkey = "BLANK ARRAY";
            else retkey = "ARRAY ("+implode(key,", ")+")";
        }
        else if(objectp(key)) retkey = "OBJECT ("+file_name(key)+")";
        else if(intp(key)) retkey = ""+key;
        else retkey = key;
        if(arrayp(val)){
            if(!sizeof(val)) retval = "BLANK ARRAY";
            else retval = "ARRAY ("+implode(val,", ")+")";
        }
        else if(objectp(val)) retval = "OBJECT ("+file_name(val)+")";
        else if(intp(val)) retval = ""+val;
        else retval = val;

        if(!retstring || retstring == "") retstring = retkey+":"+retval;
        else retstring += ", "+retkey+":"+retval;
    }
예제 #25
0
mixed cmd(string str) {
  /* call fish(x,y,z) object */
  mixed *args, file, f;
  mixed retobj;
  string *s, s1, s2;
  string fn,os, obvarname;
  string *argv;
  object *ov;
  object fish, shad, ob;

  notify_fail("USAGE : call [obvar=]lfun(arg[,arg[,arg...]]) object[s]\n");
  if (!str)
    return 0;
  obvarname = (string)0;
  sscanf(str, "%s=%s", obvarname, str);
  s = explode("&"+str+"&", ")");
  if (sizeof(s) < 2 || sscanf(s[0], "%s(%s", s1, s2) != 2)
    return 0;
  fn = replace(s1[1..], " ", "");
  s[0] = s2;
  args = PARSER->parse_args(implode(s, ")"), ")");
  if (!args) return 1;
  argv = args[0];
  os = args[1][0..<2];
  while (strlen(os) && os[0] == ' ')
    os = os[1..];
  notify_fail("Can't find object "+os+".\n");
  ov = WIZ_PRESENT->wiz_present(os, this_player());
  
  ov = filter( ov, (: reference_allowed( $1, $( this_player() ) ) :) );  

  if (!sizeof(ov)) return 0;

  if (sizeof(argv) < 6) argv += allocate(6 - sizeof(argv));

  foreach (ob in ov) {
    fish = ob;
    while (shad = shadow(fish, 0)) {
      fish = shad;
      if (f = function_exists(fn, fish)) file = f;
    }
    if (!file) file = function_exists(fn, ob);
    if (file) {
  if ( ( ob != this_player() && ob->query_property( "player" ) ) ) {
        unguarded((: write_file,
                   (LMASTER->query_member(this_player()->query_name()) ?
                    "/d/admin/log/CALL_LIAISONS.log" :
                    "/d/admin/log/CALL_CREATORS.log" ),
                   sprintf("%s: %s (%O) called %s(%s) on %s (%O)\n",
                           ctime(time()),
                           this_player()->query_name(), this_player(),
                           fn, implode(argv - ({0}), ", "),
        ob->query_name(), ob) :));
        user_event("inform", sprintf("%s called %s(%s) on %s",
            this_player()->query_name(), fn, implode(argv - ({0}), ", "),
예제 #26
0
void test_sortStringArray(const char * str)
{
  int len;
  char * * strArr = explode(str, " ", &len);
  sortStringArray(strArr, len);
  char * sortedStr = implode(strArr, len, " ");
  printf("Sorting \"%s\" gives \"%s\"\n", str, sortedStr);

  destroyStringArray(strArr, len);
  free(sortedStr);
}
예제 #27
0
void ScreenDebug::update()
{
    // récupération des messages de la console
    vector<sf::String> console_message = Console::getLogMessages();
    for (unsigned int i=0; i<console_message.size();i++)
        _console_lines.push_back(console_message[i]);
    while (_console_lines.size()>DEBUG_NB_CHAR_HEIGHT)
        _console_lines.erase(_console_lines.begin());    // efface le premier élément et décale le reste (je viens d'apprendre ça)

    vector<vector<float> > spectrum_data = _audio->getAudioSpectrum();

    for (unsigned int i=0; i<spectrum.size() && i<spectrum_data[0].size(); i++)
    {
        float size_y = spectrum_data[0][i]*500;
        spectrum[i].setSize(sf::Vector2f(3, size_y));
        spectrum[i].setPosition(sf::Vector2f(2+i*5, _window_size->y - size_y - 2));
    }
    if (spectrum_data.size() > 1)
        for (unsigned int i=0; i<spectrum2.size() && i<spectrum_data[1].size(); i++)
        {
            float size_y = spectrum_data[1][i]*500;
            spectrum2[i].setSize(sf::Vector2f(3, size_y));
            spectrum2[i].setPosition(sf::Vector2f(2+i*5, _window_size->y - size_y - 2));
        }


    int framerate = 1 / _FPSclock.restart().asSeconds();

    string uptime = formattedDuration(_clock.getElapsedTime(), 2);




    _debug_info.setString("SFML Tetris - Par Marc Baloup et Louis Behague - http://sfmltetris.no-ip.org/\nUptime : "+
                          uptime+
                          " - FPS : "+to_string(framerate) +
                          " - Particules : "+ to_string(ExplosionManager::_nbParticules) +
                          "\nJeu : " + ((_game->getPause())?"En pause":"En cours ...") +
                          ((!_game->getPause() && !_game->_AIActualPlaying)?(" - Auto descente piece : "+to_string(((_game->timeLastMoveDown+_game->getTimeAutoMoveDown())-_game->getGameTime()).asSeconds())+""):"")+
                          " - IA : "+to_string(_game->_AIActualPlaying)+" avec "+to_string((int) _game->_AINbTetromino)+" tetromino connu (next : "+to_string(_game->_AIPlay)+")"+
                          "\nAudio : "+to_string(_audio->getPlay())+
                          " - Volume : "+to_string(_audio->getVolume())+
                          " - Musique : "+((_audio->getPlay())?(_audio->getMusicList()[_audio->getMusicPlayingId()]):"aucun"));

    _debug_info_background.setSize(sf::Vector2f(_debug_info.getLocalBounds().width+10, _debug_info.getLocalBounds().height+15));

    _console_text.setString(implode(_console_lines, L"\n"));

    _console_text.setPosition(10, _window_size->y - (10 + _console_text.getLocalBounds().height));
    _console_text_background.setPosition(_console_text.getPosition()-sf::Vector2f(5, 5));
    _console_text_background.setSize(sf::Vector2f(_console_text.getLocalBounds().width+10, _console_text.getLocalBounds().height+15));

    _audio_indicator.setSize(sf::Vector2f(100*_audio->getAudioLevel(), 10));
}
예제 #28
0
std::string removeBlankLines(std::string s) {
    Vector<std::string> lines = explodeLines(s);
    Vector<std::string> newLines;
    for (std::string line : lines) {
        line = trimR(line);
        if (line.length() > 0) {
            newLines.add(line);
        }
    }
    return implode(newLines, "\n");
}
예제 #29
0
atomic string to_mudmode(mixed data) {
  string *keys;
  string *vals;
  string pref, post, result;
  int i, n;

  switch(typeof(data)) {
    case T_INT:
    case T_FLOAT: return ""+data;
    case T_STRING:
      if(strlen(data) == 0) return "";

      if(data[0..0] == "\\") {
        pref = "\\\\";
      }
      else if(data[0..0] == "\"") {
        pref = "\\\"";
      }
      else {
        pref = "";
      }

      if(data[strlen(data)-1] == '\\') {
        post = "\\\\";
      }
      else if(data[strlen(data)-1] == '"') {
        post = "\\\"";
      }
      else {
        post = "";
      }

      result = implode(explode(data, "\\"), "\\\\");
      result = implode(explode(result, "\""), "\\\"");
      return "\"" + pref + result + post + "\"";
      
    case T_OBJECT: return object_name(data);
    case T_ARRAY:
      vals = ({ });
      for(i = 0, n = sizeof(data); i < n; i++)
        vals += ({ to_mudmode(data[i]) });
예제 #30
0
std::string indent(std::string s, int spaces) {
    Vector<std::string> lines = explodeLines(s);
    Vector<std::string> newLines;
    std::string indentStr = "";
    for (int i = 0; i < spaces; i++) {
        indentStr += " ";
    }
    for (std::string line : lines) {
        newLines.add(indentStr + line);
    }
    return implode(newLines);
}