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

Enhance Easter eggs, including the /rnd command for Linux #94

Merged
merged 6 commits into from Feb 19, 2019

Conversation

MartinGuehmann
Copy link
Collaborator

This enhances the Easter eggs, from the chat window.

First, it adds the chat window to the options menu, so that I can access on Linux with a non British keyboard. Even if I switch the keyboard to a British layout CTP2 ignores it.

Then, I improved the feedback of the Easter Eggs, if the command involves a player then the feedback messages is in the color of the player given. For instance for the /attach command it is easier to see that the right player was turned into a robot.

Then the /rnd command can now be used on Linux. Just enter /rnd x and the game is running for x turn on auto turn end. Make sure that you turned the visible into a robot, before. If you want to stop auto end turn just hit the escape key.

And finally, some white space clean up with some minor code clean up. No functional change.

…board

Since the keyboard handling is a bit buggy on Linux so that I cannot use the apostrophe key to open the chat. I need an alternative way to open it. Therefore, I added it to the options menu. It is not the best place, but we do not have a better place. This is also useful for the gamer since it displays the command for the chat window in the options menu.
..\ctp2_code\ui\interface\controlpanelwindow.cpp
…r's color

When you enter a command into the ChatBox, such as /attach, that involves a
player number, then the ChatBox will give feedback in the player's color. This
allows you to see more easily, whether you have entered the right player number.
..\ctp2_code\ui\interface\chatbox.cpp
Enable the the '/rnd x' command in the chat window to run the game for x turns. Press Esc to stop auto turn cycling.
..\ctp2_code\ui\interface\chatbox.cpp

Expose the SDLMessageHandler function so that it can be used in chatbox.cpp. This is necessary so that it can catch the Esc key, while everything else is still handled by the key handler.
..\ctp2_code\ctp\civ3_main.cpp
..\ctp2_code\ctp\civ3_main.h
White space only
..\ctp2_code\ctp\civ3_main.cpp

White space only, but including one in the /rnd feedback message, which is strictly a functional change.
..\ctp2_code\ui\interface\chatbox.cpp

White space and minor code optimizations of the type:

	sint32 i;
	for(i=0;i<CP_TILEIMP_MAX;i++)

to

	for(sint32 i = 0; i < CP_TILEIMP_MAX; i++)

Note this makes a difference for Visual Studio 6, as there in both versions i is visible outside of the for loop. However, the code does not compile under VS6, anymore anyway.
..\ctp2_code\ui\interface\controlpanelwindow.cpp
@MartinGuehmann MartinGuehmann mentioned this pull request Feb 14, 2019
@LynxAbraxas
Copy link
Contributor

Love this one, many thank @MartinGuehmann, no failures with cpt2DF and worked well during manual testing. When this PR is in, I might be tempted to create a GL-CI job that records a video of some rounds in /rnd mode so we'd get not only screen-shots but also animation and sound tested;-)
I noticed though, that the diplomacy window was not always closed before the rounds went on, possibly related to #33 (comment) in the other way round?

@MartinGuehmann
Copy link
Collaborator Author

I noticed though, that the diplomacy window was not always closed before the rounds went on, possibly related to #33 (comment) in the other way round?

That is right, it is closed on the next turn. Just keep in mind that this is a debug tool, and as a developer you don't care so much about it. In principle, in an AI only game, the diplo-window shoudln't pop up at all.

@MartinGuehmann
Copy link
Collaborator Author

Merged current master in and waiting for Travis, then it'll go in.

Possibly, the opening of the diplo-window is related to #33, obviously it is strange that the AI is affected by a mere interface change.

@MartinGuehmann MartinGuehmann merged commit e1ac192 into civctp2:master Feb 19, 2019
@LynxAbraxas
Copy link
Contributor

I might be tempted to create a GL-CI job that records a video of some rounds in /rnd mode so we'd get not only screen-shots but also animation and sound tested

Trying that (https://github.com/LynxAbraxas/ctp2DF/tree/vidTest), but have troubles getting ffmpeg to record cpt2 in GL-CI under xvfb. Using ffmpeg and x11grab works locally on normal Xorg with dockerimage from GL. It also works for e.g. xclock started in GL-CI under xvfb and it works for e.g. java based GUIs started from a dockerimage under GL-CI with xvfb.
However, cpt2 from dockerimage in GL-CI under xvfb seems not to work: if xclock runs first, it is visible in the screen-cast but as soon as ctp2 starts the video is black (https://gitlab.com/LynxAbraxas/ctp2DF/-/jobs/166482352/artifacts/file/play-game_build-city.mpg) and the log shows (https://gitlab.com/LynxAbraxas/ctp2DF/-/jobs/166482352):

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":99.0"
      after 289 requests (90 known processed) with 0 events remaining.
ctp2: Fatal IO error 0 (Success) on X server :99.0.

Possibly xvfb, ffmpeg and SDL-1.2 do not work together. @MartinGuehmann any idea what could be the problem?

@MartinGuehmann
Copy link
Collaborator Author

I might be tempted to create a GL-CI job that records a video of some rounds in /rnd mode so we'd get not only screen-shots but also animation and sound tested

Trying that (https://github.com/LynxAbraxas/ctp2DF/tree/vidTest), but have troubles getting ffmpeg to record cpt2 in GL-CI under xvfb. Using ffmpeg and x11grab works locally on normal Xorg with dockerimage from GL. It also works for e.g. xclock started in GL-CI under xvfb and it works for e.g. java based GUIs started from a dockerimage under GL-CI with xvfb.
However, cpt2 from dockerimage in GL-CI under xvfb seems not to work: if xclock runs first, it is visible in the screen-cast but as soon as ctp2 starts the video is black (https://gitlab.com/LynxAbraxas/ctp2DF/-/jobs/166482352/artifacts/file/play-game_build-city.mpg) and the log shows (https://gitlab.com/LynxAbraxas/ctp2DF/-/jobs/166482352):

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":99.0"
      after 289 requests (90 known processed) with 0 events remaining.
ctp2: Fatal IO error 0 (Success) on X server :99.0.

Possibly xvfb, ffmpeg and SDL-1.2 do not work together. @MartinGuehmann any idea what could be the problem?

I haven't really worked with that stuff. From the error message, I would guess it has something to do with the (virtual) machine on GitLab. If it is just the video then you can start it without the intro video and see what happens. For that pass to ctp2 via the command line: nointromovie.

If you think that SDL-1.2 is the problem you could try SDL-2.0. I just don't know what you have to adjust for it maybe you can just install it instead of SDL-1.2. Or you need to adjust the include directory paths for it. If it is just that it would be great, because with SDL-2.0 we could support non-UK keyboards, properly.

@MartinGuehmann MartinGuehmann deleted the EnhanceEasterEggs branch February 23, 2019 22:57
@LynxAbraxas
Copy link
Contributor

If it is just the video then you can start it without the intro video and see what happens.

Already doing so: https://github.com/LynxAbraxas/ctp2DF/blob/vidTest/.gitlab-ci.yml#L104

If it is just that it would be great, because with SDL-2.0 we could support non-UK keyboards, properly.

No, sadly not: https://wiki.libsdl.org/MigrationGuide I already thought of SDL-2 but the migration does not seem to be simple. @MartinGuehmann Do you know of any SDL-1.2 test program that is part of ubuntu or alpine linux and that does not use openGL? All test programs I found so far did use openGL.

@MartinGuehmann
Copy link
Collaborator Author

If it is just that it would be great, because with SDL-2.0 we could support non-UK keyboards, properly.

No, sadly not: https://wiki.libsdl.org/MigrationGuide I already thought of SDL-2 but the migration does not seem to be simple.

The problematic stuff seems to be the graphics that needs to be re-implemented. Of course the keyboard too. But that isn't so much and it would improve the function. For the graphics it sounds to be really worth it since it also supports modern graphics cards. Audio is almost unchanged, so most likely it will work without major changes or with minor changes. The CD support is missing, but it could come from a library.

@MartinGuehmann Do you know of any SDL-1.2 test program that is part of ubuntu or alpine linux and that does not use openGL? All test programs I found so far did use openGL.

Well, I would have to search, too. But does it really need to be a specific distro? The test program I found uses openGL but those are only two functions, which possibly could be changed easily: https://gist.github.com/miguelmartin75/6946310

@LynxAbraxas
Copy link
Contributor

#104 for the follow-up, as well as #92.

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.

None yet

2 participants