Exemplo n.º 1
0
/** @copydoc command_func */
void command_arrest(object *op, const char *command, char *params)
{
    player *pl;

    if (!params) {
        draw_info(COLOR_WHITE, op, "Usage: /arrest <player>");
        return;
    }

    pl = find_player(params);

    if (!pl) {
        draw_info(COLOR_WHITE, op, "No such player.");
        return;
    }

    if (!region_enter_jail(pl->ob)) {
        /* We have nowhere to send the prisoner....*/
        draw_info(COLOR_RED, op, "Can't jail player, there is no map to hold them.");
        return;
    }

    draw_info_format(COLOR_GREEN, op, "Jailed %s.", pl->ob->name);
    LOG(CHAT, "[ARREST] Player %s arrested by %s.", pl->ob->name, op->name);
}
Exemplo n.º 2
0
/**
 * Open the player shop. */
void shop_open()
{
	_shop_struct *shop_item_tmp;
	char buf[HUGE_BUF];

	/* Need at least one item */
	if (shop_gui->shop_items_count < 1)
	{
		draw_info("You need to have at least one item to sell in order to open a shop.", COLOR_RED);
		return;
	}

	strcpy(buf, "shop open");

	/* Loop through the shop items */
	for (shop_item_tmp = shop_gui->shop_items; shop_item_tmp; shop_item_tmp = shop_item_tmp->next)
	{
		char tmp_buf[MAX_BUF];
		item *shop_item = locate_item(shop_item_tmp->tag);

		/* If the item could not be found, something is wrong */
		if (!shop_item)
		{
			draw_info("Unable to locate shop item from tag.", COLOR_RED);
			clear_shop(0);
			return;
		}

		/* Some checking */
		if (shop_item_tmp->price < 1 || shop_item_tmp->price > MAX_PRICE_VALUE)
		{
			draw_info_format(COLOR_RED, "The item %s doesn't have a valid price.", shop_item->s_name);
			return;
		}
		else if (shop_item_tmp->nrof < 1 || shop_item_tmp->nrof > MAX_PRICE_VALUE)
		{
			draw_info_format(COLOR_RED, "The item %s doesn't have a valid nrof.", shop_item->s_name);
			return;
		}

		/* Store the item tag, nrof and price */
		snprintf(tmp_buf, sizeof(tmp_buf), "|%d:%d:%d", shop_item_tmp->tag, shop_item_tmp->nrof, shop_item_tmp->price);

		/* Append it to the socket string */
		strncat(buf, tmp_buf, sizeof(buf) - strlen(buf) - 1);
	}

	/* Write the socket string to server */
	cs_write_string(buf, strlen(buf));

	/* The shop is now open */
	shop_gui->shop_state = SHOP_STATE_OPEN;
}
Exemplo n.º 3
0
/** @copydoc command_func */
void command_ban(object *op, const char *command, char *params)
{
    size_t pos = 0;
    char word[MAX_BUF];
    if (!string_get_word(params, &pos, ' ', VS(word), '"')) {
        return;
    }

    params = player_sanitize_input(params + pos);

    if (strcmp(word, "add") == 0) {
        if (params == NULL) {
            return;
        }

        ban_error_t rc = ban_add(params);
        if (rc == BAN_OK) {
            draw_info(COLOR_GREEN, op, "Added new ban successfully.");
        } else {
            draw_info_format(COLOR_RED, op, "Failed to add new ban: %s",
                    ban_strerror(rc));
        }
    } else if (strcmp(word, "remove") == 0) {
        if (params == NULL) {
            return;
        }

        ban_error_t rc = ban_remove(params);
        if (rc == BAN_OK) {
            draw_info(COLOR_GREEN, op, "Removed ban successfully.");
        } else {
            draw_info_format(COLOR_RED, op, "Failed to remove ban: %s",
                    ban_strerror(rc));
        }
    } else if (strcmp(word, "list") == 0) {
        ban_list(op);
    } else if (strcmp(word, "kick") == 0) {
        for (player *pl = first_player; pl != NULL; pl = pl->next) {
            if (ban_check(pl->cs, pl->ob->name)) {
                LOG(SYSTEM, "Ban: Kicking player due to a ban. [%s, %s]",
                        pl->ob->name, socket_get_addr(pl->cs->sc));
                draw_info_type(CHAT_TYPE_GAME, NULL, COLOR_RED, pl->ob,
                        "You have been banned.");
                pl->cs->state = ST_ZOMBIE;
            }
        }
    }
}
Exemplo n.º 4
0
/*** Jump the cursor far left or far right ***/
void jump_horiz(Project p, BYTE dir)
{
	if( dir >= 0 )
	{
		/* If cursor is already at rightmost position, scroll display */
		if( p->nbrwc == p->left_pos+gui.nbcol-1 )
		{
			p->nbrwc += gui.nbcol-1;
		}
		else p->nbrwc = p->left_pos+gui.nbcol-1;
	} else {
		/* Check if cursor is already at leftmost position */
		if( p->nbrwc == p->left_pos )
		{
			p->nbrwc = p->left_pos - (gui.nbcol-1);
			if( (LONG)p->nbrwc < 0 ) p->nbrwc = 0;
		}
		else p->nbrwc = p->left_pos;
	}

	inv_curs(p,FALSE);
	p->nbrc  = adjust_rc(p->edited, p->nbrwc, &p->nbc, dir<0);
	p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;
	{
		LONG newleft = center_horiz( p );
		if( newleft != p->left_pos )
			scroll_xy(p, newleft, p->top_line, 0);
	}
	/* Move selection or cursor? */
	if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl);
	inv_curs(p,TRUE);
	draw_info( p );
}
Exemplo n.º 5
0
/*** Join two lines and strip spaces on the next ***/
void join_strip( Project p )
{
	LINE *ln;
	if((ln = p->edited->next) != NULL)
	{
		STRPTR data; ULONG i;
		inv_curs(p, FALSE);
		p->nbc = p->edited->size;
		for(i=0, data=ln->stream; TypeChar[*data] == SPACE && i<ln->size; i++, data++);

		reg_group_by(&p->undo);
		if(i != ln->size)
		{
			/* Do not add a blank if there is already one */
			if( p->nbc > 0 && TypeChar[ p->edited->stream[ p->nbc-1 ] ] != SPACE )
				add_char(&p->undo, p->edited, p->nbc, ' ');
			if( insert_str(&p->undo, p->edited, p->edited->size, data, ln->size-i) == 0 )
				ThrowError(Wnd, ErrMsg(ERR_NOMEM));
		}
		/* ln can't be the first */
		del_line(&p->undo, NULL, ln); p->max_lines--;
		reg_group_by(&p->undo);
		prop_adj(p);
		/* Refresh screen */
		p->nbrc = p->nbrwc = x2pos(p->edited, p->nbc);
		REDRAW_CURLINE( p );
		draw_info( p );
		scroll_up(p, p->edited->next, p->ycurs, center_horiz(p));
		inv_curs(p,TRUE);
	}
}
Exemplo n.º 6
0
/* Puts robot in (0,0)
 *
 *
 * LOGS the movement
 */
void move_robot_origin()
{
	draw_info(ENERGY,ENERGY_STAT, 0, 0, DIRECTION);
	draw_log("--Ir al origen      ");

	draw_robot(0, 0, DIRECTION);

	origin();

	BOARD[X][Y] = EMPTY;
	if( is_station_below )
	{
		BOARD[X][Y] = STATION;
		draw_object(X, Y, 's');
		is_station_below=0;
	}
	X=0;
	Y=0;
	if( DIRECTION == UP)
	{
		BOARD[X][Y] = UROBOT;
	}
	else if( DIRECTION == DOWN)
	{
		BOARD[X][Y] = DROBOT;
	}
	else if( DIRECTION == RIGHT)
	{
		BOARD[X][Y] = RROBOT;
	}
	else if( DIRECTION == LEFT)
	{
		BOARD[X][Y] = LROBOT;
	}
}
Exemplo n.º 7
0
void App::initialise_1()
{
	draw_info("* Calculating Test Run Length *");

	cb_test = clan::bind_member(&tests, &Tests::test_empty);

	tests_run_length_microseconds = (uint64_t) (((double) target_test_run_length_seconds) * 1000000.0);

	const uint64_t num_block_iteration = 10000;

	uint64_t start_time = get_start_time();
	for (num_iterations = 0; ; num_iterations++)
	{
		uint64_t current_time = clan::System::get_microseconds();

		if ((current_time - start_time) >= tests_run_length_microseconds)
			break;
	
		for (uint64_t cnt=0; cnt < num_block_iteration; cnt++)
		{
			cb_test();
		}
		num_iterations+=num_block_iteration;
	}
	cb_main = clan::bind_member(this, &App::initialise_2);
}
Exemplo n.º 8
0
void App::initialise_1()
{
	draw_info("* Calculating Test Run Length *");

	cb_test.set(&tests, &Tests::test_empty);

	tests_run_length_microseconds = (clan::ubyte64) (((double) target_test_run_length_seconds) * 1000000.0);

	const clan::ubyte64 num_block_iteration = 10000;

	clan::ubyte64 start_time = get_start_time();
	for (num_iterations = 0; ; num_iterations++)
	{
		clan::ubyte64 current_time = clan::System::get_microseconds();

		if ((current_time - start_time) >= tests_run_length_microseconds)
			break;
	
		for (clan::ubyte64 cnt=0; cnt < num_block_iteration; cnt++)
		{
			cb_test.invoke();
		}
		num_iterations+=num_block_iteration;
	}
	cb_main.set(this, &App::initialise_2);
}
Exemplo n.º 9
0
/*** Move the cursor according to mouse click ***/
void click(Project p, WORD x, WORD y, BYTE update)
{
	WORD xp = (x-gui.left) / XSIZE,
	     yp = (y-gui.top) / YSIZE;
	LINE *ln;

	if(!p->ccp.select) inv_curs(p, FALSE);

	p->nbl = p->top_line + yp;
	for(ln=p->show; ln->next && yp; yp--,ln=ln->next);
	/* There was no lines, where we've clicked */
	p->nbl -= yp;
	p->edited = ln;
	p->nbrwc  = p->nbrc = xp+p->left_pos;

	xp = curs_visible(p,p->top_line);
	if(xp!=p->left_pos)
		scroll_xy(p, xp, p->top_line, FALSE);
	draw_info( p );
	RP->Mask = gui.selmask;

	/* Set starting selection point */
	if( update )
	{
		ln->flags = FIRSTSEL | LASTSEL;
		p->ccp.xc = p->ccp.xp = p->ccp.startsel = p->ccp.endsel = p->nbrc;
		p->ccp.yc = p->ccp.yp = p->nbl;
		p->ccp.cline = p->ccp.line = ln;
	}
}
Exemplo n.º 10
0
/*** Move cursor down/up one page ***/
void pg_updown(Project p, BYTE dir)
{
	LONG newtop = p->top_line, newcrs;

	if(dir>0)
		/* One page down */
		if(newtop+gui.nbline >= p->max_lines) newcrs = p->max_lines-1;
		else {
			newtop += gui.nbline;
			if(newtop+gui.nbline >= p->max_lines)
				newtop = p->max_lines - gui.nbline;
			newcrs = newtop - p->top_line + p->nbl;
		}
	else
		/* One page up */
		if(newtop == 0) newcrs=0;
		else {
			newtop -= gui.nbline;
			if(newtop<0) newtop=0;
			newcrs = newtop - p->top_line + p->nbl;
		}
	if(newcrs != p->nbl) inv_curs(p,FALSE),set_cursor_line(p,newcrs,newtop);
	scroll_xy(p,center_horiz(p),newtop,TRUE);
	if(p->ccp.select) move_selection(p, p->nbrc, p->nbl);
	inv_curs(p,TRUE);
	draw_info( p );
}
Exemplo n.º 11
0
/**
 * Handle enter key being pressed in the servers list.
 * @param list
 * The servers list.
 */
static void list_handle_enter(list_struct *list, SDL_Event *event)
{
    /* Servers list? */
    if (list == list_servers) {
        char number[16];
        uint32_t version, i;
        size_t pos;

        /* Get selected server. */
        selected_server = server_get_id(list->row_selected - 1);

        if (selected_server == NULL) {
            return;
        }

        for (pos = 0, i = 0, version = 0;
                string_get_word(selected_server->version, &pos, '.', number,
                sizeof(number), 0); i++) {
            version += atoi(number) << (i * CHAR_BIT);
        }

        if (version != 0 && version < SERVER_VERSION) {
            draw_info(COLOR_RED, "The server is outdated; "
                    "choose a different one.");
            return;
        }

        login_start();
    } else if (list == list_news) {
        if (list->text && list->text[list->row_selected - 1]) {
            game_news_open(list->text[list->row_selected - 1][0]);
        }
    }
}
Exemplo n.º 12
0
void SSG_Planet::draw(sf::RenderTarget& t)
{
    //We have to override the default as we're not drawing a sprite, but a shape
    t.draw(this->m_circle);
	drawPhysicsComponents(&t, 1000.f);
	draw_info(t);
}
Exemplo n.º 13
0
/*** Move cursor up ***/
void curs_up(Project p)
{
	LINE *ln;
	if( ( ln = p->edited->prev) )
	{
		LONG newx; BYTE scroll=0;

		inv_curs(p, FALSE);
		/* Is the cursor on top of display? */
		if(p->ycurs > gui.topcurs) p->ycurs -= YSIZE;
		else scroll=1;

		p->nbl--; p->edited=ln;
		p->nbrc  = adjust_rc(ln, p->nbrwc, &p->nbc, FALSE);
		p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;

		/* If cursor exits edit area due to horizontal **
		** adjustment, scroll the display accordingly: */
		if((newx=center_horiz(p))!=p->left_pos || scroll)
			scroll_xy(p, newx, p->top_line-scroll, scroll);

		/* Update selection */
		if(p->ccp.select) move_selection(p, p->nbrc, p->nbl);
		inv_curs(p, TRUE);
		draw_info( p );
	}
}
Exemplo n.º 14
0
/*** Move cursor down ***/
void curs_down(Project p)
{
	LINE *ln;
	if( ( ln = p->edited->next) )
	{
		LONG newx; BYTE scroll=0;

		inv_curs(p, FALSE);
		/* Is the cursor at the bottom of the display? */
		if( p->ycurs < gui.botcurs) p->ycurs += YSIZE;
		else scroll=1;

		p->nbl++; p->edited=ln;
		p->nbrc = adjust_rc(ln, p->nbrwc, &p->nbc, FALSE);
		p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;

		/* Minimise calls to scroll_xy */
		if((newx=center_horiz(p))!=p->left_pos || scroll)
			scroll_xy(p, newx, p->top_line+scroll, scroll);

		/* Update selection */
		if(p->ccp.select) move_selection(p, p->nbrc, p->nbl);
		inv_curs(p, TRUE);
		draw_info( p );
	}
}
Exemplo n.º 15
0
/*** Move cursor to absolute position ***/
void move_to_line(Project p, ULONG nbline, char dirtiness)
{
	ULONG newtop;

	if(!p->ccp.select) inv_curs(p,FALSE);
	/* Get the new top line */
	{	register ULONG old_nbl = p->nbl;
		p->nbl = nbline;
		newtop = center_vert(p);
		p->nbl = old_nbl;
	}	set_cursor_line(p, nbline, newtop);

	if(dirtiness == LINE_AS_IS)
		scroll_xy(p, center_horiz(p), newtop, TRUE);
	else
	{
		/* Some lines are modified: redraw in one pass */
		if( newtop == p->top_line ) {
			REDRAW_CURLINE(p);
			if( dirtiness == LINES_DIRTY )
				scroll_up(p, p->edited->next, p->ycurs, center_horiz(p)),
				prop_adj(p);
			else if( p->left_pos != (newtop = center_horiz(p)) )
				scroll_xy(p, newtop, p->top_line, FALSE);
		}
		else if( dirtiness == LINE_DIRTY )
			scroll_xy(p, center_horiz(p), newtop, TRUE);
		else
			set_top_line(p, newtop, center_horiz(p));
	}
	/* Move cursor or selection */
	if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl);
	inv_curs(p,TRUE);
	draw_info( p );
}
Exemplo n.º 16
0
void App::write_result()
{
	draw_info("* Writing Results To File *");

	std::string output;
#ifdef WIN32
	std::string newline = "\r\n";
#else
	std::string newline = "\r\n";
#endif

	output += "ClanLib Benchmark Utility Results" + newline + newline;

	if (!priority_class.empty())
		output += priority_class + newline;

	output += clan::string_format("Simulation Test Run Length = %1 seconds", clan::StringHelp::float_to_text((double)tests_run_length_microseconds / 1000000.0, 2)) + newline;
	output += clan::string_format("Using %1 Iterations", num_iterations) + newline;

	output+= newline;

	output += "Test Number) Time : Function" + newline;

	for (unsigned int cnt=0; cnt<testlist.size(); cnt++)
	{
		if (testlist[cnt].result != 0.0f)
		{
			output += clan::string_format("%1) %2 : %3", cnt+1, clan::StringHelp::float_to_text(testlist[cnt].result, 1), testlist[cnt].name) + newline;
		}
	}

	clan::File::write_text("results.txt", output);

	cb_main = clan::bind_member(this, &App::initialise_1);
}
Exemplo n.º 17
0
void ofApp::draw(){
    ofEnableAlphaBlending();
    //
    //
    ofBackground( 0 );

    cam.begin();{
        ofSetColor( 195, 10, 110 );
        glLineWidth( 1 );
        lines.draw();

		glLineWidth( 1 );
		p2p.draw();
		
        glPointSize( 1 );
        points.draw();
		
		glPointSize( 1 );
		attrs.draw();
    }cam.end();

    saver.save();
    
    draw_info();
}
Exemplo n.º 18
0
void ofApp::draw(){

    ofSetLineWidth(1);
    glPointSize(1);
    ofBackground(255);

    ofPushMatrix();

        if(bHandy){
            ofRotateZ(90.0);
            ofTranslate(0, -ofGetWindowWidth());
        }

        ofPushMatrix();
        ofTranslate(start_point);
        draw_bg();
        draw_wave();
        draw_audioStats();
        ofPopMatrix();
        draw_info();
    ofPopMatrix();

//    draw_vid();

}
Exemplo n.º 19
0
GtkWidget *ccreate_info(picked *c)
{
  fb = gtk_vbox_new(0,0);
  info = draw_info(c);
  gtk_container_add (GTK_CONTAINER (fb),info);
  gtk_widget_show_all(fb);
  return(fb);
}
Exemplo n.º 20
0
void App::initialise_2()
{
	draw_info("* Adjusting Run Timer *");

	cb_test = clan::bind_member(&tests, &Tests::test_empty);
	tests_run_length_microseconds = run_test();
	testlist_offset = 0;
	cb_main = clan::bind_member(this, &App::test);
}
Exemplo n.º 21
0
void redraw()
{
	erase();
	draw_borders();
	draw_ball();
	draw_users();
	draw_info();
	refresh();
}
Exemplo n.º 22
0
/*** Remove the char before the cursor ***/
void back_space(Project p, BYTE word)
{
	if(p->nbc!=0)
	{
		ULONG nbc = word ? backward_word(p->edited,p->nbc-1) : p->nbc-1;
		rem_chars(&p->undo, p->edited, nbc, p->nbc-1);

		/* Set cursor position and redraws it */
		inv_curs(p,FALSE);
		REDRAW_CURLINE(p);
		p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc=nbc);
		p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;
		if( (nbc = center_horiz(p)) != p->left_pos )
			scroll_xy(p, nbc, p->top_line, FALSE);
		inv_curs(p,TRUE);
		draw_info( p );
	}	else if(p->edited->prev != NULL) {

		p->edited = p->edited->prev;
		p->nbc    = p->edited->size;
		/* Join previous and current line */
		if( join_lines(&p->undo, p->edited, p->edited->next) )
		{
			/* Move cursor to the end of previous line */
			p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc);

			p->max_lines--; p->nbl--;
			/* Require to scroll the display? */
			inv_curs(p, FALSE);
			if(p->ycurs>gui.topcurs)
				scroll_up(p, p->edited->next, p->ycurs-=YSIZE, center_horiz(p));
			else
				p->top_line--, p->show = p->edited,
				p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;

			SetAPen(RP, pen.fg);
			REDRAW_CURLINE(p);
			/* Redraw the cursor: */
			inv_curs(p,TRUE);
			draw_info(p);
			prop_adj(p);
		}	else ThrowError(Wnd, ErrMsg(ERR_NOMEM));
	}
}
Exemplo n.º 23
0
void App::initial_pause()
{
	draw_info("* Starting in 1 second *");

	cb_test.set(&tests, &Tests::test_empty);
	cb_test.invoke();
	
	if (game_time.get_current_time() >= 1.0f)
		cb_main.set(this, &App::initialise_1);
}
Exemplo n.º 24
0
void App::initial_pause()
{
	draw_info("* Starting in 1 second *");

	cb_test = clan::bind_member(&tests, &Tests::test_empty);
	cb_test();
	
	if (game_time.get_current_time() >= 1.0f)
		cb_main = clan::bind_member(this, &App::initialise_1);
}
Exemplo n.º 25
0
GtkWidget *redraw_info(picked *c)
{
  if (fb == 0)
    fb = gtk_vbox_new(0,0);
  if (info != 0)
    gtk_widget_destroy(info);
  info = draw_info(c);
  gtk_container_add (GTK_CONTAINER (fb),info);
  gtk_widget_show_all(fb);
  return(fb);
}
Exemplo n.º 26
0
void App::test()
{
	
	draw_info(clan::string_format("* Running - %1 *", testlist[testlist_offset].name));

	cb_test = clan::bind_member(&tests, testlist[testlist_offset].func);
	int64_t microseconds = run_test();
	double result = ((double) microseconds / (double)tests_run_length_microseconds) ;
	testlist[testlist_offset].result = result + 0.05;	// Round up
	testlist_offset++;
	if (testlist_offset >= testlist.size())
		cb_main = clan::bind_member(this, &App::write_result);
}
Exemplo n.º 27
0
/*** Jump cursor to an absolute position in line (ie: beginning or end) ***/
void horiz_pos( Project p, ULONG newpos )
{
	if( newpos != p->nbrwc )
	{
		inv_curs(p, FALSE);
		p->nbrc = adjust_rc(p->edited, p->nbrwc = newpos, &p->nbc, FALSE);
		scroll_xy(p, center_horiz(p), p->top_line, FALSE);
		p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;
		if(p->ccp.select) move_selection(p, p->nbrwc, p->nbl);
		inv_curs(p, TRUE);
		draw_info( p );
	}
}
Exemplo n.º 28
0
/*** Be sure that cursor is always visible ***/
LONG curs_visible(Project p, LONG newtop)
{
	if(p->nbl < newtop) {
		/* The cursor is above the top line */
		p->ycurs = gui.topcurs;
		p->nbl   = newtop;
		goto adj_edited;
	} else if(p->nbl >= newtop+gui.nbline) {
		register LONG nb;
		register LINE *ln;

		/* The cursor is below the bottom line */
		p->nbl   = newtop+gui.nbline-1;
		p->ycurs = gui.botcurs;

		adj_edited:
		for(ln=p->the_line, nb=p->nbl; nb--; ln=ln->next);
		if(ln) p->edited=ln;
		draw_info(p);

	} else
		/* Is between the top and bottom line */
		p->ycurs = (p->nbl-newtop) * YSIZE+ gui.topcurs;

	/* Jump too far to the right? */
	newtop=p->left_pos + gui.nbcol - 1;
	if(p->nbrc>newtop) p->nbrwc=newtop;
	/* Too far on the left */
	if((newtop = p->nbrc<p->left_pos)) p->nbrwc=p->left_pos;

	/* Adjust cursor pos */
	newtop = adjust_rc(p->edited, p->nbrwc, &p->nbc, newtop);
	if(p->nbrc != newtop)
		p->nbrc  = newtop, draw_info(p);

	p->xcurs = (p->nbrc-p->left_pos)*XSIZE + gui.left;
	return center_horiz(p);
}
Exemplo n.º 29
0
/*** Set cursor to a specified position in file ***/
void set_cursor_line(Project p, LONG pos, ULONG top)
{
	LINE *ln;
	/* Adjust all related variables */
	if(pos < 0) pos = 0;
	if(pos >= p->max_lines) pos = p->max_lines-1;
	if(pos < p->nbl) for(ln=p->edited; p->nbl!=pos; ln=ln->prev, p->nbl--);
	else             for(ln=p->edited; p->nbl!=pos; ln=ln->next, p->nbl++);

	/* Cursor position */
	p->nbrc   = adjust_rc(p->edited=ln, p->nbrwc, &p->nbc, FALSE);
	p->xcurs  = (p->nbrc-p->left_pos)*XSIZE + gui.left;
	p->ycurs  = (p->nbl-top)*YSIZE + gui.topcurs;
	draw_info( p );
}
Exemplo n.º 30
0
/**
 * Shows version information.
 * @param op
 * If NULL the version is logged using LOG(), otherwise it is
 * shown to the player object using draw_info_format().
 */
void version(object *op)
{
    char buf[HUGE_BUF];

    snprintf(VS(buf), "This is Atrinik v%s", PACKAGE_VERSION);
#ifdef GITVERSION
    snprintfcat(VS(buf), "%s", " (" STRINGIFY(GITBRANCH) "/"
            STRINGIFY(GITVERSION) " by " STRINGIFY(GITAUTHOR) ")");
#endif

    if (op != NULL) {
        draw_info(COLOR_WHITE, op, buf);
    } else {
        LOG(INFO, "%s", buf);
    }
}