Skip to content
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

Break on log string feature for the AIDebug window #3496

Closed
DorpsGek opened this issue Jan 8, 2010 · 6 comments
Closed

Break on log string feature for the AIDebug window #3496

DorpsGek opened this issue Jan 8, 2010 · 6 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jan 8, 2010

Zuu opened the ticket and wrote:

This patch is not completely finished yet.

The basic functionality is there. When a log message that matches the typed string appears in the currently viewed log, the game is paused.

Things to improve:
* See big comment in OnMouseLoop function regarding checking for game being unpasued.
* Decide if the continue button should stay. It is a bit handy to have it there and it adds some visual clues (it becomes enabled when the break text is found), but it duplicates the pause button in the toolbar.
* Maybe add some more visual clues when it has stopped? (change colour of some text in the window maybe?)
* Maybe add a "clear" button.
* Maybe add a "match case" button.
* The label to the left of the edit box looks a bit like a button, not sure if that is possible to fix that somehow other than removing it.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/3496
@DorpsGek
Copy link
Member Author

Zuu wrote:

I just want to tell that I have been able to suspend the AI just after the AILog.* call. Digging into the AI/squirrel stuff I was able to reduce the number of opcodes left with a big enough number to suspend the AI for the current tick. I guess this is what the word 'suspend' means in the OpenTTD AI code. (Suspending for the reminder of the current tick, but will run next tick again)

I've seen that in sqapi.cpp (and squirrel.h) there is 'sq_suspendvm' which could be used instead of 'sq_decreaseops' which I do use now. The problem is just that sq_suspendvm doesn't do anything. (I've checked the implementation and all it does is to throw some squirrel errors in case suspending isn't allowed)

Unless I'm able to suspend it in a cleaner way I might go for renaming the function-chain into DecreaseOps or something like that with a parameter for how many Ops to decrease with.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496#comment7484

@DorpsGek
Copy link
Member Author

Zuu wrote:

Oops, clicked on the wrong button. Here is the patch. I haven't added comments to the new Suspend functions etc. as it is so far quite experimental.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496#comment7485

@DorpsGek
Copy link
Member Author

Zuu wrote:

Man, I can't read today. (hit the Add comment button instead of Attach file button a second time... :-p )

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496#comment7486

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 1, 2010

Zuu wrote:

I have made these changes

* Make use of _settings_game.ai.ai_max_opcode_till_suspend instead of decreasing the number of opcodes left with 100 000.

* The widget table is now arranged so that the log panel and the new widgets share a vertical container. The scrollbar and the resize button is in another vertical container and these two are in a horizontal container. I made this change after looking at the town list to see how it was made there. Also this should work better if someone uses a large font as then the resize button will not get resized. I have also made a few tweaks so that it is more clear that the label is a label and not a button.

* When an AI is breaked the line that matched gets higlighted as shown in the attached screenshot.

* Added comments to the declarations of the new Suspend functions that has been introduced.

* Fixed some coding style issues

The big comment is still there regarding the constant checking for if the game has been unpaused. Either that constant checking has to be acceped or I need to hook in somewhere in the game loop where there is code that is ran when the game is unpaused.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496#comment7510

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 6, 2010

Zuu wrote:

Changes:

* Highlight with black background and invert black text to white. (but red and yellow text is drawn unchanged on black background)
-- After having looked into the colour palette table in the source code I thought index 0 == black but I haven't been able to validate that on the DOS palette.

* Added Match Case button
* Added button at the bottom left to toggle the break checking on/off if you temporarily want to disable the checking without erasing what you have typed.

* The state of the two new buttons as well as the break string is stored in class static variables so that the states can be restored if the window is closed and opened again.

* Renamed some of the introduced variables to have more consistent naming of the new feature.

* Updated to last SVN version. (some time ago)

----

I think I have addressed most issues that I mentioned in my first post. I haven't added a clear button, but that would use up some more horizontal space and leave little space for typing unless one first resize the AI Debug window.

Comments on the patch are welcome.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496#comment7544

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 2, 2010

Yexo closed the ticket.

Reason for closing: Implemented

In r19544


This comment was imported from FlySpray: https://bugs.openttd.org/task/3496

@DorpsGek DorpsGek closed this as completed Apr 2, 2010
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant