-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Law and order to lua #3254
Law and order to lua #3254
Conversation
This looks good, gutting and removing |
87d9ec4
to
6196ca3
Compare
To be implemented in Lua instead
5387531
to
a417616
Compare
a417616
to
cc74f56
Compare
cc74f56
to
0b5fed9
Compare
For the record, I've been working on this PR this summer, and have it almost done, (I poked @nozmajner about the police textures, thanks). What remains is just to clean up and push the last code changes from my local computer. I currently have very little time (or at least aught to have), so I'll see when this gets done. EDIT: I updated the text in my first post a few weeks ago. Number 14 on the to-do list above is done. But to be cleaned and pushed. |
For now, we just label the police ships by l.POLICE. Would be fun to have faction specific name, but alas, those strings are not in translation system.
…l other crime handling and saving/loading of crime record in c++ (most of Polit), removed crime adding from Ship.cpp as well. SAVEBUMP needed
(These are already in lang/ui-core)
b375768
to
f99c537
Compare
This has been fermenting for over a year now (first commit: 2014 April), and I'm almost approaching issue-1719 status, but now I think I'm ready for this to be reviewed. I don't know how many times I've rebased this, but it's a lot, so the commits should make sense. I don't expect anyone to read all code, but I would like:
So 90% of this work (c++ -> lua) is nothing anyone will notice, but at least below is some eye-candy. Hmmm. Or perhaps eye-oatmeal. |
Excellent work! I don't think I can bring myself to stare at any code tonight after doing it all day for work but will try to look into it & testing next week / Sunday. Everyone else chip in where possible! |
Thanks @fluffyfreak! By the way, we're getting OpenGL errors on the new police ships, I'm guessing you can understand that more easily than me or @nozmajner. I can add that since now the code is in Lua, it's easy for anyone to play around with how fines should work, how they're accumulated, and also how/when police should be dispatched. I wrote that part over a year ago, and I'm slightly foggy on it, and it can be tweaked later, but since I lowered fine for "unlawful firing" and put a threshold for when police will start shooting at you, you now have to shoot quite a bit to raise the police. |
Baaah, just merge it, get flamed for a week or two by random users while we
put out all the fires it started, and get done with it. That's how I did it
;-).
Another, slightly less fun idea would be to issue a call for tests on SSC,
Twitter, G+ and the dev forum. I dunno who has the setup to produce random
win32 builds, but this might prove useful. @robn, @walterar maybe ?
|
@impaktor & @nozmajner I think the OpenGL errors are coming from the DDS textures using DXT1, DXT1a or DXT5 must be either power of two, or divisible by 4 in each dimension. So 1028 might be ok, or 1020, but 1025 isn't. NB: Just to confirm, it is the texture, I resized it locally, recompressed it etc and have tested a few times without the |
Also @laarmen might have a good point, we've got until the end of the month so getting more eyeballs on it and then fixing the obvious issues could be one approach. Or wait until next month and merge right at the start to give maximum time. So far I've not noticed any problems but I was only looking at the opengl issue thus far. I haven't been able to get the Police to attack me despite shooting at a ground station for a while though. Will test some more :) |
Ok, I have |
Yes, so the threshold for launching police is currently 1000, and fine for shooting in Sol is 100, (on New Hope it's 89). I think I should lower the threshold to 300, i.e. a three strike policy for I also agree with letting the players test it, and find the bugs. Ideally, I think it would be good with a "pioneer stable" version, and a "latest" version, my thinking is that the "stable" version is best for new players, since it's a bit of a bummer to try pioneer for the first time and end up with bugs and crashes. Also, please note: this PR does not include any save-bump commit, so up to the merger to fix that. Do we know of any other save-bumping code that might pop-up in the near future?
I'll look into that, what system? |
Rolling contract is kind of what I'm on now too, I expect that it will last until March/April next year but that's only based on what we've discussed there's nothing in writing. Such is life! Now then the bug: yes I see it even with the latest merged in (hoped for fixes) which is pretty bad. |
Is there a way to write to the output log from the Lua save methods so that you can see if they're being recorded/restored? Perhaps figure out where they are themselves called from and put some logging in there to figure out if they are being called, and if they are why they're not saving/restoring. |
I'm not sure my description for reproducing this bug is 100% deterministic. Seems like sometimes it works, sometimes not. I'm printing out debug statements, so I can see the bug happening "real time". I.e. when saving manually the save system always calls the serializer of the lua-class, as it should, and it prints out "...SERIALIZED!" (I've pushed a debug commit). When autosave does a save, it prints out "SAVED ". So just by doing:
I can get two different printouts: without bug triggered:I get one print from CrimeRecord serializer for each save call (1 manual, 1 from autosave), and then AutoSave notifies me it's been called and saved to a file called
with bug triggered:First printout if from my manual save. Second is from AutoSave, but somewhere down the line it failed to call the serializer of the class:
So I'm guessing somewhere between LuaGame.cpp and LuaSerializer.cpp something strange is happening. I cant poke this more tonight. |
I'm mostly afk these days, but I'll try to take a look. I had my fair share
of battles against this subsystem ;-)
|
That would be greatly appreciated @laarmen, because I'm at a loss here! It might be interesting to also have debug printout for the Equipment serialization, since that might also have the bug, and if it doesn't then that's narrowed it down further. My CrimeRecord class is, as of my recent fix of the bug fluffy found, basically just an exact copy of your Equipment implementation. |
Best guess about the bug is that it's because both the AutoSave module and the Player module have registered handlers for the "onGameEnd" event. The Player module onGameEnd handler clears out the player's data -- if that runs before AutoSave onGameEnd then the _exit save will have no crime record. Should be fairly easy to fix -- don't try to clean up any state in onGameEnd; instead, reset the state in onGameStart (and then inject anything needed from loaded_data). It's not a very nice system, but should work ok. |
I believe you are as usual, spot on! And as usual, I was way off. (How come I always look for bugs in the wrong place... until I find it? 😜 ) I've put a printout in |
6aea8c8
to
724459b
Compare
and a policeDispatched table added.
Differentiate current factions by using newly added police ships, and change default from Kanara to: - Default: sinonatrix_police - Federation: kanara - CIW: pumpkinseed_police
…s for storing dirty deeds.
...Since when just echoing it to comms it's not seen behind the Lobby window.
…and one crime record for the authority to remember the past crimes. Police now also display list of both (current) "Outstanding fines", and (past) "Crime Record"
In the process, use the functionality for lua classes from utils
724459b
to
b3be4d3
Compare
Rebased (probably for the +40th time), and cleaned/squashed up previous fixes, (except for the last one, since that commit would have to be split in two and then each part merged into two different commits, and I don't feel much like doing that). So, to the best of my knowledge, this PR is now done. |
09a8231
to
b3be4d3
Compare
Move Law to Lua
This moves the law enforcement from
Polit.cpp
(which is almost empty now) to lua. I worked on this about 6 months ago, but I got stuck due to a segfault when loading a game, but it seems to have fixed itself now (after updating branch to master).Update: as of 2015-08 I'm continuing this due to #887 being "fixed".
Changed/New features
Some of the changes in how police will behave now:
fine = 0
anymore, butmaxFineTolerated=1e3
1e5
, and weapons discharge to1e2
, allowing the latter to be below themaxFineTolerated
level.Design / Code
I'm not sure about what code to put in which file, i.e. how to structure it. Current structure reflects a lot of the development history during my work on this.
libs/Legal.Lua
that holds the crime constants, and anotifyOfCrime()
which was previously inPolit.cpp
.modules/CrimeTracking
to be symmetric with ourmodules/StatsTracking
. It has the event triggers (onShip<ActionX>
) for killing, firing, jettison, etc. and it holds thedoLawAndOrder()
(previously inSpaceStation.cpp
).libs/Player.lua
has a local CrimeRecord class, which the player has two copies of for each faction (current crimes, and past crimes). There are also Player:AddCrime() and such.libs/SpaceStation.lua
, but thought it needs only be called once (about every 5 seconds), at which point a check is made to find the closest space station (calls a new method:Ship:GetLawEnforcingStations()
, returns stations within "law range"), thus you will not be fined twice for one single illegal action done within range of both stations. (I still have to check the distance of the player to all stations every call.)Station.lawEnforcedRange
(100 km).SpaceStation:LaunchPolice(targetShip)
andStation:LandPolice()
.Progress
Player.record
table?Player:ClearCrimeFine
, and clean up comments inlib/Player.lua
For another separate pull request:
When this is merged, I'll be looking into:
NotifyOfCrime
. For now: works as it used to.IsCommodityLegal
should be in lua?