Compare commits
5 Commits
52f8034f4e
...
2c7d1d0b43
Author | SHA1 | Date | |
---|---|---|---|
2c7d1d0b43 | |||
00b83e6de2 | |||
9881567009 | |||
f23f307e17 | |||
dd658c9c1d |
@@ -103,10 +103,13 @@ namespace connect_code {
|
|||||||
std::string addr_expanded = expand_ip6_addr(address);
|
std::string addr_expanded = expand_ip6_addr(address);
|
||||||
std::string addr_coded = "";
|
std::string addr_coded = "";
|
||||||
std::vector<std::string> addr_tokenized = tokenize_str(addr_expanded, ":");
|
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 += base_convert(addr_tokenized[i], 16, 32);
|
||||||
addr_coded += "-";
|
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.
|
/* 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. */
|
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) {
|
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) {
|
if (connect_code.find("_") == std::string::npos) {
|
||||||
throw std::invalid_argument("Invalid code entered.");
|
throw std::invalid_argument("Invalid code entered.");
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# This script copies required DLLs, and the application itself into a folder called 'release'. It only runs on MinGW.
|
# 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)
|
BASE_DIR=$(dirname $0)
|
||||||
REL_DIR="$BASE_DIR/release/dist"
|
REL_DIR="$BASE_DIR/release/dist"
|
||||||
|
|
||||||
|
26
create_static_linux.sh
Executable file
26
create_static_linux.sh
Executable 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/"
|
@@ -26,11 +26,16 @@ unsigned int to_decimal(std::string num, int from_base) {
|
|||||||
std::string from_decimal(unsigned int num, int to_base) {
|
std::string from_decimal(unsigned int num, int to_base) {
|
||||||
std::string return_val;
|
std::string return_val;
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
/* 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) {
|
while (num > 0) {
|
||||||
val = num % to_base;
|
val = num % to_base;
|
||||||
return_val.push_back(possible_chars[val]);
|
return_val.push_back(possible_chars[val]);
|
||||||
num /= to_base;
|
num /= to_base;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Reverse the string, since we started from the right */
|
/* Reverse the string, since we started from the right */
|
||||||
std::reverse(return_val.begin(), return_val.end());
|
std::reverse(return_val.begin(), return_val.end());
|
||||||
|
1
todo.txt
1
todo.txt
@@ -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.
|
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.
|
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).
|
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.
|
||||||
|
Reference in New Issue
Block a user