aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/main.ha21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/main.ha b/client/main.ha
index 04e6854..4c70892 100644
--- a/client/main.ha
+++ b/client/main.ha
@@ -1,13 +1,16 @@
use fmt;
use sdl2;
use math;
+use io;
use net;
use net::dial;
+use unix::poll;
+
use drawing;
use drawing::{pos,CHUNKSIZE};
use client::paintui;
-use unix::poll;
use packet_reader;
+use packet_reader::{VERSION};
def NCHUNKS = 16;
@@ -19,7 +22,7 @@ export fn main() void = {
sdl2::SDL_Init(sdl2::SDL_INIT_VIDEO)!;
defer sdl2::SDL_Quit();
- const win = sdl2::SDL_CreateWindow("hi", sdl2::SDL_WINDOWPOS_UNDEFINED, sdl2::SDL_WINDOWPOS_UNDEFINED, 640, 480, sdl2::SDL_WindowFlags::NONE)!;
+ const win = sdl2::SDL_CreateWindow("garden", sdl2::SDL_WINDOWPOS_UNDEFINED, sdl2::SDL_WINDOWPOS_UNDEFINED, 640, 480, sdl2::SDL_WindowFlags::NONE)!;
defer sdl2::SDL_DestroyWindow(win);
const wsurf = sdl2::SDL_GetWindowSurface(win)!;
@@ -42,11 +45,21 @@ export fn main() void = {
};
// connect to server
- const conn = match(dial::dial("tcp","localhost","41460")) {
+ const conn = match(dial::dial("tcp","ubq323.website","41460")) {
case let c: net::socket => yield c;
case let err: net::error =>
fmt::fatal("couldn't connect to server:",net::strerror(err));
};
+
+ let byte = [0u8];
+ match (io::read(conn, byte)) {
+ case let e: io::error =>
+ fmt::fatal("error with server handshake",io::strerror(e));
+ case => if (byte[0] != VERSION)
+ fmt::fatalf("invalid version: got {}, expecting {}",
+ byte[0], VERSION);
+ };
+
const pollfd: [1]poll::pollfd = [ poll::pollfd {
fd = conn, events=poll::event::POLLIN, revents = 0
@@ -150,7 +163,7 @@ export fn main() void = {
};
- drawing::clear_picture(&win_pic, 0xff0000);
+ drawing::clear_picture(&win_pic, 0xdddddd);
for (let i = 0z; i < len(pictures); i += 1) {
const psurf = picture_surfaces[i];