Пример #1
0
int do_purge_all_players()
{
        int i, j, ppl_cnt, count;
        string *dir, *ppls, name;
        mixed info;

        seteuid(getuid());
        message("system", "\n*** 整理玩家储存档中,请稍候.... ***\n", users());
        write("处理中:");
        count = 0;
        ppl_cnt = 0;
        dir = get_dir(DATA_DIR + "login/");
        for(i=0; i<sizeof(dir); i++) {
                reset_eval_cost();
                write(dir[i]);
                ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/");
                ppl_cnt += sizeof(ppls);
                for(j=0; j<sizeof(ppls); j++) {
                        if( sscanf(ppls[j], "%s.o", name)==1 )
                                if( (string)SECURITY_D->get_status(name)!="(player)" )
                                        continue;
                        info = stat(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]);
                        if( SECURITY_D->get_status(name) == "(player)" ) {
                                rm(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]);
                                rm(DATA_DIR + "user/" + dir[i] + "/" + ppls[j]);
                                count ++;
                        }
                }
        }
        write("\n\n原来总共有 " + ppl_cnt + " 位使用者。\n");
        write("现在总共有 " + (ppl_cnt - count) + " 位使用者。\n");

        return 1;
}
Пример #2
0
void write_file(const std::string& fname, const std::string& data)
{
	//Try to ensure that the dir the file is in exists.
	std::vector<std::string> components = util::split(fname, '/');
	if(!components.empty()) {
		components.pop_back();

		std::vector<std::string> tmp;
		while(components.empty() == false && get_dir(util::join(components, '/')).empty()) {
			tmp.push_back(components.back());
			components.pop_back();
		}

		while(!components.empty() && !tmp.empty()) {
			components.push_back(tmp.back());
			tmp.pop_back();

			get_dir(util::join(components, '/'));
		}
	}

	//Write the file.
	std::ofstream file(fname.c_str(),std::ios_base::binary);
	file << data;
}
Пример #3
0
void ai::go_to(const vec3 &pos, int dt)
{
    if (m_plane.expired())
        return;

    const float kdt = dt * 0.001f;

    auto p = m_plane.lock();

    vec3 next_pos = p->phys->pos + p->phys->vel * kdt;

    vec3 target_diff = pos - next_pos;
    vec3 target_dir = vec3::normalize(target_diff);

    auto dir = p->get_dir();

    //pitch
    if (target_dir.y > 0.01f && dir.y < 0.6)
        p->controls.rot.x = -1.0f;
    else if (target_dir.y < -0.01f && dir.y > -0.6)
        p->controls.rot.x = 1.0f;
    else
        p->controls.rot.x = 0.0f;

    auto dir_normal = vec3::cross(p->get_dir(), target_dir);

    //yaw
    if (dir_normal.y > 0.01f)
        p->controls.rot.y = -1.0f;
    else if (dir_normal.y < -0.01f)
        p->controls.rot.y = 1.0f;

    //ToDo: roll
}
Пример #4
0
editor_controller::editor_controller(const config &game_config, CVideo& video, hero_map& heros, int mode)
	: controller_base(SDL_GetTicks(), game_config, video)
	, heros_(heros)
	, mode_(mode)
	, mouse_handler_base()
	, rng_(NULL)
	, rng_setter_(NULL)
	, map_contexts_()
	, current_context_index_(0)
	, gui_(NULL)
	, map_generators_()
	, tods_()
	, palette_()
	, floating_label_manager_(NULL)
	, do_quit_(false)
	, quit_mode_(EXIT_ERROR)
	, brushes_()
	, brush_(NULL)
	, mouse_actions_()
	, mouse_action_hints_()
	, mouse_action_(NULL)
	, toolbar_dirty_(true)
	, foreground_terrain_(t_translation::MOUNTAIN)
	, background_terrain_(t_translation::GRASS_LAND)
	, clipboard_()
	, auto_update_transitions_(preferences::editor::auto_update_transitions())
	, use_mdi_(preferences::editor::use_mdi())
	, default_dir_(preferences::editor::default_dir())
{
	create_default_context();

	if (default_dir_.empty()) {
		default_dir_ = get_dir(get_dir(get_user_data_dir() + "/editor") + "/maps");
	}
	init_gui(video);
	init_brushes(game_config);
	init_mouse_actions(game_config);
	init_map_generators(game_config);
	init_tods(game_config);
	init_sidebar(game_config);
	init_music(game_config);
	hotkey_set_mouse_action(gui2::teditor_theme::HOTKEY_EDITOR_TOOL_PAINT);
	rng_.reset(new rand_rng::rng());
	rng_setter_.reset(new rand_rng::set_random_generator(rng_.get()));
	get_map_context().set_starting_position_labels(gui());
	cursor::set(cursor::NORMAL);
	image::set_color_adjustment(preferences::editor::tod_r(), preferences::editor::tod_g(), preferences::editor::tod_b());
	refresh_all();
	events::raise_draw_event();

	map_type = tmap_type();
	if (mode_ != NONE) {
		BOOST_FOREACH (const config& type, game_config.child_range("map_type")) {
			const std::string& id = type["id"];
			if (mode == SIEGE && id == "siege") {
				map_type = tmap_type(*gui_, type);
			}
		}
	}
Пример #5
0
void Guideline::rangeOfAttachedObjects(double& min, double& max) const
{
    min = DBL_MAX;
    max = -DBL_MAX;

    for (RelsList::const_iterator curr = relationships.begin(); curr != relationships.end(); ++curr)
    {
        QRectF itemRect;
        if ((*curr)->shape)
        {
            itemRect = (*curr)->shape->boundingRect();
            itemRect.moveCenter((*curr)->shape->pos());
        }
        else if ((*curr)->distro)
        {
            itemRect = (*curr)->distro->boundingRect();
            itemRect.moveCenter((*curr)->distro->pos());
        }
        else if ((*curr)->separation)
        {
            itemRect = (*curr)->separation->boundingRect();
            itemRect.moveCenter((*curr)->separation->pos());
        }

        if (itemRect.isValid())
        {
            if (get_dir() == GUIDE_TYPE_HORI)
            {
                min = qMin(min, itemRect.left());
                max = qMax(max, itemRect.right());
            }
            else
            {
                min = qMin(min, itemRect.top());
                max = qMax(max, itemRect.bottom());
            }
        }
    }

    // Cope with the case where there are no attached objects.
    if ((min == DBL_MAX) && (max = -DBL_MAX) && canvas())
    {
        QRectF sceneBounds = canvas()->combinedViewsRect();

        if (get_dir() == GUIDE_TYPE_HORI)
        {
            min = sceneBounds.left();
            max = sceneBounds.right();
        }
        else
        {
            min = sceneBounds.top();
            max = sceneBounds.bottom();
        }
    }
}
Пример #6
0
void create(void) {
   mixed *list;

   list = get_dir("/data/banned/a/*");
   a_banned_sites = list[0];
   list = get_dir("/data/banned/b/*");
   b_banned_sites = list[0];
   list = get_dir("/data/banned/c/*");
   c_banned_sites = list[0];
}
Пример #7
0
int count_ppls()
{
        int count,i;
        string *dir, *ppls;

        seteuid(getuid());

        dir = get_dir(DATA_DIR + "login/");
        for(i=0; i<sizeof(dir); i++) {
        ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/");
        count += sizeof(ppls);
        }
        return count;
}
Пример #8
0
int main(object me,string arg)
{
	string *files;
	mixed *file;
	int i,j,w=0,col,total=0;
	int size;
	set_eval_limit(1); 
	seteuid(getuid());
	if(!arg || arg=="") return notify_fail("╕ё╩╜▓╗╢╘гб\n");

	error = 0;

	if (arg == "-o")
		arg = "/daemon/";
	else
		arg = "/daemon/class/"+arg+"/";
    
	file = get_dir(arg, -1);
   	reset_eval_cost();
	if( !sizeof(file) )
	{if (file_size(arg) == -2) return notify_fail("╬─╡╡╝╨╩╟┐╒╡─бг\n");
		else
		return notify_fail("├╗╙╨╒т╕Ў╬─╡╡╝╨бг\n");
	}

	write(HIW"╒¤╘┌╦є╤▓"+arg+"╬─╡╡╝╨гогого\n"NOR);

	i = sizeof(file);
	w = 0;
	while(i--) {
		if (file[i][1]==-2) 
		{
			files = get_dir(arg+file[i][0]+"/");
		   	reset_eval_cost();
			// р┼гм╒т╕Ў╙ж╕├╩╟╢╘╙ж╡─skill╬─╡╡гм╥╗╞Ё▒р╥ы░╔
			update_function(me,"/daemon/skill/"+file[i][0]);
			// is a directory , ╜Ў╫╖╦▌╥╗▓убг
			for(j=0; j<sizeof(files); j++) 
			{
				size=sizeof(files[j]);
				if(files[j][(size-2)..size]==".c")
				{
					update_function(me,arg+file[i][0]+"/"+files[j]);
					total++;
				}
			}   	 	
			file[i][0] += "/";
		}
	}
Пример #9
0
int main(object me, string arg)
{
	int i;
	string direc,*dir, roomname;
	string status;
	object room;
        if(!me->query("env/yesiknow")) return notify_fail("╒т╕Ў╓╕┴ю╥╤╛н▒╗╖╧│¤┴╦гб\n");
	status = wizhood(me);
	if( me!=this_player(1)
	|| wiz_level(me) < wiz_level(status) )
		return notify_fail("─у├╗╙╨╚и┴ж╩╣╙├╒т╕Ў╓╕┴юбг\n");
	if( !arg ) return notify_fail(SYNTAX);
	if( sscanf(arg, "%s", direc)!=1 )
		return notify_fail(SYNTAX);
	seteuid(getuid());
	dir = get_dir(arg+"/");
        for(i=0; i<sizeof(dir); i++) {
	if( sscanf(dir[i],"%s.c", roomname) != 1) continue;
	if( room = find_object(arg+"/"+roomname+".c"))
			destruct(room);	
	room = load_object(arg+"/"+roomname+".c");
	if(!room->query("coor"))
	log_file("LEAK",sprintf("%s/%s\n",arg,roomname));
	}
	return 1;
}
Пример #10
0
void ShootMovement::update(float dt)
{
    double add_x, add_y;
    get_dir(instance->direction, add_x, add_y);
    double m = get_pixels(speed) * instance->frame->timer_mul;
    move(add_x * m, add_y * m);
}
Пример #11
0
void EightDirections::update(float dt)
{
    if (max_speed == 0)
        return;

    bool on = false;
    int dir = get_joystick_direction(1);
    if (dir == 8)
        dir = instance->direction;
    else {
        on = true;
        dir *= 4;
        instance->set_direction(dir, false);
    }
    double mul = instance->frame->timer_mul;

    double change;
    if (on)
        change = get_accelerator(acceleration);
    else
        change = -get_accelerator(deceleration);

    set_speed(int_max(0, int_min(speed + change * mul, max_speed)));

    if (speed == 0)
        return;

    double add_x, add_y;
    get_dir(instance->direction, add_x, add_y);
    double m = get_pixels(speed) * mul;
    move(add_x * m, add_y * m);
    last_move = m;
}
Пример #12
0
Файл: _du.c Проект: ehershey/pd
int disk_usage(string path, int level) 
{
 int i, total, num;
 string *dir;

 if (level>MAX_RECURSE) return 0;

 total= file_size(path);
 if (total == -1)
   {
    write("Cannot access: " + path + "\n");
    return 0;
   }
 if (total == -2)
   {
    total= 0;
    dir = get_dir(path + "/");
    if (dir)
      {
       num = sizeof(dir);
       for (i=0; i<num; i++) total += disk_usage(path+"/"+dir[i], level+1);
      }
/* series of fixes by Valodin 1-19-93 */
    message("system", sprintf("%d Kbytes   %d bytes   %s", (1+total/1024),
      total, path), this_player());
   }
 return total;
}
Пример #13
0
void PinballMovement::set_direction(int value)
{
    float dist = get_length(x_speed, y_speed);
    get_dir(value, x_speed, y_speed);
    x_speed *= dist;
    y_speed *= dist;
}
Пример #14
0
int cmd_convert(string str) {
    int i, x;
    string *dir, name, tmp;
    mapping m;

    if(!str || str != "ok") return 0;
    if(!GUILD_D->valid_master(this_player()->query_name())) return 0;
    m=([]);
    write("Converting .o files to master.o\n");
    dir=get_dir("/d/guilds/save/");
    i=sizeof(dir);
    while(i--) {
	if(file_exists("/d/guilds/save/"+dir[i])) {
	    restore_object("/d/guilds/save/"+dir[i]);
	    name=lower_case(dir[i][0..sizeof(dir[i])-3]);
	    x=sizeof(member);
	    while(x--) {
		m[member[x]]=name;
	    }
	    x=sizeof(squire);
	    while(x--) {
		m[squire[x]]=name;
	    }
	    x=sizeof(council);
	    while(x--) {
		m[council[x]]=name;
	    }
	    x=sizeof(leader);
	    while(x--) {
		m[leader[x]]=name;
	    }
	}
    }
Пример #15
0
Файл: dir.c Проект: mudchina/fy3
int main(object me, string arg)
{
	int mark_loaded;
	int i, j, w, col;
	string dir;
	mixed *file;

	dir = resolve_path(me->query("cwd"), arg);
	if( file_size(dir)==-2 && dir[strlen(dir)-1] != '/' ) dir += "/";
	file = get_dir(dir, -1);
	if( !sizeof(file) )
	{if (file_size(dir) == -2) return notify_fail("目录是空的。\n");
		else
		return notify_fail("没有这个目录。\n");
	}

	i = sizeof(file);
	w = 0;
	while(i--) {
		if (file[i][1]==-2) file[i][0] += "/";
		if (strlen(file[i][0])>w) w = strlen(file[i][0]) + 1;
	}
	write("目录:" + dir + "\n");
	col = 70 / (w+6);
	if (sizeof(file))
		for(i=0, j = sizeof(file); i<j; i++)
			printf("%4d %-*s%s", file[i][1]/1024 + 1, w+1,
				file[i][0] + (find_object(dir + file[i][0])? "*":" ") ,
				((i+1)%col)?"  ":"\n");
	else write("    没有任何档案。\n");
	write("\n");
	
	return 1;	
}
Пример #16
0
int rm_dir(string dir)
{
	mixed *file;
	int count;
	int i;
/*
	if (! is_root(previous_object()))
		return 0;
*/
	count = 0;
	if (dir[strlen(dir) - 1] != '/') dir += "/";
	file = get_dir(dir, -1);

	i = sizeof(file);
	while (i--)
	{
		reset_eval_cost();
		if (file[i][1] != -2)
			if (rm(dir + file[i][0]))
				count++;
	}

	i = sizeof(file);
	while (i--)
	{
		reset_eval_cost();
		if (file[i][1] == -2)
			count += rm_dir(dir + file[i][0]);
	}

	write (HIC "删除目录(" + dir + ")。\n" NOR);
	rmdir(dir);
	return count;
}
Пример #17
0
int main(object me, string arg)
{
	mixed *dir;
	string *id;
	mapping data;
	object lingpai;
	string msg,banghui;
	int i;
	if(! arg)	{
	dir=get_dir("/data/guild/",0);
	if(! dir)	return notify_fail("朕念短嗤販採逸氏。\n");
	msg=sprintf("%-16s%-10s%-10s%-10s%-10s\n",
		"逸氏兆各","逸麼","螺社方","NPC方","仇徒方");
	msg+="------------------------------------------------------------\n";
	lingpai=new("/obj/lingpai");
	for(i=0;i<sizeof(dir);i++)	{
		if(sscanf(dir[i],"%s.o",banghui)==1)	{
			lingpai->create(banghui);
//			msg+=sprintf("%-16s%-10s%-10d%-10d%-10d\n",
			msg+=sprintf("%s%-16s%-10s%-10d%-10d%-10d"NOR"\n",
			member_array(banghui,npc_banghui)!=-1?HIG:"",
			banghui,lingpai->query("bangzhu"),sizeof(lingpai->query("player")),sizeof(lingpai->query("npc")),sizeof(lingpai->query("area")));
	}
	}
	destruct(lingpai);
	}
Пример #18
0
static int shog_rmdir(const char *path) {
	struct remove_packet p;
	char *dirpath = get_dir(path);
	int err, sock;
	pthread_mutex_t *mutex;

	p.type = ODT_DIR;
	p.obj = path_to_id(path);
	p.dir_obj = path_to_id(dirpath);

	free(dirpath);

	do {
		choose_peer(&sock, &mutex);

		pthread_mutex_lock(mutex);
		err = send_packet(sock, OP_REMOVE, &p, sizeof(struct remove_packet));
		if (err < 0) {
			pthread_mutex_unlock(mutex);
			continue;
		}
		err = receive_reply(sock, NULL, 0);
		pthread_mutex_unlock(mutex);
		break;
	} while (1);

	return err;
}
Пример #19
0
static void	update_expulsed(t_server *s, t_tile *t,
				t_player *front, t_player *p)
{
  t_player	*tmp;
  t_player	*back;
  static char	str[500];

  tmp = front;
  while (tmp)
    {
      if (p->dir == NORTH)
	tmp->y = (p->y - 1 + s->y) % s->y;
      else if (p->dir == EAST)
	tmp->x = (p->x + 1) % s->x;
      else if (p->dir == SOUTH)
	tmp->y = (p->y + 1) % s->y;
      else
	tmp->x = (p->x - 1 + s->x) % s->x;
      memset(str, 0, 500);
      sprintf(str, "deplacement: %d\n", get_dir(s, tmp, p->x, p->y));
      communication_sendto(tmp->client_data, str, 0);
      request_broadcast(s, ppo, tmp->id, 0);
      back = tmp;
      tmp = tmp->next_t;
    }
  back->next_t = t->players;
  t->players = front;
}
Пример #20
0
//  This function recursively cleans a specific directory path
//  If flag = 1, it will not protect PROTECTed files
static int move_contents(string path, int flag) {
   mixed *dir;
   string what;
   int loop;
 
   //	Get directory contents array
   dir = get_dir( path );
   if(!dir || !sizeof(dir))  return -1;
 
   //	Loop through and delete contents of dir array
   for(loop=0; loop<sizeof(dir); loop++) {
   what = path + dir[loop];

   //	If selection is a directory ... recursively clean and remove it
   if(file_size( what ) == -2) {
  what = replace_string( what, "//", "/" );
   mkdirs( PURGED + what + "/" );
   move_contents(what + "/", 1);
   rmdir(what);  
   }
 
   //	If file isn't protected ... remove it
  if( flag ) {
  what = replace_string( what, "//", "/" );
     rename( what, PURGED + what );
	rm(what);
   }
  }
 
return 1; }
Пример #21
0
string *query_languages(void) {
   string name, *langs, *files;
   object obj;
   int i, x;

   files = get_dir(RACE_DIR + "/*.c")[0];
   langs = ({ });
Пример #22
0
static int shog_mkdir(const char *path, mode_t mode) {
	struct create_packet p;
	char *dirpath = get_dir(path);
	char *fname = get_filename(path);
	int err, sock;
	pthread_mutex_t *mutex;

	p.type = ODT_DIR;
	p.obj = path_to_id(path);
	strncpy((char*)p.name, fname, 256);
	p.dir_obj = path_to_id(dirpath);

	free(fname);
	free(dirpath);

	do {
		choose_peer(&sock, &mutex);
		pthread_mutex_lock(mutex);
		err = send_packet(sock, OP_CREATE, &p, sizeof(struct create_packet));
		if (err < 0) {
			pthread_mutex_unlock(mutex);
			continue;
		}
		err = receive_reply(sock, NULL, 0);
		pthread_mutex_unlock(mutex);
		break;
	} while (1);

	return err;
}
Пример #23
0
int random_go(object me, string* dirs)
{
    int		i, j, k;
    object	newob;
    mixed*	file;

    if( !sizeof(dirs) )  return 1;

    i = random(sizeof(dirs));    // pick up one directory

    file = get_dir( dirs[i]+"*.c", -1 );
    if( !sizeof(file) )		return 1;

    k = sizeof(file);
    while(1)  {
        j = random(k);
        if( file[j][1] > 0 )		break; 		// pick up a file with size > 0
    }

    if( (newob=find_object(dirs[i]+file[j][0])) )   {
        me->move( newob );
    }
    else  {
        seteuid(getuid(me));
        newob = load_object(dirs[i]+file[j][0]);
        if (newob)   // now this is not necessary, only for debug use
            me->move(newob);
        else  {
            tell_object(me, "Error.\n");
        }
    }

    return 1;
}
Пример #24
0
/*
** create()
**
** When this daemon is loaded, get each of the verb objects loaded.
** Each verb object will define its rules.
*/
void create()
{
    string * files;

    files = get_dir(CMD_DIR_VERBS "/*.c");
    map_array(files, (: reload_verb :));
}
Пример #25
0
Файл: cmod.c Проект: imclab/cmod
void add_recursive(char *path, char **ent, int nfil)
{
  char **e;
  char *buff;
  int i;
  int item = 0;
  int nf;

  for(i=0; i<nfil; i++) {
    if(!is_dir(path, ent[i])) {
      buff = mystrcat(path,ent[i],1);
      if(add(&playlist_h, buff, &playlist_t)) {
        if(p_p == -1) p_p++;
        nsongs++;
      }
      free(buff);
    }  else { // is a dir
      if(strncmp(ent[i], ".." ,2) != 0) { // d'oh!
        buff = mystrcat(path, ent[i], 1);
        if(e = get_dir(buff, &nf)) {
          add_recursive(buff, e, nf);
          while(item < nf) {
            free(e[item++]);
          }
          free(e);
        }
        free(buff);
      }
    }
  }
}
Пример #26
0
int main(object me,string arg)
// arg should be /d/baiyun/ ....
{
    	string *files;
    	int i,total=0;
    	int size;
    	set_eval_limit(1); 
    	seteuid(getuid());
    	if(!arg || arg=="") return notify_fail("╕ё╩╜▓╗╢╘гб\n");
    
    	error = 0;
    	
    	write(HIW"╒¤╘┌╦є╤▓"+arg+"╬─╡╡╝╨гогого\n"NOR);
    	
    	files= get_dir(arg);
    	reset_eval_cost();
    	for(i=0; i<sizeof(files); i++) 
    	{
    	    size=sizeof(files[i]);
        	if(files[i][(size-2)..size]==".c"){
        		if (files[i]=="updatep.c") continue;
        		total++;
				update_function(me, arg+files[i]);
			}	
//  	           	me->ccommand(sprintf("update %s%s",arg,files[i]));
        }   
        
        write(HIW"гогого"+arg+"╬─╡╡╝╨▒р╥ы═ъ│╔бг
бббббб╣▓╦є╤▓╡╜"+total+"╕Ў╡╡░╕гм╞ф╓╨"+error+"╕Ў▒р╥ы╩з░▄бг\n"NOR);	 	
    	return 1;
}
Пример #27
0
void Guideline::rangeOfAttachedShapes(double& min, double& max, int& nodes)
{
    min = DBL_MAX;
    max = -DBL_MAX;

    nodes = 0;

    for (RelsList::iterator curr = relationships.begin(); curr != relationships.end(); ++curr)
    {
        if ((*curr)->shape)
        {
            ++nodes;
            QPointF shPos = (*curr)->shape->centrePos();
            if (get_dir() == GUIDE_TYPE_HORI)
            {
                min = qMin(min, shPos.x());
                max = qMax(max, shPos.x());
            }
            else
            {
                min = qMin(min, shPos.y());
                max = qMax(max, shPos.y());
            }
        }
    }
}
Пример #28
0
/*
  This function sorts the first token of the record. The first token can be an
  instruction, a directive or a label. Anything else results in an error,
  indicated here as type UNKNOWN. It gets called again when the first token is
  a LABEL to determine the type of the following token.
*/
struct firsttoken sort(char *token){
  struct firsttoken result;
  struct symbol_entry* entry;
  result.instptr = NULL;
  result.dirptr = NULL;
  result.type = UNKNOWN;

  if(result.instptr = get_inst(token)){       //Check INST list
    result.type = INST;
    return result;
  }
  else if(result.dirptr = get_dir(token)){    //Check DIR list
    result.type = DIR;
    return result;
  }
  else if(is_label(token)){                   //Check Label rules
    result.type = LABEL;
    if(entry = get_entry(token)){
      if(entry->type == REGTYPE){       //Ensures that the "valid" label is
        result.type = UNKNOWN;          //not a register. If it's a reg
      }                                 //return UNKNOWN to show error.
    }
    return result;
  }
  else if(*token = ';'){                //For the cases in which the comment
    result.type = COMMENT;              //starts further into the line
  }
  return result;                        //If none of the above return UNKNOWN
}
Пример #29
0
unsigned char is_label(char* token){
  int short i = 1;
  unsigned char res = FALSE;

  if(isalpha(*token)){
    while(i < (strlen(token))){
      res = (!isalnum(token[i]) || i == MAX_NAME_LEN) ? FALSE : TRUE;
      if(res == FALSE){     // Breaks loop once an error is detected
        if(i == MAX_NAME_LEN){
          error_count("ERROR: Label is too long:", token);
        }
        return res;
      }
      i++;
    }

    if(get_inst(token)){  // Labels cannot have instruction names
      res = FALSE;
      #ifdef debug
      printf("LABEL >>%s<< HAS INSTRUCTION NAME\n", token);
      #endif /* debug */
    }

    if(get_dir(token)){ // Lables cannot have directive names
      res = FALSE;
      #ifdef debug
      printf("LABEL >>%s<< HAS DIRECTIVE NAME\n", token);
      #endif /* debug */
    }
  }
  return res;
}
Пример #30
0
void makeone()
{
    object socialism = find_player( "socialism" );
    
    string *locations = get_dir( FROOM "*1.c" );
    object monster;
    object room = load_object( locations[ random( sizeof(
      locations) )] );
      
    tell_player( socialism, "Loaded random room." );
    
    int gotime = random( 300 ) + 4;
    if( monster = present_clone( FMONS "tent2.c", room ) )
    {
      tell_object( room, "The tendrils recede into the ground." );
      destruct( monster );
      call_out( "makeone", gotime );
      tell_player( socialism, "Tent already in this room.\n" );
      return;
    }
    move_object( clone_object( FMONS "tent2" ), room );
    tell_object( room, "Tendrils erupt from the ground!\n" );
    call_out( "makeone", gotime );
    tell_player( socialism, "Cloned a monster in a room." );
    return;
}