void sock_initround() { char s[3] = "n1"; sock_flags &= ~PL2_GARBAGE; sock_sendbyte('G'); if (is_server) { s[2] = *tetrom_seq; writebytes(s, 3); s[1] = '2'; writebytes(s, 3); s[2] = tetrom_seq[1]; writebytes(s, 3); s[1] = '1'; writebytes(s, 3); } if (player1.height) sendboard(p1_height_lines()); }
void sock_initgame() { static char saved_mode; static char saved_lineslimit; opponent_name[0] = '\0'; if (sock_flags & CONN_PROXY) { game->mode = saved_mode; player1.lineslimit = saved_lineslimit; } else { saved_mode = game->mode; saved_lineslimit = player1.lineslimit; if (is_server) playerlist_n = 0; } if (is_server) player2.lineslimit = player1.lineslimit; else { sock_sendbyte('i'); sock_sendplayer(); if (waitinput_sock(500) || waitinput_sock(500)) sock_getkeypress(0); } }
int processkey_ingame(int key, int flags) { static int discard_count; struct player *plr; int i = TWOPLAYER_MODE && key & PLAYER_2; int safe; switch (key & 0x7F) { case ESC: case '\b': game->state = 0; return -2; case 'q': exit(0); case STARTBTN: case 'p': if (flags & NO_PAUSE || !game_running || TWOPLAYER_MODE) break; i = pausegame(); textgfx_flags &= ~LOST_FOCUS; return i; } if (flags & DISCARD_MOVES) { if (++discard_count > 5) kb_flushinp(); return -1; } discard_count = 0; plr = game->player+i; safe = dropsafe(i); key &= 0x7F; if (!(flags & DISCARD_DROPS)) { switch (key) { case HARDDROP: if (socket_fd > -1 && !i) { sock_sendpiece(plr); if (harddrop(plr, safe) == -1) return -1; sock_sendbyte(HARDDROP); return 0; } return harddrop(plr, safe); case MVDOWN: if (!TWOPLAYER_MODE) return softdrop(softdrop_speed, safe); if (!movedown(plr, 1)) return 0; if (socket_fd > -1 && !i) sock_sendbyte(MVDOWN); return 1; } } switch (key) { case MVLEFT: moveleft(plr); break; case MVRIGHT: moveright(plr); break; case MVUP: rotate(plr, plr->rotationsys & ROT_CLOCKWISE); break; case A_BTN: rotate(plr, 1); break; case B_BTN: //rotate(plr, 0); if(!makeSwitch(plr)) return 99; break; default: return -1; } if (socket_fd > -1 && !i) sock_sendbyte(key); upd_screen(1+i); return 1; }