-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dario Pagani
committed
Oct 3, 2020
0 parents
commit a4320f3
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
generator | ||
regionInfo.dat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CXXFLAGS = -g -Wall -Wwrite-strings | ||
EXEC = generator | ||
|
||
all: | ||
g++ $(CXXFLAGS) main.cpp -o $(EXEC) | ||
|
||
clean: | ||
rm -f *.o *.bak core $(EXEC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Custom `regionInfo.dat` generator for Among Us | ||
**This is an ugly C/C++ program held together with tape!** | ||
|
||
This program generates a regionInfo.dat file to allow Among Us to connect to custom servers like [Impostor](https://github.com/AeonLucid/Impostor/). | ||
|
||
## Building on Android | ||
1. Install Termux, run `termux-setup-storage` and allow for disk access. | ||
2. Install via CLI clang and make (and git if you want to clone this repo with it) | ||
3. cd into the repo and run `make all` | ||
4. ??? | ||
5. Profit! | ||
|
||
## How to run | ||
run `./generator` with the following options | ||
|
||
- `-s [server address]` to specify on which server you want the game to connect | ||
- `-p [port]` to specify the port, it defaults to the default port | ||
- `-o [file]` to specify on which file you want to write, it defaults to `/sdcard/Android/data/com.innersloth.spacemafia/files/regionInfo.dat` | ||
|
||
|
||
## F.A.Q. | ||
|
||
### Why not a Java Android app? | ||
I don't worship cows so I'm really handy with Android development. Also this program is meant as a quick and dirty utility with no time nor the desire to mess around GUI toolkits | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <unistd.h> | ||
|
||
#include<netdb.h> | ||
#include<arpa/inet.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
std::string fileName = "/sdcard/Android/data/com.innersloth.spacemafia/files/regionInfo.dat"; | ||
std::string serverAddress = "localhost"; | ||
uint16_t port = 22023; | ||
std::ofstream file; | ||
int option = -1; | ||
uint32_t zero32 = 0; | ||
uint32_t serverLen = 1; | ||
uint8_t strLen; | ||
|
||
hostent *he = nullptr; | ||
std::string ipAddress; | ||
|
||
do | ||
{ | ||
option = getopt(argc, argv, "s:p:o:"); | ||
|
||
switch(option) | ||
{ | ||
case 's': | ||
serverAddress = optarg; | ||
break; | ||
case 'p': | ||
port = std::stoi(optarg); | ||
break; | ||
case 'o': | ||
fileName = optarg; | ||
break; | ||
} | ||
} | ||
while(option != -1); | ||
|
||
// Resolving hostname | ||
he = gethostbyname(serverAddress.c_str()); | ||
|
||
if(!he || he->h_addr_list == nullptr) | ||
{ | ||
std::cerr << "Error resolving the net address " << serverAddress << '\n'; | ||
return -1; | ||
} | ||
|
||
ipAddress = inet_ntoa(**(in_addr **)he->h_addr_list); | ||
|
||
file = std::ofstream(fileName, std::ios::binary); | ||
if(!file) | ||
{ | ||
std::cerr << "I/O error\n"; | ||
return -1; | ||
} | ||
|
||
// Region info | ||
file.write((char*)&zero32, sizeof(uint32_t)); | ||
file.write("\x08Impostor", 9); | ||
|
||
// Region address | ||
strLen = serverAddress.size(); | ||
file.write((char*)&strLen, sizeof(uint8_t)); | ||
file << serverAddress; | ||
|
||
// N of servers (always 1) | ||
file.write( (char*)&serverLen, sizeof(uint32_t)); | ||
|
||
// First and only server name | ||
file << "\x11Impostor-Master-1"; | ||
|
||
// First and only server address (numeric form not as string) | ||
file.write((char*)&(*(in_addr **)he->h_addr_list)->s_addr, sizeof(uint32_t)); | ||
file.write((char*)&port, sizeof(uint16_t)); | ||
|
||
file.write((char*)&zero32, sizeof(uint32_t)); | ||
|
||
file.close(); | ||
|
||
return 0; | ||
} |