-
Notifications
You must be signed in to change notification settings - Fork 17
Players and misc. stuff #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
luasoft10
wants to merge
18
commits into
RBLXDecomp:master
Choose a base branch
from
luasoft10:players
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3936efe
Players
luasoft10 d342d70
what the dog doin
luasoft10 a5e5231
whitespace police
luasoft10 3788ed0
newlines
luasoft10 671d123
oops
luasoft10 c95c76e
a few more functions
luasoft10 94726d0
a few more
luasoft10 d9d0374
chat, frontendProcessing
luasoft10 e05fc90
abuse reporting
luasoft10 3531b3f
Merge branch 'master' into players
luasoft10 4d5cec0
move includes and declarations
luasoft10 30101d5
Merge branch 'players' of https://github.com/luasoft10/RBXGSdecomp in…
luasoft10 7310658
OOPS
luasoft10 dfe007b
Merge branch 'master' into players
luasoft10 874dce8
consistency
luasoft10 b506855
playerFromCharacter, getPlayerByID
luasoft10 4a20f61
oops
luasoft10 b3c750c
Context::current
luasoft10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #include <boost/thread/tss.hpp> | ||
| #include <G3D/format.h> | ||
|
|
||
| namespace RBX | ||
| { | ||
| namespace Security | ||
| { | ||
| enum Identities | ||
| { | ||
| Anonymous, | ||
| LocalGUI, | ||
| GameScript, | ||
| CmdLine, | ||
| TrustedCOM, | ||
| TrustedWebService, | ||
| Replicator | ||
| }; | ||
|
|
||
| enum Permissions | ||
| { | ||
| None, | ||
| Administrator | ||
| }; | ||
|
|
||
| class Context | ||
| { | ||
| friend class Impersonator; | ||
|
|
||
| private: | ||
| const Identities identity; | ||
| public: | ||
| void requirePermission(Permissions permission, const char* operation) const | ||
| { | ||
| if (!isInRole(identity, permission)) | ||
| { | ||
| if (operation) | ||
| throw std::runtime_error(G3D::format("The current security context cannot %s", operation)); | ||
| else | ||
| throw std::runtime_error(G3D::format("The current security context cannot perform the requested operation")); | ||
| } | ||
| } | ||
|
|
||
| bool hasPermission(Permissions); | ||
| private: | ||
| Context(Identities identity) | ||
| : identity(identity) | ||
| { | ||
| } | ||
|
|
||
| public: | ||
| static Context& current() | ||
| { | ||
| Context* context = ptr().get(); | ||
| if (!context) | ||
| { | ||
| context = new Context(Anonymous); | ||
| ptr().reset(context); | ||
| } | ||
|
|
||
| return *context; | ||
| } | ||
| static __declspec(noinline) bool isInRole(Identities identity, Permissions permission); | ||
| private: | ||
| static boost::thread_specific_ptr<Context>& ptr() | ||
| { | ||
| static boost::thread_specific_ptr<Context> value; | ||
| return value; | ||
| } | ||
| }; | ||
|
|
||
| class Impersonator | ||
| { | ||
| private: | ||
| Context* previous; | ||
| public: | ||
| Impersonator(Identities identity) | ||
| { | ||
| Context* newContext = new Context(identity); | ||
| previous = Context::ptr().release(); | ||
| Context::ptr().reset(newContext); | ||
| } | ||
|
|
||
| ~Impersonator() | ||
| { | ||
| Context::ptr().reset(previous); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include "util/RunStateOwner.h" | ||
|
|
||
| namespace RBX | ||
| { | ||
| extern const char* sTimerService; | ||
|
|
||
| class TimerService : public DescribedCreatable<TimerService, Instance, &sTimerService>, public Service, public Listener<RunService, Heartbeat> | ||
| { | ||
| class Item | ||
| { | ||
| public: | ||
| G3D::RealTime time; | ||
| boost::function0<void> func; | ||
| }; | ||
|
|
||
| private: | ||
| boost::shared_ptr<RunService> runService; | ||
| std::list<Item> items; | ||
| public: | ||
| TimerService(); | ||
| void delay(boost::function0<void>, double); | ||
| protected: | ||
| virtual void onServiceProvider(const ServiceProvider*, const ServiceProvider*); | ||
| virtual void onEvent(const RunService*, Heartbeat); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include "security/SecurityContext.h" | ||
|
|
||
| namespace RBX | ||
| { | ||
| namespace Security | ||
| { | ||
| bool Context::isInRole(Identities identity, Permissions permission) | ||
| { | ||
| switch (identity) | ||
| { | ||
| case Anonymous: | ||
| case GameScript: | ||
| return permission == None; | ||
|
|
||
| case LocalGUI: | ||
| case CmdLine: | ||
| case TrustedCOM: | ||
| case TrustedWebService: | ||
| case Replicator: | ||
| return true; | ||
|
|
||
| default: | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| #include "Player.h" | ||
| #include "Client.h" | ||
| #include "v8datamodel/TimerService.h" | ||
|
|
||
| namespace RBX | ||
| { | ||
| namespace Network | ||
| { | ||
| Reflection::PropDescriptor<Player, BrickColor> prop_teamColor("TeamColor", "Team", &Player::getTeamColor, &Player::setTeamColor, Reflection::PropertyDescriptor::STANDARD); | ||
| Reflection::PropDescriptor<Player, bool> prop_neutral("Neutral", "Team", &Player::getNeutral, &Player::setNeutral, Reflection::PropertyDescriptor::STANDARD); | ||
| Reflection::PropDescriptor<Player, std::string> prop_characterAppearance("CharacterAppearance", "Data", &Player::getCharacterAppearance, &Player::setCharacterAppearance, Reflection::PropertyDescriptor::STANDARD); | ||
|
|
||
| Reflection::SignalDesc<Player, void(float)> event_Idled("Idled", "time"); | ||
|
|
||
| Backpack* Player::getPlayerBackpack() const | ||
| { | ||
| Backpack* backpack = findFirstChildOfType<Backpack>(); | ||
|
|
||
| RBXASSERT(backpack != NULL); | ||
| return backpack; | ||
| } | ||
|
|
||
| void Player::onCharacterChangedFrontend() | ||
| { | ||
| RBXASSERT(Players::frontendProcessing(this, true)); | ||
|
|
||
| Player* localPlayer = Players::findLocalPlayer(this); | ||
| if (this == localPlayer) | ||
| { | ||
| Workspace* workspace = ServiceProvider::find<Workspace>(this); | ||
| RBXASSERT(workspace != NULL); | ||
|
|
||
| if (!character) | ||
| { | ||
| workspace->getCamera()->setCameraType(Camera::FIXED_CAMERA); | ||
| workspace->getCamera()->setDistanceFromTarget(0.0f); | ||
| workspace->getCamera()->zoom(-1.0f); | ||
| } | ||
| else | ||
| { | ||
| workspace->getCamera()->setCameraSubject(Humanoid::modelIsCharacter(character.get())); | ||
| workspace->getCamera()->setCameraType(Camera::CUSTOM_CAMERA); | ||
| workspace->getCamera()->setDistanceFromTarget(13.0f); | ||
| workspace->getCamera()->zoom(-1.0f); | ||
| workspace->setDefaultMouseCommand(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void Player::setTeamColor(BrickColor value) | ||
| { | ||
| if (value != teamColor) | ||
| { | ||
| teamColor = value; | ||
| raisePropertyChanged(prop_teamColor); | ||
| } | ||
| } | ||
|
|
||
| void Player::setNeutral(bool value) | ||
| { | ||
| if (value != neutral) | ||
| { | ||
| neutral = value; | ||
| raisePropertyChanged(prop_neutral); | ||
| } | ||
| } | ||
|
|
||
| void Player::removeCharacter() | ||
| { | ||
| if (!Players::backendProcessing(this, true)) | ||
| throw std::runtime_error("RemoveCharacter can only be called by the backend server"); | ||
|
|
||
| setCharacter(NULL); | ||
| } | ||
|
|
||
| void Player::setName(const std::string& value) | ||
| { | ||
| Security::Context::current().requirePermission(Security::Administrator, "set a Player's name"); | ||
| Instance::setName(value); | ||
| } | ||
|
|
||
| void Player::setCharacterAppearance(const std::string& value) | ||
| { | ||
| if (value != characterAppearance) | ||
| { | ||
| characterAppearance = value; | ||
| if (Players::backendProcessing(this, false)) | ||
| loadCharacterAppearance(); | ||
|
|
||
| raisePropertyChanged(prop_characterAppearance); | ||
| } | ||
| } | ||
|
|
||
| void Player::onServiceProvider(const ServiceProvider* oldProvider, const ServiceProvider* newProvider) | ||
| { | ||
| if (oldProvider && Players::backendProcessing(oldProvider, true)) | ||
| setCharacter(NULL); | ||
|
|
||
| Instance::onServiceProvider(oldProvider, newProvider); | ||
|
|
||
| if (newProvider && Players::frontendProcessing(newProvider, true)) | ||
| onCharacterChangedFrontend(); | ||
|
|
||
| if (!oldProvider && Players::frontendProcessing(newProvider, true)) | ||
| { | ||
| RBXASSERT(Players::frontendProcessing(this, true)); | ||
| lastActivityTime = G3D::System::getLocalTime(); | ||
| doPeriodicIdleCheck(); | ||
| } | ||
| } | ||
|
|
||
| void Player::doPeriodicIdleCheck() | ||
| { | ||
| if (ServiceProvider::findServiceProvider(this)) | ||
| { | ||
| RBXASSERT(Players::frontendProcessing(this, true)); | ||
| if (lastActivityTime != 0.0) | ||
| { | ||
| G3D::RealTime idleTime = G3D::System::getLocalTime() - lastActivityTime; | ||
| if (idleTime > 120.0) | ||
| { | ||
| Players* players = ServiceProvider::find<Players>(this); | ||
| if (players && players->getLocalPlayer() && Players::clientIsPresent(this, true)) | ||
| { | ||
| event_Idled.fire(this, idleTime); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| TimerService* timerService = ServiceProvider::create<TimerService>(this); | ||
|
|
||
| if (timerService) | ||
| timerService->delay(boost::bind(&Player::doPeriodicIdleCheck, shared_from(this)), 30.0); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this
noinline?It won't inline regardless, since its defined in a C++ file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SecurityContext::requirePermission does not inline this function in RBXGS although it was inlined for me when I was matching this function.
Functions defined in the source file can STILL be inlined, see BlockBlockContact::computeIsColliding overloads
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? requirePermission is defined in the header, and isInRole is defined in the C++ file. It should not inline.
Shouldn't be possible.