Skip to content

Fix issue #106 - #118

Open
TreeDB wants to merge 1 commit into
Civcraft:masterfrom
TreeDB:patch-1
Open

Fix issue #106#118
TreeDB wants to merge 1 commit into
Civcraft:masterfrom
TreeDB:patch-1

Conversation

@TreeDB

@TreeDB TreeDB commented Sep 21, 2015

Copy link
Copy Markdown

No description provided.

@ttk2

ttk2 commented Sep 21, 2015

Copy link
Copy Markdown

how does this approach the fix?

@rourke750

Copy link
Copy Markdown

Its the redstone that's the issue. I dont think this will fix anything.

@TreeDB

TreeDB commented Sep 21, 2015

Copy link
Copy Markdown
Author

@ttk2 It checks the blocks on all 4 sides of a pressure plate for openable blocks. If a reinforcement is found and the player doesn't have access to it the event is cancelled preventing access.

@suirad

suirad commented Sep 30, 2015

Copy link
Copy Markdown

Tested it, this does fix the issue #106.

@CivcraftBot

Copy link
Copy Markdown

Can one of the admins verify this patch? Type 'ok to test' to test.

@ProgrammerDan

Copy link
Copy Markdown

My only real concern with the patch is since it's on physical interaction, every player physical interaction will trigger this event (potentially). I haven't tested to see what in all triggers it, so hopefully someone can/will/has and assuage my fears, but this could potentially be a bit of a resource hog if such a check is run too often.

@suirad

suirad commented Sep 30, 2015

Copy link
Copy Markdown

So would it be better to approach this as a redstone interaction as @rourke750 mentioned?

@ProgrammerDan

Copy link
Copy Markdown

Can't speak to that, but it would be better to check that the block being interacted with is of the class of interact-able blocks where this fix matters, before checking all the sides. E.g. fail fast, and reduce running time within the method to the minimal set of tests. Make sure that the test likely to discard the largest number of interactions happens first, etc.

@suirad

suirad commented Sep 30, 2015

Copy link
Copy Markdown

I am working on an alternate implementation.

@suirad

suirad commented Sep 30, 2015

Copy link
Copy Markdown

Maybe something like this:
https://gist.github.com/suirad/6b8330c824fd999d3560

@ProgrammerDan

Copy link
Copy Markdown

Significant improvement. Drop the stack frame cost of the function call for the press-able check unless you're using it in multiple places.

Edit: In fact both checks should simply live inside the IF statement, unless we've got motivation to use them elsewhere it's a premature optimization, and introduces an extra frame/context switch cost per execution that we don't need.

@suirad

suirad commented Oct 1, 2015

Copy link
Copy Markdown

I was thinking the same, but left it there as i was testing for clarity of the gist. I could make a pull for it.

@ProgrammerDan

Copy link
Copy Markdown

Sounds good!

@TreeDB

TreeDB commented Oct 2, 2015

Copy link
Copy Markdown
Author

@suirad @ProgrammerDan Would you like me to update this pull request with the changes you have suggested?

@ProgrammerDan

Copy link
Copy Markdown

That'd be awesome!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instanceof will return false if the object is null, so you dont need an additional null check here

@suirad

suirad commented Oct 5, 2015

Copy link
Copy Markdown

@TreeDB Your change looks good.

@ProgrammerDan

Copy link
Copy Markdown

Seconded, much improved even with just those small changes. Should be good to go; have you tested it locally, @TreeDB ?

@TreeDB

TreeDB commented Oct 5, 2015

Copy link
Copy Markdown
Author

@ProgrammerDan No

@ttk2

ttk2 commented Oct 6, 2015

Copy link
Copy Markdown

ok to test

@ttk2

ttk2 commented Oct 6, 2015

Copy link
Copy Markdown

drat, can't get a build to test it with. @ProgrammerDan think I should merge and throw on Civtest?

@rourke750

Copy link
Copy Markdown

ok to test

@rourke750

Copy link
Copy Markdown

@ttk2 lol let me look into that.

@rourke750

Copy link
Copy Markdown

I think you just did something weird.

@ttk2

ttk2 commented Oct 6, 2015

Copy link
Copy Markdown

did you put the testing build on Civtest?

@rourke750

Copy link
Copy Markdown

I did not, citadel is still broken from the other changes. I'll try getting to this later in the week. I might have time later today to fix citadel.

@rourke750

Copy link
Copy Markdown

ok to test

@ProgrammerDan

Copy link
Copy Markdown

@Maxopoly @rourke750 any reason you can think of not to include this? Has it been superceded by future changes?

@rourke750

Copy link
Copy Markdown

I forgot this existed. If it works might as well merge. I dont believe this was fixed anywhere else.

@ProgrammerDan

Copy link
Copy Markdown

Ok, going to do an omnibus PR w/ database change to new CivModCore standard, I'll tack this on. Will test it then too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants