It is currently January 20th, 2018, 6:26 pm


All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Skip block
PostPosted: July 16th, 2012, 12:50 pm 
User avatar

Joined: October 20th, 2011, 9:20 am
Posts: 220
Location: Subnet
Imitates the skip block behaviour from 0.700

It may not be as sophisticated as f's implementation but this was the easiest way for modders to copy it.

Patch:
Show


Manual implementation:
Show

_________________
A = {x ∈ P(U) | x ∉ x}

Show
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Skip block
PostPosted: July 16th, 2012, 8:05 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
The official skip-block support was added in r1458-r1459. Here's the diff (won't be applicable to 0.6xx).

The most notable change was rewroting CommandReader.NextBlock(), CommandReader.NextBlockWithParam(), and Map.GetBlockByName(). Previously they just took a string and a player name, and returned Block. Now they write result into an "out" variable, and return a bool. This allows me to distinguish between cases where "skip" block was given and when an unrecognized block name was given.
Code:
/// <summary> Finds Block corresponding to given blockName. </summary>
/// <param name="blockName"> Given block name to parse. </param>
/// <param name="allowNoneBlock"> Whether "none" block type is acceptible. </param>
/// <param name="block"> Block corresponding to given blockName;
/// Block.None if value could not be parsed. </param>
/// <returns> True if given blockName was parsed as an acceptible block type. </returns>
/// <exception cref="ArgumentNullException"> If blockName is null. </exception>
public static bool GetBlockByName( [NotNull] string blockName, bool allowNoneBlock, out Block block ) {...


So a typical usage before was...
Code:
Block block = cmd.NextBlock( Player );
if( block == Block.Undefined ){
    // unrecognized block name
}else{
    // normal blocktype given
}

...and now it became...
Code:
Block block;
if( !cmd.NextBlock( Player, true, out block ) ){
    // unrecognized block name
}else if( block == Block.None ){
    // "none" blocktype given
}else{
    // normal blocktype given
}


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Skip block
PostPosted: August 14th, 2012, 4:55 am 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
I merged the official "skip" block implementation with fCraft 0.630:

SVN wrote:
fcraft: fragmer * r1646 /branch-0.60x/fCraft/ (34 files in 9 dirs):
Added support for "none" block in brushes - viewtopic.php?p=18087
Rewrote CommandReader.NextBlock, CommandReader.NextBlockWithParam, and Map.GetBlockByName to accommodate the change.
Renamed Block.Undefined to Block.None


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net