1 /** 2 Copyright: Copyright (c) 2015-2016 Andrey Penechko. 3 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 4 Authors: Andrey Penechko. 5 */ 6 module main; 7 8 import std.experimental.logger; 9 import voxelman.utils.log; 10 import server; 11 import storage; 12 13 struct EditEvent { 14 uint tick; 15 int pos; 16 } 17 18 enum NUM_CLIENTS = 2; 19 enum NUM_TICKS = 20; 20 string[] clientNames = ["A", "B", "C", "D"]; 21 EditEvent[] events = [ 22 {2, 0}, {3, 0}, {3, 1}, {4, -1}]; 23 24 void main(string[] args) 25 { 26 setupLogger("snapman.log"); 27 28 Server server = new Server(); 29 30 Client*[NUM_CLIENTS] clients; 31 foreach(i, ref c; clients) 32 c = new Client(clientNames[i], cast(uint)i+1, Volume1D(0, 1)); 33 clients[0].viewVolume = Volume1D(-1, 3); 34 35 // connect clients 36 foreach(c; clients) 37 server.onClientConnected(c); 38 39 // main loop 40 foreach(tick; 0..NUM_TICKS) { 41 infof("-- %s", tick); 42 server.preUpdate(); 43 44 while (events.length > 0 && events[0].tick == tick) { 45 server.setBlock(BlockWorldPos(events[0].pos * (CHUNK_SIZE)), 1); 46 events = events[1..$]; 47 } 48 49 if (tick == 10) { 50 server.save(); 51 } 52 53 server.postUpdate(); 54 } 55 56 // disconnect clients 57 foreach(c; clients) 58 server.onClientDisconnected(c); 59 }