Author Topic: New colony game uploaded to SVN. Need some help before releasing.  (Read 5512 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
I posted my nearly completed Eden Starship Colony Game to the repository under https://github.com/Brett208/OP2MissionRisingFromTheAshes.

The scenario isn’t finished yet. However, it is playable and mostly complete with fairly balanced gameplay (in my opinion). I’m looking for a code review plus some specific help if someone has some time to dig through what I uploaded.

In particular
  • Am I following best practices using C++, and suggestions to improve
  • Am I following best practices using the Outpost 2 SDK, and suggestions to improve
  • Specific help with the problems outlined below (listed in order of importance to me)

Critical Mission Objectives Bug
Solved by Hooman & ArklonIf you save a scenario and then reload it and check the mission objectives tab, the game will crash. I would really like to see this fixed, but I’m unsure what is causing it. I am guessing something is happening with the save data not capturing something that it needs to about the mission objectives.

Also, when you launch the evacuation module and complete the starship, fulfilling the final victory condition, you lose the game instead of winning.

Showing a Mission Briefing
Finally have briefing screen working. Closely followed angellus' code in the Mission within the repository (which is in turn heavily based on BlackBox's code). I have a lengthy mission briefing which you can read in the level’s root directory in the file briefing.rtf. (If anyone wants to proofread and make suggestions, I wouldn’t mind) I want this to appear in a pop-up window before the scenario starts like BlackBox’s Cold War scenario does.

Unfortunately, I have been defeated by the process and am requesting a major assist. BlackBox appears to have used a combination of Resources, Win32 API, and a Dynamix DLL calls to ODASL to make the window appear. I am coming from zero experience with Resources and Win32 API besides spending a few hours reading about them online. Programming Outpost 2 scenarios is very humbling for a hobbyist programmer. I’m encountering a lot of stuff I’ve never touched before.

I have a dialog box described in the resource script file. Although I’m not sure I’ve identified all the required properties in the resource.h file from the dialog box.

Whenever running the scenario in Outpost 2, it just skips the briefing screen and goes straight to the scenario, probably just failing gracefully since my code isn’t opening a dialog box correctly.

Okay, so the next issue is that I cannot find a built in resource type for a rich text document. I decided that it might be easier just to load the briefing from an rtf file that wasn’t an embedded resource. I have a separate project that can open an rtf file and load it into the richedit2.0 Control that is part of the resource dialog box. See BOOL FillRichEditFromFile(HWND hwnd, LPCTSTR pszFile). Unfortunately, it requires MFC (Microsoft Foundation Classes), which I think I would rather avoid if possible. Although I think using the control RichEdit2.0 requires MFC anyways?

So to summarize, can someone walk me through opening a dialog before the mission starts with a mission briefing, or go into my source code and tweak it to work. Please back-fill me if you tweak yourself so I know what is going on.


Tech Tree
I’m using Multitek.txt with the exception of disabling Lava Defenses for Eden. I created a new tech tree (multitekNoLavaWalls.txt) and removed Eden’s ability to research Lava Walls. I would rather not create a whole new tech tree just to disable Lava Walls. Is there an accepted way to restrict an individual technology for a player through the API, or am I stuck keeping a new tech file?

AI Base Repair Bugs
I had difficulty nailing down good repair code for the AI’s base. I ended up just designating an AI convec as their repair vehicle. I enumerate through all the AI’s buildings and check if a building is damaged enough to need repairs and then send the convec. The only problem is, the convec goes off and tries to repair buildings that are under construction. I cannot find a way to differentiate between buildings having low health due to being under construction vs post construction damage. Some help here would be appreciated. The AI colony does fine with this erratic repair behavior, it just looks a little odd.

Also, if you destroy the AI’s vehicle factory and construction convec, then the repair convec will not switch roles and construct a new vehicle factory, basically stalling out the AI’s base. This isn’t too big a deal because if you have penetrated the AI’s defenses far enough to destroy both one of the convecs and the vehicle factory, the AI is probably done for anyways. I think I could hack a solution for it, but when I started, the code became very ugly and gory fast. This probably stems from my poor hack at repair code. I think I’ll leave this bug in place unless someone has a simple easy solution.

To summarize the repair bugs, if someone knows how to do this better, please let me know, but I’m not too worried since the scenario is very playable even with these quirks.

Project Admin Note
The post build events assume your Outpost 2 install is C:/Outpost 2 Divided Destiny using the GameDownload directory of the repository. The DLL, MAP file, and tech tree will all be copied on successful build of the project. The 3 required copy commands are remarked out by default so no files will be copied into a directory on someone's computer unless they want them to and remove the remarks from the post build event.

I think everything needed is loaded into the SVN, but I am new to subversion, so let me know if I missed something.


Sorry for the long post, hopefully some people can help with my laundry list. :|

----
Edited to reflect changes in project's post build events.
Edited again to cross out fixed problems. Thanks to Hooman for finding the fix!
« Last Edit: May 26, 2019, 09:50:03 PM by Vagabond »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #1 on: February 29, 2016, 10:25:02 AM »
 :)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #2 on: March 01, 2016, 04:02:57 AM »
In main.cpp:17 (starting line 17), you have this section:
Code: [Select]
// Declaring Classes
UnitHelper::VehicleBuilder vehicleBuilderAI;
AIFightGroups::AIFightGroupMaker fightGroupMaker;
ScriptGlobal scriptGlobal;

The vehicleBuilderAI and fightGroupMaker variables are outside of the scriptGlobal struct. These will not be saved and restored during a game save/load. After loading a game, these variables are in a sense uninitialized. Using them could be related to crashes you've been seeing.


Rather than post a bunch of nitpicks, perhaps I'll go through a bit of the code, and if I see things, I'll make changes and commit them. The commit messages will explain each change. Run an SVN update when you want to see the changes, and before you work on your project next.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #3 on: March 01, 2016, 04:57:00 PM »
Thank you Hooman, for reviewing. I'll stay out of the code until you give the all clear and then review the commit logs for what has been changed.

Hooman and Vagabond stand at attention
Hooman: "I relieve you"
Vagabond: "I stand relieved. Attention on the bridge, Hooman has the deck."

----

I am reinitializing vehicleBuilderAI and fightGroup Maker in the AIProc function (assuming I wrote the code correctly?), however this is a bit of a hack. I didn't realize I could put custom classes in the scriptGlobal function.

Code: [Select]
//From AIProc function

//NOTE: When the VehicleBuilder class is instantiated after a game is loaded, it defaults to player 0.
if (vehicleBuilderAI.GetPlayer() != 1)
{
InitializeAIHelperClasses();
}

----

For the Victory condition bug crashing the game after loading a save file. Even if I strip all the code from the project except for 1 victory condition, this still occurs so I really believe this is being caused external to the code. Perhaps something to do with how I link into the SDK or something?

I would like to remove all the SDK code from the project and just link to the SDK projects in the repository, but they are built using Visual Studio 2010. I'm guessing they would have to be updated to Visual Studio 2015 for me to use, or I would need to drop to Visual Studio 2010. Microsoft makes it difficult by coming out with a new Visual Studio version every 2 years.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #4 on: March 02, 2016, 01:54:39 AM »
No need to stop development. Just run SVN update at the start of each coding session. I plan to do the same. Also try not to leave changes in your working copy that are not checked in. If you complete something check it in. If it takes longer than a day to complete, consider breaking up the change into smaller change sets, and checking those in.

It's possible to get a conflict if we both update the same line at the same time. However, I'm not likely to be working on this while you're awake, so as long as any changes get checked in early and often, and the other person remembers to run SVN update, there shouldn't be any problems.

If a conflict does happen, it's really not the end of the world. They're not that difficult to deal with, they're just not automatically merged by SVN. If we both change the same line, it will mark the file as conflicted, and you'll have 3 versions of it. The base version, your own changes, and the remote changes (such as by me) downloaded from the repository. You can compare the changes, manually set what the merged output should be, and mark the conflict as resolved. An unresolved conflict will prevent you from making a commit, so it's impossible to accidentally overwrite someone else's changes. If you forget to run SVN update, and one of your changes conflicts, you'll get an error message when you try to commit, reminding you to run SVN update first.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #5 on: March 15, 2016, 02:53:29 PM »
I managed to do this with OutpostHD's code last week when I was working on it at home and at work and forgot to commit my changes at home. Broke the whole damn build in the process.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #6 on: March 16, 2016, 12:08:57 AM »
@leeor_net: It might be worth starting a thread to detail the experience. Version control mishaps can be instructive. Especially if you know what exactly went wrong, and more so if you know how to fix it once the mistake is noticed.

@Vagabond: I'm sorry I haven't looked very in depth at your actual code so far. I only changed two minor things. My cursory glance didn't reveal any particular code style/idiom issues. I see the AI repair bug is still outstanding.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #7 on: March 16, 2016, 01:22:58 PM »
@Hooman,

By fixing the save/load mission objectives bug, you really helped this scenario along! Good to hear you don't see anything egregious about the code.

The repair bug doesn't  affect gameplay. It is just strange watching the convec I designated for repairs wondering over to buildings under construction and trying to repair them. The problem is that I cannot seem to use the SDK to determine if a building is just damage or under construction. If I could find an under construction property of some sort, I could tell the repair code to ignore these buildings

I saw in the forums some posts about repair code that Eddy-B created, but I haven't found it or other people's solutions to review and see if there is a better way.


On a separate note, I'm working on other scenarios and I would like to share some of the helper classes/code files between projects. I'm unsure where to put it in the repository. I could put it in a sub-folder under API, but unsure if this is appropriate. Some of the code would probably be good for others to review and some may be fairly specific to the scenarios I'm making and not so useful.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: New colony game uploaded to SVN. Need some help before releasing.
« Reply #8 on: March 17, 2016, 02:39:32 AM »
Adding new code under API is appropriate. You can add to existing projects if you want, or create your own. If you're building only on the core Outpost2DLL API, then it's entirely appropriate to add code to the OP2Helper project. If you're using memory hacking techniques, or relying on another API that does, then it should probably go somewhere else. Either as an addition to the library you're using, or as your own library.

It's possible that some of your changes can be added to an existing library, while other changes will need to go elsewhere. If you have any reasonably generic code that can be added to OP2Helper, I highly encourage you to add to it there.

If you have specific functions you'd like advice on, feel free to point them out. (Paste, link, refer to)