otp: Basic access level support in preperation for Magic Words

This commit is contained in:
Little Cat 2021-06-14 05:21:33 -03:00
parent ca2286b470
commit 13c2df29ed
No known key found for this signature in database
GPG key ID: 68CC2B4D0E5AF41C
5 changed files with 630 additions and 7 deletions

View file

@ -1,3 +1,4 @@
<<<<<<< Updated upstream
from direct.distributed import DistributedObject/AI/UD from direct.distributed import DistributedObject/AI/UD
from direct.distributed import DistributedNode/AI/UD from direct.distributed import DistributedNode/AI/UD
from direct.distributed import DistributedSmoothNode/AI from direct.distributed import DistributedSmoothNode/AI
@ -61,6 +62,7 @@ dclass AstronAccount {
string CREATED db; string CREATED db;
string LAST_LOGIN db; string LAST_LOGIN db;
string ACCOUNT_ID db; string ACCOUNT_ID db;
string ACCESS_LEVEL db;
}; };
struct BarrierData { struct BarrierData {
@ -252,6 +254,7 @@ dclass DistributedPlayer : DistributedAvatar {
WishNameState(string = "LOCKED") db ram; WishNameState(string = "LOCKED") db ram;
setPreviousAccess(uint8 = 0) required db airecv; setPreviousAccess(uint8 = 0) required db airecv;
setAccess(uint8 = 2) broadcast ownrecv required ram airecv; setAccess(uint8 = 2) broadcast ownrecv required ram airecv;
setAccessLevel(uint16 accessLevel = 0) ownrecv required airecv;
setAsGM(bool = 0) required ram broadcast ownrecv airecv; setAsGM(bool = 0) required ram broadcast ownrecv airecv;
}; };
@ -546,3 +549,554 @@ dclass AstronLoginManager : DistributedObject {
requestPlayAvatar(uint32) clsend; requestPlayAvatar(uint32) clsend;
}; };
=======
from direct.distributed import DistributedObject/AI/UD
from direct.distributed import DistributedNode/AI/UD
from direct.distributed import DistributedSmoothNode/AI
from direct.distributed import DistributedCartesianGrid/AI
from direct.distributed import DistributedCamera/AI/OV
from otp.distributed import Account/AI/UD
from otp.distributed import AstronAccount/AI/UD
from otp.ai import TimeManager/AI
from otp.ai import MagicWordManager/AI
from otp.avatar import DistributedAvatar/AI/UD
from otp.avatar import DistributedPlayer/AI
from otp.friends import FriendManager/AI
from otp.friends import AvatarFriendsManager/UD
from otp.friends import PlayerFriendsManager/UD
from otp.friends import GuildManager/AI/UD
from otp.friends import FriendInfo
from otp.friends import AvatarFriendInfo
from otp.distributed import ObjectServer/AI/UD
from otp.distributed import DistributedDistrict/AI/UD
from otp.distributed import DistributedDirectory/AI
from otp.distributed import DistributedTestObject/AI
from otp.snapshot import SnapshotDispatcher/AI/UD
from otp.snapshot import SnapshotRenderer/AI/UD
from otp.uberdog import OtpAvatarManager/AI/UD
from otp.uberdog import DistributedChatManager/AI/UD
from otp.uberdog import SpeedchatRelay/UD
from otp.distributed import CentralLogger/AI/UD
from otp.web import SettingsMgr/AI/UD
from otp.status import StatusDatabase/UD
from otp.avatar import AvatarHandle
from otp.login import AstronLoginManager/UD
typedef uint8 bool;
typedef uint32 DoId;
typedef DoId DoIdList[];
struct AvatarPendingDel {
uint32 Avatar;
uint32 date;
};
dclass Account {
string DcObjectType db;
uint32[] ACCOUNT_AV_SET required db;
uint32[] pirateAvatars required db;
uint32[] HOUSE_ID_SET db;
uint32 ESTATE_ID db;
AvatarPendingDel ACCOUNT_AV_SET_DEL[] db;
string PLAYED_MINUTES db;
string PLAYED_MINUTES_PERIOD db;
string CREATED db;
string LAST_LOGIN db;
};
dclass AstronAccount {
uint32[] ACCOUNT_AV_SET required db;
uint32 ESTATE_ID db;
AvatarPendingDel ACCOUNT_AV_SET_DEL[] db;
string CREATED db;
string LAST_LOGIN db;
string ACCOUNT_ID db;
string ACCESS_LEVEL db;
};
struct BarrierData {
uint16 context;
string name;
uint32 avIds[];
};
dclass DistributedObject {
setBarrierData(BarrierData []) broadcast ram;
setBarrierReady(uint16) airecv clsend;
execCommand(string, uint32, uint32, uint32);
broadcastMessage() broadcast;
};
dclass DistributedTestObject : DistributedObject {
uint32 AutoInterest[];
setParentingRules(string, string) broadcast ram;
setRequiredField(uint32) required broadcast ram;
setB(uint32) broadcast;
setBA(uint32) broadcast airecv;
setBO(uint32) broadcast ownsend;
setBR(uint32) broadcast ram;
setBRA(uint32) broadcast ram airecv;
setBRO(uint32) broadcast ram ownsend;
setBROA(uint32) broadcast ram ownsend airecv;
};
struct OSInfo {
string name;
int16 platform;
int16 major;
int16 minor;
};
struct CPUSpeed {
int32/1000 maxSpeed;
int32/1000 currentSpeed;
};
dclass TimeManager : DistributedObject {
requestServerTime(uint8) airecv clsend;
serverTime(uint8, int32, uint32);
setDisconnectReason(uint8) airecv clsend;
setExceptionInfo(string(0-1024)) airecv clsend;
setSignature(string(0-1024), blob, blob) airecv clsend;
setFrameRate(uint16/10, uint16/1000, uint16, string(0-256), uint32/10, uint32/10, string(0-256), uint16, uint16, uint32/10, uint32/10, uint32/10, uint32, OSInfo, CPUSpeed, uint16, uint16, string(0-256)) airecv clsend;
setCpuInfo(string(0-1024), string) airecv clsend;
checkForGarbageLeaks(bool) airecv clsend;
setNumAIGarbageLeaks(uint32);
setClientGarbageLeak(uint32, string(0-1024)) airecv clsend;
checkAvOnDistrict(uint32, DoId) clsend airecv;
checkAvOnDistrictResult(uint32, DoId, bool);
};
dclass ObjectServer {
setName(string) airecv ram required;
setDcHash(uint32) ram required;
setDateCreated(uint32) airecv;
};
dclass DistributedDirectory : DistributedObject {
setParentingRules(string, string) broadcast ram;
};
dclass DistributedDistrict : DistributedObject {
setName(string) required broadcast ram;
setAvailable(uint8) required broadcast ram;
};
dclass DistributedNode : DistributedObject {
setParentStr(blob) broadcast ram ownsend airecv;
setParent(uint32) broadcast ram ownsend airecv;
setX(int16/10) broadcast ram ownsend airecv;
setY(int16/10) broadcast ram ownsend airecv;
setZ(int16/10) broadcast ram ownsend airecv;
setH(int16%360/10) broadcast ram ownsend airecv;
setP(int16%360/10) broadcast ram ownsend airecv;
setR(int16%360/10) broadcast ram ownsend airecv;
setPos : setX, setY, setZ;
setHpr : setH, setP, setR;
setPosHpr : setX, setY, setZ, setH, setP, setR;
setXY : setX, setY;
setXZ : setX, setZ;
setXYH : setX, setY, setH;
setXYZH : setX, setY, setZ, setH;
};
dclass DistributedSmoothNode : DistributedNode {
setComponentL(uint64) broadcast ram ownsend airecv;
setComponentX(int16/10) broadcast ram ownsend airecv;
setComponentY(int16/10) broadcast ram ownsend airecv;
setComponentZ(int16/10) broadcast ram ownsend airecv;
setComponentH(int16%360/10) broadcast ram ownsend airecv;
setComponentP(int16%360/10) broadcast ram ownsend airecv;
setComponentR(int16%360/10) broadcast ram ownsend airecv;
setComponentT(int16) broadcast ram ownsend airecv;
setSmStop : setComponentT;
setSmH : setComponentH, setComponentT;
setSmZ : setComponentZ, setComponentT;
setSmXY : setComponentX, setComponentY, setComponentT;
setSmXZ : setComponentX, setComponentZ, setComponentT;
setSmPos : setComponentX, setComponentY, setComponentZ, setComponentT;
setSmHpr : setComponentH, setComponentP, setComponentR, setComponentT;
setSmXYH : setComponentX, setComponentY, setComponentH, setComponentT;
setSmXYZH : setComponentX, setComponentY, setComponentZ, setComponentH, setComponentT;
setSmPosHpr : setComponentX, setComponentY, setComponentZ, setComponentH, setComponentP, setComponentR, setComponentT;
setSmPosHprL : setComponentL, setComponentX, setComponentY, setComponentZ, setComponentH, setComponentP, setComponentR, setComponentT;
clearSmoothing(int8) broadcast ownsend;
suggestResync(uint32, int16, int16, int32, uint16, uint16/100) ownrecv clsend;
returnResync(uint32, int16, int32, uint16, uint16/100) ownrecv clsend;
};
dclass DistributedCartesianGrid : DistributedNode {
setCellWidth(uint32) required broadcast ram;
setParentingRules(string, string) broadcast ram;
};
struct Fixture {
int32/10 x;
int32/10 y;
int32/10 z;
int16/10 h;
int16/10 p;
int16/10 r;
string state;
};
dclass DistributedCamera : DistributedNode {
setCamParent(uint32) required broadcast ram ownsend airecv;
setFixtures(Fixture []) required broadcast ram ownsend airecv;
};
struct TalkModification {
uint16 offset;
uint16 size;
};
dclass TalkPath_owner {
setTalk(uint32, uint32, string(0-256), string(0-400), TalkModification [], uint8) broadcast ownsend;
};
dclass TalkPath_whisper {
setTalkWhisper(uint32, uint32, string(0-256), string(0-400), TalkModification [], uint8) ownrecv clsend;
};
dclass TalkPath_group {
setTalkGroup(uint32, uint32, string(0-256), string(0-400), TalkModification [], uint8) clsend airecv;
};
dclass TalkPath_account {
setTalkAccount(uint32, uint32, string(0-256), string(0-400), TalkModification [], uint8) airecv clsend;
};
dclass AvatarHandle : TalkPath_whisper {
};
dclass DistributedAvatar : DistributedSmoothNode, TalkPath_owner, TalkPath_whisper {
string DcObjectType db;
setName(string = "Avatar") required broadcast db airecv;
friendsNotify(int32, int8) ownrecv airecv clsend;
checkAvOnShard(uint32) clsend airecv;
confirmAvOnShard(uint32, int8);
};
struct FriendEntry {
uint32 friendId;
uint8 friendCode;
};
dclass DistributedPlayer : DistributedAvatar {
arrivedOnDistrict(uint32) ownrecv ram;
setAccountName(string = "") required ownrecv db;
setWhisperFrom(uint32, string(0-256), uint32) ownrecv clsend;
setWhisperWLFrom(uint32, string(0-256), uint32) ownrecv clsend;
setWhisperSCFrom(uint32, uint16) ownrecv clsend;
setWhisperSCCustomFrom(uint32, uint16) ownrecv clsend;
setWhisperSCEmoteFrom(uint32, uint16) ownrecv clsend;
setSystemMessage(uint32, string(0-256)) ownrecv;
setCommonChatFlags(uint8) broadcast ownrecv ram airecv;
setWhitelistChatFlags(uint8) broadcast ownrecv ram airecv;
setSC(uint16) broadcast ownsend airecv;
setSCCustom(uint16) broadcast ownsend airecv;
setFriendsList(FriendEntry[] = []) ownrecv required db airecv;
setDISLname(string) broadcast ownrecv ram;
setDISLid(uint32 = 0) broadcast ownrecv ram db airecv required;
OwningAccount(uint32);
WishName(string = "") db ram;
WishNameState(string = "LOCKED") db ram;
setPreviousAccess(uint8 = 0) required db airecv;
setAccess(uint8 = 2) broadcast ownrecv required ram airecv;
setAccessLevel(uint16 accessLevel = 0) ownrecv required airecv;
setAsGM(bool = 0) required ram broadcast ownrecv airecv;
};
dclass MagicWordManager : DistributedObject {
setMagicWord(string, uint32, uint32, string(0-256)) airecv clsend;
setMagicWordResponse(string) airecv;
setWho(uint32[]) airecv clsend;
};
dclass OtpAvatarManager : DistributedObject {
online();
requestAvatarList(uint32) airecv clsend;
rejectAvatarList(uint32);
avatarListResponse(blob);
requestAvatarSlot(uint32, uint32, uint8) clsend airecv;
rejectAvatarSlot(uint32, uint32, uint8);
avatarSlotResponse(uint32, uint8);
requestPlayAvatar(uint32, uint32, uint32) clsend airecv;
rejectPlayAvatar(uint32, uint32);
playAvatarResponse(uint32, uint32, uint8, uint8);
rejectCreateAvatar(uint32);
createAvatarResponse(uint32, uint32, uint8, uint8);
requestRemoveAvatar(uint32, uint32, uint32, string(0-256)) airecv clsend;
rejectRemoveAvatar(uint32);
removeAvatarResponse(uint32, uint32);
requestShareAvatar(uint32, uint32, uint32, uint8) airecv clsend;
rejectShareAvatar(uint32);
shareAvatarResponse(uint32, uint32, uint8);
};
dclass DistributedChatManager : DistributedObject {
online();
adminChat(uint32, string);
setAvatarLocation(uint32, uint32, uint32);
setAvatarCrew(uint32, uint32);
setAvatarGuild(uint32, uint32);
chatParentId(uint32) airecv clsend;
chatZoneId(uint32) airecv clsend;
chatFace(uint32) airecv clsend;
chatEmote(uint16) airecv clsend;
chatEmoteTarget(uint32) airecv clsend;
chatIndex(uint16) airecv clsend;
chatString(string(0-256)) airecv clsend;
chatToAvatarIndex : chatZoneId, chatIndex;
chatParentZoneFaceEmoteWithTargetIndex : chatParentId, chatZoneId, chatFace, chatEmote, chatEmoteTarget, chatIndex;
chatToAvatarString : chatZoneId, chatString;
chatParentZoneFaceEmoteWithTargetString : chatParentId, chatZoneId, chatFace, chatEmote, chatEmoteTarget, chatString;
speedChatTo(uint16) airecv clsend;
speedChatFrom(uint32, uint16);
speedChatCustomTo(uint16) airecv clsend;
speedChatCustomFrom(uint32, uint16);
whisperSCTo(uint32, uint16) airecv clsend;
whisperSCFrom(uint32, uint16);
whisperSCCustomTo(uint32, uint16) airecv clsend;
whisperSCCustomFrom(uint32, uint16);
whisperSCEmoteTo(uint32, uint16) airecv clsend;
whisperSCEmoteFrom(uint32, uint16);
whisperIgnored(uint32);
};
dclass FriendManager : DistributedObject {
friendQuery(int32) airecv clsend;
cancelFriendQuery(int32) airecv clsend;
inviteeFriendConsidering(int8, int32) airecv clsend;
inviteeFriendResponse(int8, int32) airecv clsend;
inviteeAcknowledgeCancel(int32) airecv clsend;
friendConsidering(int8, int32);
friendResponse(int8, int32);
inviteeFriendQuery(int32, string, blob, int32);
inviteeCancelFriendQuery(int32);
requestSecret() airecv clsend;
requestSecretResponse(int8, string);
submitSecret(string(0-256)) airecv clsend;
submitSecretResponse(int8, int32);
};
struct FriendInfo {
string avatarName;
uint32 avatarId;
string playerName;
uint8 onlineYesNo;
uint8 openChatEnabledYesNo;
uint8 openChatFriendshipYesNo;
uint8 wlChatEnabledYesNo;
string location;
string sublocation;
uint32 timestamp;
};
struct AvatarFriendInfo {
string avatarName;
string playerName;
uint32 playerId;
uint8 onlineYesNo;
uint8 openChatEnabledYesNo;
uint8 openChatFriendshipYesNo;
uint8 wlChatEnabledYesNo;
};
struct MemberInfo {
uint32 avatarId;
string avatarName;
uint8 avatarRank;
uint8 avatarOnline;
uint32 bandManagerId;
uint32 bandId;
};
struct leaderBoardRecordResponces {
char found;
uint32 id;
string text;
int32 value;
};
struct leaderBoardRecord {
uint32 id;
string text;
int32 value;
};
dclass LeaderBoardReceiver {
getTopTenResponce(string, leaderBoardRecord []);
getValuesResponce(string, leaderBoardRecordResponces []);
};
dclass LeaderBoard : LeaderBoardReceiver {
setValue(string [], uint32, string, int32);
alterValue(string [], uint32, string, int32);
setHighScore(string [], uint32, string, int32);
getValues(string, uint32 []);
getTopTen(string);
getValuesRespondTo(string, uint32 [], uint32);
getTopTenRespondTo(string, uint32);
};
dclass GuildManager : DistributedObject, LeaderBoardReceiver, TalkPath_group {
online();
guildRejectInvite(uint32, uint32);
invitationFrom(uint32, string, uint32, string);
requestInvite(uint32) airecv clsend;
memberList() airecv clsend;
createGuild() airecv clsend;
acceptInvite() airecv clsend;
declineInvite() airecv clsend;
setWantName(string(0-256)) airecv clsend;
removeMember(uint32) airecv clsend;
changeRank(uint32, uint8) airecv clsend;
changeRankAvocate(uint32) airecv clsend;
statusRequest() airecv clsend;
requestLeaderboardTopTen() airecv clsend;
guildStatusUpdate(uint32, string(0-256), uint8);
guildNameReject(uint32);
guildNameChange(string, uint8);
receiveMember(MemberInfo);
receiveMembersDone();
guildAcceptInvite(uint32);
guildDeclineInvite(uint32);
updateRep(uint32, uint32);
leaderboardTopTen(leaderBoardRecord []);
recvAvatarOnline(uint32, string, uint32, uint32);
recvAvatarOffline(uint32, string);
sendChat(string(0-256), uint8, uint32) airecv clsend;
sendWLChat(string(0-256), uint8, uint32) airecv clsend;
sendSC(uint16) airecv clsend;
sendSCQuest(uint16, uint16, uint16) airecv clsend;
recvChat(uint32, string, uint8, uint32);
recvWLChat(uint32, string, uint8, uint32);
recvSC(uint32, uint16);
recvSCQuest(uint32, uint16, uint16, uint16);
sendTokenRequest() airecv clsend;
recvTokenGenerated(string);
recvTokenInviteValue(string, int8);
sendTokenForJoinRequest(string(0-256), string(0-256)) airecv clsend;
recvTokenRedeemMessage(string);
recvTokenRedeemedByPlayerMessage(string);
sendTokenRValue(string(0-256), int8) airecv clsend;
sendPermToken() airecv clsend;
sendNonPermTokenCount() airecv clsend;
recvPermToken(string);
recvNonPermTokenCount(uint8);
sendClearTokens(uint8) airecv clsend;
sendAvatarBandId(uint32, uint32, uint32);
recvMemberAdded(MemberInfo, uint32, string);
notifyGuildKicksMaxed();
recvMemberRemoved(uint32, uint32, string, string);
recvMemberUpdateName(uint32, string);
recvMemberUpdateRank(uint32, uint32, string, string, uint8, bool);
recvMemberUpdateBandId(uint32, uint32, uint32);
avatarOnline(uint32, uint16);
avatarOffline(uint32);
reflectTeleportQuery(uint32, uint32, uint32, uint32, uint32) clsend airecv;
teleportQuery(uint32, uint32, uint32, uint32, uint32);
reflectTeleportResponse(uint32, int8, uint32, uint32, uint32) clsend airecv;
teleportResponse(uint32, int8, uint32, uint32, uint32);
requestGuildMatesList(uint32, uint32, uint32);
updateAvatarName(uint32, string);
avatarDeleted(uint32);
};
dclass AvatarFriendsManager : DistributedObject {
online();
requestInvite(uint32) airecv clsend;
friendConsidering(uint32) airecv clsend;
invitationFrom(uint32, string);
retractInvite(uint32);
rejectInvite(uint32, uint32);
requestRemove(uint32) airecv clsend;
rejectRemove(uint32, uint32);
updateAvatarFriend(uint32, AvatarFriendInfo);
removeAvatarFriend(uint32);
updateAvatarName(uint32, string);
avatarOnline(uint32, uint32, string, bool, bool, string, string);
avatarOffline(uint32);
};
dclass PlayerFriendsManager : DistributedObject, TalkPath_account {
requestInvite(uint32, uint32, uint8) airecv clsend;
invitationFrom(uint32, string);
retractInvite(uint32);
invitationResponse(uint32, uint16, uint32);
requestDecline(uint32, uint32) airecv clsend;
requestDeclineWithReason(uint32, uint32, uint32) airecv clsend;
requestRemove(uint32, uint32) airecv clsend;
secretResponse(string);
rejectSecret(string);
rejectUseSecret(string);
updatePlayerFriend(uint32, FriendInfo, uint8);
removePlayerFriend(uint32);
};
dclass SnapshotDispatcher : DistributedObject {
online();
requestRender(uint32);
avatarDeleted(uint32);
requestNewWork(uint32);
errorFetchingAvatar(uint32, uint32);
errorRenderingAvatar(uint32, uint32);
renderSuccessful(uint32, uint32);
};
dclass SnapshotRenderer : DistributedObject {
online();
requestRender(uint32, uint32, string);
};
dclass SpeedchatRelay : DistributedObject, TalkPath_account {
forwardSpeedchat(uint32, uint8, uint32 [], uint32, string(0-256), uint8) clsend;
};
dclass CentralLogger : DistributedObject {
sendMessage(string(0-256), string(0-1024), uint32, uint32) clsend;
logAIGarbage() airecv;
};
dclass SettingsMgr : DistributedObject {
requestAllChangedSettings() airecv clsend;
settingChange(string, string) airecv;
};
dclass StatusDatabase : DistributedObject {
requestOfflineAvatarStatus(uint32 []) airecv clsend;
recvOfflineAvatarStatus(uint32, uint32);
};
dclass CallbackObject {
callback(uint32, bool, uint8);
};
struct PotentialAvatar {
uint32 avNum;
string avName;
blob avDNA;
uint8 avPosition;
uint8 nameState;
};
dclass AstronLoginManager : DistributedObject {
requestLogin(string) clsend;
loginResponse(blob);
requestAvatarList() clsend;
avatarListResponse(PotentialAvatar[]);
createAvatar(blob, uint8) clsend;
createAvatarResponse(uint32);
setNamePattern(uint32, int16, uint8, int16, uint8, int16, uint8, int16, uint8) clsend;
namePatternAnswer(uint32, uint8);
setNameTyped(uint32, string) clsend;
nameTypedResponse(uint32, uint8);
acknowledgeAvatarName(uint32) clsend;
acknowledgeAvatarNameResponse();
requestRemoveAvatar(uint32) clsend;
requestPlayAvatar(uint32) clsend;
};
>>>>>>> Stashed changes

View file

@ -42,6 +42,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
self._districtWeAreGeneratedOn = None self._districtWeAreGeneratedOn = None
self.DISLname = '' self.DISLname = ''
self.DISLid = 0 self.DISLid = 0
self.accessLevel = 0
self.autoRun = 0 self.autoRun = 0
self.whiteListEnabled = base.config.GetBool('whitelist-chat-enabled', 1) self.whiteListEnabled = base.config.GetBool('whitelist-chat-enabled', 1)
@ -453,3 +454,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
def getAutoRun(self): def getAutoRun(self):
return self.autoRun return self.autoRun
def setAccessLevel(self, accessLevel):
self.accessLevel = accessLevel

View file

@ -14,6 +14,7 @@ class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.Pl
self.friendsList = [] self.friendsList = []
self.DISLname = '' self.DISLname = ''
self.DISLid = 0 self.DISLid = 0
self.accessLevel = 0
if __dev__: if __dev__:
@ -109,6 +110,9 @@ class DistributedPlayerAI(DistributedAvatarAI.DistributedAvatarAI, PlayerBase.Pl
def setDISLid(self, id): def setDISLid(self, id):
self.DISLid = id self.DISLid = id
def setAccessLevel(self, accessLevel):
self.accessLevel = accessLevel
def d_setFriendsList(self, friendsList): def d_setFriendsList(self, friendsList):
self.sendUpdate('setFriendsList', [friendsList]) self.sendUpdate('setFriendsList', [friendsList])

View file

@ -7,6 +7,8 @@ from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
from direct.distributed.PyDatagram import * from direct.distributed.PyDatagram import *
from otp.otpbase import OTPGlobals
from toontown.makeatoon.NameGenerator import NameGenerator from toontown.makeatoon.NameGenerator import NameGenerator
from toontown.toon.ToonDNA import ToonDNA from toontown.toon.ToonDNA import ToonDNA
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
@ -43,15 +45,37 @@ class DeveloperAccountDB(AccountDB):
# Check if this play token exists in the dbm: # Check if this play token exists in the dbm:
if str(playToken) not in self.dbm: if str(playToken) not in self.dbm:
# It is not, so we'll associate them with a brand new account object. # It is not, so we'll associate them with a brand new account object.
# Get the default access level from config.
accessLevel = config.GetString('default-access-level', "SYSTEM_ADMIN")
if accessLevel not in OTPGlobals.AccessLevelName2Int:
self.loginManager.notify.warning(f'Access Level "{accessLevel}" isn\'t defined. Reverting back to SYSTEM_ADMIN')
accessLevel = "SYSTEM_ADMIN"
callback({'success': True, callback({'success': True,
'accountId': 0, 'accountId': 0,
'databaseId': playToken}) 'databaseId': playToken,
'accessLevel': accessLevel})
else:
def handleAccount(dclass, fields):
if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']:
result = {'success': False,
'reason': 'Your account object (%s) was not found in the database!' % dclass}
else: else:
# We already have an account object, so we'll just return what we have. # We already have an account object, so we'll just return what we have.
callback({'success': True, result = {'success': True,
'accountId': int(self.dbm[playToken]), 'accountId': int(self.dbm[playToken]),
'databaseId': playToken}) 'databaseId': playToken,
'accessLevel': fields.get('ACCESS_LEVEL', 'NO_ACCESS')}
callback(result)
# Query the account from Astron to verify its existance. We need to get
# the ACCESS_LEVEL field anyways.
# TODO: Add a timeout timer?
self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId,
int(self.dbm[playToken]), handleAccount,
self.loginManager.air.dclassesByName['AstronAccountUD'],
('ACCESS_LEVEL',))
class GameOperation: class GameOperation:
@ -89,6 +113,7 @@ class LoginOperation(GameOperation):
return return
self.databaseId = result.get('databaseId', 0) self.databaseId = result.get('databaseId', 0)
self.accessLevel = result.get('accessLevel', 0)
accountId = result.get('accountId', 0) accountId = result.get('accountId', 0)
if accountId: if accountId:
self.accountId = accountId self.accountId = accountId
@ -114,7 +139,8 @@ class LoginOperation(GameOperation):
'ACCOUNT_AV_SET_DEL': [], 'ACCOUNT_AV_SET_DEL': [],
'CREATED': time.ctime(), 'CREATED': time.ctime(),
'LAST_LOGIN': time.ctime(), 'LAST_LOGIN': time.ctime(),
'ACCOUNT_ID': str(self.databaseId)} 'ACCOUNT_ID': str(self.databaseId),
'ACCESS_LEVEL': self.accessLevel}
self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId,
self.loginManager.air.dclassesByName['AstronAccountUD'], self.loginManager.air.dclassesByName['AstronAccountUD'],
@ -162,6 +188,13 @@ class LoginOperation(GameOperation):
# set client state to established, thus un-sandboxing the sender # set client state to established, thus un-sandboxing the sender
self.loginManager.air.setClientState(self.sender, 2) self.loginManager.air.setClientState(self.sender, 2)
# Update the last login timestamp.
self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.accountId,
self.loginManager.air.dclassesByName['AstronAccountUD'],
{'LAST_LOGIN': time.ctime(),
'ACCOUNT_ID': str(self.databaseId),
'ACCESS_LEVEL': self.accessLevel})
responseData = { responseData = {
'returnCode': 0, 'returnCode': 0,
'respString': '', 'respString': '',
@ -600,8 +633,11 @@ class LoadAvatarOperation(AvatarOperation):
self.__handleSetAvatar() self.__handleSetAvatar()
def __handleSetAvatar(self): def __handleSetAvatar(self):
# Get the client channel.
channel = self.loginManager.GetAccountConnectionChannel(self.sender) channel = self.loginManager.GetAccountConnectionChannel(self.sender)
# We will first assign a POST_REMOVE that will unload the
# avatar in the event of them disconnecting while we are working.
cleanupDatagram = PyDatagram() cleanupDatagram = PyDatagram()
cleanupDatagram.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM) cleanupDatagram.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
cleanupDatagram.addUint32(self.avId) cleanupDatagram.addUint32(self.avId)
@ -611,7 +647,12 @@ class LoadAvatarOperation(AvatarOperation):
datagram.appendData(cleanupDatagram.getMessage()) datagram.appendData(cleanupDatagram.getMessage())
self.loginManager.air.send(datagram) self.loginManager.air.send(datagram)
self.loginManager.air.sendActivate(self.avId, 0, 0, self.loginManager.air.dclassesByName['DistributedToonUD']) # Get the avatar's "true" access (that is, the integer value that corresponds to the assigned string value).
accessLevel = self.account.get('ACCESS_LEVEL', 'NO_ACCESS')
accessLevel = OTPGlobals.AccessLevelName2Int.get(accessLevel, 0)
self.loginManager.air.sendActivate(self.avId, 0, 0, self.loginManager.air.dclassesByName['DistributedToonUD'],
{'setAccessLevel': (accessLevel,)})
datagram = PyDatagram() datagram = PyDatagram()
datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL) datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)

View file

@ -355,3 +355,23 @@ AccessInvalid = 3
AvatarPendingCreate = -1 AvatarPendingCreate = -1
AvatarSlotUnavailable = -2 AvatarSlotUnavailable = -2
AvatarSlotAvailable = -3 AvatarSlotAvailable = -3
AccessLevelName2Int = {
'RESTRICTED': -100,
'NO_ACCESS': 0,
'MODERATOR': 100,
'DEVELOPER': 200,
'ADMIN': 300,
'SYSTEM_ADMIN': 400,
}
AccessLevelInt2Name = {v: k for k, v in AccessLevelName2Int.items()}
AccessLevelDebug2Name = {
'RESTRICTED': 'Banned',
'NO_ACCESS': 'Player',
'MODERATOR': 'Mod',
'DEVELOPER': 'Developer',
'ADMIN': 'Admin',
'SYSTEM_ADMIN': 'Sysadmin',
}