Skip to content

Commit

Permalink
Implement custom commands (client console) loading (ABCxFF#63)
Browse files Browse the repository at this point in the history
* Update dma.js

* add config for custom commands

* implement custom commands & add docs

* Update config.js

* this should work

* test (ABCxFF#77)

* guardiaaaaaaan

* tiny fixes?

* fix the summoner again probably

* fix bug in bosses and dominator (ABCxFF#64)

* Update FallenOverlord.ts

* Update Dominator.ts

* fix bugs in bosses and dominator

* mothership gamemode (ABCxFF#61)

* Add files via upload

* Add files via upload

* Update Arena.ts

* Update Game.ts

* Update index.ts

* Update Mothership.ts

* Update Mothership.ts

* Update Mothership.ts

* Update Mothership.ts

* Update Mothership.ts

* Update Mothership.ts

* Update Mothership.ts

* Update index.ts

* Update Mothership.ts

* Update Mothership.ts

* circle on rect more accurate

* docs: fix license link (ABCxFF#65)

* patch(ABCxFF#59): disable flags and movement on disconnection

* patch some mothership stuff (ABCxFF#66)

* patch some mothership stuff

- removed a random bug
- changed colors to accurate and also added color map
- made mothership stop being possessed after 10 minutes
- changed "hasFinished" prop to a new state in ArenaState in preparation for Domination and Tagmode

* sort scoreboard by health

* rework spawns

Co-authored-by: c86ec23b-fef1-4979-b2fa-b9adc351b8cc <87239823+c86ec23b-fef1-4979-b2fa-b9adc351b8cc@users.noreply.github.com>

* chore

* annoying

* undo deletion

* drone ai doesn't care if inputs deleted

* cleanup

* cleanup (remove useless imports and code)

* cleanup

* fix: allow utf-8 in changelog (and all other content served)

* fix domination once again

* cleanup and bugs

* remove useless stuff probably

* Update Mothership.ts

* fix: domination "peaceful" bases do not kill bases anymore (ABCxFF#67)

* checks for pushFactor before deleting

* fix: mothership implemented

* patch some mothership stuff

- removed a random bug
- changed colors to accurate and also added color map
- made mothership stop being possessed after 10 minutes
- changed "hasFinished" prop to a new state in ArenaState in preparation for Domination and Tagmode

* sort scoreboard by health

* rework spawns

* merge conflict + fix up mothership

* fix barrels shooting from opposite team on first creation

* Update TeamEntity.ts

Co-authored-by: c86ec23b-fef1-4979-b2fa-b9adc351b8cc <87239823+c86ec23b-fef1-4979-b2fa-b9adc351b8cc@users.noreply.github.com>

* fix: let non teamed players get broadcasted on death of mot

Co-authored-by: ABC <[email protected]>

* feat: barrel addons and "swarm" (ABCxFF#69)

* fix: double ai view range of swarm drones

* ALLOW PUSH TO MAIN

* add back license spaces

Co-authored-by: ABC <[email protected]>

Co-authored-by: c86ec23b-fef1-4979-b2fa-b9adc351b8cc <87239823+c86ec23b-fef1-4979-b2fa-b9adc351b8cc@users.noreply.github.com>
Co-authored-by: ABCxFF <[email protected]>
Co-authored-by: Somka000 <[email protected]>

* Create Commands.ts

* modularize possession of ais

* add command parser

* implement custom commands on the client

* redo fix (ABCxFF#1 probably)

:')

* redo fix (2 :x)

* implement other util clientside commands

* add getTankByName func

* send accessLevel to client

* fix typo

* fix Clientinputs for ai possessing

* update endpoints

- made /servers only serve running servers
- added /commands

* import commanddefs

* fix next weird bug :d

* Update loader.js

* add semicolon

* add config option for custom commands

* implement execution prevention option for remote commands

* endpoint /commands results in empty array if command execution is disabled

* change to hasOwnProperty

* use map instead of object, also verbose client logging

Co-authored-by: c86ec23b-fef1-4979-b2fa-b9adc351b8cc <87239823+c86ec23b-fef1-4979-b2fa-b9adc351b8cc@users.noreply.github.com>
Co-authored-by: ABCxFF <[email protected]>
Co-authored-by: Somka000 <[email protected]>
  • Loading branch information
4 people authored Nov 21, 2022
1 parent 693442f commit ea211c0
Show file tree
Hide file tree
Showing 8 changed files with 728 additions and 112 deletions.
91 changes: 88 additions & 3 deletions client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,16 @@ const MOD_CONFIG = {
"loadVectorDone": 22,
"loadChangelog": 447,
"loadTankDefinitions": 277,
"getTankDefinition": 101
"getTankDefinition": 101,
"findCommand": 496
},
"memory": {
"gamemodeButtons": 113480,
"changelog": 167328,
"changelogLoaded": 168632,
"tankDefinitions": 166572,
"tankDefinitionsCount": 166576
"tankDefinitionsCount": 166576,
"commandList": 53064
},
"wasmFunctionHookOffset": {
"gamemodeButtons": 33,
Expand All @@ -274,9 +276,92 @@ const ADDON_MAP = {
}
};

const CUSTOM_COMMANDS = [
{
"id": "test",
"description": "Test command to check if custom commands are working, prints 'Hello World' to the console",
"callback": args => { // array of strings, you need to parse them yourself
console.log("Hello World");
}
}, {
"id": "util_reload_servers",
"usage": "[?interval]",
"description": "Sets the interval in which gamemodes are reloaded automatically (milliseconds, 'never' or 'connect') or reloads once if no interval is given",
"callback": args => {
if(args[0]) {
const num = parseInt(args[0]);
if(isNaN(num)) {
switch(args[0]) {
case "never":
return Module.reloadServersInterval = -1;
case "connect":
return Module.reloadServersInterval = -2;
}
}
return Module.reloadServersInterval = num;
}
Game.reloadServers();
}
}, {
"id": "util_reload_tanks",
"usage": "[?interval]",
"description": "Sets the interval in which tanks are reloaded automatically (milliseconds, 'never' or 'connect') or reloads once if no interval is given",
"callback": args => {
if(args[0]) {
const num = parseInt(args[0]);
if(isNaN(num)) {
switch(args[0]) {
case "never":
return Module.reloadTanksInterval = -1;
case "connect":
return Module.reloadTanksInterval = -2;
}
}
return Module.reloadTanksInterval = num;
}
Game.reloadTanks();
}
}, {
"id": "util_reload_commands",
"usage": "[?interval]",
"description": "Sets the interval in which commands are reloaded automatically (milliseconds, 'never' or 'connect') or reloads once if no interval is given",
"callback": args => {
if(args[0]) {
const num = parseInt(args[0]);
if(isNaN(num)) {
switch(args[0]) {
case "never":
return Module.reloadCommandsInterval = -1;
case "connect":
return Module.reloadCommandsInterval = -2;
}
}
return Module.reloadCommandsInterval = num;
}
Game.reloadCommands();
}
}, {
"id": "util_set_changelog",
"usage": "[line 1\\n] [line 2] ...",
"description": "Sets the changelog to the given text, remember to use \\n before and after each line",
"callback": args => {
Game.changeChangelog(args.join(' ').split("\\n"));
}
}
];

const COMMANDS_LOOKUP = {
"con_toggle": 52952,
"game_spawn": 52992,
"help": 49956,
"lb_reconnect": 50056,
"net_replace_color": 50152,
"net_replace_colors": 50192,
"ui_replace_colors": 49916
};

const WASM_TABLE = {
"initial": 687,
"maximum": 687,
"element": "anyfunc"
};

Expand Down
48 changes: 43 additions & 5 deletions client/dma.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,48 @@ const setupDMAHelpers = () => {
$.write(ptr + offset, type, value);
}

$.List = class LinkedList {
constructor(ptr, type, typeSize) {
this.ptr = ptr;
this.type = type;
this.typeSize = typeSize;
}

push(...entries) {
for(const entry of entries) this._append(this._end, entry);
this.length += entries.length;
}

forEach(cb) {
let current = $(this.ptr);
while(current.i32) {
cb(current.i32);
current = current.$;
}
}

get length() {
return $(this.ptr)[4].i32;
}

set length(val) {
$.write(this.ptr + 4, "u32", val);
}

get _end() {
let current = $(this.ptr);
while(current.i32) current = current.$;
return current.at;
}

_append(last, entry) {
const ptr = Module.exports.malloc(this.typeSize);
$.write(ptr, this.type, entry);
$.write(last, "$", ptr);
}
}


$.Vector = class Vector {
constructor(ptr, type, typeSize) {
this.ptr = ptr;
Expand All @@ -56,11 +98,7 @@ const setupDMAHelpers = () => {
Module.HEAPU8.subarray(this.start, this.maxCapacity).fill(0);
}

delete() {
this._free();
}

_free() {
destroy() {
Module.exports.free(this.start);
this.start = 0;
this.end = 0;
Expand Down
Loading

0 comments on commit ea211c0

Please sign in to comment.