From 4a270f301bbf2cf07c340e895cb79c226b9fb7fb Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 4 Jan 2019 11:01:49 -0500 Subject: Restore old data format --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client.c') diff --git a/client.c b/client.c index 6edcd6e..7f4c158 100644 --- a/client.c +++ b/client.c @@ -490,7 +490,7 @@ static void inputNormal(bool keyCode, wchar_t ch) { static void inputHelp(bool keyCode, wchar_t ch) { (void)keyCode; (void)ch; - if (tile.meta.createTime) drawTile(&tile); + if (tileMeta(&tile).createTime) drawTile(&tile); modeNormal(); } -- cgit 1.4.1 From b346547d965f7ae61d40ef1b114f5fdefa4053a1 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 4 Jan 2019 11:30:49 -0500 Subject: Disable flip --- client.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 7f4c158..c2819e4 100644 --- a/client.c +++ b/client.c @@ -257,11 +257,6 @@ static void clientMove(int8_t dx, int8_t dy) { clientMessage(msg); } -static void clientFlip(void) { - struct ClientMessage msg = { .type = ClientFlip }; - clientMessage(msg); -} - static void clientPut(uint8_t color, uint8_t cell) { struct ClientMessage msg = { .type = ClientPut, @@ -404,7 +399,6 @@ static void inputNormal(bool keyCode, wchar_t ch) { break; case Esc: modeNormal(); input.shift = 0; break; case 'q': endwin(); exit(EX_OK); - break; case 'g': clientFlip(); break; case 'h': clientMove(-1, 0); break; case 'l': clientMove( 1, 0); break; case 'k': clientMove( 0, -1); -- cgit 1.4.1 From 59e32020d84dcdea696ae5942eba901d92803806 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 4 Jan 2019 12:20:23 -0500 Subject: Add indicator of current position in map --- client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'client.c') diff --git a/client.c b/client.c index c2819e4..40b52e0 100644 --- a/client.c +++ b/client.c @@ -220,6 +220,7 @@ static void serverMap(void) { wchar_t cell = MapCells[count]; uint8_t color = MapColors[time]; wchar_t tile[] = { cell, cell, cell, L'\0' }; + if (y == MapRows / 2 && x == MapCols / 2) tile[1] = L'⌂'; attr_set(colorAttr(color), colorPair(color), NULL); mvaddwstr(MapY + y, MapX + 3 * x, tile); } -- cgit 1.4.1 From 538c81ed09c9fc575126c7e11f89e9d9bc475e3a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 4 Jan 2019 13:00:13 -0500 Subject: Add simplified speed control --- client.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 40b52e0..d48ba17 100644 --- a/client.c +++ b/client.c @@ -282,10 +282,12 @@ static struct { ModeDraw, ModeLine, } mode; + int8_t delta; uint8_t color; uint8_t shift; uint8_t draw; } input = { + .delta = 1, .color = ColorWhite, }; @@ -380,10 +382,10 @@ static uint8_t inputCell(wchar_t ch) { static void inputNormal(bool keyCode, wchar_t ch) { if (keyCode) { switch (ch) { - break; case KEY_LEFT: clientMove(-1, 0); - break; case KEY_RIGHT: clientMove( 1, 0); - break; case KEY_UP: clientMove( 0, -1); - break; case KEY_DOWN: clientMove( 0, 1); + break; case KEY_LEFT: clientMove(-input.delta, 0); + break; case KEY_RIGHT: clientMove( input.delta, 0); + break; case KEY_UP: clientMove( 0, -input.delta); + break; case KEY_DOWN: clientMove( 0, input.delta); break; case KEY_F(1): input.shift = 0x00; break; case KEY_F(2): input.shift = 0xC0; @@ -400,14 +402,16 @@ static void inputNormal(bool keyCode, wchar_t ch) { break; case Esc: modeNormal(); input.shift = 0; break; case 'q': endwin(); exit(EX_OK); - break; case 'h': clientMove(-1, 0); - break; case 'l': clientMove( 1, 0); - break; case 'k': clientMove( 0, -1); - break; case 'j': clientMove( 0, 1); - break; case 'y': clientMove(-1, -1); - break; case 'u': clientMove( 1, -1); - break; case 'b': clientMove(-1, 1); - break; case 'n': clientMove( 1, 1); + break; case '\\': input.delta = (input.delta == 1 ? 4 : 1); + + break; case 'h': clientMove(-input.delta, 0); + break; case 'l': clientMove( input.delta, 0); + break; case 'k': clientMove( 0, -input.delta); + break; case 'j': clientMove( 0, input.delta); + break; case 'y': clientMove(-input.delta, -input.delta); + break; case 'u': clientMove( input.delta, -input.delta); + break; case 'b': clientMove(-input.delta, input.delta); + break; case 'n': clientMove( input.delta, input.delta); break; case '0': colorFg(ColorBlack); break; case '1': colorFg(ColorRed); -- cgit 1.4.1 From 7f49436baea5d29586c7ac10c4586ef59d788e5d Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 4 Jan 2019 13:22:21 -0500 Subject: Add teleportation "Spawns" in the old code. --- client.c | 7 +++++++ server.c | 13 +++++++++++++ torus.h | 13 +++++++++++++ 3 files changed, 33 insertions(+) (limited to 'client.c') diff --git a/client.c b/client.c index d48ba17..c9800cf 100644 --- a/client.c +++ b/client.c @@ -271,6 +271,11 @@ static void clientMap(void) { clientMessage(msg); } +static void clientTele(uint8_t port) { + struct ClientMessage msg = { .type = ClientTele, .port = port }; + clientMessage(msg); +} + static struct { enum { ModeNormal, @@ -402,6 +407,8 @@ static void inputNormal(bool keyCode, wchar_t ch) { break; case Esc: modeNormal(); input.shift = 0; break; case 'q': endwin(); exit(EX_OK); + break; case 'Q': clientTele(input.color % ARRAY_LEN(Ports)); + break; case '\\': input.delta = (input.delta == 1 ? 4 : 1); break; case 'h': clientMove(-input.delta, 0); diff --git a/server.c b/server.c index ad9815b..356387f 100644 --- a/server.c +++ b/server.c @@ -359,6 +359,16 @@ static bool clientMap(const struct Client *client) { return true; } +static bool clientTele(struct Client *client, uint8_t port) { + if (port >= ARRAY_LEN(Ports)) return false; + struct Client old = *client; + client->tileX = Ports[port].tileX; + client->tileY = Ports[port].tileY; + client->cellX = CellInitX; + client->cellY = CellInitY; + return clientUpdate(client, &old); +} + int main(int argc, char *argv[]) { int error; @@ -477,6 +487,9 @@ int main(int argc, char *argv[]) { break; case ClientMap: { success = clientMap(client); } + break; case ClientTele: { + success = clientTele(client, msg.port); + } } if (!success) clientRemove(client); } diff --git a/torus.h b/torus.h index a18f515..ba552eb 100644 --- a/torus.h +++ b/torus.h @@ -104,6 +104,17 @@ static const size_t TilesSize = sizeof(struct Tile[TileRows][TileCols]); static const uint32_t TileInitX = 0; static const uint32_t TileInitY = 0; +static const struct { + uint32_t tileX; + uint32_t tileY; +} Ports[] = { + { TileInitX, TileInitY }, + { TileCols * 3 / 4, TileRows * 3 / 4 }, // NW + { TileCols * 1 / 4, TileRows * 3 / 4 }, // NE + { TileCols * 1 / 4, TileRows * 1 / 4 }, // SE + { TileCols * 3 / 4, TileRows * 1 / 4 }, // SW +}; + enum { MapRows = 11, MapCols = 11, @@ -152,6 +163,7 @@ struct ClientMessage { ClientFlip, ClientPut, ClientMap, + ClientTele, } type; union { struct { @@ -162,5 +174,6 @@ struct ClientMessage { uint8_t color; uint8_t cell; } put; + uint8_t port; }; }; -- cgit 1.4.1