Porting to C++

For code related discussions and questions
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Porting to C++

Post by Chojun » 13 Jan 2012, 03:57

Per wrote:Pumpkin created this game with several people working on it for years, full time. You are going to make it from scratch, alone, in your spare time? Perhaps it is time for a reality check?
How long did it take to invent the wheel?

How long did it take the 2nd time?

User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: Porting to C++

Post by vexed » 13 Jan 2012, 04:11

Chojun wrote:
Per wrote:Pumpkin created this game with several people working on it for years, full time. You are going to make it from scratch, alone, in your spare time? Perhaps it is time for a reality check?
How long did it take to invent the wheel?

How long did it take the 2nd time?
Image
:help:
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.

stiv
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 876
Joined: 18 Jul 2008, 04:41
Location: 45N 86W

Re: Porting to C++

Post by stiv » 13 Jan 2012, 05:01

How long did it take to make the first apples-to-oranges comparison?

User avatar
lav_coyote25
Professional
Professional
Posts: 3434
Joined: 08 Aug 2006, 23:18

Re: Porting to C++

Post by lav_coyote25 » 13 Jan 2012, 06:14

now before this turns into a freaking flame war, lets just say all parties are correct. one persons working on the source will take years / decades. now if that same work were to be divided into team work, would obviously take less time. still, years. so there it is. 2004 till now is just a spit in the bucket. and the source is now better than it was. to those that disagree - fork it and prove me freaking wrong. now, the next one to start a discussion should remember that every one has an opinion and that opinion will surface. everyone is entitled to be wrong. right? :annoyed:

Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Porting to C++

Post by Chojun » 13 Jan 2012, 06:35

lav_coyote25 wrote:now before this turns into a freaking flame war
I think your intuition and experience serves you well.
stiv wrote:How long did it take to make the first apples-to-oranges comparison?
I'll distance myself from this discussion.

:stare:

Lord Apocalypse
Regular
Regular
Posts: 678
Joined: 29 Jul 2009, 18:01

Re: Porting to C++

Post by Lord Apocalypse » 08 Mar 2012, 10:12

Seismo wrote:
vexed wrote:FWIW, last I heard, Chojun's code was given to Seismo who is working on a C# version.
While they both have project pages on SF, neither of them have anything in the repo.
I am still working on the c# version. I was under heavy load to finalize my engine all belongs to, now i implement the logic. It is sad, i can not use any line of orginal WZ sourcecode due to its old style. I have to code all new. I use the WZ code only to understand some specific parts like the game internal rules. For a first draft i would like to use the models and textures from orginal, but than i would have a dilemma, i do not want to share my engines source code... So SF seems to be not the best platform for this project and i need new graphic objects too. Oh man, still so many things to do... :augh:
Given a good understanding of the original source as well as the C++ source provided by Chojun plus a firm grasp of C# (and a good design) its possible to have a working engine in a short amount of time. From my understanding C# falls somewhere between C++/Java and Visual Basic in how the code is written and operates.

Quick code sample from a Master of Orion 3 clone Majesty of Omega

Code: Select all

namespace Majesty_of_Omega.Logic.GameConfiguration
{
    /// <summary>
    /// The game manager saves and loads games to the My Games folder of majesty of omega
    /// </summary>
    public class SaveGameManager
    {
        /// <summary>
        /// the standard save game extension
        /// </summary>
        private const string saveGameExtension = ".moosav";

        /// <summary>
        /// this value is true, if the SaveGameManager is operating in unit test modes.
        /// the variable changes the behavior of the MooGameFolder property
        /// </summary>
        private readonly bool _testMode;

        /// <summary>
        /// Initialize a new instance of  <see cref="SaveGameManager"/> class.
        /// </summary>
        public SaveGameManager()
        {
        }

        /// <summary>
        /// Initialize a new instance of <see cref="SaveGameManager"/> class.
        /// </summary>
        /// <param name="testMode">if set to <c>true</c> then the SaveGameManager is operating in unit test mode.</param>
        /// <remarks>the variable changes the behavior of the MooGameFolder property</remarks>
        public SaveGameManager(bool testMode)
        {
            _testMode = testMode;
        }

        /// <summary>
        /// Gets the last games, which resides int the my games folder of majesty of omega
        /// </summary>
        /// <value>The last games.</value>
        public List<SaveGameInfo> LastGamesInMooGameFolder
        {
            get
            {
                var gameInfos = from file in Directory.GetFiles(MooGameFolder)
                                orderby file
                                select LoadGameInfo(file);
                return new List<SaveGameInfo>(gameInfos);
            }
        }

        /// <summary>
        /// Gets the Majesty of Omega save game folder.
        /// </summary>
        /// <value>The moo game folder.</value>
        public string MooGameFolder
        {
            get
            {
                var mooGameFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                                    @"\My Games\Majesty of Omega";
                if (_testMode)
                {
                    mooGameFolder = Path.GetTempPath() + @"\Majesty of Omega";
                }
                if (!Directory.Exists(mooGameFolder))
                {
                    Directory.CreateDirectory(mooGameFolder);
                }
                return mooGameFolder;
            }
        }

        /// <summary>
        /// Saves the specified game to a file stream.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <param name="path">The full path to the file system or a simple file system compatible game name.</param>
        public void Save(SaveGame game, string path)
        {
            Require.IsNotNull(game);
            // Assures the correct save game extension
            path = Path.ChangeExtension(path, saveGameExtension);

            // check, if the path contains a directory. if not, assign the standard
            // save game folder
            var directoryName = Path.GetDirectoryName(path);
            if (string.IsNullOrEmpty(directoryName))
            {
                path = Path.Combine(MooGameFolder, path);
            }

            var gameInfo = new SaveGameInfo
                               {
                                   GameName = Path.GetFileNameWithoutExtension(path),
                                   TurnNumber = game.TurnNumber,
                                   Time = DateTime.Now
                               };
            var fStream = new FileStream(path, FileMode.Create);

            // Create our binary formatter object.
            var formatter = new BinaryFormatter();

            // Serialize our data.
            formatter.Serialize(fStream, gameInfo);
            formatter.Serialize(fStream, game);

            // Close our data file.
            fStream.Close();
        }

Post Reply