Compare commits

...

5 Commits

5 changed files with 51 additions and 6 deletions

View File

@@ -103,10 +103,13 @@ namespace connect_code {
std::string addr_expanded = expand_ip6_addr(address);
std::string addr_coded = "";
std::vector<std::string> addr_tokenized = tokenize_str(addr_expanded, ":");
for (int i = 0; i < addr_tokenized.size(); i++ ) {
for (int i = 0; i < addr_tokenized.size()-1; i++ ) {
addr_coded += base_convert(addr_tokenized[i], 16, 32);
addr_coded += "-";
}
addr_coded += base_convert(addr_tokenized[addr_tokenized.size()-1], 16, 32); // I put this outside the loop, because I don't want a hyphen after it
/* TODO - Check if the IP address is actually converted properly, and test if the server socket is created correctly.
Also do the same for client side, and check client-server connection. */
@@ -124,6 +127,15 @@ namespace connect_code {
}
std::vector<std::string> decode(std::string connect_code) {
//<AIRPLANE_CODE>
int ip_ver = 0;
if (connect_code.find("-") == connect_code.npos) {
ip_ver = 6; // If the string contains hyphens, it must be an IPv6 address encoding.
} else {
ip_ver = 4;
}
//</AIRPLANE_CODE>
if (connect_code.find("_") == std::string::npos) {
throw std::invalid_argument("Invalid code entered.");
}

View File

@@ -2,6 +2,7 @@
# This script copies required DLLs, and the application itself into a folder called 'release'. It only runs on MinGW.
set -o errexit # Stop executing when a command fails
BASE_DIR=$(dirname $0)
REL_DIR="$BASE_DIR/release/dist"

26
create_static_linux.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# This script creates and packages a statically-linked build of the game, for Linux.
# It must be placed in the root of the source code.
set -o errexit # Stop executing when a command fails
BASE_DIR=$(dirname 0)
REL_DIR="$BASE_DIR/release/static/pong"
mkdir -p "$REL_DIR"
# Set the default build target to static
meson configure -Ddefault_library=static "$BASE_DIR/build/"
# Build the application
meson compile -C "$BASE_DIR/build/"
# Package the application:
# 1. Copy the executable to REL_DIR
# 2. Create a tarball
cp "$BASE_DIR/build/pong" "$REL_DIR"
tar -czf "$BASE_DIR/release/pong.tar.gz" "$REL_DIR"
# Reset default build target to shared
meson configure -Ddefault_library=shared "$BASE_DIR/build/"

View File

@@ -26,12 +26,17 @@ unsigned int to_decimal(std::string num, int from_base) {
std::string from_decimal(unsigned int num, int to_base) {
std::string return_val;
int val = 0;
while (num > 0) {
val = num % to_base;
return_val.push_back(possible_chars[val]);
num /= to_base;
/* Handle the special case of num being zero: In this case, the result is also zero */
if (num == 0) {
return_val = "0";
} else {
while (num > 0) {
val = num % to_base;
return_val.push_back(possible_chars[val]);
num /= to_base;
}
}
/* Reverse the string, since we started from the right */
std::reverse(return_val.begin(), return_val.end());

View File

@@ -10,3 +10,4 @@
10. Add 'install' target to Meson, to allow the user to install the game. This should also copy the .so files to the right locations.
11. Allow the user to specify which paddle they want to control, in multi-player mode.
12. Add IPv6 support for the server and client sockets (and everything that goes along with it, such as error handling for IP addresses).
13. Figure out how to make 'tar' not include the entire directory structure, when creating the archive in create_static_linux.sh.