Merge branch 'main' into master

This commit is contained in:
Kaan Soral
2023-11-06 14:47:11 +03:00
committed by GitHub
20 changed files with 20088 additions and 11286 deletions
Vendored
BIN
View File
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
name: Code Quality
on:
- pull_request
- push
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
working-directory: node
- name: Run ESLint
run: npm run lint
working-directory: node
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
+13
View File
@@ -0,0 +1,13 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.configPath": "./node/.prettierrc",
"prettier.printWidth": 120,
"prettier.tabWidth": 2,
"prettier.trailingComma": "all",
"prettier.semi": true,
"prettier.useTabs": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
+43 -13
View File
@@ -1,6 +1,9 @@
# Adventure Land - The Open Source CODE MMORPG
https://adventure.land
The Source Code is now available to anyone, even for commercial use! (License applies)
**Please consider supporting Adventure Land on Patreon: https://www.patreon.com/AdventureLand**
## Discussion
@@ -10,17 +13,29 @@ Consider using the #development channel on Discord or messaging me directly on D
## Installation
Clone the game files into the adventureland folder:
```sh
git clone https://github.com/kaansoral/adventureland adventureland
```
Clone a modified copy of Python2 App Engine Local App Server into the python folder along with an initialized database with map files:
```sh
git clone https://github.com/kaansoral/adventureland-appserver appserver
```
Set up secrets files and remember to change secret keys!
```sh
cp adventureland/useful/template.secrets.py adventureland/secrets.py
cp adventureland/useful/template.variables.js adventureland/node/variables.js
cp adventureland/useful/template.live_variables.js adventureland/node/live_variables.js
```
You'll need to download Python2.7 and use the command that comes along with it - it could be ./python or python.exe depending on your setup method
Here's the download page: https://www.python.org/downloads/release/python-2718/
For Linux:
```sh
apt update
apt upgrade -y
@@ -35,47 +50,54 @@ pip2.7 check
For MacOS pyenv makes sense as it prevents clash between Python versions and allows local versioning by just adding a .python-version to the folder https://github.com/pyenv/pyenv
Make sure to install lxml afterwards:
```sh
pip2.7 install lxml
```
Run the Python2.7 backend - includes an HTTP server, datastore, various utilities - emulates Google App Engine:
```sh
python2.7 appserver/sdk/dev_appserver.py --storage_path=appserver/storage/ --blobstore_path=appserver/storage/blobstore/ --datastore_path=appserver/storage/db.rdbms --host=0.0.0.0 --port=8083 adventureland/ --require_indexes --skip_sdk_update_check
```
Set up the NodeJS project for helpful scripts:
```sh
npm install adventureland/scripts/
python2.7 appserver/sdk/dev_appserver.py --storage_path=appserver/storage/ --blobstore_path=appserver/storage/blobstore/ --datastore_path=appserver/storage/db.rdbms --host=0.0.0.0 --port=80 adventureland/ --require_indexes --skip_sdk_update_check
```
Set up the NodeJS game server:
```sh
npm install adventureland/node/
```
Edit the paths in `adventureland/node/variables.js`
Edit the paths in `adventureland/node/variables.js` if you want to run the server from any path
Enter the path of the NodeJS server:
```sh
cd adventureland/node
```
Run a server:
```sh
node adventureland/node/server.js EU I 8022
```
You should be able to access the game at: http://0.0.0.0:8083/
```sh
node server.js EU I 8022
```
You should be able to access the game at: http://0.0.0.0/
If you're on Windows and have issues with `0.0.0.0` - replace them with `127.0.0.1` and use http://127.0.0.1/
The **useful/** folder has useful commands
`secrets.py` has the secrets
## Network
Add these to your /etc/hosts file:
```sh
0.0.0.0 thegame.com
0.0.0.0 www.thegame.com
```
And setup nginx with a conf such as:
```sh
worker_processes 3;
@@ -130,6 +152,14 @@ I suggest you go live with this development codebase and approach development in
The main problem with traditional MMORPG's is people seeking power and while an offline game can provide this for everyone, an online game cannot. Pretty soon new players will avoid such MMORPG's and existing players will also dwindle. In my opinion there are 2 solutions, you could introduce a decay mechanic to overcome this, or concentrate your innovations and additions to make a more social game rather than a game for power hungry people. Originally I intended to add a lot more social integrations, for example browser notifications integrated to the social hub of the game and easy drop ins to friends playing the game etc. So making a more idle and more social game, with new custom art and a new direction could also be a good option, it's definitely the more serene option that anyone can pursue.
## Code formatting
This project uses [Eslint](https://eslint.org/) and [Prettier](https://prettier.io/).
For now, this is only used inside the game servers (`/node/` folder).
If you use VSCode, please install the recommended extensions for [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). The formatting will be automatically done on save.
If you have suggestions regarding the formatting, feel free to open an issue or discuss it on Discord. [Here is the history](https://discord.com/channels/238332476743745536/1163453037126357074) of the conversation regarding the formatting.
As you might notice, several eslint rules have been marked as warnings instead of errors. This is to allow a smooth and iterative transition. Make sure your new code respects the rules, even the warnings. If you want to submit a PR to fix a specific warning in a specific part of the code, feel free to do so.
## Freelancers
Adventure Land's map designer is available for freelance work or for hire. Contact: markjlacandula@gmail.com
@@ -140,4 +170,4 @@ If you have specific requirements, for example a unique cloud architecture in mi
## License
https://github.com/kaansoral/adventureland/blob/master/LICENSE
https://github.com/kaansoral/adventureland/blob/master/LICENSE
+1 -1
View File
@@ -407,7 +407,7 @@ class MapLister(webapp.RequestHandler):
def map_to_html(m):
return "<div style='margin-bottom: 2px'><a href='%s/%s' target='_blank' style='color: white; font-weight: bold; text-decoration:none'>%s</a></div>"%(url,m.id(),m.id())
html="<style> html{background-color:gray}</style>"
if is_sdk: url="http://thegame.com/admin/map_editor"
if is_sdk: url="%s/admin/map_editor"%(domain.base_url)
else: url="%s/%s"%(domain.base_url,"communitymaps")
if order=="key":
for m in Map.query().fetch(5000,keys_only=True): html+=map_to_html(m)
+25
View File
@@ -0,0 +1,25 @@
{
"extends": ["eslint:recommended", "eslint-config-prettier"],
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 10
},
"plugins": ["prettier"],
"rules": {
"no-constant-condition": "off",
"no-dupe-else-if": "off",
"indent": "off",
"no-empty": "warn",
"no-inner-declarations": "warn",
"no-unreachable": "warn",
"no-undef": "warn",
"no-unused-vars": "warn",
"no-redeclare": "warn",
"curly": "error",
"prettier/prettier": "error",
"one-var": ["error", "never"],
"no-sequences": "error"
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"singleQuote": false,
"printWidth": 120,
"trailingComma": "all",
"semi": true,
"bracketSpacing": true,
"arrowParens": "always",
"useTabs": true
}
-19
View File
@@ -1,19 +0,0 @@
module.exports={
"cfunctions_path":"./server/common_functions.js",
"functions_path":"./server/server_functions.js",
"worker_path":"./server/server_worker.js",
"data_path":"./server/data.js",
"base_url":"https://yourappspoturldontincludedashes.appspot.com",
"keyword":"123",
"master":"123",
"server_master":"123",
"bot_key":"123",
"discord_token":"NDXXXXXXXXXXX...",
"apple_token":"acXXXXXXXX...",
"steam_key":"8aXXXXXXXXX...",
"steam_web_key":"B4XXXXXXX...",
"steam_partner_key":"F9XXXXXXX...",
"close_timeout":24000,
"ip_limit":3,
"character_limit":3,
}
+2863 -1
View File
File diff suppressed because it is too large Load Diff
+19 -7
View File
@@ -5,15 +5,27 @@
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js EU I 8120"
"start": "node server.js EU I 8120",
"lint": "eslint --ext .js .",
"lint:fix": "eslint --fix --ext .js ."
},
"author": "",
"license": "AdventureLandOnlyUse",
"dependencies": {
"socket.io": "^4.0.0",
"request": "^2.88.2",
"range_check": "^1.4.0",
"bytebuffer": "^5.0.1",
"protobufjs": "^6.9.0",
"bytebuffer": "^5.0.1"
}
}
"range_check": "^1.4.0",
"request": "^2.88.2",
"socket.io": "^4.0.0"
},
"devDependencies": {
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.0.3"
},
"eslintIgnore": [
"node_modules/*",
"data.js"
]
}
+33 -25
View File
@@ -1,27 +1,35 @@
var is_game=0,is_server=0,is_code=0;
var variables=require('./variables');
var is_sdk=variables.is_sdk;
var fs=require('fs');
var precomputed=null;
eval(""+fs.readFileSync(variables.cfunctions_path));
eval(""+fs.readFileSync(variables.functions_path));
var mode={},server_id='precompute',server_auth="123456",base_url=variables.base_url;
var is_game = 0;
var is_server = 0;
var is_code = 0;
var variables = require("./variables");
var is_sdk = variables.is_sdk;
var fs = require("fs");
var precomputed = null;
eval("" + fs.readFileSync(variables.cfunctions_path));
eval("" + fs.readFileSync(variables.functions_path));
var mode = {};
var server_id = "precompute";
var server_auth = "123456";
var base_url = variables.base_url;
appengine_call("reload_server",{keyword:variables.keyword},function(result){
if(result.failed) return;
G=result.game;
var start=new Date();
for(var mname in G.maps)
{
if(G.maps[mname].ignore) continue;
var cstart=new Date();
server_bfs(mname);
console.log("Precomputed: "+mname+" in "+mssince(cstart)+"ms");
appengine_call("reload_server", { keyword: variables.keyword }, function (result) {
if (result.failed) {
return;
}
console.log("Done: "+mssince(start)+"ms");
var precomputed={};
precomputed.version=G.version;
precomputed.amap_data=amap_data;
precomputed.smap_data=smap_data;
fs.writeFileSync(variables.data_path,'var precomputed='+JSON.stringify(precomputed)+';');
});
G = result.game;
var start = new Date();
for (var mname in G.maps) {
if (G.maps[mname].ignore) {
continue;
}
var cstart = new Date();
server_bfs(mname);
console.log("Precomputed: " + mname + " in " + mssince(cstart) + "ms");
}
console.log("Done: " + mssince(start) + "ms");
var precomputed = {};
precomputed.version = G.version;
precomputed.amap_data = amap_data;
precomputed.smap_data = smap_data;
fs.writeFileSync(variables.data_path, "var precomputed=" + JSON.stringify(precomputed) + ";");
});
+12577 -8239
View File
File diff suppressed because it is too large Load Diff
+4373 -2918
View File
File diff suppressed because it is too large Load Diff
+22 -17
View File
@@ -1,23 +1,28 @@
var is_game=0,is_server=1,is_code=0;
var variables=require('./variables');
var is_sdk=variables.is_sdk;
var fs=require('fs');
eval(""+fs.readFileSync(variables.cfunctions_path));
eval(""+fs.readFileSync(variables.functions_path));
var {workerData,parentPort}=require('worker_threads');
var G=workerData.G,smap_data=workerData.smap_data,amap_data=workerData.amap_data;
var is_game = 0;
var is_server = 1;
var is_code = 0;
var variables = require("./variables");
var is_sdk = variables.is_sdk;
var fs = require("fs");
eval("" + fs.readFileSync(variables.cfunctions_path));
eval("" + fs.readFileSync(variables.functions_path));
var { workerData, parentPort } = require("worker_threads");
var G = workerData.G;
var smap_data = workerData.smap_data;
var amap_data = workerData.amap_data;
parentPort.on("message",function(data){
try{
parentPort.on("message", function (data) {
try {
//console.log(data);
if(data.type=="fast_astar")
parentPort.postMessage({type:"monster_move",move:fast_astar(data),id:data.id,in:data.in});
if(data.type=="exit") process.exit();
}catch(e){
if (data.type == "fast_astar") {
parentPort.postMessage({ type: "monster_move", move: fast_astar(data), id: data.id, in: data.in });
}
if (data.type == "exit") {
process.exit();
}
} catch (e) {
console.log(e);
}
});
setInterval(function(){
},10);
setInterval(function () {}, 10);
+49 -23
View File
@@ -1,13 +1,14 @@
var crypto=require('crypto');
var protobuf=require('protobufjs'),ByteBuffer=require('bytebuffer');
var crypto = require("crypto");
var protobuf = require("protobufjs");
var ByteBuffer = require("bytebuffer");
function symmetricDecrypt(input, key, checkHmac) {
var aesIv = crypto.createDecipheriv('aes-256-ecb', key, '');
var aesIv = crypto.createDecipheriv("aes-256-ecb", key, "");
aesIv.setAutoPadding(false);
aesIv.end(input.slice(0, 16));
var iv = aesIv.read();
var aesData = crypto.createDecipheriv('aes-256-cbc', key, iv);
var aesData = crypto.createDecipheriv("aes-256-cbc", key, iv);
aesData.end(input.slice(16));
var plaintext = aesData.read();
@@ -24,7 +25,7 @@ function symmetricDecrypt(input, key, checkHmac) {
}
return plaintext;
};
}
function parseAppTicket(ticket) {
// https://github.com/SteamRE/SteamKit/blob/master/Resources/Structs/steam3_appticket.hsl
@@ -70,11 +71,16 @@ function parseAppTicket(ticket) {
// Start reading the ownership ticket
let ownershipTicketOffset = ticket.offset;
let ownershipTicketLength = ticket.readUint32(); // including itself, for some reason
if (ownershipTicketOffset + ownershipTicketLength != ticket.limit && ownershipTicketOffset + ownershipTicketLength + 128 != ticket.limit) {
if (
ownershipTicketOffset + ownershipTicketLength != ticket.limit &&
ownershipTicketOffset + ownershipTicketLength + 128 != ticket.limit
) {
return null;
}
let i, j, dlc;
let i;
let j;
let dlc;
details.version = ticket.readUint32();
details.steamID = ticket.readUint64().toString();
@@ -117,34 +123,54 @@ function parseAppTicket(ticket) {
let date = new Date();
details.isExpired = details.ownershipTicketExpires < date;
details.hasValidSignature = !!details.signature && SteamCrypto.verifySignature(ticket.slice(ownershipTicketOffset, ownershipTicketOffset + ownershipTicketLength).toBuffer(), details.signature);
details.hasValidSignature =
!!details.signature &&
SteamCrypto.verifySignature(
ticket.slice(ownershipTicketOffset, ownershipTicketOffset + ownershipTicketLength).toBuffer(),
details.signature,
);
details.isValid = !details.isExpired && (!details.signature || details.hasValidSignature);
} catch (ex) {
console.log("parseAppTicket: "+ex);
console.log("parseAppTicket: " + ex);
return details;
return null; // not a valid ticket
}
return details;
}
var proto = {
nested: {
EncryptedAppTicket: {
fields: {
ticketVersionNo: { type: "uint32", id: 1 },
crcEncryptedticket: { type: "uint32", id: 2 },
cbEncrypteduserdata: { type: "uint32", id: 3 },
cbEncryptedAppownershipticket: { type: "uint32", id: 4 },
encryptedTicket: { type: "bytes", id: 5 },
},
},
},
};
var proto_root = protobuf.Root.fromJSON(proto);
var EncryptedAppTicket = proto_root.lookupType("EncryptedAppTicket");
var proto={ "nested": {EncryptedAppTicket: { fields:
{ ticketVersionNo: { type: 'uint32', id: 1 },
crcEncryptedticket: { type: 'uint32', id: 2 },
cbEncrypteduserdata: { type: 'uint32', id: 3 },
cbEncryptedAppownershipticket: { type: 'uint32', id: 4 },
encryptedTicket: { type: 'bytes', id: 5 } } }}};
var proto_root=protobuf.Root.fromJSON(proto);
var EncryptedAppTicket=proto_root.lookupType("EncryptedAppTicket");
var outer=EncryptedAppTicket.decode(new Buffer("080110a7e59890031815204f2a80014527ad8cccd8cd9b7d3260529556004ddf0454a1c2e8543495b1eb72b3dff44d9d67555798ef44b7e3f97cf86d3bf1bc3f84a91de415c382b0d96033c8e5398f2b775bcb004f5487c651d81ef410d7d2917cbb407713397d2c29a455b6852eac7db1a0e52248585bd5440ef07de54b7519f67eefbad5420d97b77ef7e35450af","hex"));
var decrypted=symmetricDecrypt(outer.encryptedTicket,new Buffer("8af5c487af6c7709ef1a4e6e2275fcc0a90f57ae4319de793fca3d7ed8655520","hex"));
var outer = EncryptedAppTicket.decode(
new Buffer(
"080110a7e59890031815204f2a80014527ad8cccd8cd9b7d3260529556004ddf0454a1c2e8543495b1eb72b3dff44d9d67555798ef44b7e3f97cf86d3bf1bc3f84a91de415c382b0d96033c8e5398f2b775bcb004f5487c651d81ef410d7d2917cbb407713397d2c29a455b6852eac7db1a0e52248585bd5440ef07de54b7519f67eefbad5420d97b77ef7e35450af",
"hex",
),
);
var decrypted = symmetricDecrypt(
outer.encryptedTicket,
new Buffer("8af5c487af6c7709ef1a4e6e2275fcc0a90f57ae4319de793fca3d7ed8655520", "hex"),
);
let userData = decrypted.slice(0, outer.cbEncrypteduserdata);
let ownershipTicketLength = decrypted.readUInt32LE(outer.cbEncrypteduserdata);
let ownershipTicket = parseAppTicket(decrypted.slice(outer.cbEncrypteduserdata, outer.cbEncrypteduserdata + ownershipTicketLength));
let ownershipTicket = parseAppTicket(
decrypted.slice(outer.cbEncrypteduserdata, outer.cbEncrypteduserdata + ownershipTicketLength),
);
if (ownershipTicket) {
ownershipTicket.userData = userData.toString();
}
console.log(ownershipTicket);
-23
View File
@@ -1,23 +0,0 @@
const path = require("node:path")
module.exports={
"cfunctions_path":path.resolve(__dirname, "../js/common_functions.js"),
"functions_path":path.resolve(__dirname, "server_functions.js"),
"worker_path":path.resolve(__dirname, "server_worker.js"),
"data_path":path.resolve(__dirname, "data.js"),
"base_url":"http://thegame.com",
"keyword":"123",
"master":"123",
"server_master":"123",
"bot_key":"123",
"discord_token":"NDXXXXXXXXXXX...",
"apple_token":"acXXXXXXXX...",
"steam_key":"8aXXXXXXXXX...",
"steam_web_key":"B4XXXXXXX...",
"steam_partner_key":"F9XXXXXXX...",
"is_sdk":1,
"close_timeout":4000,
"ip_limit":3,
"character_limit":3,
"fast_sdk":0,
}
+18
View File
@@ -0,0 +1,18 @@
module.exports = {
cfunctions_path: "./server/common_functions.js",
functions_path: "./server/server_functions.js",
worker_path: "./server/server_worker.js",
data_path: "./server/data.js",
base_url: "https://yourappspoturldontincludedashes.appspot.com",
keyword: "123",
access_master: "123",
bot_key: "123",
discord_token: "NDXXXXXXXXXXX...",
apple_token: "acXXXXXXXX...",
steam_key: "8aXXXXXXXXX...",
steam_web_key: "B4XXXXXXX...",
steam_partner_key: "F9XXXXXXX...",
close_timeout: 24000,
ip_limit: 3,
character_limit: 3,
};
+22
View File
@@ -0,0 +1,22 @@
const path = require("node:path");
module.exports = {
cfunctions_path: path.resolve(__dirname, "../js/common_functions.js"),
functions_path: path.resolve(__dirname, "server_functions.js"),
worker_path: path.resolve(__dirname, "server_worker.js"),
data_path: path.resolve(__dirname, "data.js"),
base_url: "http://thegame.com",
keyword: "123",
access_master: "123",
bot_key: "123",
discord_token: "NDXXXXXXXXXXX...",
apple_token: "acXXXXXXXX...",
steam_key: "8aXXXXXXXXX...",
steam_web_key: "B4XXXXXXX...",
steam_partner_key: "F9XXXXXXX...",
is_sdk: 1,
close_timeout: 4000,
ip_limit: 3,
character_limit: 3,
fast_sdk: 0,
};