mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
security patch and other bug fixes.
This commit is contained in:
parent
99352f0f84
commit
cafc2e0225
20 changed files with 494 additions and 263 deletions
4
dist/ba_root/mods/changelogs.json
vendored
4
dist/ba_root/mods/changelogs.json
vendored
|
|
@ -46,6 +46,10 @@
|
|||
"77": {
|
||||
"log": "system logs, security patch, discord webhook logs dump.",
|
||||
"time": "8 April 2023"
|
||||
},
|
||||
"78": {
|
||||
"log": "security update: auto handle server queue, fake accounts protection, allow owner to join houefull server. And other bug fixes. ",
|
||||
"time": "28 May 2023"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ import ba
|
|||
import ba.internal
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def clientid_to_accountid(clientid):
|
||||
"""
|
||||
Transform Clientid To Accountid
|
||||
|
|
@ -24,9 +21,6 @@ def clientid_to_accountid(clientid):
|
|||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def check_permissions(accountid, command):
|
||||
"""
|
||||
Checks The Permission To Player To Executive Command
|
||||
|
|
@ -44,7 +38,7 @@ def check_permissions(accountid, command):
|
|||
return True
|
||||
|
||||
for role in roles:
|
||||
if accountid in roles[role]["ids"] and "ALL" in roles[role]["commands"]:
|
||||
if accountid in roles[role]["ids"] and "ALL" in roles[role]["commands"]:
|
||||
return True
|
||||
|
||||
elif accountid in roles[role]["ids"] and command in roles[role]["commands"]:
|
||||
|
|
@ -54,5 +48,5 @@ def check_permissions(accountid, command):
|
|||
|
||||
def is_server(accid):
|
||||
for i in ba.internal.get_game_roster():
|
||||
if i['account_id']==accid and i['client_id']==-1:
|
||||
if i['account_id'] == accid and i['client_id'] == -1:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -182,7 +182,8 @@ class Floater(ba.Actor):
|
|||
pn = self.node.position
|
||||
dist = self.distance(pn[0], pn[1], pn[2], px, py, pz)
|
||||
self.node.velocity = ((px - pn[0]) / dist, (py - pn[1]) / dist, (pz - pn[2]) / dist)
|
||||
ba.timer(dist-1, ba.WeakCall(self.move), suppress_format_warning=True)
|
||||
t = dist - 1 if dist - 1 >= 0 else 0.1
|
||||
ba.timer(t, ba.WeakCall(self.move), suppress_format_warning=True)
|
||||
|
||||
def handlemessage(self, msg):
|
||||
if isinstance(msg, ba.DieMessage):
|
||||
|
|
|
|||
12
dist/ba_root/mods/chatHandle/handlechat.py
vendored
12
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -5,7 +5,7 @@ from serverData import serverdata
|
|||
from chatHandle.ChatCommands import Main
|
||||
from tools import logger, servercheck
|
||||
from chatHandle.chatFilter import ChatFilter
|
||||
from features import EndVote
|
||||
from features import votingmachine
|
||||
import ba, _ba
|
||||
import ba.internal
|
||||
import setting
|
||||
|
|
@ -18,7 +18,7 @@ def filter_chat_message(msg, client_id):
|
|||
if msg.startswith("/"):
|
||||
Main.Command(msg, client_id)
|
||||
return None
|
||||
logger.log("Host msg: | " + msg , "chat")
|
||||
logger.log(f"Host msg: | {msg}" , "chat")
|
||||
return msg
|
||||
acid = ""
|
||||
displaystring = ""
|
||||
|
|
@ -36,14 +36,15 @@ def filter_chat_message(msg, client_id):
|
|||
msg = ChatFilter.filter(msg, acid, client_id)
|
||||
if msg == None:
|
||||
return
|
||||
logger.log(acid + " | " + displaystring + " | " + currentname + " | " + msg, "chat")
|
||||
logger.log(f'{acid} | {displaystring}| {currentname} | {msg}', "chat")
|
||||
if msg.startswith("/"):
|
||||
msg = Main.Command(msg, client_id)
|
||||
if msg == None:
|
||||
return
|
||||
|
||||
if msg == "end" and settings["allowEndVote"]:
|
||||
EndVote.vote_end(acid, client_id)
|
||||
if msg in ["end","dv","nv","sm"] and settings["allowVotes"]:
|
||||
votingmachine.vote(acid, client_id, msg)
|
||||
|
||||
|
||||
if acid in serverdata.clients and serverdata.clients[acid]["verified"]:
|
||||
|
||||
|
|
@ -64,7 +65,6 @@ def filter_chat_message(msg, client_id):
|
|||
return Main.QuickAccess(msg, client_id)
|
||||
return msg
|
||||
|
||||
|
||||
else:
|
||||
_ba.screenmessage("Fetching your account info , Wait a minute", transient=True, clients=[client_id])
|
||||
return None
|
||||
|
|
|
|||
92
dist/ba_root/mods/custom_hooks.py
vendored
92
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -8,10 +8,11 @@
|
|||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import annotations
|
||||
from ba._servermode import ServerController
|
||||
from ba._session import Session
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from datetime import datetime
|
||||
|
||||
import _thread
|
||||
import importlib
|
||||
import time
|
||||
|
|
@ -19,19 +20,18 @@ import os
|
|||
import ba
|
||||
import _ba
|
||||
import logging
|
||||
from ba import _hooks
|
||||
from bastd.activity import dualteamscore, multiteamscore, drawscore
|
||||
from bastd.activity.coopscore import CoopScoreScreen
|
||||
import setting
|
||||
|
||||
from tools import account
|
||||
from chatHandle import handlechat
|
||||
from features import team_balancer, afk_check, fire_flies, hearts, dual_team_score as newdts
|
||||
from stats import mystats
|
||||
from spazmod import modifyspaz
|
||||
from tools import servercheck, ServerUpdate, logger, playlist
|
||||
from tools import servercheck, ServerUpdate, logger, playlist, servercontroller
|
||||
from playersData import pdata
|
||||
from serverData import serverdata
|
||||
from features import EndVote
|
||||
from features import votingmachine
|
||||
from features import text_on_map, announcement
|
||||
from features import map_fun
|
||||
from spazmod import modifyspaz
|
||||
|
|
@ -46,19 +46,17 @@ def filter_chat_message(msg: str, client_id: int) -> str | None:
|
|||
return handlechat.filter_chat_message(msg, client_id)
|
||||
|
||||
# ba_meta export plugin
|
||||
|
||||
|
||||
class modSetup(ba.Plugin):
|
||||
def on_app_running(self):
|
||||
"""Runs when app is launched."""
|
||||
bootstraping()
|
||||
servercheck.checkserver().start()
|
||||
ServerUpdate.check()
|
||||
|
||||
ba.timer(5, account.updateOwnerIps)
|
||||
if settings["afk_remover"]['enable']:
|
||||
afk_check.checkIdle().start()
|
||||
if (settings["useV2Account"]):
|
||||
from tools import account
|
||||
|
||||
if (ba.internal.get_v1_account_state() == 'signed_in' and ba.internal.get_v1_account_type() == 'V2'):
|
||||
logging.debug("Account V2 is active")
|
||||
else:
|
||||
|
|
@ -133,17 +131,20 @@ def bootstraping():
|
|||
import subprocess
|
||||
# Install psutil package
|
||||
# Download get-pip.py
|
||||
curl_process = subprocess.Popen(["curl", "-sS", "https://bootstrap.pypa.io/get-pip.py"], stdout=subprocess.PIPE)
|
||||
curl_process = subprocess.Popen(
|
||||
["curl", "-sS", "https://bootstrap.pypa.io/get-pip.py"], stdout=subprocess.PIPE)
|
||||
|
||||
# Install pip using python3.10
|
||||
python_process = subprocess.Popen(["python3.10"], stdin=curl_process.stdout)
|
||||
python_process = subprocess.Popen(
|
||||
["python3.10"], stdin=curl_process.stdout)
|
||||
|
||||
# Wait for the processes to finish
|
||||
curl_process.stdout.close()
|
||||
python_process.wait()
|
||||
|
||||
subprocess.check_call(["python3.10","-m","pip", "install", "psutil"])
|
||||
#restart after installation
|
||||
subprocess.check_call(
|
||||
["python3.10", "-m", "pip", "install", "psutil"])
|
||||
# restart after installation
|
||||
print("dependency installed , restarting server")
|
||||
_ba.quit()
|
||||
from tools import healthcheck
|
||||
|
|
@ -155,8 +156,6 @@ def bootstraping():
|
|||
if settings["whitelist"]:
|
||||
pdata.load_white_list()
|
||||
|
||||
#
|
||||
|
||||
import_discord_bot()
|
||||
import_games()
|
||||
import_dual_team_score()
|
||||
|
|
@ -193,7 +192,7 @@ def import_games():
|
|||
|
||||
def import_dual_team_score() -> None:
|
||||
"""Imports the dual team score."""
|
||||
if settings["newResultBoard"] and _ba.get_foreground_host_session().use_teams:
|
||||
if settings["newResultBoard"]:
|
||||
dualteamscore.TeamVictoryScoreScreenActivity = newdts.TeamVictoryScoreScreenActivity
|
||||
multiteamscore.MultiTeamScoreScreenActivity.show_player_scores = newdts.show_player_scores
|
||||
drawscore.DrawScoreScreenActivity = newdts.DrawScoreScreenActivity
|
||||
|
|
@ -208,8 +207,8 @@ def new_begin(self):
|
|||
night_mode()
|
||||
if settings["colorfullMap"]:
|
||||
map_fun.decorate_map()
|
||||
EndVote.voters = []
|
||||
EndVote.game_started_on = time.time()
|
||||
votingmachine.reset_votes()
|
||||
votingmachine.game_started_on = time.time()
|
||||
|
||||
|
||||
ba._activity.Activity.on_begin = new_begin
|
||||
|
|
@ -224,13 +223,19 @@ def new_end(self, results: Any = None, delay: float = 0.0, force: bool = False):
|
|||
if isinstance(activity, CoopScoreScreen):
|
||||
team_balancer.checkToExitCoop()
|
||||
org_end(self, results, delay, force)
|
||||
|
||||
|
||||
ba._activity.Activity.end = new_end
|
||||
|
||||
org_player_join = ba._activity.Activity.on_player_join
|
||||
|
||||
|
||||
def on_player_join(self, player) -> None:
|
||||
"""Runs when player joins the game."""
|
||||
team_balancer.on_player_join()
|
||||
org_player_join(self, player)
|
||||
|
||||
|
||||
ba._activity.Activity.on_player_join = on_player_join
|
||||
|
||||
|
||||
|
|
@ -277,30 +282,31 @@ def on_map_init():
|
|||
text_on_map.textonmap()
|
||||
modifyspaz.setTeamCharacter()
|
||||
|
||||
from ba._servermode import ServerController
|
||||
|
||||
def shutdown(func) -> None:
|
||||
"""Set the app to quit either now or at the next clean opportunity."""
|
||||
def wrapper(*args, **kwargs):
|
||||
# add screen text and tell players we are going to restart soon.
|
||||
ba.internal.chatmessage("Server will restart on next opportunity. (series end)")
|
||||
_ba.restart_scheduled = True
|
||||
_ba.get_foreground_host_activity().restart_msg = _ba.newnode('text',
|
||||
attrs={
|
||||
'text':"Server going to restart after this series.",
|
||||
'flatness':1.0,
|
||||
'h_align':'right',
|
||||
'v_attach':'bottom',
|
||||
'h_attach':'right',
|
||||
'scale':0.5,
|
||||
'position':(-25,54),
|
||||
'color':(1,0.5,0.7)
|
||||
})
|
||||
func(*args, **kwargs)
|
||||
return wrapper
|
||||
"""Set the app to quit either now or at the next clean opportunity."""
|
||||
def wrapper(*args, **kwargs):
|
||||
# add screen text and tell players we are going to restart soon.
|
||||
ba.internal.chatmessage(
|
||||
"Server will restart on next opportunity. (series end)")
|
||||
_ba.restart_scheduled = True
|
||||
_ba.get_foreground_host_activity().restart_msg = _ba.newnode('text',
|
||||
attrs={
|
||||
'text': "Server going to restart after this series.",
|
||||
'flatness': 1.0,
|
||||
'h_align': 'right',
|
||||
'v_attach': 'bottom',
|
||||
'h_attach': 'right',
|
||||
'scale': 0.5,
|
||||
'position': (-25, 54),
|
||||
'color': (1, 0.5, 0.7)
|
||||
})
|
||||
func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
ServerController.shutdown = shutdown(ServerController.shutdown)
|
||||
|
||||
from ba._session import Session
|
||||
|
||||
def on_player_request(func) -> bool:
|
||||
def wrapper(*args, **kwargs):
|
||||
player = args[1]
|
||||
|
|
@ -309,11 +315,15 @@ def on_player_request(func) -> bool:
|
|||
return False
|
||||
for current_player in args[0].sessionplayers:
|
||||
if current_player.get_v1_account_id() == player.get_v1_account_id():
|
||||
count +=1
|
||||
count += 1
|
||||
if count >= settings["maxPlayersPerDevice"]:
|
||||
_ba.screenmessage("Reached max players limit per device",clients=[player.inputdevice.client_id],transient=True,)
|
||||
_ba.screenmessage("Reached max players limit per device", clients=[player.inputdevice.client_id], transient=True,)
|
||||
return False
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
Session.on_player_request = on_player_request(Session.on_player_request)
|
||||
|
||||
|
||||
ServerController._access_check_response = servercontroller._access_check_response
|
||||
|
|
|
|||
150
dist/ba_root/mods/features/dual_team_score.py
vendored
150
dist/ba_root/mods/features/dual_team_score.py
vendored
|
|
@ -46,17 +46,17 @@ class TeamVictoryScoreScreenActivity(MultiTeamScoreScreenActivity):
|
|||
best_txt = ba.Lstr(resource='bestOfSeriesText',
|
||||
subs=[('${COUNT}',
|
||||
str(session.get_series_length()))])
|
||||
|
||||
# ZoomText(best_txt,
|
||||
# position=(0, 175),
|
||||
# shiftposition=(-250, 175),
|
||||
# shiftdelay=2.5,
|
||||
# flash=False,
|
||||
# trail=False,
|
||||
# h_align='center',
|
||||
# scale=0.25,
|
||||
# color=(0.5, 0.5, 0.5, 1.0),
|
||||
# jitter=3.0).autoretain()
|
||||
if len(self.teams) != 2:
|
||||
ZoomText(best_txt,
|
||||
position=(0, 175),
|
||||
shiftposition=(-250, 175),
|
||||
shiftdelay=2.5,
|
||||
flash=False,
|
||||
trail=False,
|
||||
h_align='center',
|
||||
scale=0.25,
|
||||
color=(0.5, 0.5, 0.5, 1.0),
|
||||
jitter=3.0).autoretain()
|
||||
for team in self.session.sessionteams:
|
||||
ba.timer(
|
||||
i * 0.15 + 0.15,
|
||||
|
|
@ -86,49 +86,94 @@ class TeamVictoryScoreScreenActivity(MultiTeamScoreScreenActivity):
|
|||
def _show_team_name(self, pos_v: float, team: ba.SessionTeam,
|
||||
kill_delay: float, shiftdelay: float) -> None:
|
||||
del kill_delay # Unused arg.
|
||||
ZoomText(ba.Lstr(value='${A}', subs=[('${A}', team.name)]),
|
||||
position=(-250, 260) if pos_v == 65 else (250, 260),
|
||||
shiftposition=(-250, 260) if pos_v == 65 else (250, 260),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
h_align='center',
|
||||
maxwidth=300,
|
||||
scale=0.45,
|
||||
color=team.color,
|
||||
jitter=1.0).autoretain()
|
||||
if len(self.teams) != 2:
|
||||
ZoomText(
|
||||
ba.Lstr(value='${A}:', subs=[('${A}', team.name)]),
|
||||
position=(100, pos_v),
|
||||
shiftposition=(-150, pos_v),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
h_align='right',
|
||||
maxwidth=300,
|
||||
color=team.color,
|
||||
jitter=1.0,
|
||||
).autoretain()
|
||||
else:
|
||||
ZoomText(ba.Lstr(value='${A}', subs=[('${A}', team.name)]),
|
||||
position=(-250, 260) if pos_v == 65 else (250, 260),
|
||||
shiftposition=(-250, 260) if pos_v == 65 else (250, 260),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
h_align='center',
|
||||
maxwidth=300,
|
||||
scale=0.45,
|
||||
color=team.color,
|
||||
jitter=1.0).autoretain()
|
||||
|
||||
def _show_team_old_score(self, pos_v: float, sessionteam: ba.SessionTeam,
|
||||
shiftdelay: float) -> None:
|
||||
ZoomText(str(sessionteam.customdata['score'] - 1),
|
||||
position=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
maxwidth=100,
|
||||
color=(0.6, 0.6, 0.7),
|
||||
shiftposition=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
lifespan=1.0,
|
||||
scale=0.56,
|
||||
h_align='center',
|
||||
jitter=1.0).autoretain()
|
||||
|
||||
if len(self.teams) != 2:
|
||||
ZoomText(
|
||||
str(sessionteam.customdata['score'] - 1),
|
||||
position=(150, pos_v),
|
||||
maxwidth=100,
|
||||
color=(0.6, 0.6, 0.7),
|
||||
shiftposition=(-100, pos_v),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
lifespan=1.0,
|
||||
h_align='left',
|
||||
jitter=1.0,
|
||||
).autoretain()
|
||||
else:
|
||||
ZoomText(str(sessionteam.customdata['score'] - 1),
|
||||
position=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
maxwidth=100,
|
||||
color=(0.6, 0.6, 0.7),
|
||||
shiftposition=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=False,
|
||||
trail=False,
|
||||
lifespan=1.0,
|
||||
scale=0.56,
|
||||
h_align='center',
|
||||
jitter=1.0).autoretain()
|
||||
|
||||
def _show_team_score(self, pos_v: float, sessionteam: ba.SessionTeam,
|
||||
scored: bool, kill_delay: float,
|
||||
shiftdelay: float) -> None:
|
||||
del kill_delay # Unused arg.
|
||||
ZoomText(str(sessionteam.customdata['score']),
|
||||
position=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
maxwidth=100,
|
||||
color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7),
|
||||
shiftposition=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=scored,
|
||||
trail=scored,
|
||||
scale=0.56,
|
||||
h_align='center',
|
||||
jitter=1.0,
|
||||
trailcolor=(1, 0.8, 0.0, 0)).autoretain()
|
||||
if len(self.teams) != 2:
|
||||
ZoomText(
|
||||
str(sessionteam.customdata['score']),
|
||||
position=(150, pos_v),
|
||||
maxwidth=100,
|
||||
color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7),
|
||||
shiftposition=(-100, pos_v),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=scored,
|
||||
trail=scored,
|
||||
h_align='left',
|
||||
jitter=1.0,
|
||||
trailcolor=(1, 0.8, 0.0, 0),
|
||||
).autoretain()
|
||||
else:
|
||||
ZoomText(str(sessionteam.customdata['score']),
|
||||
position=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
maxwidth=100,
|
||||
color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7),
|
||||
shiftposition=(-250, 190) if pos_v == 65 else (250, 190),
|
||||
shiftdelay=shiftdelay,
|
||||
flash=scored,
|
||||
trail=scored,
|
||||
scale=0.56,
|
||||
h_align='center',
|
||||
jitter=1.0,
|
||||
trailcolor=(1, 0.8, 0.0, 0)).autoretain()
|
||||
|
||||
|
||||
# ===================================================================================================
|
||||
|
|
@ -241,6 +286,19 @@ def show_player_scores(self,
|
|||
h_align=Text.HAlign.CENTER,
|
||||
extrascale=1.4,
|
||||
maxwidth=None)
|
||||
else:
|
||||
tval = ba.Lstr(
|
||||
resource='gameLeadersText',
|
||||
subs=[('${COUNT}', str(session.get_game_number()))],
|
||||
)
|
||||
_txt(
|
||||
180,
|
||||
43,
|
||||
tval,
|
||||
h_align=Text.HAlign.CENTER,
|
||||
extrascale=1.4,
|
||||
maxwidth=None,
|
||||
)
|
||||
_txt(-15, 4, ba.Lstr(resource='playerText'), h_align=Text.HAlign.LEFT)
|
||||
_txt(180, 4, ba.Lstr(resource='killsText'))
|
||||
_txt(280, 4, ba.Lstr(resource='deathsText'), maxwidth=100)
|
||||
|
|
|
|||
12
dist/ba_root/mods/features/team_balancer.py
vendored
12
dist/ba_root/mods/features/team_balancer.py
vendored
|
|
@ -27,11 +27,12 @@ def balanceTeams():
|
|||
teamBSize += 1
|
||||
except:
|
||||
pass
|
||||
if abs(teamBSize-teamASize) >= 0:
|
||||
if teamBSize > teamASize and teamBSize != 0:
|
||||
movePlayers(1, 0, abs(teamBSize-teamASize)-1)
|
||||
elif teamASize > teamBSize and teamASize != 0:
|
||||
movePlayers(0, 1, abs(teamBSize-teamASize)-1)
|
||||
if settings["autoTeamBalance"]:
|
||||
if abs(teamBSize-teamASize) >= 0:
|
||||
if teamBSize > teamASize and teamBSize != 0:
|
||||
movePlayers(1, 0, abs(teamBSize-teamASize)-1)
|
||||
elif teamASize > teamBSize and teamASize != 0:
|
||||
movePlayers(0, 1, abs(teamBSize-teamASize)-1)
|
||||
|
||||
|
||||
def movePlayers(fromTeam, toTeam, count):
|
||||
|
|
@ -40,7 +41,6 @@ def movePlayers(fromTeam, toTeam, count):
|
|||
toTeam = session.sessionteams[toTeam]
|
||||
for i in range(0, count):
|
||||
player = fromTeam.players.pop()
|
||||
print("moved"+player.get_v1_account_id())
|
||||
broadCastShiftMsg(player.get_v1_account_id())
|
||||
player.setdata(team=toTeam, character=player.character,
|
||||
color=toTeam.color, highlight=player.highlight)
|
||||
|
|
|
|||
1
dist/ba_root/mods/features/text_on_map.py
vendored
1
dist/ba_root/mods/features/text_on_map.py
vendored
|
|
@ -21,6 +21,7 @@ class textonmap:
|
|||
nextMap=ba.internal.get_foreground_host_session().get_next_game_description().evaluate()
|
||||
except:
|
||||
pass
|
||||
top = top.replace("@IP", _ba.our_ip).replace("@PORT", _ba.our_port)
|
||||
self.index = 0
|
||||
self.highlights = data['center highlights']["msg"]
|
||||
self.left_watermark(left)
|
||||
|
|
|
|||
|
|
@ -1,31 +1,40 @@
|
|||
# EndVote by -mr.smoothy
|
||||
# Electronic Voting Machine (EVM) by -mr.smoothy
|
||||
|
||||
import _ba
|
||||
import ba
|
||||
import ba.internal
|
||||
import time
|
||||
|
||||
last_end_vote_start_time = 0
|
||||
end_vote_duration = 50
|
||||
game_started_on = 0
|
||||
min_game_duration_to_start_end_vote = 30
|
||||
|
||||
voters = []
|
||||
|
||||
|
||||
def vote_end(pb_id, client_id):
|
||||
global voters
|
||||
global last_end_vote_start_time
|
||||
vote_machine = {"end": {"last_vote_start_time": 0, "vote_duration": 50,
|
||||
"min_game_duration_to_start_vote": 30, "voters": []},
|
||||
"sm": {"last_vote_start_time": 0, "vote_duration": 50,
|
||||
"min_game_duration_to_start_vote": 1, "voters": []},
|
||||
"nv": {"last_vote_start_time": 0, "vote_duration": 50,
|
||||
"min_game_duration_to_start_vote": 1, "voters": []},
|
||||
"dv": {"last_vote_start_time": 0, "vote_duration": 50,
|
||||
"min_game_duration_to_start_vote": 1, "voters": []}}
|
||||
|
||||
|
||||
def vote(pb_id, client_id, vote_type):
|
||||
global vote_machine
|
||||
voters = vote_machine[vote_type]["voters"]
|
||||
last_vote_start_time = vote_machine[vote_type]["last_vote_start_time"]
|
||||
vote_duration = vote_machine[vote_type]["vote_duration"]
|
||||
min_game_duration_to_start_vote = vote_machine[vote_type]["min_game_duration_to_start_vote"]
|
||||
|
||||
now = time.time()
|
||||
if now > last_end_vote_start_time + end_vote_duration:
|
||||
if now > last_vote_start_time + vote_duration:
|
||||
voters = []
|
||||
last_end_vote_start_time = now
|
||||
if now < game_started_on + min_game_duration_to_start_end_vote:
|
||||
last_vote_start_time = now
|
||||
if now < game_started_on + min_game_duration_to_start_vote:
|
||||
_ba.screenmessage("Seems game just started, Try again after some time", transient=True,
|
||||
clients=[client_id])
|
||||
return
|
||||
if len(voters) == 0:
|
||||
ba.internal.chatmessage("end vote started")
|
||||
ba.internal.chatmessage(f"{vote_type} vote started")
|
||||
|
||||
# clean up voters list
|
||||
active_players = []
|
||||
|
|
@ -36,25 +45,34 @@ def vote_end(pb_id, client_id):
|
|||
voters.remove(voter)
|
||||
if pb_id not in voters:
|
||||
voters.append(pb_id)
|
||||
_ba.screenmessage("Thanks for vote , encourage other players to type 'end' too.", transient=True,
|
||||
_ba.screenmessage(f'Thanks for vote , encourage other players to type {vote_type} too.', transient=True,
|
||||
clients=[client_id])
|
||||
update_vote_text(required_votes(len(active_players)) - len(voters))
|
||||
if required_votes(len(active_players)) - len(
|
||||
voters) == 3: # lets dont spam chat/screen message with votes required , only give message when only 3 votes left
|
||||
ba.internal.chatmessage("3 more end votes required")
|
||||
if vote_type == 'end':
|
||||
update_vote_text(required_votes(len(active_players)) - len(voters))
|
||||
|
||||
if len(voters) >= required_votes(len(active_players)):
|
||||
ba.internal.chatmessage("end vote succeed")
|
||||
try:
|
||||
with _ba.Context(_ba.get_foreground_host_activity()):
|
||||
_ba.get_foreground_host_activity().end_game()
|
||||
except:
|
||||
pass
|
||||
ba.internal.chatmessage(f"{vote_type} vote succeed")
|
||||
if vote_type == "end":
|
||||
try:
|
||||
with _ba.Context(_ba.get_foreground_host_activity()):
|
||||
_ba.get_foreground_host_activity().end_game()
|
||||
except:
|
||||
pass
|
||||
elif vote_type == "nv":
|
||||
_ba.chatmessage("/nv")
|
||||
elif vote_type == "dv":
|
||||
_ba.chatmessage("/dv")
|
||||
elif vote_type == "sm":
|
||||
_ba.chatmessage("/sm")
|
||||
|
||||
def reset_votes():
|
||||
global vote_machine
|
||||
for value in vote_machine.values():
|
||||
value["voters"] = []
|
||||
|
||||
def required_votes(players):
|
||||
if players == 2:
|
||||
return 1
|
||||
return 2
|
||||
elif players == 3:
|
||||
return 2
|
||||
elif players == 4:
|
||||
2
dist/ba_root/mods/plugins/colorfulmaps2.py
vendored
2
dist/ba_root/mods/plugins/colorfulmaps2.py
vendored
|
|
@ -11,7 +11,7 @@ CONFIGS = {
|
|||
"AdaptivePos": True,
|
||||
"IgnoreOnMaps": [],
|
||||
"Colors": {
|
||||
"Intensity": 0.8,
|
||||
"Intensity": 0.5,
|
||||
"Animate": True,
|
||||
"Random": True,
|
||||
"LeftSide": (1, 0, 1),
|
||||
|
|
|
|||
13
dist/ba_root/mods/setting.json
vendored
13
dist/ba_root/mods/setting.json
vendored
|
|
@ -6,7 +6,7 @@
|
|||
"BrodcastCommand": true
|
||||
},
|
||||
"textonmap": {
|
||||
"top watermark": "Welcome to server \nip 192.168.0.1",
|
||||
"top watermark": "Welcome to server \nIP @IP PORT @PORT",
|
||||
"bottom left watermark": "Owner : <owner-name> \nEditor : <bablu>\nScripts : BCS1.7.13",
|
||||
"center highlights":{
|
||||
"color":[1,0,0],
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
"minPlayerToExitCoop":0
|
||||
},
|
||||
"mikirogQuickTurn":{
|
||||
"enable":true
|
||||
"enable":false
|
||||
},
|
||||
"colorful_explosions":{
|
||||
"enable":true
|
||||
|
|
@ -102,14 +102,21 @@
|
|||
"kick_idle_from_lobby":true,
|
||||
"lobby_idle_time_in_secs":10
|
||||
},
|
||||
"playermod": {
|
||||
"default_boxing_gloves": true,
|
||||
"default_shield" : false,
|
||||
"default_bomb" : "normal",
|
||||
"default_bomb_count" : 1
|
||||
},
|
||||
"allowTeamChat":true,
|
||||
"allowEndVote":true,
|
||||
"allowVotes":true,
|
||||
"allowInGameChat":true,
|
||||
"sameCharacterForTeam":false,
|
||||
"newResultBoard":true,
|
||||
"HostDeviceName":"v1.4",
|
||||
"HostName":"BCS",
|
||||
"ShowKickVoteStarterName":true,
|
||||
"autoTeamBalance": true,
|
||||
"KickVoteMsgType":"chat",
|
||||
"minAgeToChatInHours":78,
|
||||
"minAgeToJoinInHours":24,
|
||||
|
|
|
|||
101
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
101
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
|
|
@ -2,71 +2,80 @@ from spazmod import tag
|
|||
import setting
|
||||
from random import randint
|
||||
from spazmod import hitmessage
|
||||
import _ba,ba
|
||||
import _ba
|
||||
import ba
|
||||
import ba.internal
|
||||
_setting=setting.get_settings_data()
|
||||
_setting = setting.get_settings_data()
|
||||
|
||||
|
||||
if _setting['enableeffects']:
|
||||
from spazmod import spaz_effects
|
||||
spaz_effects.apply()
|
||||
from spazmod import spaz_effects
|
||||
spaz_effects.apply()
|
||||
|
||||
|
||||
def update_name():
|
||||
import ba.internal
|
||||
from stats import mystats
|
||||
stat = mystats.get_all_stats()
|
||||
ros = ba.internal.get_game_roster()
|
||||
for i in ros:
|
||||
if i['account_id']:
|
||||
name = i['display_string']
|
||||
aid = i['account_id']
|
||||
if aid in stat:
|
||||
stat[aid]['name'] = name
|
||||
mystats.dump_stats(stat)
|
||||
import ba.internal
|
||||
from stats import mystats
|
||||
stat = mystats.get_all_stats()
|
||||
ros = ba.internal.get_game_roster()
|
||||
for i in ros:
|
||||
if i['account_id']:
|
||||
name = i['display_string']
|
||||
aid = i['account_id']
|
||||
if aid in stat:
|
||||
stat[aid]['name'] = name
|
||||
mystats.dump_stats(stat)
|
||||
|
||||
# all activites related to modify spaz by any how will be here
|
||||
|
||||
|
||||
def main(spaz, node, player):
|
||||
if _setting['enablehptag']:
|
||||
tag.addhp(node, spaz)
|
||||
if _setting['enabletags']:
|
||||
tag.addtag(node, player)
|
||||
if _setting['enablerank']:
|
||||
tag.addrank(node, player)
|
||||
if _setting["playermod"]['default_boxing_gloves']:
|
||||
spaz.equip_boxing_gloves()
|
||||
if _setting['playermod']['default_shield']:
|
||||
spaz.equip_shields()
|
||||
spaz.bomb_type_default = _setting['playermod']['default_bomb']
|
||||
spaz.bomb_count = _setting['playermod']['default_bomb_count']
|
||||
# update_name() will add threading here later . it was adding delay on game start
|
||||
|
||||
if _setting['enablehptag']:
|
||||
tag.addhp(node, spaz)
|
||||
if _setting['enabletags']:
|
||||
tag.addtag(node,player)
|
||||
if _setting['enablerank']:
|
||||
tag.addrank(node,player)
|
||||
|
||||
#update_name() will add threading here later . it was adding delay on game start
|
||||
def getCharacter(player, character):
|
||||
|
||||
def getCharacter(player,character):
|
||||
if _setting["sameCharacterForTeam"]:
|
||||
|
||||
if _setting["sameCharacterForTeam"]:
|
||||
if "character" in player.team.sessionteam.customdata:
|
||||
|
||||
if "character" in player.team.sessionteam.customdata:
|
||||
return player.team.sessionteam.customdata["character"]
|
||||
|
||||
return player.team.sessionteam.customdata["character"]
|
||||
|
||||
return character
|
||||
return character
|
||||
|
||||
|
||||
def getRandomCharacter(otherthen):
|
||||
characters=list(ba.app.spaz_appearances.keys())
|
||||
invalid_characters=["Snake Shadow","Lee","Zola","Butch","Witch","Middle-Man","Alien","OldLady","Wrestler","Gretel","Robot"]
|
||||
characters = list(ba.app.spaz_appearances.keys())
|
||||
invalid_characters = ["Snake Shadow", "Lee", "Zola", "Butch", "Witch",
|
||||
"Middle-Man", "Alien", "OldLady", "Wrestler", "Gretel", "Robot"]
|
||||
|
||||
while True:
|
||||
val=randint(0,len(characters)-1)
|
||||
ch=characters[val]
|
||||
if ch not in invalid_characters and ch not in otherthen:
|
||||
return ch
|
||||
while True:
|
||||
val = randint(0, len(characters)-1)
|
||||
ch = characters[val]
|
||||
if ch not in invalid_characters and ch not in otherthen:
|
||||
return ch
|
||||
|
||||
|
||||
def setTeamCharacter():
|
||||
if not _setting["sameCharacterForTeam"]:
|
||||
return
|
||||
used=[]
|
||||
teams=ba.internal.get_foreground_host_session().sessionteams
|
||||
if len(teams) < 10:
|
||||
for team in teams:
|
||||
character=getRandomCharacter(used)
|
||||
used.append(character)
|
||||
team.name=character
|
||||
team.customdata["character"]=character
|
||||
|
||||
if not _setting["sameCharacterForTeam"]:
|
||||
return
|
||||
used = []
|
||||
teams = ba.internal.get_foreground_host_session().sessionteams
|
||||
if len(teams) < 10:
|
||||
for team in teams:
|
||||
character = getRandomCharacter(used)
|
||||
used.append(character)
|
||||
team.name = character
|
||||
team.customdata["character"] = character
|
||||
|
|
|
|||
100
dist/ba_root/mods/spazmod/tag.py
vendored
100
dist/ba_root/mods/spazmod/tag.py
vendored
|
|
@ -26,12 +26,12 @@ def addtag(node,player):
|
|||
|
||||
|
||||
def addrank(node,player):
|
||||
session_player=player.sessionplayer
|
||||
account_id=session_player.get_v1_account_id()
|
||||
rank=mystats.getRank(account_id)
|
||||
session_player=player.sessionplayer
|
||||
account_id=session_player.get_v1_account_id()
|
||||
rank=mystats.getRank(account_id)
|
||||
|
||||
if rank:
|
||||
Rank(node,rank)
|
||||
if rank:
|
||||
Rank(node,rank)
|
||||
|
||||
def addhp(node, spaz):
|
||||
def showHP():
|
||||
|
|
@ -44,36 +44,36 @@ def addhp(node, spaz):
|
|||
spaz.hptimer = ba.Timer(100,ba.Call(showHP),repeat = True, timetype=ba.TimeType.SIM, timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
|
||||
class Tag(object):
|
||||
def __init__(self,owner=None,tag="somthing",col=(1,1,1)):
|
||||
self.node=owner
|
||||
def __init__(self,owner=None,tag="somthing",col=(1,1,1)):
|
||||
self.node=owner
|
||||
|
||||
mnode = ba.newnode('math',
|
||||
mnode = ba.newnode('math',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'input1': (0, 1.5, 0),
|
||||
'operation': 'add'
|
||||
})
|
||||
self.node.connectattr('torso_position', mnode, 'input2')
|
||||
if '\\' in tag:
|
||||
self.node.connectattr('torso_position', mnode, 'input2')
|
||||
if '\\' in tag:
|
||||
|
||||
tag = tag.replace('\\d', ('\ue048'))
|
||||
tag = tag.replace('\\c', ('\ue043'))
|
||||
tag = tag.replace('\\h', ('\ue049'))
|
||||
tag = tag.replace('\\s', ('\ue046'))
|
||||
tag = tag.replace('\\n', ('\ue04b'))
|
||||
tag = tag.replace('\\f', ('\ue04f'))
|
||||
tag = tag.replace('\\g', ('\ue027'))
|
||||
tag = tag.replace('\\i', ('\ue03a'))
|
||||
tag = tag.replace('\\m', ('\ue04d'))
|
||||
tag = tag.replace('\\t', ('\ue01f'))
|
||||
tag = tag.replace('\\bs', ('\ue01e'))
|
||||
tag = tag.replace('\\j', ('\ue010'))
|
||||
tag = tag.replace('\\e', ('\ue045'))
|
||||
tag = tag.replace('\\l', ('\ue047'))
|
||||
tag = tag.replace('\\a', ('\ue020'))
|
||||
tag = tag.replace('\\b', ('\ue00c'))
|
||||
tag = tag.replace('\\d', ('\ue048'))
|
||||
tag = tag.replace('\\c', ('\ue043'))
|
||||
tag = tag.replace('\\h', ('\ue049'))
|
||||
tag = tag.replace('\\s', ('\ue046'))
|
||||
tag = tag.replace('\\n', ('\ue04b'))
|
||||
tag = tag.replace('\\f', ('\ue04f'))
|
||||
tag = tag.replace('\\g', ('\ue027'))
|
||||
tag = tag.replace('\\i', ('\ue03a'))
|
||||
tag = tag.replace('\\m', ('\ue04d'))
|
||||
tag = tag.replace('\\t', ('\ue01f'))
|
||||
tag = tag.replace('\\bs', ('\ue01e'))
|
||||
tag = tag.replace('\\j', ('\ue010'))
|
||||
tag = tag.replace('\\e', ('\ue045'))
|
||||
tag = tag.replace('\\l', ('\ue047'))
|
||||
tag = tag.replace('\\a', ('\ue020'))
|
||||
tag = tag.replace('\\b', ('\ue00c'))
|
||||
|
||||
self.tag_text = ba.newnode('text',
|
||||
self.tag_text = ba.newnode('text',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'text': tag,
|
||||
|
|
@ -84,31 +84,41 @@ class Tag(object):
|
|||
'scale': 0.01,
|
||||
'h_align': 'center'
|
||||
})
|
||||
mnode.connectattr('output', self.tag_text, 'position')
|
||||
if sett["enableTagAnimation"]:
|
||||
ba.animate_array(node=self.tag_text, attr='color', size=3, keys={
|
||||
0.2: (2,0,2),
|
||||
0.4: (2,2,0),
|
||||
0.6: (0,2,2),
|
||||
0.8: (2,0,2),
|
||||
1.0: (1,1,0),
|
||||
1.2: (0,1,1),
|
||||
1.4: (1,0,1)
|
||||
}, loop=True)
|
||||
mnode.connectattr('output', self.tag_text, 'position')
|
||||
if sett["enableTagAnimation"]:
|
||||
ba.animate_array(node=self.tag_text, attr='color', size=3, keys={
|
||||
0.2: (2,0,2),
|
||||
0.4: (2,2,0),
|
||||
0.6: (0,2,2),
|
||||
0.8: (2,0,2),
|
||||
1.0: (1,1,0),
|
||||
1.2: (0,1,1),
|
||||
1.4: (1,0,1)
|
||||
}, loop=True)
|
||||
class Rank(object):
|
||||
def __init__(self,owner=None,rank=99):
|
||||
self.node=owner
|
||||
mnode = ba.newnode('math',
|
||||
def __init__(self,owner=None,rank=99):
|
||||
self.node=owner
|
||||
mnode = ba.newnode('math',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'input1': (0, 1.2, 0),
|
||||
'operation': 'add'
|
||||
})
|
||||
self.node.connectattr('torso_position', mnode, 'input2')
|
||||
self.rank_text = ba.newnode('text',
|
||||
self.node.connectattr('torso_position', mnode, 'input2')
|
||||
if (rank == 1):
|
||||
rank = '\ue01f' + "#"+str(rank) +'\ue01f'
|
||||
elif (rank ==2):
|
||||
rank = '\ue01f' + "#"+str(rank) +'\ue01f'
|
||||
elif (rank ==3):
|
||||
rank = '\ue01f' + "#"+str(rank) +'\ue01f'
|
||||
else:
|
||||
rank = "#"+str(rank)
|
||||
|
||||
|
||||
self.rank_text = ba.newnode('text',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'text': "#"+str(rank),
|
||||
'text': rank,
|
||||
'in_world': True,
|
||||
'shadow': 1.0,
|
||||
'flatness': 1.0,
|
||||
|
|
@ -116,7 +126,7 @@ class Rank(object):
|
|||
'scale': 0.01,
|
||||
'h_align': 'center'
|
||||
})
|
||||
mnode.connectattr('output', self.rank_text, 'position')
|
||||
mnode.connectattr('output', self.rank_text, 'position')
|
||||
|
||||
class HitPoint(object):
|
||||
def __init__(self,position = (0,1.5,0),owner = None,prefix = '0',shad = 1.2):
|
||||
|
|
|
|||
2
dist/ba_root/mods/stats/mystats.py
vendored
2
dist/ba_root/mods/stats/mystats.py
vendored
|
|
@ -101,7 +101,7 @@ def dump_stats(s: dict):
|
|||
|
||||
|
||||
def get_stats_by_id(account_id: str):
|
||||
a = get_cached_stats
|
||||
a = get_cached_stats()
|
||||
if account_id in a:
|
||||
return a[account_id]
|
||||
else:
|
||||
|
|
|
|||
2
dist/ba_root/mods/tools/ServerUpdate.py
vendored
2
dist/ba_root/mods/tools/ServerUpdate.py
vendored
|
|
@ -6,7 +6,7 @@ from efro.terminal import Clr
|
|||
import json
|
||||
import requests
|
||||
import _ba
|
||||
VERSION=77
|
||||
VERSION=78
|
||||
|
||||
def check():
|
||||
|
||||
|
|
|
|||
42
dist/ba_root/mods/tools/account.py
vendored
42
dist/ba_root/mods/tools/account.py
vendored
|
|
@ -2,21 +2,23 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import ba
|
||||
import _ba
|
||||
import bacommon.cloud
|
||||
import logging
|
||||
from efro.error import CommunicationError
|
||||
|
||||
from playersData import pdata
|
||||
|
||||
|
||||
STATUS_CHECK_INTERVAL_SECONDS = 2.0
|
||||
|
||||
|
||||
class AccountUtil:
|
||||
def __init__(self):
|
||||
self._proxyid: str | None = None
|
||||
self._proxykey: str | None = None
|
||||
ba.internal.sign_out_v1()
|
||||
ba.app.cloud.send_message_cb(bacommon.cloud.LoginProxyRequestMessage(),
|
||||
on_response=ba.Call(self._on_proxy_request_response))
|
||||
on_response=ba.Call(self._on_proxy_request_response))
|
||||
|
||||
def _on_proxy_request_response(self, response: bacommon.cloud.LoginProxyRequestResponse | Exception) -> None:
|
||||
if isinstance(response, Exception):
|
||||
|
|
@ -26,7 +28,7 @@ class AccountUtil:
|
|||
return
|
||||
address = ba.internal.get_master_server_address(
|
||||
version=2) + response.url
|
||||
logging.debug("Copy this URL to your browser : " +address)
|
||||
logging.debug("Copy this URL to your browser : " + address)
|
||||
self._proxyid = response.proxyid
|
||||
self._proxykey = response.proxykey
|
||||
ba.timer(STATUS_CHECK_INTERVAL_SECONDS,
|
||||
|
|
@ -47,9 +49,9 @@ class AccountUtil:
|
|||
# with a vague error message. Can be more verbose later if need be.
|
||||
if (isinstance(response, bacommon.cloud.LoginProxyStateQueryResponse)
|
||||
and response.state is response.State.FAIL):
|
||||
logging.error("error occured ..terminating login request")
|
||||
logging.critical("Falling back to V1 account")
|
||||
ba.internal.sign_in_v1('Local')
|
||||
logging.error("error occured ..terminating login request")
|
||||
logging.critical("Falling back to V1 account")
|
||||
ba.internal.sign_in_v1('Local')
|
||||
|
||||
# If we got a token, set ourself as signed in. Hooray!
|
||||
if (isinstance(response, bacommon.cloud.LoginProxyStateQueryResponse)
|
||||
|
|
@ -57,7 +59,7 @@ class AccountUtil:
|
|||
assert response.credentials is not None
|
||||
ba.app.accounts_v2.set_primary_credentials(response.credentials)
|
||||
|
||||
ba.timer(3,self._logged_in)
|
||||
ba.timer(3, self._logged_in)
|
||||
|
||||
return
|
||||
|
||||
|
|
@ -66,15 +68,19 @@ class AccountUtil:
|
|||
or response.state is response.State.WAITING):
|
||||
ba.timer(STATUS_CHECK_INTERVAL_SECONDS,
|
||||
ba.Call(self._ask_for_status))
|
||||
def _logged_in(self):
|
||||
logging.info("Logged in as: "+ba.internal.get_v1_account_display_string())
|
||||
|
||||
# #ba_meta export plugin
|
||||
# class AccountV2(ba.Plugin):
|
||||
# def __init__(self):
|
||||
# if(ba.internal.get_v1_account_state()=='signed_in' and ba.internal.get_v1_account_type()=='V2'):
|
||||
# logging.debug("Account V2 is active")
|
||||
# else:
|
||||
# logging.warning("Account V2 login require ....stay tuned.")
|
||||
# ba.timer(3, ba.Call(logging.debug,"Starting Account V2 login process...."))
|
||||
# ba.timer(6,AccountUtil)
|
||||
def _logged_in(self):
|
||||
logging.info("Logged in as: " +
|
||||
ba.internal.get_v1_account_display_string())
|
||||
|
||||
|
||||
def updateOwnerIps():
|
||||
accountIds = pdata.get_roles()["owner"]["ids"]
|
||||
profiles = pdata.get_profiles()
|
||||
|
||||
for account_id in accountIds:
|
||||
if account_id in profiles:
|
||||
profile = profiles[account_id]
|
||||
if "lastIP" in profile:
|
||||
ip = profile["lastIP"]
|
||||
_ba.append_owner_ip(ip)
|
||||
|
|
|
|||
29
dist/ba_root/mods/tools/servercheck.py
vendored
29
dist/ba_root/mods/tools/servercheck.py
vendored
|
|
@ -27,7 +27,7 @@ class checkserver(object):
|
|||
def start(self):
|
||||
self.players = []
|
||||
|
||||
self.t1 = ba.timer(1, ba.Call(self.check), repeat=True)
|
||||
self.t1 = ba.Timer(1, ba.Call(self.check), repeat=True, timetype=ba.TimeType.REAL)
|
||||
|
||||
def check(self):
|
||||
newPlayers = []
|
||||
|
|
@ -36,6 +36,10 @@ class checkserver(object):
|
|||
for ros in ba.internal.get_game_roster():
|
||||
ip = _ba.get_client_ip(ros["client_id"])
|
||||
device_id = _ba.get_client_public_device_uuid(ros["client_id"])
|
||||
# if not ros["account_id"]:
|
||||
# logger.log(f'Player disconnected, None account Id || {ros["display_string"] } IP {ip} {device_id}' ,
|
||||
# "playerjoin")
|
||||
# ba.internal.disconnect_client(ros["client_id"], 0)
|
||||
if device_id not in deviceClientMap:
|
||||
deviceClientMap[device_id] = [ros["client_id"]]
|
||||
else:
|
||||
|
|
@ -43,7 +47,7 @@ class checkserver(object):
|
|||
if len(deviceClientMap[device_id]) >= settings['maxAccountPerIP']:
|
||||
_ba.chatmessage(f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.", clients=[ros["client_id"]])
|
||||
ba.internal.disconnect_client(ros["client_id"])
|
||||
logger.log(" Player disconnected, reached max players per device ||"+ ros["account_id"] ,
|
||||
logger.log(f'Player disconnected, reached max players per device || {ros["account_id"]}' ,
|
||||
"playerjoin")
|
||||
continue
|
||||
if ip not in ipClientMap:
|
||||
|
|
@ -53,7 +57,7 @@ class checkserver(object):
|
|||
if len(ipClientMap[ip]) >= settings['maxAccountPerIP']:
|
||||
_ba.chatmessage(f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.", clients=[ros["client_id"]])
|
||||
ba.internal.disconnect_client(ros["client_id"])
|
||||
logger.log(" Player disconnected, reached max players per IP address ||"+ ros["account_id"] ,
|
||||
logger.log(f'Player disconnected, reached max players per IP address || {ros["account_id"]}' ,
|
||||
"playerjoin")
|
||||
continue
|
||||
newPlayers.append(ros['account_id'])
|
||||
|
|
@ -65,8 +69,9 @@ class checkserver(object):
|
|||
d_str2 = profanity.censor(d_str)
|
||||
try:
|
||||
logger.log(
|
||||
d_str + "||" + ros["account_id"] + "|| joined server",
|
||||
f'{d_str} || {ros["account_id"]} || joined server',
|
||||
"playerjoin")
|
||||
logger.log(f'{ros["account_id"]} {ip} {device_id}')
|
||||
except:
|
||||
pass
|
||||
if d_str2 != d_str:
|
||||
|
|
@ -75,8 +80,7 @@ class checkserver(object):
|
|||
color=(1, 0, 0), transient=True,
|
||||
clients=[ros['client_id']])
|
||||
try:
|
||||
logger.log(d_str + "||" + ros[
|
||||
"account_id"] + "|| kicked by profanity check",
|
||||
logger.log(f'{d_str} || { ros["account_id"] } || kicked by profanity check',
|
||||
"sys")
|
||||
except:
|
||||
pass
|
||||
|
|
@ -88,8 +92,7 @@ class checkserver(object):
|
|||
_ba.screenmessage("Not in whitelist,contact admin",
|
||||
color=(1, 0, 0), transient=True,
|
||||
clients=[ros['client_id']])
|
||||
logger.log(d_str + "||" + ros[
|
||||
"account_id"] + " | kicked > not in whitelist")
|
||||
logger.log(f'{d_str} || { ros["account_id"]} | kicked > not in whitelist')
|
||||
ba.internal.disconnect_client(ros['client_id'])
|
||||
|
||||
return
|
||||
|
|
@ -124,7 +127,7 @@ def on_player_join_server(pbid, player_data, ip):
|
|||
_ba.screenmessage("Joining too fast , slow down dude",
|
||||
color=(1, 0, 1), transient=True,
|
||||
clients=[clid])
|
||||
logger.log(pbid + "|| kicked for joining too fast")
|
||||
logger.log(f'{pbid} || kicked for joining too fast')
|
||||
ba.internal.disconnect_client(clid)
|
||||
_thread.start_new_thread(reportSpam, (pbid,))
|
||||
return
|
||||
|
|
@ -198,7 +201,7 @@ def on_player_join_server(pbid, player_data, ip):
|
|||
|
||||
# pdata.add_profile(pbid,d_string,d_string)
|
||||
|
||||
def check_ban(clid,pbid):
|
||||
def check_ban(clid, pbid):
|
||||
ip = _ba.get_client_ip(clid)
|
||||
|
||||
device_id = _ba.get_client_public_device_uuid(clid)
|
||||
|
|
@ -230,7 +233,7 @@ def verify_account(pb_id, p_data):
|
|||
serverdata.clients[pb_id]["verified"] = True
|
||||
|
||||
|
||||
# ============== IGNORE BLOW CODE , ELSE DIE =======================
|
||||
# ============== IGNORE BELOW CODE =======================
|
||||
|
||||
def _make_request_safe(request, retries=2, raise_err=True):
|
||||
try:
|
||||
|
|
@ -262,10 +265,6 @@ def get_account_creation_date(pb_id):
|
|||
# Convert to IST
|
||||
creation_time += datetime.timedelta(hours=5, minutes=30)
|
||||
return str(creation_time)
|
||||
# now = datetime.datetime.now()
|
||||
# delta = now - creation_time
|
||||
# delta_hours = delta.total_seconds() / (60 * 60)
|
||||
# return delta_hours
|
||||
|
||||
|
||||
def get_device_accounts(pb_id):
|
||||
|
|
|
|||
114
dist/ba_root/mods/tools/servercontroller.py
vendored
Normal file
114
dist/ba_root/mods/tools/servercontroller.py
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
from efro.terminal import Clr
|
||||
import _ba
|
||||
import ba
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _access_check_response(self, data) -> None:
|
||||
|
||||
if data is None:
|
||||
print('error on UDP port access check (internet down?)')
|
||||
else:
|
||||
addr = data['address']
|
||||
port = data['port']
|
||||
|
||||
addrstr = f' {addr}'
|
||||
poststr = ''
|
||||
_ba.our_ip = addr
|
||||
_ba.our_port = port
|
||||
if data['accessible']:
|
||||
# _fetch_public_servers()
|
||||
_ba.queue_chcker_timer = ba.Timer(8, ba.Call(simple_queue_checker), repeat=True, timetype=ba.TimeType.REAL)
|
||||
print(
|
||||
f'{Clr.SBLU}Master server access check of{addrstr}'
|
||||
f' udp port {port} succeeded.\n'
|
||||
f'Your server appears to be'
|
||||
f' joinable from the internet .{poststr}{Clr.RST}'
|
||||
)
|
||||
if self._config.party_is_public:
|
||||
print(
|
||||
f'{Clr.SBLU}Your party {self._config.party_name}'
|
||||
f' visible in public party list.{Clr.RST}'
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f'{Clr.SBLU}Your private party {self._config.party_name}'
|
||||
f'can be joined by {addrstr} {port}.{Clr.RST}'
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f'{Clr.SRED}Master server access check of{addrstr}'
|
||||
f' udp port {port} failed.\n'
|
||||
f'Your server does not appear to be'
|
||||
f' joinable from the internet. Please check your firewall or instance security group.{poststr}{Clr.RST}'
|
||||
)
|
||||
|
||||
|
||||
def _fetch_public_servers():
|
||||
ba.internal.add_transaction(
|
||||
{
|
||||
'type': 'PUBLIC_PARTY_QUERY',
|
||||
'proto': ba.app.protocol_version,
|
||||
'lang': ba.app.lang.language,
|
||||
},
|
||||
callback=ba.Call(_on_public_party_response),
|
||||
)
|
||||
ba.internal.run_transactions()
|
||||
|
||||
def _on_public_party_response(result):
|
||||
if result is None:
|
||||
return
|
||||
parties_in = result['l']
|
||||
queue_id = None
|
||||
for party_in in parties_in:
|
||||
addr = party_in['a']
|
||||
assert isinstance(addr, str)
|
||||
port = party_in['p']
|
||||
assert isinstance(port, int)
|
||||
if addr == _ba.our_ip and str(port) == str(_ba.our_port):
|
||||
queue_id = party_in['q']
|
||||
# aah sad , public party result dont include our own server
|
||||
if queue_id:
|
||||
_ba.our_queue_id = queue_id
|
||||
_ba.queue_chcker_timer = ba.timer(6, ba.Call(check_queue), repeat=True)
|
||||
else:
|
||||
print("Something is wrong , why our server is not in public list.")
|
||||
def check_queue():
|
||||
ba.internal.add_transaction(
|
||||
{'type': 'PARTY_QUEUE_QUERY', 'q': _ba.our_queue_id},
|
||||
callback=ba.Call(on_update_response),
|
||||
)
|
||||
ba.internal.run_transactions()
|
||||
# lets dont spam our own queue
|
||||
ba.internal.add_transaction(
|
||||
{'type': 'PARTY_QUEUE_REMOVE', 'q': _ba.our_queue_id}
|
||||
)
|
||||
ba.internal.run_transactions()
|
||||
|
||||
def on_update_response(response):
|
||||
allowed_to_join = response["c"]
|
||||
players_in_queue = response["e"]
|
||||
max_allowed_in_server = _ba.app.server._config.max_party_size
|
||||
current_players = len(_ba.get_game_roster())
|
||||
# print(allowed_to_join)
|
||||
if allowed_to_join:
|
||||
# looks good , yipee
|
||||
_ba.set_public_party_queue_enabled(True)
|
||||
return
|
||||
if not allowed_to_join and len(players_in_queue) > 1 and current_players < max_allowed_in_server:
|
||||
# something is wrong , lets disable queue for some time
|
||||
_ba.set_public_party_queue_enabled(False)
|
||||
|
||||
def simple_queue_checker():
|
||||
max_allowed_in_server = _ba.app.server._config.max_party_size
|
||||
current_players = len(_ba.get_game_roster())
|
||||
|
||||
if current_players < max_allowed_in_server:
|
||||
_ba.set_public_party_queue_enabled(False)
|
||||
else:
|
||||
_ba.set_public_party_queue_enabled(True)
|
||||
|
||||
|
||||
BIN
dist/bombsquad_headless
vendored
BIN
dist/bombsquad_headless
vendored
Binary file not shown.
BIN
dist/bombsquad_headless_aarch64
vendored
BIN
dist/bombsquad_headless_aarch64
vendored
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue