Skip to content
Snippets Groups Projects
Commit b29346ee authored by OleL's avatar OleL
Browse files

blargh

parent e76b5d6e
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,22 @@ void hostGame() {
#endif
}
bool isValidIp(String ip){
unsigned short pos0 = ip.indexOf('.');
unsigned short pos1 = ip.indexOf('.', pos0);
unsigned short pos2 = ip.indexOf('.', pos1);
unsigned short pos3 = ip.indexOf('.', pos2);
String part0 = ip.substring(0, pos0);
String part1 = ip.substring(pos0, pos1);
String part2 = ip.substring(pos1, pos2);
String part3 = ip.substring(pos2, ip.length());
Serial.printf("Zerhackstuekelte IP: %s:%s:%s:%s", part0.c_str(), part1.c_str(), part2.c_str(), part3.c_str());
}
String recv_ir() {
badge.setGPIO(IR_EN, HIGH);
Serial.println("Entering receive mode");
......@@ -126,7 +142,7 @@ String recv_ir() {
Serial.printf("->:\n\t0: %c\n\t1: %c\n\t2: %c\n\t3: %c\n", buf[0], buf[1], buf[2], buf[3]);
if (buf[0] == '\n' || buf[1] == '\n' || buf[2] == '\n' || buf[3] == '\n') {
stringCompleted = true;
done = true;
done = isValidIp(received.substring(1, received.length() - 2));
}
}
irrecv.resume(); // Prepare for the next value
......
......@@ -43,7 +43,7 @@ void GameClient::joinGame(String ip) {
badge->setVibrator(false);
playerList->addMenuItem(new MenuItem(player->getNickname(), []() {}));
ui->open(playerList);
client->connect(ip, SERVER_PORT);
client->connect(ip.c_str(), SERVER_PORT);
client->print(player->getNickname());
client->flush();
......
......@@ -22,7 +22,7 @@ public:
void startGame();
void joinGame();
void joinGame(String ip);
bool wasHit(String* lastHitBy, int* lastDamage, bool enable = true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment