Etheria v0.8, the version where anyone could accept a bid on anyone's tile
Historical Significance
Tiles here are named, owned, farmed and traded individually, which is the shape of a non fungible token more than two years before ERC-721.
Context
Deployed in the Frontier era, three weeks before the version that became the Etheria people still play.
Key Facts
Description
Etheria is a world of hexagonal tiles that accounts own, farm and build on, all held in one contract. Version 0.8 added buying and selling, and its author later documented the flaw that followed: the bid acceptance path checks nothing about who is calling, so any account could place a small bid on any tile and immediately accept its own bid. Deployed on 15 October 2015 by 0xcf684dfb8304729355b58315e8019b1aa2ad1bac, the account of Cyrus Adkisson, and recovered from the author's own published source.
Source Verified
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
/*
Folder name = NKNVELSC (Non-killable, non-viable, Etheria-like smart contract)
WARNING! This test contract is live on the chain, can't be killed but is FATALLY BUGGED.
______ _____ _ _ _____ _____ ______ _ ___ __
| _ \ _ | | \ | | _ |_ _| | ___ \ | | \ \ / /
| | | | | | | | \| | | | | | | | |_/ / | | |\ V /
| | | | | | | | . ` | | | | | | | ___ \ | | | \ /
| |/ /\ \_/ / | |\ \ \_/ / | | | |_/ / |_| | | |
|___/ \___/ \_| \_/\___/ \_/ \____/ \___/ \_/
There is no wrapper. There is no official support/website.
Anything you may see for Etheria 0xcf1ee is a SCAM!
No wrapper or anything else can fix the underlying bug.
It is FATAL, not cosmetic. Anyone can accept bids on any tile at any time.
This means anyone can place a 0.01 ETH bid on your tile and immediately accept it.
Etheria v0.8
Block 385709
Oct-15-2015 03:55:57 AM +UTC
0xcf1eecf5929c151427dc3662a28353266ea3f9e6
var etheriaAddress = "0xcf1eecf5929c151427dc3662a28353266ea3f9e6";
var abi = [{"constant":false,"inputs":[],"name":"setLocked","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getWhatHappened","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getLocked","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"buyTile","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"},{"name":"_s","type":"string"}],"name":"setStatus","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"},{"name":"newowner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"getLastFarm","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"},{"name":"index","type":"uint256"},{"name":"_block","type":"int8[5]"}],"name":"editBlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"},{"name":"blocktype","type":"int8"}],"name":"farmTile","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"},{"name":"_n","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"getName","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"getStatus","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"getOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"empty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"col","type":"uint8"},{"name":"row","type":"uint8"}],"name":"getBlocks","outputs":[{"name":"","type":"int8[5][]"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"col","type":"uint8"},{"indexed":false,"name":"row","type":"uint8"}],"name":"TileChanged","type":"event"}];
var etheria = new web3.eth.Contract(abi, etheriaAddress);
Exact bytecode match with code below and
Solidity: 0.1.5 w/ default optimization (200) (1 compilation)
chain: 0x606060405236156100ae5760e060020a6000350463049b785281146100b057806354746dac146101ba5780635c24b074146102185780636266b5141461022f5780636a8645591461028b5780638cae137414610329578063959eac47146103b2578063a0e67e2b14610406578063a5ffca0e1461051b578063a713081c14610689578063c7dafc78146106dd578063edffcd5714610773578063f25e675d14610807578063fa93019c14610890575b005b61095e612420604051908101604052806011905b610220604051908101604052806011905b60008152602001906001900390816100d5579050508152602001906001900390816100c45750506040805161242081019091526011815b610220604051908101604052806011905b600081526020019060019003908161011d5790505081526020019060019003908161010c575060009050805b60005460ff9081169083161015610ba7575060005b60005460ff9081169082161015610baf576001816011811015610002576066020182601181101561000257600602015460ff1683826011811015610002576020020151836011811015610002575060208402015260010161015e565b6040805161010081019091526100ae90600480359161032490602460086000835b828210156109a3576040805160608181019092529083810286019060039083908390808284378201915050505050815260200190600101906101db565b6100ae6004356106c75460ff1615610b8457610ba4565b6100ae6004356024356000662386f26fc10000341080610258575069ffffffffffffffffffff34115b15611b7b573460001461028657604051600160a060020a03331690600090349082818181858883f150505050505b505050565b610adf6004356024356040805160208101909152600081526001836011811015610002575060668402018260118110156100025790906006020160005060010180546040805160208381028201810190925282815292919083018282801561031d57602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116102fe575b50505050509050611a63565b6040805160a08181019092526100ae9160048035926024359260443592916101049160649060059083908390808284375090955050505050506000808080808080600160a060020a03331660018c6011811015610002575060668d02018b601181101561000257909060060201600050546101009004600160a060020a031614610f9057611395565b6100ae600435602435600080600160a060020a03331660018560118110156100025750606686020184601181101561000257909060060201600050546101009004600160a060020a031614610bf857610bf2565b61095e612420604051908101604052806011905b610220604051908101604052806011905b600081526020019060019003908161042b5790505081526020019060019003908161041a5750506040805161242081019091526011815b610220604051908101604052806011905b600081526020019060019003908161047357905050815260200190600190039081610462575060009050805b60005460ff9081169083161015610ba7575060005b60005460ff9081169082161015610bbb57600181601181101561000257606602018260118110156100025760060201546101009004600160a060020a03168382601181101561000257602002015183601181101561000257506020840201526001016104b4565b6100ae60043560243560443560018360118110156100025750606684020182601181101561000257909060060201600050546101009004600160a060020a031660006001856011811015610002575060668602018460118110156100025790906006020160005060020180548490811015610002575081526020812083015460405182818181858883f15060019350869250505060118110156100025750606684020182601181101561000257909060060201600050600101805482908110156100025750600090815260209020810154600160a060020a03166001846011811015610002575060668502018360118110156100025790906006020160005080546101009290920261010060a860020a031990921691909117905560018360118110156100025750606684020182601181101561000257909060060201600050600101805460008083559182526020909120612222918101905b80821115610ccf5760008155600101610675565b6100ae600435602435604435600160a060020a03331660018460118110156100025750606685020183601181101561000257909060060201600050546101009004600160a060020a031614611fb557610286565b610adf6004356024356040805160208101909152600081526001836011811015610002575060668402018260118110156100025790906006020160005060020180546040805160208381028201810190925282815292919083018282801561031d57602002820191906000526020600020905b816000505481526020019060010190808311610750575b50505050509050611a63565b6100ae60043560243560005b6001836011811015610002576066020182601181101561000257600602016001015460ff8216101561028657600160a060020a0333166001846011811015610002576066020183601181101561000257600602016001018054839081101561000257600091825260209091200154600160a060020a03161415611fad57611fad838383611fbc565b604080516102208181019092526100ae91600480359290916102449190602490601190839083908082843750909550505050505060005b60005460ff90811690821610156102865781816011811015610002576020020151600182601181101561000257606602018460118110156100025760060201805460ff1916909117905560010161083e565b610b29600435602435604080516020810190915260008152600183601181101561000257606602016000508260118110156100025760060201600050600301600050805480602002602001604051908101604052809291908181526020016000905b82821015611a5c576000848152602081206040805160a08101918290529291850191600591908390855b825461010083900a900460000b81526020600192830181810494850194909303909202910180841161091c5790505050505050815260200190600101906108f2565b6040516000826011835b81841015610993576020840283015161022080838184600060046042f1509050019260010192610968565b9250505091505060405180910390f35b5050604080518535870180356020818102840181019094528083529597968301959194508201925090819060009085015b82821015610a11576040805160608181019092529083810287019060039083908390808284378201915050505050815260200190600101906109d4565b5093955050505050506000808080866106c98160148110156100025750600a90910201805460ff1916881790555b60088460ff161015611a6957600092505b60038360ff161015611aab57858460088110156100025760200201518360038110156100025760200201516106c98860148110156100025750506106ca600a890201856008811015610002579090016000508460038110156100025760208082049092019190066101000a81548160ff021916908360f860020a90810204021790555060019290920191610a50565b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b60405180806020018281038252838181518152602001915080516000925b81841015610b735760208481028401015160a08083818460006004601ef1509050019260010192610b47565b925050509250505060405180910390f35b6106c7805461010060a860020a03191661010083021760ff191660011790555b50565b509092915050565b60019190910190610149565b6001919091019061049f565b4360018560118110156100025750606686020184601181101561000257909060060201600050600401555b50505050565b6110e0600185601181101561000257506066860201846011811015610002579090600602016000506004015443031015610c3157610bf2565b505043600019014060005b60148160ff161015610bc75760056001856011811015610002575060668602018460118110156100025790906006020160005060030180549182018082559182908015829011610c9d57600083815260209020610c9d918101908301610675565b505050506020610cd3838360008160ff166000141561226c575060028102603e0360100a60ff16808306830304611a63565b5090565b60ff1606600185601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060006101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060016101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060026101000a81548160ff021916908360f860020a90810204021790555060001960016000508560118110156100025750606686020184601181101561000257909060060201600050600301600180876011811015610002579090606602016000508660118110156100025750508154808401915081101561000257906000526020600020900160005060036101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060046101000a81548160ff021916908360f860020a908102040217905550600101610c3c565b606088015160001960009190910b1215610fa957611395565b60018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a0154810b900b808952611201908c908c908b6001505060408c015160208d015160608e01519091906000808080808080806106c98c820b601481101561000257600a026106ca019750505b60088660ff161015612297578a878760088110156100025781015460000b90910190876008811015610002578101805460ff191660f860020a938402939093049290921790915550898787600881101561000257810154610100900460000b909101908760088110156100025701805461ff00191660f860020a9283029290920461010002919091179055600260008b810b91909107810b148015906110f757506002878760088110156100025701546101009004600090810b810b91909107810b14155b15611134578686600881101561000257015460000b600101878760088110156100025701805460ff191660f860020a928302929092049190911790555b88878760088110156100025781015462010000900460000b90910190876008811015610002578101805462ff0000191660f860020a938402939093046201000002929092179091555061246e8787600881101561000257015460000b888860088110156100025701546101009004600090810b90808083810b602019138015906111c2575060218460000b13155b156128bd5760028460000b0760000b60001415156128d5578460000b603119131580156111f3575060318560000b13155b156128b057600192506128b5565b156113955787516106c99060000b601481101561000257600a026106ca01975060009650505b60088660ff1610156113a2576020880151878760088110156100025781015460000b90910190876008811015610002578101805460ff191660f860020a93840293909304929092179091555060408801518787600881101561000257810154610100900460000b909101908760088110156100025701805461ff00191660f860020a9283029290920461010090810292909217905587546002919004600090810b810b91909107810b148015906112fd57506002878760088110156100025701546101009004600090810b810b91909107810b14155b1561133a578686600881101561000257015460000b600101878760088110156100025701805460ff191660f860020a928302929092049190911790555b606088015187876008811015610002578181015462010000900460000b909201916008811015610002570160005060026101000a81548160ff021916908360f860020a90810204021790555060019590950194611227565b50505b5050505050505050505050565b600060018c6011811015610002575060668d02018b60118110156100025790906006020160005060030180548b9081101561000257508152602081208a015463010000009004810b810b1261164a5787516106c99060000b601481101561000257600a026106ca01955060009450505b60088460ff1610156116af5760018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a01546101009004900b858560088110156100025781015460000b909101908560088110156100025701805460ff191660f860020a9283029290920491909117905560018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257906000526020600020900160005060029054906101000a900460000b8585600881101561000257810154610100900460000b909101908560088110156100025701805461ff00191660f860020a9283029290920461010090810292909217905585546002919004600090810b810b91909107810b1480159061157157506002858560088110156100025701546101009004600090810b810b91909107810b14155b156115ae578484600881101561000257015460000b600101858560088110156100025701805460ff191660f860020a928302929092049190911790555b60018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a015463010000009004900b85856008811015610002578082015462010000900460000b909201916008811015610002570160005060026101000a81548160ff021916908360f860020a90810204021790555060019390930192611412565b5060005b60088160ff1610156118a85760018b6011811015610002575060668c02018a60118110156100025790906006020160005060050180546001810180835590919082801582901161197557600083815260209020611975918101908301610675565b600092505b60088360ff1610156118a857600091505b60018b6011811015610002575060668c02018a6011811015610002579090600602016000506005015482101561193a5760018b6011811015610002575060668c02018a60118110156100025790906006020160005060050180548390811015610002576000918252602082200154810b900b8584600881101561000257505085840154600090810b900b1480156117c0575060018b601181101561000257606602016000508a601181101561000257909060060201600050600501805483908110156100025760206000908120909101546101009004810b900b905085846008811015610002575050858401546101009004600090810b900b145b8015611830575060018b601181101561000257606602016000508a60118110156100025790906006020160005060050180548390811015610002576000918252602082200154620100009004810b900b8584600881101561000257505085840154620100009004600090810b900b145b156119495786836008811015610002570160005060018c6011811015610002575060668d02018b60118110156100025760060201600050600501805484908110156100025760009182526020909120019060018281019190839082015b8281111561195557825482559160010191906001019061188d565b8760018c6011811015610002575060668d02018b60118110156100025790906006020160005060030180548b9081101561000257506000908152602081208b01916001830191839060a08301905b83821115611a2257835183826101000a81548160ff021916908360f860020a90810204021790555092602001926001016020816000010492830192600103026118f6565b600192909201916116b4565b50505b600191909101906116c5565b506119469291505b80821115610ccf57805460ff1916815560010161195d565b5050505086816008811015610002570160018c601181101561000257606602018b601181101561000257600602016005016001808e601181101561000257606602018d60118110156100025760060201600050600501548254919003908110156100025760009182526020909120019060018281019190839082015b82811115611a0c5782548255916001019190600101906119f1565b50611a1892915061195d565b505060010161164e565b8015611a4f5782816101000a81549060ff0219169055600101602081600001049283019260010302611a22565b505061139292915061195d565b5050505090505b92915050565b84516106c9886014811015610002575050600a88026106d201805482825582908015829011611ab757818360005260206000209182019101611ab79190610675565b60019390930192610a3f565b50505050600091505b84518260ff161015611b66575060005b60038160ff161015611b6f578482815181101561000257906020019060200201518160038110156100025760200201516106c9886014811015610002575050600a88026106d201805484908110156100025760009182526020909120018260038110156100025760208082049092019190066101000a81548160ff021916908360f860020a908102040217905550600101611ad0565b50505050505050565b60019190910190611ac0565b607d600184601181101561000257506066850201836011811015610002579090600602016000505460ff1610801590611be75750600060018460118110156100025750606685020183601181101561000257909060060201600050546101009004600160a060020a0316145b15611c2157670de0b6b3a76400003414611d8157604051600160a060020a03331690600090349082818181858883f1935050505050610286565b600a60018460118110156100025750606685020183601181101561000257909060060201600050600101541015610286575060005b60018360118110156100025750606684020182601181101561000257600602016000506001015460ff82161015611def57600160a060020a0333166001846011811015610002576066020160005083601181101561000257600602016000506001018054839081101561000257600091825260209091200154600160a060020a03161415611e4557600160a060020a0333166000600185601181101561000257606602018150846011811015610002579090600602016000506002018054849081101561000257908252602082206040519101549082818181858883f193505050505034600160005084601181101561000257506066850201836011811015610002579090600602016000506002018054839081101561000257602060009081209290520155610286565b6040516106c854600160a060020a031690600090349082818181858883f1935050505050336001600050846011811015610002575060668502018360118110156100025790906006020160005080546101009290920261010060a860020a0319909216919091179055610286565b600183601181101561000257606602016000508260118110156100025790906006020160005060019081018054918201808255828015829011611e4d57818360005260206000209182019101611e4d9190610675565b600101611c56565b5050505060016000508360118110156100025750606684020182601181101561000257909060060201600050600201805460018101808355909190828015829011611eab57818360005260206000209182019101611eab9190610675565b505050503360016000508460118110156100025750606685020183601181101561000257909060060201600050600190810190808660118110156100025790906066020160005085601181101561000257505081546000198101915081101561000257508054600091825260209091200160001901805473ffffffffffffffffffffffffffffffffffffffff1916909117905534600184601181101561000257506066850201836011811015610002579090600602016000506002016001808660118110156100025790906066020160005085601181101561000257505081546000198101915081101561000257906000526020600020900160005055505050565b60010161077f565b6102868383835b60006001846011811015610002576066020183601181101561000257600602016001018054839081101561000257908252602082200154600160a060020a0316816001866011811015610002576066020185601181101561000257600602016002018054859081101561000257908252602082206040519101549082818181858883f1506001935087925050506011811015610002576066020183601181101561000257600602016001018054839081101561000257906000526020600020900160006101000a815490600160a060020a030219169055600160005084601181101561000257606602018360118110156100025760060201600201805483908110156100025790600052602060002090016000506000905550600181015b6001846011811015610002576066020183601181101561000257600602016001015460ff82161015612802576001846011811015610002576066020183601181101561000257600602016001018054829081101561000257600091825260209091200154600160a060020a03166001856011811015610002576066020184601181101561000257600602016001018054600019840190811015610002576000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916909117905560018460118110156100025760660201836011811015610002576006020160020180548290811015610002579060005260206000209001600050546001856011811015610002576066020184601181101561000257600602016002018054600019840190811015610002579060005260206000209001600050556001016120da565b506001836011811015610002575060668402018260118110156100025790906006020160005060020180546000808355918252602090912061226691810190610675565b50610286565b5060028102603e819003601090810a60ff90811660409390930390910a168306818106900304611a63565b6106c960008d900b601481101561000257600a02016000506000965060090194505b845460ff87161015612489578a85878154811015610002576000828152602081208354920154900b90920191889081101561000257602060002001805460ff191660f860020a93840293909304929092179091555084548a908690889081101561000257906000526020600020900160005060019054906101000a900460000b018587815481101561000257906000526020600020900160005060016101000a81548160ff021916908360f860020a90810204021790555060028a60000b0760000b6000141580156123bb575060028587815481101561000257906000526020600020900160005060019054906101000a900460000b60000b0760000b600014155b1561240d57848681548110156100025760009182526020822001548654910b6001019086908890811015610002576000918252602090912001805460ff191660f860020a928302929092049190911790555b8885878154811015610002578154600083815260208120830154620100009004900b9093019281101561000257505060206000208701805462ff0000191660f860020a928302929092046201000002919091179055600195909501946122b9565b151561247d57600097506127f1565b60019590950194611032565b8454600893508390111561249c57845492505b600091505b828260ff161015612617575060005b60018e6011811015610002575060668f02018d60118110156100025760060201600050600501548110156126295760088260ff16108015612543575060018e601181101561000257606602016000508d6011811015610002576006020160005060050180548290811015610002576000918252602082200154810b900b87836008811015610002570154600090810b900b145b80156125a5575060018e601181101561000257606602018d60118110156100025760060201600501805482908110156100025760009182526020822001546101009004810b900b878360088110156100025701546101009004600090810b900b145b8015612609575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154620100009004810b900b87836008811015610002570154620100009004600090810b900b145b1561264b57600097506127f1565b83600114156127ec57600197506127f1565b60088260ff161015801561263d5750836001145b156127e057600197506127f1565b836000148015612672575086826008811015610002570154620100009004600090810b810b145b1561267c57600193505b83600014801561268f5750845460ff8316105b80156126f2575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154865490820b90910b9086908490811015610002576000918252602082200154810b900b145b801561275f575060018e601181101561000257606602018d60118110156100025760060201600501805482908110156100025760009182526020822001548654610100909104820b90910b90869084908110156100025760009182526020822001546101009004810b900b145b80156127ce575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154865462010000909104820b90910b9086908490811015610002576000918252602082200154620100009004810b900b145b156127d857600193505b6001016124b0565b600191909101906124a1565b600097505b505050505050509695505050505050565b6001846011811015610002576066020183601181101561000257600602016001018054600019810180835590919082801582901161285157600083815260209020612851918101908301610675565b50505050600160005084601181101561000257606602018360118110156100025760060201600201805460001981018083559091908280158290116128a7576000838152602090206128a7918101908301610675565b50505050610bf2565b600092505b505092915050565b60008560000b12156128fa57600019850291506128fe565b8460000b603019131580156111f357506031600086900b136128b057600192506128b5565b8491505b60008460000b121561291557506000198302612918565b50825b60008460000b12158015612930575060008560000b12155b8061294c575060008460000b12801561294c575060008560000b135b156129805760028460000b0760000b60001415156129ae5760c660028302600383020160ff16116128b057600192506128b5565b60028460000b0760000b600014156129ae5760c660028302600383020160ff16116128b057600192506128b5565b60c66001830160020260001983016003020160ff16116128b057600192506128b556
compiled:606060405236156100ae5760e060020a6000350463049b785281146100b057806354746dac146101ba5780635c24b074146102185780636266b5141461022f5780636a8645591461028b5780638cae137414610329578063959eac47146103b2578063a0e67e2b14610406578063a5ffca0e1461051b578063a713081c14610689578063c7dafc78146106dd578063edffcd5714610773578063f25e675d14610807578063fa93019c14610890575b005b61095e612420604051908101604052806011905b610220604051908101604052806011905b60008152602001906001900390816100d5579050508152602001906001900390816100c45750506040805161242081019091526011815b610220604051908101604052806011905b600081526020019060019003908161011d5790505081526020019060019003908161010c575060009050805b60005460ff9081169083161015610ba7575060005b60005460ff9081169082161015610baf576001816011811015610002576066020182601181101561000257600602015460ff1683826011811015610002576020020151836011811015610002575060208402015260010161015e565b6040805161010081019091526100ae90600480359161032490602460086000835b828210156109a3576040805160608181019092529083810286019060039083908390808284378201915050505050815260200190600101906101db565b6100ae6004356106c75460ff1615610b8457610ba4565b6100ae6004356024356000662386f26fc10000341080610258575069ffffffffffffffffffff34115b15611b7b573460001461028657604051600160a060020a03331690600090349082818181858883f150505050505b505050565b610adf6004356024356040805160208101909152600081526001836011811015610002575060668402018260118110156100025790906006020160005060010180546040805160208381028201810190925282815292919083018282801561031d57602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116102fe575b50505050509050611a63565b6040805160a08181019092526100ae9160048035926024359260443592916101049160649060059083908390808284375090955050505050506000808080808080600160a060020a03331660018c6011811015610002575060668d02018b601181101561000257909060060201600050546101009004600160a060020a031614610f9057611395565b6100ae600435602435600080600160a060020a03331660018560118110156100025750606686020184601181101561000257909060060201600050546101009004600160a060020a031614610bf857610bf2565b61095e612420604051908101604052806011905b610220604051908101604052806011905b600081526020019060019003908161042b5790505081526020019060019003908161041a5750506040805161242081019091526011815b610220604051908101604052806011905b600081526020019060019003908161047357905050815260200190600190039081610462575060009050805b60005460ff9081169083161015610ba7575060005b60005460ff9081169082161015610bbb57600181601181101561000257606602018260118110156100025760060201546101009004600160a060020a03168382601181101561000257602002015183601181101561000257506020840201526001016104b4565b6100ae60043560243560443560018360118110156100025750606684020182601181101561000257909060060201600050546101009004600160a060020a031660006001856011811015610002575060668602018460118110156100025790906006020160005060020180548490811015610002575081526020812083015460405182818181858883f15060019350869250505060118110156100025750606684020182601181101561000257909060060201600050600101805482908110156100025750600090815260209020810154600160a060020a03166001846011811015610002575060668502018360118110156100025790906006020160005080546101009290920261010060a860020a031990921691909117905560018360118110156100025750606684020182601181101561000257909060060201600050600101805460008083559182526020909120612222918101905b80821115610ccf5760008155600101610675565b6100ae600435602435604435600160a060020a03331660018460118110156100025750606685020183601181101561000257909060060201600050546101009004600160a060020a031614611fb557610286565b610adf6004356024356040805160208101909152600081526001836011811015610002575060668402018260118110156100025790906006020160005060020180546040805160208381028201810190925282815292919083018282801561031d57602002820191906000526020600020905b816000505481526020019060010190808311610750575b50505050509050611a63565b6100ae60043560243560005b6001836011811015610002576066020182601181101561000257600602016001015460ff8216101561028657600160a060020a0333166001846011811015610002576066020183601181101561000257600602016001018054839081101561000257600091825260209091200154600160a060020a03161415611fad57611fad838383611fbc565b604080516102208181019092526100ae91600480359290916102449190602490601190839083908082843750909550505050505060005b60005460ff90811690821610156102865781816011811015610002576020020151600182601181101561000257606602018460118110156100025760060201805460ff1916909117905560010161083e565b610b29600435602435604080516020810190915260008152600183601181101561000257606602016000508260118110156100025760060201600050600301600050805480602002602001604051908101604052809291908181526020016000905b82821015611a5c576000848152602081206040805160a08101918290529291850191600591908390855b825461010083900a900460000b81526020600192830181810494850194909303909202910180841161091c5790505050505050815260200190600101906108f2565b6040516000826011835b81841015610993576020840283015161022080838184600060046042f1509050019260010192610968565b9250505091505060405180910390f35b5050604080518535870180356020818102840181019094528083529597968301959194508201925090819060009085015b82821015610a11576040805160608181019092529083810287019060039083908390808284378201915050505050815260200190600101906109d4565b5093955050505050506000808080866106c98160148110156100025750600a90910201805460ff1916881790555b60088460ff161015611a6957600092505b60038360ff161015611aab57858460088110156100025760200201518360038110156100025760200201516106c98860148110156100025750506106ca600a890201856008811015610002579090016000508460038110156100025760208082049092019190066101000a81548160ff021916908360f860020a90810204021790555060019290920191610a50565b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b60405180806020018281038252838181518152602001915080516000925b81841015610b735760208481028401015160a08083818460006004601ef1509050019260010192610b47565b925050509250505060405180910390f35b6106c7805461010060a860020a03191661010083021760ff191660011790555b50565b509092915050565b60019190910190610149565b6001919091019061049f565b4360018560118110156100025750606686020184601181101561000257909060060201600050600401555b50505050565b6110e0600185601181101561000257506066860201846011811015610002579090600602016000506004015443031015610c3157610bf2565b505043600019014060005b60148160ff161015610bc75760056001856011811015610002575060668602018460118110156100025790906006020160005060030180549182018082559182908015829011610c9d57600083815260209020610c9d918101908301610675565b505050506020610cd3838360008160ff166000141561226c575060028102603e0360100a60ff16808306830304611a63565b5090565b60ff1606600185601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060006101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060016101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060026101000a81548160ff021916908360f860020a90810204021790555060001960016000508560118110156100025750606686020184601181101561000257909060060201600050600301600180876011811015610002579090606602016000508660118110156100025750508154808401915081101561000257906000526020600020900160005060036101000a81548160ff021916908360f860020a9081020402179055506000600160005085601181101561000257506066860201846011811015610002579090600602016000506003016001808760118110156100025790906066020160005086601181101561000257505081546000198101915081101561000257906000526020600020900160005060046101000a81548160ff021916908360f860020a908102040217905550600101610c3c565b606088015160001960009190910b1215610fa957611395565b60018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a0154810b900b808952611201908c908c908b6001505060408c015160208d015160608e01519091906000808080808080806106c98c820b601481101561000257600a026106ca019750505b60088660ff161015612297578a878760088110156100025781015460000b90910190876008811015610002578101805460ff191660f860020a938402939093049290921790915550898787600881101561000257810154610100900460000b909101908760088110156100025701805461ff00191660f860020a9283029290920461010002919091179055600260008b810b91909107810b148015906110f757506002878760088110156100025701546101009004600090810b810b91909107810b14155b15611134578686600881101561000257015460000b600101878760088110156100025701805460ff191660f860020a928302929092049190911790555b88878760088110156100025781015462010000900460000b90910190876008811015610002578101805462ff0000191660f860020a938402939093046201000002929092179091555061246e8787600881101561000257015460000b888860088110156100025701546101009004600090810b90808083810b602019138015906111c2575060218460000b13155b156128bd5760028460000b0760000b60001415156128d5578460000b603119131580156111f3575060318560000b13155b156128b057600192506128b5565b156113955787516106c99060000b601481101561000257600a026106ca01975060009650505b60088660ff1610156113a2576020880151878760088110156100025781015460000b90910190876008811015610002578101805460ff191660f860020a93840293909304929092179091555060408801518787600881101561000257810154610100900460000b909101908760088110156100025701805461ff00191660f860020a9283029290920461010090810292909217905587546002919004600090810b810b91909107810b148015906112fd57506002878760088110156100025701546101009004600090810b810b91909107810b14155b1561133a578686600881101561000257015460000b600101878760088110156100025701805460ff191660f860020a928302929092049190911790555b606088015187876008811015610002578181015462010000900460000b909201916008811015610002570160005060026101000a81548160ff021916908360f860020a90810204021790555060019590950194611227565b50505b5050505050505050505050565b600060018c6011811015610002575060668d02018b60118110156100025790906006020160005060030180548b9081101561000257508152602081208a015463010000009004810b810b1261164a5787516106c99060000b601481101561000257600a026106ca01955060009450505b60088460ff1610156116af5760018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a01546101009004900b858560088110156100025781015460000b909101908560088110156100025701805460ff191660f860020a9283029290920491909117905560018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257906000526020600020900160005060029054906101000a900460000b8585600881101561000257810154610100900460000b909101908560088110156100025701805461ff00191660f860020a9283029290920461010090810292909217905585546002919004600090810b810b91909107810b1480159061157157506002858560088110156100025701546101009004600090810b810b91909107810b14155b156115ae578484600881101561000257015460000b600101858560088110156100025701805460ff191660f860020a928302929092049190911790555b60018b6011811015610002575060668c02018a60118110156100025790906006020160005060030180548a9081101561000257506000908152602081208a015463010000009004900b85856008811015610002578082015462010000900460000b909201916008811015610002570160005060026101000a81548160ff021916908360f860020a90810204021790555060019390930192611412565b5060005b60088160ff1610156118a85760018b6011811015610002575060668c02018a60118110156100025790906006020160005060050180546001810180835590919082801582901161197557600083815260209020611975918101908301610675565b600092505b60088360ff1610156118a857600091505b60018b6011811015610002575060668c02018a6011811015610002579090600602016000506005015482101561193a5760018b6011811015610002575060668c02018a60118110156100025790906006020160005060050180548390811015610002576000918252602082200154810b900b8584600881101561000257505085840154600090810b900b1480156117c0575060018b601181101561000257606602016000508a601181101561000257909060060201600050600501805483908110156100025760206000908120909101546101009004810b900b905085846008811015610002575050858401546101009004600090810b900b145b8015611830575060018b601181101561000257606602016000508a60118110156100025790906006020160005060050180548390811015610002576000918252602082200154620100009004810b900b8584600881101561000257505085840154620100009004600090810b900b145b156119495786836008811015610002570160005060018c6011811015610002575060668d02018b60118110156100025760060201600050600501805484908110156100025760009182526020909120019060018281019190839082015b8281111561195557825482559160010191906001019061188d565b8760018c6011811015610002575060668d02018b60118110156100025790906006020160005060030180548b9081101561000257506000908152602081208b01916001830191839060a08301905b83821115611a2257835183826101000a81548160ff021916908360f860020a90810204021790555092602001926001016020816000010492830192600103026118f6565b600192909201916116b4565b50505b600191909101906116c5565b506119469291505b80821115610ccf57805460ff1916815560010161195d565b5050505086816008811015610002570160018c601181101561000257606602018b601181101561000257600602016005016001808e601181101561000257606602018d60118110156100025760060201600050600501548254919003908110156100025760009182526020909120019060018281019190839082015b82811115611a0c5782548255916001019190600101906119f1565b50611a1892915061195d565b505060010161164e565b8015611a4f5782816101000a81549060ff0219169055600101602081600001049283019260010302611a22565b505061139292915061195d565b5050505090505b92915050565b84516106c9886014811015610002575050600a88026106d201805482825582908015829011611ab757818360005260206000209182019101611ab79190610675565b60019390930192610a3f565b50505050600091505b84518260ff161015611b66575060005b60038160ff161015611b6f578482815181101561000257906020019060200201518160038110156100025760200201516106c9886014811015610002575050600a88026106d201805484908110156100025760009182526020909120018260038110156100025760208082049092019190066101000a81548160ff021916908360f860020a908102040217905550600101611ad0565b50505050505050565b60019190910190611ac0565b607d600184601181101561000257506066850201836011811015610002579090600602016000505460ff1610801590611be75750600060018460118110156100025750606685020183601181101561000257909060060201600050546101009004600160a060020a0316145b15611c2157670de0b6b3a76400003414611d8157604051600160a060020a03331690600090349082818181858883f1935050505050610286565b600a60018460118110156100025750606685020183601181101561000257909060060201600050600101541015610286575060005b60018360118110156100025750606684020182601181101561000257600602016000506001015460ff82161015611def57600160a060020a0333166001846011811015610002576066020160005083601181101561000257600602016000506001018054839081101561000257600091825260209091200154600160a060020a03161415611e4557600160a060020a0333166000600185601181101561000257606602018150846011811015610002579090600602016000506002018054849081101561000257908252602082206040519101549082818181858883f193505050505034600160005084601181101561000257506066850201836011811015610002579090600602016000506002018054839081101561000257602060009081209290520155610286565b6040516106c854600160a060020a031690600090349082818181858883f1935050505050336001600050846011811015610002575060668502018360118110156100025790906006020160005080546101009290920261010060a860020a0319909216919091179055610286565b600183601181101561000257606602016000508260118110156100025790906006020160005060019081018054918201808255828015829011611e4d57818360005260206000209182019101611e4d9190610675565b600101611c56565b5050505060016000508360118110156100025750606684020182601181101561000257909060060201600050600201805460018101808355909190828015829011611eab57818360005260206000209182019101611eab9190610675565b505050503360016000508460118110156100025750606685020183601181101561000257909060060201600050600190810190808660118110156100025790906066020160005085601181101561000257505081546000198101915081101561000257508054600091825260209091200160001901805473ffffffffffffffffffffffffffffffffffffffff1916909117905534600184601181101561000257506066850201836011811015610002579090600602016000506002016001808660118110156100025790906066020160005085601181101561000257505081546000198101915081101561000257906000526020600020900160005055505050565b60010161077f565b6102868383835b60006001846011811015610002576066020183601181101561000257600602016001018054839081101561000257908252602082200154600160a060020a0316816001866011811015610002576066020185601181101561000257600602016002018054859081101561000257908252602082206040519101549082818181858883f1506001935087925050506011811015610002576066020183601181101561000257600602016001018054839081101561000257906000526020600020900160006101000a815490600160a060020a030219169055600160005084601181101561000257606602018360118110156100025760060201600201805483908110156100025790600052602060002090016000506000905550600181015b6001846011811015610002576066020183601181101561000257600602016001015460ff82161015612802576001846011811015610002576066020183601181101561000257600602016001018054829081101561000257600091825260209091200154600160a060020a03166001856011811015610002576066020184601181101561000257600602016001018054600019840190811015610002576000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916909117905560018460118110156100025760660201836011811015610002576006020160020180548290811015610002579060005260206000209001600050546001856011811015610002576066020184601181101561000257600602016002018054600019840190811015610002579060005260206000209001600050556001016120da565b506001836011811015610002575060668402018260118110156100025790906006020160005060020180546000808355918252602090912061226691810190610675565b50610286565b5060028102603e819003601090810a60ff90811660409390930390910a168306818106900304611a63565b6106c960008d900b601481101561000257600a02016000506000965060090194505b845460ff87161015612489578a85878154811015610002576000828152602081208354920154900b90920191889081101561000257602060002001805460ff191660f860020a93840293909304929092179091555084548a908690889081101561000257906000526020600020900160005060019054906101000a900460000b018587815481101561000257906000526020600020900160005060016101000a81548160ff021916908360f860020a90810204021790555060028a60000b0760000b6000141580156123bb575060028587815481101561000257906000526020600020900160005060019054906101000a900460000b60000b0760000b600014155b1561240d57848681548110156100025760009182526020822001548654910b6001019086908890811015610002576000918252602090912001805460ff191660f860020a928302929092049190911790555b8885878154811015610002578154600083815260208120830154620100009004900b9093019281101561000257505060206000208701805462ff0000191660f860020a928302929092046201000002919091179055600195909501946122b9565b151561247d57600097506127f1565b60019590950194611032565b8454600893508390111561249c57845492505b600091505b828260ff161015612617575060005b60018e6011811015610002575060668f02018d60118110156100025760060201600050600501548110156126295760088260ff16108015612543575060018e601181101561000257606602016000508d6011811015610002576006020160005060050180548290811015610002576000918252602082200154810b900b87836008811015610002570154600090810b900b145b80156125a5575060018e601181101561000257606602018d60118110156100025760060201600501805482908110156100025760009182526020822001546101009004810b900b878360088110156100025701546101009004600090810b900b145b8015612609575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154620100009004810b900b87836008811015610002570154620100009004600090810b900b145b1561264b57600097506127f1565b83600114156127ec57600197506127f1565b60088260ff161015801561263d5750836001145b156127e057600197506127f1565b836000148015612672575086826008811015610002570154620100009004600090810b810b145b1561267c57600193505b83600014801561268f5750845460ff8316105b80156126f2575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154865490820b90910b9086908490811015610002576000918252602082200154810b900b145b801561275f575060018e601181101561000257606602018d60118110156100025760060201600501805482908110156100025760009182526020822001548654610100909104820b90910b90869084908110156100025760009182526020822001546101009004810b900b145b80156127ce575060018e601181101561000257606602018d6011811015610002576006020160050180548290811015610002576000918252602082200154865462010000909104820b90910b9086908490811015610002576000918252602082200154620100009004810b900b145b156127d857600193505b6001016124b0565b600191909101906124a1565b600097505b505050505050509695505050505050565b6001846011811015610002576066020183601181101561000257600602016001018054600019810180835590919082801582901161285157600083815260209020612851918101908301610675565b50505050600160005084601181101561000257606602018360118110156100025760060201600201805460001981018083559091908280158290116128a7576000838152602090206128a7918101908301610675565b50505050610bf2565b600092505b505092915050565b60008560000b12156128fa57600019850291506128fe565b8460000b603019131580156111f357506031600086900b136128b057600192506128b5565b8491505b60008460000b121561291557506000198302612918565b50825b60008460000b12158015612930575060008560000b12155b8061294c575060008460000b12801561294c575060008560000b135b156129805760028460000b0760000b60001415156129ae5760c660028302600383020160ff16116128b057600192506128b5565b60028460000b0760000b600014156129ae5760c660028302600383020160ff16116128b057600192506128b5565b60c66001830160020260001983016003020160ff16116128b057600192506128b556
*/
contract Etheria //is EtheriaHelper
{
/***
* _____ _ _ _ _ _
* / __ \ | | | | (_) (_) |
* | / \/ ___ _ __ | |_ _ __ __ _ ___| |_ _ _ __ _| |_
* | | / _ \| '_ \| __| '__/ _` |/ __| __| | | '_ \| | __|
* | \__/\ (_) | | | | |_| | | (_| | (__| |_ | | | | | | |_
* \____/\___/|_| |_|\__|_| \__,_|\___|\__| |_|_| |_|_|\__|
*
*/
uint8 mapsize = 17;
Tile[17][17] tiles;
bool initializerset;
address initializer;
address creator;
struct Tile
{
uint8 elevation;
address owner;
address[] offerers;
uint[] offers;
int8[5][] blocks; //0 = which,1 = blockx,2 = blocky,3 = blockz, 4 = color
uint lastfarm;
int8[3][] occupado;
}
function Etheria() {
creator = msg.sender;
}
function setInitializer(address _i)
{
if(initializerset)
return;
initializer = _i;
initializerset = true;
}
/***
* ___ ___ _ _ _
* | \/ | (_) (_) |
* | . . | __ _ _ __ _ _ __ _| |_
* | |\/| |/ _` | '_ \ | | '_ \| | __|
* | | | | (_| | |_) | | | | | | | |_
* \_| |_/\__,_| .__/ |_|_| |_|_|\__|
* | |
* |_|
*/
function initElevations(uint8 row, uint8[17] _elevations)
{
// TODO
// if(msg.sender != initializer)
// return;
for(uint8 col = 0; col < mapsize; col++)
tiles[col][row].elevation = _elevations[col];
}
function getElevations() constant returns (uint8[17][17])
{
uint8[17][17] memory elevations;
for(uint8 row = 0; row < mapsize; row++)
{
for(uint8 col = 0; col < mapsize; col++)
{
elevations[col][row] = tiles[col][row].elevation;
}
}
return elevations;
}
function getOwners() constant returns(address[17][17])
{
address[17][17] memory owners;
for(uint8 row = 0; row < mapsize; row++)
{
for(uint8 col = 0; col < mapsize; col++)
{
owners[col][row] = tiles[col][row].owner;
}
}
return owners;
}
/***
* ______ _ _ _ _ _ _ _ _ _
* | ___| | | (_) | | (_) | | | | | | |
* | |_ __ _ _ __ _ __ ___ | |_ _| | ___ ___ ___ __| |_| |_ | |__ | | ___ ___| | _____
* | _/ _` | '__| '_ ` _ \ | __| | |/ _ \/ __| / _ \/ _` | | __| | '_ \| |/ _ \ / __| |/ / __|
* | || (_| | | | | | | | | | |_| | | __/\__ \_ | __/ (_| | | |_ | |_) | | (_) | (__| <\__ \
* \_| \__,_|_| |_| |_| |_| \__|_|_|\___||___( ) \___|\__,_|_|\__| |_.__/|_|\___/ \___|_|\_\___/
* |/
*
*/
// see EtheriaHelper for non-refucktored version of this algorithm.
function getUint8FromByte32(bytes32 _b32, uint8 byteindex) private constant returns(uint8)
{
if(byteindex == 0)
return uint8((uint(_b32) - (uint(_b32) % (16 ** (64 - 2 - (byteindex*2))))) / (16 ** (64 - 2 - (byteindex*2))));
else
return uint8(((uint(_b32) % (16 ** (64 - (byteindex*2)))) - ((uint(_b32) % (16 ** (64 - (byteindex*2)))) % (16 ** (64 - 2 - (byteindex*2))))) / (16 ** (64 - 2 - (byteindex*2))));
}
function farmTile(uint8 col, uint8 row)
{
if(tiles[col][row].owner != msg.sender)
return;
if((block.number - tiles[col][row].lastfarm) < 4320) // a day's worth of blocks hasn't passed yet. can only farm once a day. (Assumes block times of 20 seconds.)
return;
bytes32 lastblockhash = block.blockhash(block.number - 1);
for(uint8 i = 0; i < 20; i++)
{
tiles[col][row].blocks.length+=5;
tiles[col][row].blocks[tiles[col][row].blocks.length - 1][0] = int8(getUint8FromByte32(lastblockhash,i) % 32); // which, guaranteed 0-31
tiles[col][row].blocks[tiles[col][row].blocks.length - 1][1] = 0; // x
tiles[col][row].blocks[tiles[col][row].blocks.length - 1][2] = 0; // y
tiles[col][row].blocks[tiles[col][row].blocks.length - 1][3] = -1; // z
tiles[col][row].blocks[tiles[col][row].blocks.length - 1][4] = 0; // color
}
tiles[col][row].lastfarm = block.number;
}
function editBlock(uint8 col, uint8 row, uint index, int8[5] block)
{
if(tiles[col][row].owner != msg.sender)
return;
if(block[3] < -1) // Can't hide blocks or change configuration of hidden blocks. This limitation is to prevent massive reorganization of occupado.
return;
block[0] = tiles[col][row].blocks[index][0]; // can't change the which, so set it to whatever it already was
if(isValidBlockLocation(col,row,block[0],block[1],block[2],block[3]))
{ // the new placement is valid
// get the proposed new 8 hex locations
int8[3][8] wouldoccupy = blocks[uint(block[0])].occupies;
for(uint8 b = 0; b < 8; b++) // always 8 hexes
{
wouldoccupy[b][0] = wouldoccupy[b][0]+block[1];
wouldoccupy[b][1] = wouldoccupy[b][1]+block[2];
if(wouldoccupy[0][1] % 2 != 0 && wouldoccupy[b][1]%2 != 0)
wouldoccupy[b][0] = wouldoccupy[b][0]+1; // anchor y and this hex y are both odd, offset by +1
wouldoccupy[b][2] = wouldoccupy[b][2]+block[3];
}
if(tiles[col][row].blocks[index][3] >= 0) // If the previous z was greater than 0 (i.e. not hidden) ...
{
// get the previous 8 hex locations
int8[3][8] didoccupy = blocks[uint(block[0])].occupies;
for(uint8 a = 0; a < 8; a++) // always 8 hexes
{
didoccupy[a][0] = didoccupy[a][0]+tiles[col][row].blocks[index][1];
didoccupy[a][1] = didoccupy[a][1]+tiles[col][row].blocks[index][2];
if(didoccupy[0][1] % 2 != 0 && didoccupy[a][1]%2 != 0)
didoccupy[a][0] = didoccupy[a][0]+1; // anchor y and this hex y are both odd, offset by +1
didoccupy[a][2] = didoccupy[a][2]+tiles[col][row].blocks[index][3];
}
for(uint8 l = 0; l < 8; l++) // loop 8 times,find the previous occupado entries and overwrite them
{
for(uint o = 0; o < tiles[col][row].occupado.length; o++)
{
if(didoccupy[l][0] == tiles[col][row].occupado[o][0] && didoccupy[l][1] == tiles[col][row].occupado[o][1] && didoccupy[l][2] == tiles[col][row].occupado[o][2]) // are the arrays equal?
{
tiles[col][row].occupado[o] = wouldoccupy[l]; // found it. Overwrite it
}
}
}
}
else // previous block was hidden
{
for(uint8 ll = 0; ll < 8; ll++) // add the 8 new hexes to occupado
{
tiles[col][row].occupado.length++;
tiles[col][row].occupado[tiles[col][row].occupado.length-1] = wouldoccupy[ll];
}
}
tiles[col][row].blocks[index] = block;
}
// else not a valid block location, return
return;
}
function getBlocks(uint8 col, uint8 row) constant returns (int8[5][])
{
return tiles[col][row].blocks;
}
// TODO:
// DONE block texturing
// DONE angle camera
// DONE block edit validation coordinate constraints in JS
// DONE block edit validation must touch, no overlap in JS
// block edit validation coordinate constraints in solidity
// block edit validation must touch, no overlap in solidity
// DONE block lookup caching
// register name for owner
// FULL GAME TODO:
// Fitness vote
// Cast threat
// chat
// messaging
// block trading
// reclamation
// price modifier
Block[20] blocks;
struct Block
{
uint8 which;
int8[3][8] occupies; // [x,y,z] 8 times
int8[3][] surroundedby; // [x,y,z]
}
function initBlockDef(uint8 which, int8[3][8] occupies, int8[3][] surroundedby)
{
// TODO
// if(msg.sender != initializer)
// return;
blocks[which].which = which;
for(uint8 o = 0; o < 8; o++)
{
for(uint8 i = 0; i < 3; i++)
{
blocks[which].occupies[o][i] = occupies[o][i];
}
}
blocks[which].surroundedby.length = surroundedby.length;
for(uint8 oo = 0; oo < surroundedby.length; oo++)
{
for(uint8 ii = 0; ii < 3; ii++)
{
blocks[which].surroundedby[oo][ii] = surroundedby[oo][ii];
}
}
}
// function getOccupies(int8 which, int8 x, int8 y, int8 z) private constant returns (int8[3][8])
// {
// int8[3][8] wouldoccupy = blocks[uint(which)].occupies;
// for(uint8 b = 0; b < 8; b++) // always 8 hexes
// {
// wouldoccupy[b][0] = wouldoccupy[b][0]+x;
// wouldoccupy[b][1] = wouldoccupy[b][1]+y;
// if(y % 2 != 0 && wouldoccupy[b][1]%2 != 0)
// wouldoccupy[b][0] = wouldoccupy[b][0]+1; // anchor y and this hex y are both odd, offset by +1
// wouldoccupy[b][2] = wouldoccupy[b][2]+z;
// }
// return wouldoccupy;
// }
//
// function getSurroundings(int8 which, int8 x, int8 y, int8 z) private constant returns (int8[3][])
// {
// int8[3][] surroundings = blocks[uint(which)].surroundedby;
// for(uint8 b = 0; b < surroundings.length; b++)
// {
// surroundings[b][0] = surroundings[b][0]+x;
// surroundings[b][1] = surroundings[b][1]+y;
// if(y % 2 != 0 && surroundings[b][1]%2 != 0)
// surroundings[b][0] = surroundings[b][0]+1; // anchor y and this hex y are both odd, offset by +1
// surroundings[b][2] = surroundings[b][2]+z;
// }
// return surroundings;
// }
function isValidBlockLocation(uint8 col, uint8 row, int8 which, int8 x, int8 y, int8 z) private constant returns (bool)
{
// first, get the 8 hexes it would occupy
int8[3][8] wouldoccupy = blocks[uint(which)].occupies;
for(uint8 b = 0; b < 8; b++) // always 8 hexes
{
wouldoccupy[b][0] = wouldoccupy[b][0]+x;
wouldoccupy[b][1] = wouldoccupy[b][1]+y;
if(y % 2 != 0 && wouldoccupy[b][1]%2 != 0)
wouldoccupy[b][0] = wouldoccupy[b][0]+1; // anchor y and this hex y are both odd, offset by +1
wouldoccupy[b][2] = wouldoccupy[b][2]+z;
if(!blockHexCoordsValid(wouldoccupy[b][0], wouldoccupy[b][1])) // this is the out-of-bounds check
return false;
}
int8[3][] surroundings = blocks[uint(which)].surroundedby;
for(b = 0; b < surroundings.length; b++)
{
surroundings[b][0] = surroundings[b][0]+x;
surroundings[b][1] = surroundings[b][1]+y;
if(y % 2 != 0 && surroundings[b][1]%2 != 0)
surroundings[b][0] = surroundings[b][0]+1; // anchor y and this hex y are both odd, offset by +1
surroundings[b][2] = surroundings[b][2]+z;
}
bool touches;
uint numloops = 8;
if(surroundings.length > 8)
numloops = surroundings.length;
for(uint8 l = 0; l < numloops; l++)
{
for(uint o = 0; o < tiles[col][row].occupado.length; o++)
{
if(l < 8 && wouldoccupy[l][0] == tiles[col][row].occupado[o][0] && wouldoccupy[l][1] == tiles[col][row].occupado[o][1] && wouldoccupy[l][2] == tiles[col][row].occupado[o][2]) // are the arrays equal?
return false; // this hex conflicts. The proposed block does not avoid overlap. Return false immediately.
if(touches == false && wouldoccupy[l][2] == 0) // if on the ground, touches is always true
touches = true;
if(touches == false && l < surroundings.length && surroundings[l][0] == tiles[col][row].occupado[o][0] && surroundings[l][1] == tiles[col][row].occupado[o][1] && surroundings[l][2] == tiles[col][row].occupado[o][2]) // are the arrays equal?
touches = true;
}
if(l >= 8 && touches == true)
return true;
}
if(touches == true)
return true;
else
return false;
}
function blockHexCoordsValid(int8 x, int8 y) private constant returns (bool)
{
if(-33 <= y && y <= 33)
{
if(y % 2 != 0 ) // odd
{
if(-50 <= x && x <= 49)
return true;
}
else // even
{
if(-49 <= x && x <= 49)
return true;
}
}
else
{
uint8 absx;
uint8 absy;
if(x < 0)
absx = uint8(x*-1);
else
absx = uint8(x);
if(y < 0)
absy = uint8(y*-1);
else
absy = uint8(y);
if((y >= 0 && x >= 0) || (y < 0 && x > 0)) // first or 4th quadrants
{
if(y % 2 != 0 ) // odd
{
if (((absx*2) + (absy*3)) <= 198)
return true;
}
else // even
{
if ((((absx+1)*2) + ((absy-1)*3)) <= 198)
return true;
}
}
else
{
if(y % 2 == 0 ) // even
{
if (((absx*2) + (absy*3)) <= 198)
return true;
}
else // odd
{
if ((((absx+1)*2) + ((absy-1)*3)) <= 198)
return true;
}
}
}
return false;
}
/***
* _____ __ __
* | _ |/ _|/ _|
* | | | | |_| |_ ___ _ __ ___
* | | | | _| _/ _ \ '__/ __|
* \ \_/ / | | || __/ | \__ \
* \___/|_| |_| \___|_| |___/
*
*
*/
function makeOffer(uint8 col, uint8 row)
{
if(msg.value < 10000000000000000 || msg.value > 1208925819614629174706175) // .01 ether up to (2^80 - 1) wei is the valid range
{
if(!(msg.value == 0))
msg.sender.send(msg.value); // return their money
return;
}
else if(tiles[col][row].elevation >= 125 && tiles[col][row].owner == address(0)) // if unowned and above sea level, accept offer of 1 ETH immediately
{
if(msg.value != 1000000000000000000) // 1 ETH is the starting value. If not enough or too much...
{
msg.sender.send(msg.value); // return their money
return;
}
else
{
creator.send(msg.value); // this was a valid offer, send money to contract owner
tiles[col][row].owner = msg.sender; // set tile owner to the buyer
return;
}
}
else
{
if(tiles[col][row].offerers.length < 10) // this tile can only hold 10 offers at a time
{
for(uint8 i = 0; i < tiles[col][row].offerers.length; i++)
{
if(tiles[col][row].offerers[i] == msg.sender) // user has already made an offer. Update it and return;
{
msg.sender.send(tiles[col][row].offers[i]); // return their previous money
tiles[col][row].offers[i] = msg.value; // set the new offer
return;
}
}
// the user has not yet made an offer
tiles[col][row].offerers.length++; // make room for 1 more
tiles[col][row].offers.length++; // make room for 1 more
tiles[col][row].offerers[tiles[col][row].offerers.length - 1] = msg.sender; // record who is making the offer
tiles[col][row].offers[tiles[col][row].offers.length - 1] = msg.value; // record the offer
}
}
}
function retractOffer(uint8 col, uint8 row) // retracts the first offer in the array by this user.
{
for(uint8 i = 0; i < tiles[col][row].offerers.length; i++)
{
if(tiles[col][row].offerers[i] == msg.sender) // this user has an offer on file. Remove it.
removeOffer(col,row,i);
}
}
function rejectOffer(uint8 col, uint8 row, uint8 i) // index 0-10
{
if(tiles[col][row].owner != msg.sender) // only the owner can reject offers
return;
removeOffer(col,row,i);
return;
}
function removeOffer(uint8 col, uint8 row, uint8 i) private // index 0-10, can't be odd
{
// return the money
tiles[col][row].offerers[i].send(tiles[col][row].offers[i]);
// delete user and offer and reshape the array
delete tiles[col][row].offerers[i]; // zero out user
delete tiles[col][row].offers[i]; // zero out offer
for(uint8 j = i+1; j < tiles[col][row].offerers.length; j++) // close the arrays after the gap
{
tiles[col][row].offerers[j-1] = tiles[col][row].offerers[j];
tiles[col][row].offers[j-1] = tiles[col][row].offers[j];
}
tiles[col][row].offerers.length--;
tiles[col][row].offers.length--;
return;
}
function acceptOffer(uint8 col, uint8 row, uint8 i) // accepts the offer at index (1-10)
{
tiles[col][row].owner.send(tiles[col][row].offers[i]); // send offer money to oldowner
tiles[col][row].owner = tiles[col][row].offerers[i]; // new owner is the offerer
delete tiles[col][row].offerers; // delete all offerers
delete tiles[col][row].offers; // delete all offers
return;
}
function getOfferers(uint8 col, uint8 row) constant returns (address[])
{
return tiles[col][row].offerers;
}
function getOffers(uint8 col, uint8 row) constant returns (uint[])
{
return tiles[col][row].offers;
}
}External Links
Related contracts
GetBalance
Same deployerCyrus Adkisson experimental getter (Sep 2015) exposing the ether balance of a hardcoded address via getMyBalance(). Verified byte-for-byte with soljson v0.1.1.
0x759ad4...239a87August 26, 2015Contract 0xddcd64...a08e7b
Same deployerThe greeter tutorial contract: it stores a greeting set at deployment and can be shut down by its owner.
0xddcd64...a08e7bAugust 26, 2015basicInfoGetter
Same deployerA tour of the EVM globals, carrying the constructor of the file it was copied from
0xad826c...d33547August 31, 2015Contract 0x3ea0db...b922e0
Same deployerThe basic info getter from the solidity-baby-steps tutorials, a read only window onto the block and message globals.
0x3ea0db...b922e0August 31, 2015Contract 0xba575c...78733f
Same deployerA contract built to probe what the msg globals actually return, endowed with 5 ETH, deployed 1 September 2015.
0xba575c...78733fSeptember 1, 2015Contract 0x8b180c...c084df
Same deployerA third deployment of the msgExaminer that records its own creation message
0x8b180c...c084dfSeptember 1, 2015