Skip to content

Commit a4320f3

Browse files
author
Dario Pagani
committed
hope for the best
0 parents  commit a4320f3

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
generator
2+
regionInfo.dat
3+

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CXXFLAGS = -g -Wall -Wwrite-strings
2+
EXEC = generator
3+
4+
all:
5+
g++ $(CXXFLAGS) main.cpp -o $(EXEC)
6+
7+
clean:
8+
rm -f *.o *.bak core $(EXEC)

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Custom `regionInfo.dat` generator for Among Us
2+
**This is an ugly C/C++ program held together with tape!**
3+
4+
This program generates a regionInfo.dat file to allow Among Us to connect to custom servers like [Impostor](https://github.com/AeonLucid/Impostor/).
5+
6+
## Building on Android
7+
1. Install Termux, run `termux-setup-storage` and allow for disk access.
8+
2. Install via CLI clang and make (and git if you want to clone this repo with it)
9+
3. cd into the repo and run `make all`
10+
4. ???
11+
5. Profit!
12+
13+
## How to run
14+
run `./generator` with the following options
15+
16+
- `-s [server address]` to specify on which server you want the game to connect
17+
- `-p [port]` to specify the port, it defaults to the default port
18+
- `-o [file]` to specify on which file you want to write, it defaults to `/sdcard/Android/data/com.innersloth.spacemafia/files/regionInfo.dat`
19+
20+
21+
## F.A.Q.
22+
23+
### Why not a Java Android app?
24+
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
25+

main.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include <unistd.h>
4+
5+
#include<netdb.h>
6+
#include<arpa/inet.h>
7+
8+
int main(int argc, char **argv)
9+
{
10+
std::string fileName = "/sdcard/Android/data/com.innersloth.spacemafia/files/regionInfo.dat";
11+
std::string serverAddress = "localhost";
12+
uint16_t port = 22023;
13+
std::ofstream file;
14+
int option = -1;
15+
uint32_t zero32 = 0;
16+
uint32_t serverLen = 1;
17+
uint8_t strLen;
18+
19+
hostent *he = nullptr;
20+
std::string ipAddress;
21+
22+
do
23+
{
24+
option = getopt(argc, argv, "s:p:o:");
25+
26+
switch(option)
27+
{
28+
case 's':
29+
serverAddress = optarg;
30+
break;
31+
case 'p':
32+
port = std::stoi(optarg);
33+
break;
34+
case 'o':
35+
fileName = optarg;
36+
break;
37+
}
38+
}
39+
while(option != -1);
40+
41+
// Resolving hostname
42+
he = gethostbyname(serverAddress.c_str());
43+
44+
if(!he || he->h_addr_list == nullptr)
45+
{
46+
std::cerr << "Error resolving the net address " << serverAddress << '\n';
47+
return -1;
48+
}
49+
50+
ipAddress = inet_ntoa(**(in_addr **)he->h_addr_list);
51+
52+
file = std::ofstream(fileName, std::ios::binary);
53+
if(!file)
54+
{
55+
std::cerr << "I/O error\n";
56+
return -1;
57+
}
58+
59+
// Region info
60+
file.write((char*)&zero32, sizeof(uint32_t));
61+
file.write("\x08Impostor", 9);
62+
63+
// Region address
64+
strLen = serverAddress.size();
65+
file.write((char*)&strLen, sizeof(uint8_t));
66+
file << serverAddress;
67+
68+
// N of servers (always 1)
69+
file.write( (char*)&serverLen, sizeof(uint32_t));
70+
71+
// First and only server name
72+
file << "\x11Impostor-Master-1";
73+
74+
// First and only server address (numeric form not as string)
75+
file.write((char*)&(*(in_addr **)he->h_addr_list)->s_addr, sizeof(uint32_t));
76+
file.write((char*)&port, sizeof(uint16_t));
77+
78+
file.write((char*)&zero32, sizeof(uint32_t));
79+
80+
file.close();
81+
82+
return 0;
83+
}

0 commit comments

Comments
 (0)